lorniper
lorniper

Reputation: 638

Fortran file dependency with Intel ifort

I am working in a standard Unix environment, with Intel Fortran 2012 compiler. since my codes have some old .f files and some newer .f90 files, the makefile is organized in the following structure,

f_sources= ... ...
f90_sources= ... ...

f_objects = $(patsubst %.f,%.o,$(f_sources))
f90_objects = $(patsubst %.f90,%.o,$(f90_sources))

$(f_objects): %.o: %.f
        @echo compiling $<
        $(FC) $(FC_FLAGS) -c $< -o $@

# compile f90 files:
$(f90_objects): %.o: %.f90
        @echo compiling $<
        $(FC) $(FC_FLAGS) -c $< -o $@

The problem is, few strange .f files depend on the modules defined in some .f90 files, and then the compiler seems not able to detect the dependency since I compile first all the .f files...

Error in opening the compiled module file.  Check INCLUDE paths.

Is there a way to solve this problem?

Upvotes: 1

Views: 1911

Answers (2)

Etan Reisner
Etan Reisner

Reputation: 80931

Add

f77_file_with_module_dependency.o: f90_file_for_module.o

to your Makefile somewhere.

Upvotes: 2

Kyle Kanos
Kyle Kanos

Reputation: 3264

Supposing that you have a there.f file that depends on mod_here.f90, you declare in your makefile the following:

there.o: mod_here.o
      $(FC) $(FC_FLAG) -c there.f -o there.o

When the makefile gets to this file, there.f, it will see that it depends on mod_here.f90, which hasn't yet been compiled, so it'll compile it.

Upvotes: 0

Related Questions