【问题标题】:Problems compiling FORTRAN program编译 FORTRAN 程序的问题
【发布时间】:2016-02-28 19:36:16
【问题描述】:

我必须编译 Fortran 程序,但我没能做到。
我不是这个主题的经验丰富的人,但我尝试在 makefile 中进行一些更改,不幸的是问题仍然存在。

原来的makefile是:

CC = cc
F77 = f77
CFLAGS = -g -DSOLARIS -DDEBUG   #-DINTEL -DFREEBSD  #-DDEBUG
FFLAGS = -g -c
OBJDIR= ../bin
LIB = ./sub/libsaito.a

all: shearSAITOniu shearsaito.li shearsaito shearsaito.2 \
#   shearsaito run.saito saito

shearSAITOniu: shearSAITOniu.f  ${LIB}
    f77 shearSAITOniu.f -e -o ${OBJDIR}/shearSAITOniu -g ${LIB}

shearsaito.li: shearsaito.li.f  ${LIB}
    f77 shearsaito.li.f -e -o ${OBJDIR}/shearsaito.li -g ${LIB}

shearsaito: shearsaito.f ${LIB}
    f77 shearsaito.f -e -o ${OBJDIR}/shearsaito ${LIB}

shearsaito.2: shearsaito.2.f  ${LIB}
    f77 shearsaito.2.f -e -o ../bin/shearsaito.2 -g ${LIB}

qsaito.li: qsaito.li.f ${LIB}
    f77 qsaito.li.f -e -o ${OBJDIR}/qsaito.li ${LIB}

forward: forward.f ${LIB}
    f77 forward.f -e -o ${OBJDIR}/forward ${LIB}

#shear3d: shear3d.f ${LIB}
    f77 shear3d.f -e -o shear3d ${LIB}

#run.saito: run.saito.f ${LIB}
    f77 run.saito.f -o run.saito ${LIB}

#s_saito:   s_saito.f ${LIB}
#   f77 s_saito.f -o s_saito ${LIB}

然后我在 CCFLAGS 中进行了更改,将 -DSOLARIS 替换为 -D_LINUX。
做make后出现错误信息:

f77 ShearSAITOniu.f -e -o ../bin/shearSAITOniu -g ./sub/libsaito.a
/usr/bin/f77:非法选项:-e
make: *** [shearSAIToniu] 错误 255

我不确定此错误消息的含义,但我也尝试将 f77 编译器替换为 gfortran 并得到此错误:

gfortran 剪切SAITOniu.f -e -o ./shearSAITOniu -g ./sub/libsaito.a
gfortran:错误:./shearSAITOniu:不存在 el archivo o el Directorio
make: *** [shearSAIToniu] 错误1

我认为这个程序最初是在 32 位机器上编译的,我的是 64 位的,但我不知道这究竟会产生什么影响。我希望你能帮我解决这个问题,谢谢。

【问题讨论】:

  • 使用标签fortran获得更多关注。

标签: compilation makefile fortran gfortran


【解决方案1】:

要使用gfortran 编译程序shearSAITOniu,请使用命令行:

gfortran shearSAITOniu.f -ffree-form -o ./shearSAITOniu -g ./sub/libsaito.a

这将解决错误:

gfortran: error: ./shearSAITOniu: No existe el archivo o el directorio

但不一定是您尚未发现的其他错误。

这是该错误的原因:

-e 是f77 编译器的一个选项,它 表示:接受加长输入源行。

-o filename 是f77 和gfortran 编译器的一个选项 表示:创建输出文件“文件名”。

-e symbol 是gfortran 编译器的一个选项(严格来说,是链接器) 这意味着:将符号“符号”作为程序的入口点。

对于f77 和gfortran 编译器,出现的文件名 在前面没有选项 -o 的命令行上被解释 就像为编译或链接命名输入文件一样。

因此失败的命令行是什么:

gfortran shearSAITOniu.f -e -o ./shearSAITOniu -g ./sub/libsaito.a

gfortran 的意思是:编译并链接输入文件 shearSAITOniu.f, ./shearSAITOniu 和 ./sub/libsaito.a; 在结果程序中插入调试信息 (-g), 并制作符号-o程序的入口点。

-o 被解释为选项-e 的符号 和./shearSAITOniu 被解释为不存在的输入文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-07
    • 2015-02-15
    • 2020-01-03
    • 1970-01-01
    相关资源
    最近更新 更多