我在标准的Unix环境中工作,使用Intel Fortran 2012编译器。由于我的代码有一些旧的.f
文件和一些较新的.f90
文件,因此makefile按以下结构组织,
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 $@
问题是,很少有奇怪的.f
文件依赖于某些.f90
文件中定义的模块,然后编译器似乎无法检测到依赖关系,因为我首先编译了所有.f
文件......
Error in opening the compiled module file. Check INCLUDE paths.
有没有办法解决这个问题?
添加
f77_file_with_module_dependency.o: f90_file_for_module.o
到你的制作文件的某个地方。
假设您有一个依赖于mod_here.f90
的there.f
文件,您可以在makefile中声明以下内容:
there.o: mod_here.o
$(FC) $(FC_FLAG) -c there.f -o there.o
当makefile到达这个文件时,there.f
,它会看到它依赖于尚未编译的mod_here.f90
,因此它将对其进行编译。