是否有适用于f77和f90代码的通用Fortran编译器 [英] Is there any common Fortran compiler for both f77 and f90 codes
本文介绍了是否有适用于f77和f90代码的通用Fortran编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行我的团队的一些旧的Fortran代码。
- 我有两个Fortran 77代码(
cklib.f
和grcom.f
),我用fort77编译,得到了两个目标文件。 - 我有两个Fortran 90代码(
write_counterflow_sol.f
和read_counterflow_sol.f
),我用gfortran编译了它们,得到了另外两个目标文件。
现在,使用以下生成文件,我正在尝试创建一个名为remail.e
SOURCE_CHEMKIN = ../CHEMKIN/DATA_BASES/SOURCES
SOURCE_APPLI= ../SOURCES_COUNTERFLOW/
SOURCES_f77 = $(SOURCE_CHEMKIN)cklib.f $(SOURCE_APPLI)grcom.f $(SOURCE_APPLI)write_counterflow_sol.f $(SOURCE_APPLI)read_counterflow_sol.f
TARGET = remail.e
OBJECTS = $(SOURCES_f77:.f=.o)
COMPILE = f90
.f90.o :
$(COMPILE) -o $*.o -c $*.f90
.f.o :
$(COMPILE) -o $*.o -c $*.f
$(TARGET) : $(OBJECTS)
$(COMPILE) $(OBJECTS) -o $@
del :
$(DELETE) $(OBJECTS)
,但最终出现以下错误
make: f90: Command not found
make: *** [remail.e] Error 127
我知道我的系统中没有F90编译器,所以我尝试在Makefile中使用COMPILE=gfortran
而不是COMPILE=f90
,结果出现此错误。
gfortran ../CHEMKIN/DATA_BASES/SOURCES/cklib.o ../SOURCES_COUNTERFLOW/grcom.o ../SOURCES_COUNTERFLOW/write_counterflow_sol.o ../SOURCES_COUNTERFLOW/read_counterflow_sol.o -o remail.e
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
../CHEMKIN/DATA_BASES/SOURCES/cklib.o: In function `ckcomp_':
fort77-27216-1.c:(.text+0x3a4a): undefined reference to `s_cmp'
../CHEMKIN/DATA_BASES/SOURCES/cklib.o: In function `ckcpml_':
fort77-27216-1.c:(.text+0x3eb8): undefined reference to `pow_di'
fort77-27216-1.c:(.text+0x476f): undefined reference to `s_wsle'
fort77-27216-1.c:(.text+0x4788): undefined reference to `do_lio'
fort77-27216-1.c:(.text+0x478d): undefined reference to `e_wsle'
../CHEMKIN/DATA_BASES/SOURCES/cklib.o: In function `ckrat_':
fort77-27216-1.c:(.text+0xfac0): undefined reference to `pow_dd'
fort77-27216-1.c:(.text+0xfb17): undefined reference to `pow_dd'
fort77-27216-1.c:(.text+0xfef5): undefined reference to `pow_di'
../SOURCES_COUNTERFLOW/grcom.o: In function `MAIN__':
fort77-27073-1.c:(.text+0x1d): undefined reference to `s_copy'
fort77-27073-1.c:(.text+0x36): undefined reference to `s_copy'
fort77-27073-1.c:(.text+0x13e): undefined reference to `s_wsle'
../SOURCES_COUNTERFLOW/write_counterflow_sol.o: In function `write_counterflow_sol__':
fort77-27083-1.c:(.text+0x85): undefined reference to `f_open'
fort77-27083-1.c:(.text+0xc0): undefined reference to `s_wsfe'
fort77-27083-1.c:(.text+0xd6): undefined reference to `do_fio'
../SOURCES_COUNTERFLOW/read_counterflow_sol.o: In function `read_counterflow_sol__':
fort77-28808-1.c:(.text+0x85): undefined reference to `f_open'
fort77-28808-1.c:(.text+0x9b): undefined reference to `s_rsfe'
fort77-28808-1.c:(.text+0xb1): undefined reference to `do_fio'
collect2: error: ld returned 1 exit status
make: *** [remail.e] Error 1
我还尝试在生成文件中使用COMPILE=f77
并成功执行,但在运行可执行文件时收到以下错误。
fmt: end of file
apparent state: unit 14 named sol2
last format: (3i10)
lately reading sequential formatted external IO
Aborted (core dumped)
f77 -v
的输出如下
/usr/bin/f77: fort77 Version 1.15
/usr/bin/f77: No input files specified
f77 --version
的输出如下
/usr/bin/f77: Illegal option: --version
type f77
的输出如下
f77 is hashed (/usr/bin/f77)
很抱歉发了这么长的帖子。但任何帮助都是我们的感激之情。
推荐答案
Gfortran支持Fortran 90,这是Fortran 77的超集。Gfortran还支持Fortran 90之前常用的几种常用语言扩展。
尝试使用多个不同的编译器编译单个应用程序可能会因为不同的运行时库和不同的ABI而导致问题。
所以,忘掉fort77和g77以及其他过时的编译器吧。
这篇关于是否有适用于f77和f90代码的通用Fortran编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文