Feature request/status: Automatically resolve dependancies like gfortran 4.6

Feature request/status: Automatically resolve dependancies like gfortran 4.6

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.)


12 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

-M is implemented in the current version 12 (Intel Fortran Composer XE 2011).

Steve - Intel Developer Support

If it is there is no documentation in the man page. Also my testing suggests otherwise:

$ 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 Build 20101116
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

The contents of xetest.f90 are:

module mymodule
  use foo
  use bar
  use baz
  implicit none
  real :: stuff


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

end module mymodule

Expected output is Makefile dependency specification, like this:

xetest.o mymodule.mod: xetest.f90 foo.mod bar.mod baz.mod

Do i need a more recent version of composer xe 2011? Is something else amiss?-Z


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.

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


ifort -?

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

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

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

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

-- Lorri

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=49149In 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.


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?



I tried an example and it seemed to work ok. Can you attach a tar file of a small example thst shows the problem?

Steve - Intel Developer Support


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

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.


Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!