2

I have installed the new Phortran 7 as part of the PTP.

I want to develop my code using an OOP approach which requires me to have many modules I have found that the managed build system doesn't understand dependencies in my .f90 files.

I was working on this problem for a day now. I will explain my problem using a "fake" project

My project have 2 files

main.f90, module1.f90

main.f90 :

program main
    use module1
    implicit none
    .....
    code...
    .....
end program main

module1.f90:

module module1
    implicit none
    contains
     .....
    code...
    .....
end module module1

When I compile this code using the managed make and build command in the IDE I get the following error:

Fatal Error: Can't open module file 'module1.mod' for reading at (1): No such file or directory
make: *** [main.o] Error 1

It seems like that makefile goes in the alphabet order

taken from the subdir file:

F90_SRCS += \
../main.f90 \
../module1.f90

OBJS += \
./main.o \
./module1.o

I did checked this and if the I compile the project in the order of modul1.f90 before main.f90 everything works great.

But I was under the impression that the IDE can automatically take care of this problem, the USE keyword in Fortran needs to tell the IDE what order to link the files.

Can someone help me with this, I have read in other threads that the managed make should understand dependencies.

Thank you very much.

David MZ
  • 3,648
  • 6
  • 33
  • 50

1 Answers1

0

I've made a little workaround trying to tell the makefile processor to find the dependences. (Tested on Eclipse for Parallel Application Developers. Version: Juno Release. Build id: 20120614-1722)

  1. Set Module and Include Paths (This numeral is cited)

If your source code contains INCLUDE lines or USE lines referencing modules in other files, Photran needs to know where to look in order to find these. It will not figure this out automatically. For each project in which you plan to use refactoring support,

  1. Right-click on your project's folder in the Fortran Projects view
  2. Click on Properties
  3. Expand Fortran General in the list on the left, and click on Analysis/Refactoring
  4. List the folders in which Photran should search for INCLUDE files and modules when refactoring. They will be searched in order from the first folder listed to the last.Subfolders are not searched automatically; you must include them explicitly.
  5. Click OK

. 2.In the eclipse IDE make right click in your project folder then ->refactor->subprogram->introduce call tree. It should show you all the dependences in your modules.

You should be careful with the order of your modules:

with the module

module constants
  implicit none
  real, parameter :: PI=3.14
  real, parameter :: E=2.71828183
  integer, parameter :: answer=42
  real, parameter :: earthRadiusInMeters=6.38e6
end module constants
module constants2
  implicit none
  real, parameter :: PI2=3.14
  real, parameter :: E2=2.71828183
  integer, parameter :: answer2=42
  real, parameter :: earthRadiusInMeters2=6.38e6
end module constants2

it will run with (Code modified from here)

program test
! Option #1:  blanket "use constants"
!  use constants
! Option #2:  Specify EACH variable you wish to use.
  use constants, only : PI,E,answer,earthRadiusInMeters
  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  implicit none

  write(6,*) "Hello world.  Here are some constants:"
  write(6,*) PI, E, answer, earthRadiusInMeters
    write(6,*) PI2, E2, answer2, earthRadiusInMeters2
end program test

but if you change

  use constants, only : PI,E,answer,earthRadiusInMeters
  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  implicit none

for this

  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  use constants, only : PI,E,answer,earthRadiusInMeters
  implicit none

You'll get the same error.

For a bigger program i've used the manual makefile option. But for debugging i've used Intel debugger idb because with the same makefile Photran's debugger did't put the breakpoints.

Best luck pal.

Community
  • 1
  • 1
ebrioloco
  • 59
  • 2