Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Makefile编译F90时出错_Makefile_Fortran_Gnu Make_Gfortran - Fatal编程技术网

使用Makefile编译F90时出错

使用Makefile编译F90时出错,makefile,fortran,gnu-make,gfortran,Makefile,Fortran,Gnu Make,Gfortran,我的源代码f90包括: (1) 模块:dat_io.f90,dimconvert.f90 (2) 主要名称:elastic_2D.f90 以下是我的Makefile: FC=gfortran FCFLAGS=-Wall -O3 FLFLAGS=-mcmodel=large SRCS = $(wildcard *.f90) EXES = $(patsubst %.f90,%,$(SRCS)) %.o: %.f90 $(FC) $(FCFLAGS) -c $< SRC_CODE=\

我的源代码f90包括:

(1) 模块:dat_io.f90,dimconvert.f90

(2) 主要名称:elastic_2D.f90

以下是我的Makefile:

FC=gfortran
FCFLAGS=-Wall -O3
FLFLAGS=-mcmodel=large
SRCS = $(wildcard *.f90)
EXES = $(patsubst %.f90,%,$(SRCS))
%.o: %.f90
    $(FC) $(FCFLAGS) -c $<
SRC_CODE=\
        dat_io.f90\
        dimconvert.f90\
        elastic_2D.f90
OBJ = $(SRC_CODE:%.f90=%.o)
elastic: $(OBJ)
    $(FC) $^ $(FLFLAGS) -o $@
clean:
    rm -rf *.o *.mod *~ $(EXES)
all: clean elastic

这里有什么问题,如何修改?

当使用
-mcmodel=
选项时,在编译和链接时使用此选项非常重要。在这里的Makefile中,
-mcmodel=large
仅在链接阶段给出(通过
FLFLAGS


在这里将选项添加到
FCFLAGS
也将在编译时使用它。

是否有许多通用的静态数组等?否,所有变量通常都是声明的,如int、double、character…这并不意味着“否”。如果没有代表性代码,可能就没有什么可说的了。但是,您是否需要在编译时使用
-mcmodel
,而不仅仅是在链接时?(我不知道gfortran如何处理这个选项。).mod文件会影响结果吗,因为我的Makefile中只包含了.o文件。我不知道如何将它们包含在Makefile中,或者这并不重要,因为它们已经编译成obj文件。在这样的基本设置中,
.mod
文件不需要担心。几乎可以肯定,这与你的问题无关。
elastic_2D.o: In function `MAIN__':
elastic_2D.f90:(.text+0x167): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x1ce): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x23a): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x2b9): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x320): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x38c): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x40b): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x472): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x4de): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x530): relocation truncated to fit: R_X86_64_32S against `.bss'
elastic_2D.f90:(.text+0x5e8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make: *** [elastic] Error 1