1

我正在使用 Intel Fortran 2012 编译器的标准 Unix 环境中工作。因为我的代码有一些旧.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.

有没有办法解决这个问题?

4

2 回答 2

2

添加

f77_file_with_module_dependency.o: f90_file_for_module.o

到你的 Makefile 某处。

于 2013-11-08T15:34:45.823 回答
0

假设您有一个there.f依赖于 的文件mod_here.f90,您在 makefile 中声明以下内容:

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

当makefile到达这个文件时there.f,它会看到它依赖于mod_here.f90尚未编译的,所以它会编译它。

于 2013-11-08T15:31:36.813 回答