I have a directory structure like this:
main/
foo.f90
bar.f90
main/stuff
floop.f90
foo.f90 contains a PROGRAM which includes functionality of bar.f90 via the USE keyword, and bar.f90 includes functionality of floop.f90 via USE
My Makefile looks like:
# define objects, mods
objects: foo.o bar.o floop.o
mods: foo.mod bar.mod floop.mod
FC = gfortran
# make
foo: $(objects)
$(FC) -o foo $(objects)
floop.o : stuff/floop.f90
$(FC) -c stuff/floop.f90
bar.o : bar.f90
$(FC) -c bar.f90
foo.o : bar.o floop.o foo.f90
$(FC) -c foo.f90
Trying to make this, though, I get an error from the bar.f90 source:
gfortran -c bar.f90
use floop
1
Fatal Error: Can't open module file 'floop.mod' for reading at (1): No such file or directory
How do I make gfortran aware of the location of thus module? As I understand, mod files are created in the current working directory by default, so I thought that constructing the floop.o target correctly, by explicitly pointing to the source at stuff/floop.f90, would be sufficient.