Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29231 Discussions

Feature request/status: Automatically resolve dependancies like gfortran 4.6

Izaak_Beekman
New Contributor II
1,790 Views
From the gfortran 4.6 news:

Support the generation of Makefile dependencies via the `-M...` flags of GCC; you may need to specify additionally the -cpp option. The dependencies take modules, Fortran's include, and CPP's #include into account. Note: Using -M for the module path is no longer supported, use -J instead.

Any hope of seeing similar functionality in Intel Fortran compilers in the future (or in an additional tool packaged with the compiler)?

Parsing out the modules used and provided, along with the complexity of support for older language features like common blocks makes writing a robust, generic tool to do this a real nightmare. Resolving Fortran dependencies is a headache, even doing this manually with only a handful of source files if they are pathological enough, but writing an automated tool to handle all of the possible pathologies (like token continuation) is really a huge headache.

Since the compiler must already be parsing the source code, and is able to complain when missing .mod files are absent, it should be possible to leverage the source code parsing already in place for the compiler to implement this.

I know seeing this functionality added would make a lot of users happy. In the mean time I am asking my sysadmins to install gfortran 4.6 just so that I can stop writing tens or hundreds of absurd dependency resolution lines in my Makefiles. I'm still using ifort for the actual compilation though ;-p

Thanks in response for getting back to me! (And my appologies if this feature is already included; if it is, there is no evidence of it in the man page.)

-Z
0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,790 Views
-M is implemented in the current version 12 (Intel Fortran Composer XE 2011).
0 Kudos
Izaak_Beekman
New Contributor II
1,790 Views
If it is there is no documentation in the man page. Also my testing suggests otherwise:
[bash]$ ifort -M ~/xetest.f90 > ~/xetest.d
ifort: command line error: option '-M' is ambiguous
$ ifort -V
Intel Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.1.107 Build 20101116
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.
[/bash]
The contents of xetest.f90 are:
[fortran]module mymodule
  use foo
  use bar
  use baz
  implicit none
  real :: stuff

contains

  subroutine foobar(in,out)
    real, intent(in)  :: in
    real, intent(out) :: out
    
    out = in
  end subroutine foobar

end module mymodule
[/fortran]
Expected output is Makefile dependency specification, like this:
[plain]xetest.o mymodule.mod: xetest.f90 foo.mod bar.mod baz.mod[/plain]
Do i need a more recent version of composer xe 2011? Is something else amiss?
-Z
0 Kudos
mecej4
Honored Contributor III
1,790 Views
Short answer:

ifort /gen-dep:opqp.mak /gen-depformat:make xx.f90 yy.f90 zz.f90

Caveat: if you use in addition the /fpp option, the preprocessor outputs will be given temporary-file-names, and those name will appear in the generated makefile.

Longer answer:

You can do

ifort -help | grep -A5 -B5 -i make (on Linux)

ifort -? | find /I "make" (on Windows)

to see the options related (possibly) to your question.
0 Kudos
Izaak_Beekman
New Contributor II
1,790 Views
Ah I see, great thanks so much. There's a lot of stuff that seems extraneous that gets added, but i will search throuhg the man page to figure out exactly whats going on here. Thanks again for your help. Very glad to see this feature in ifort!
-Z
0 Kudos
Michal_Kvasnicka
Beginner
1,790 Views

ifort -?

ifort: command line warning #10006: ignoring unknown option '-?'

ifort: command line error: no files specified; for help type "ifort -help

0 Kudos
Lorri_M_Intel
Employee
1,790 Views

the command "ifort -?" will work on Windows, not Linux or MacOS.

On the other hand, "ifort -help" works on all three.

-- Lorri

0 Kudos
Izaak_Beekman
New Contributor II
1,790 Views
A quick note about 'gfortran -M': It appears on the latest stable release of gfortran that the -M flag to resolve dependencies has a bug in it: In order to execute the tool on a source file which USEs MODULEs, the .mod files must already be present! I have submitted a bug report to the volunteers over at GCC/gfortran here:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49149
In my initial tests of ifort Composer XE seem to indicate that the equivalent functionality works as expected, albeit generates a lot of dependencies on seemingly obscure library files, possibly required by the compiler/linker.
Just thought some of you might be interested.
0 Kudos
Tobias_Loew
Novice
1,790 Views
Hi Steve,

I still have problems with the module dependency detection in ifort version 12:

The compiler seems to resolve only dependencies that are directly in the code-file, but not dependencies to modules that are used inside included files. Can you have a look at that?

Tobias
0 Kudos
Steven_L_Intel1
Employee
1,790 Views
Tobias,

I tried an example and it seemed to work ok. Can you attach a tar file of a small example thst shows the problem?
0 Kudos
lccostajr
Beginner
1,790 Views

Hi,

I have to preprocess my Fortran files before compile, so I use the /fpp option. Is there a way to avoid temporary file names to appear in the dependency file?

Regards, Luiz

0 Kudos
Lorri_M_Intel
Employee
1,790 Views

Hi Luiz -

That is a known problem, and we're working on it, but we haven't resolved it yet.

May I suggest that you use -save-temps on your command line as a temporary workaround?  There will still be temporary filenames in the dependency file, but they will be reasonably named and the files will be persistent.

                  --Lorri

0 Kudos
Reply