Search code examples
makefilefortranintel-fortran

The case that ifort with -gen-dep option cannot generate dependecy without .mod files


First of all, please read ---PS--- part. This problem is my misunderstanding.

I'm using ubuntu18.04 OS and intel fortran compiler of "parallel studio xe 2020 update 4" ifort.

I have tried to generate dependency among fortran source files using the ifort compiler with the -gen-dep option.

The following simple code was written for my test. The filename is "main.f90".

program main
    use mod_a
    implicit none

end program main

I executed following command to generate dependency of "main.f90".

ifort -gen-dep -syntax-only main.f90

As a result, I got following error message.

main.f90(2): エラー #7002: コンパイル済みモジュールファイルを開くときのエラーです。INCLUDE パスを確認してください。   [MOD_A]
    use mod_a
--------^

The error message notifies that "mod_a.mod" file does not existed yet (while it is written in Japanese). In the case the "mod_a.mod" has already been generated with compiling mod_a.f90, I got the following "true dependency" with executing above command.

main.o : \
  main.f90 mod_a.mod

How can I generate dependency without generating mod_a.mod? If it exist that the additional ifort options to achieve my goal, I want to know the options with priority.

Thank you for reading.

---PS---

I appologize to everyone who has read this post. This problem is my misunderstanding.

I tried compiling my "main.f90" program again with ifort -gen-dep -syntax-only main.f90.

program main
    use mod_a
    implicit none

end program main

As a result, I got following error message and "true dependency".

main.f90(2): エラー #7002: コンパイル済みモジュールファイルを開くときのエラーです。INCLUDE パスを確認してください。   [MOD_A]
    use mod_a
--------^
main.o : \
  main.f90 mod_a.mod

I don't know why I didn't see this "true dependency", but my goal was already achieved.

However, additionally, I found a another probrem and solved it. In the case that "main.f90" has huge code which use many subroutines, functions, variables, etc... ifort -gen-dep -syntax-only main.f90 returned

fatal error: too many errors emitted, stopping now

and didn't return dependency. To solve this problem, I added the -no-diag-error-limit to ifort command.


Solution

  • You need to supply information about mod_a. Either compile it beforehand or supply it to the ifort -gen-dep command as such

    $ ifort -gen-dep -syntax-only main.f90 mod_a.f90 
    main.o : \
      main.f90 mod_a.mod
    
    mod_a.mod : \
      mod_a.f90
    
    mod_a.o : \
      mod_a.f90