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
如何解决gfortran编译和链接错误?_Fortran_Gfortran - Fatal编程技术网

如何解决gfortran编译和链接错误?

如何解决gfortran编译和链接错误?,fortran,gfortran,Fortran,Gfortran,我试图用gfortran编译一组旧的fortran和C代码。它们在linux工作站上编译得很好,但在Mac电脑上编译失败。有没有办法解决这个问题?Linux版本中的Makefile在CFLAGS和FFLAGS-mcmodel=large中有一个额外的标志,我根据一些建议删除了这个标志 这是最后一条链接线上的错误 gfortran -fopenmp -O3 -m64 lsmrDataModule.o lsmrModule.o delsph.o gaussian.o CalSurfG2.o main

我试图用gfortran编译一组旧的fortran和C代码。它们在linux工作站上编译得很好,但在Mac电脑上编译失败。有没有办法解决这个问题?Linux版本中的Makefile在CFLAGS和FFLAGS
-mcmodel=large
中有一个额外的标志,我根据一些建议删除了这个标志

这是最后一条链接线上的错误

gfortran -fopenmp -O3 -m64 lsmrDataModule.o lsmrModule.o delsph.o gaussian.o CalSurfG2.o main2.o aprod.o cluster1.o covar.o datum.o delaz.o delaz2.o direct1.o dist.o exist.o freeunit.o ifindi.o indexxi.o juliam.o matmult1.o matmult2.o matmult3.o mdian1.o normlz.o ran.o redist.o resstat_FDD.o scopy.o sdc2.o setorg.o snrm2.o sort.o sorti.o sscal.o svd.o tiddid.o trialsrc_FDD_shot.o trimlen.o vmodel.o RaySPDR2new.o getinpSPDR.o getdata_SPDR.o dtres_FDD_lm5.o weighting_FDD.o lsfitHFDD_lsqr_lm5.o get_dims.o add_sta.o find_id2.o surfdisp96.o atoangle_.o atoangle.o datetime_.o hypot_.o rpad_.o sscanf3_.o transform_r_gfortran_double.o   -o tomoJointBS
final section layout:
    __TEXT/__text addr=0x1000014A0, size=0x0008F7D1, fileOffset=0x000014A0, type=1
    __TEXT/__text_startup addr=0x100090C80, size=0x00000026, fileOffset=0x00090C80, type=1
    __TEXT/__stubs addr=0x100090CA6, size=0x0000018C, fileOffset=0x00090CA6, type=28
    __TEXT/__stub_helper addr=0x100090E34, size=0x000002A4, fileOffset=0x00090E34, type=32
    __TEXT/__cstring addr=0x1000910D8, size=0x000130B9, fileOffset=0x000910D8, type=13
    __TEXT/__const addr=0x1000A41A0, size=0x00004C6C, fileOffset=0x000A41A0, type=0
    __TEXT/__eh_frame addr=0x1000A8E10, size=0x000051E0, fileOffset=0x000A8E10, type=19
    __DATA/__got addr=0x1000AE000, size=0x00000028, fileOffset=0x000AE000, type=29
    __DATA/__nl_symbol_ptr addr=0x1000AE028, size=0x00000010, fileOffset=0x000AE028, type=29
    __DATA/__la_symbol_ptr addr=0x1000AE038, size=0x00000210, fileOffset=0x000AE038, type=27
    __DATA/__const addr=0x1000AE248, size=0x00000010, fileOffset=0x000AE248, type=0
    __DATA/__data addr=0x1000AE260, size=0x00000030, fileOffset=0x000AE260, type=0
    __DATA/__pu_bss2 addr=0x1000AE290, size=0x000000A8, fileOffset=0x00000000, type=25
    __DATA/__pu_bss5 addr=0x1000AE340, size=0x000004C0, fileOffset=0x00000000, type=25
    __DATA/__bss5 addr=0x1000AE800, size=0x00229680, fileOffset=0x00000000, type=25
    __DATA/__pu_bss3 addr=0x1002D7E80, size=0x00000028, fileOffset=0x00000000, type=25
    __DATA/__common addr=0x1002D7EC0, size=0x000000A0, fileOffset=0x00000000, type=25
    __DATA/__bss3 addr=0x1002D7F60, size=0x00000010, fileOffset=0x00000000, type=25
    __DATA/__bss2 addr=0x1002D7F70, size=0x00000004, fileOffset=0x00000000, type=25
    __DATA/__huge addr=0x1002D7F80, size=0x3FA6069F4, fileOffset=0x00000000, type=25
ld: unexpected bindingNone in '_MAIN__' from main2.o for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [tomoJointBS] Error 1
这是Makefile

CMD = tomoJointBS
CC  = gcc
FC  = gfortran
SRCS    = main2.f\
      aprod.f cluster1.f covar.f datum.f \
      delaz.f delaz2.f direct1.f dist.f exist.f \
      freeunit.f ifindi.f \
      indexxi.f juliam.f  \
      matmult1.f matmult2.f matmult3.f mdian1.f \
      normlz.f ran.f redist.f \
      resstat_FDD.f scopy.f sdc2.f setorg.f \
      snrm2.f sort.f sorti.f sscal.f \
      svd.f tiddid.f trialsrc_FDD_shot.f trimlen.f \
      vmodel.f RaySPDR2new.f  \
          getinpSPDR.f getdata_SPDR.f \
          dtres_FDD_lm5.f weighting_FDD.f lsfitHFDD_lsqr_lm5.f \
      get_dims.f add_sta.f find_id2.f \
      surfdisp96.f 
CSRCS   = atoangle_.c atoangle.c datetime_.c hypot_.c rpad_.c \
          sscanf3_.c transform_r_gfortran_double.c
F90SRCS = lsmrDataModule.f90 \
          lsmrModule.f90 delsph.f90 gaussian.f90
OBJS    = $(F90SRCS:%.f90=%.o) CalSurfG2.o $(SRCS:%.f=%.o) $(CSRCS:%.c=%.o) 
INCLDIR = ./include

CFLAGS = -O3 -I$(INCLDIR) -m64
FFLAGS  = -O3 -I$(INCLDIR) -ffixed-line-length-none -ffloat-store -W  -m64 -fbounds-check
LDFLAGS         = -O3 -m64

all: $(CMD) 

$(CMD): $(OBJS)
    $(FC) -fopenmp $(LDFLAGS) $(OBJS) $(LIBS) -o $@
%.o: %.f90
    $(FC) $(FFLAGS) -c $(@F:.o=.f90) -o $@
CalSurfG2.o:CalSurfGnew2.f90                                                 
        $(FC) -fopenmp $(FFLAGS) -c $< -o $@
%.o: %.f
    $(FC) $(FFLAGS) -c $(@F:.o=.f) -o $@
CMD=tomoJointBS
CC=gcc
FC=gfortran
SRCS=main2.f\
近似f聚类1.f坐标f基准f\
delaz.f delaz2.f direct1.f dist.f exist.f\
自由单位\
indexxi.f juliam.f\
matmult1.f matmult2.f matmult3.f mdian1.f\
normlz.f run.f redist.f\
resstat_FDD.f scopy.f sdc2.f setorg.f\
snrm2.f sort.f sorti.f sscal.f\
svd.f TIDDED.f trialsrc\U FDD\U shot.f trimlen.f\
vmodel.f rayspr2new.f\
getinpsdr.f getdata\u SPDR.f\
dtres_FDD_lm5.f加权_FDD.f lsfitHFDD_lsqr_lm5.f\
获取dims.f添加sta.f查找id2.f\
surfdisp96.f
CSRCS=atoangle\uC.atoangle.c datetime\uC Hypto\uC.rpad\uC\
sscanf3.c变换\u r\u gfortran\u double.c
F90SRCS=lsmrDataModule.f90\
lsmrModule.f90 delsph.f90 gaussian.f90
OBJS=$(F90SRCS:%.f90=%.o)CalSurfG2.o$(SRCS:%.f=%.o)$(CSRCS:%.c=%.o)
INCLDIR=/包括
CFLAGS=-O3-I$(包括DIR)-m64
FFLAGS=-O3-I$(INCLDIR)-ffixed line length none-ffloat store-W-m64-fbounds check
LDFLAGS=-O3-m64
全部:$(CMD)
$(CMD):$(OBJS)
$(FC)-fopenmp$(LDFLAGS)$(OBJS)$(LIBS)-o$@
%.o:%.f90
$(FC)$(FFLAGS)-c$(@F:.o=.f90)-o$@
CalSurfG2.o:CalSurfGnew2.f90
$(FC)-fopenmp$(FFLAGS)-c$<-o$@
%.o:%.f
$(FC)$(FFLAGS)-c$(@F:.o=.F)-o$@

此消息似乎来自macOS链接器。您是否验证了可以先编译一些简单的hello world Fortran程序?其次,从性能角度来看,删除-ffloat存储选项。在x86-64上使用SSE寄存器进行浮点运算是毫无意义的。此外,从性能角度来看,-fbounds check(或者更好的是,-fcheck=all)有助于调试,但一旦您验证了一切正常,您可能希望删除该选项。能否显示main2.f的内容(或者至少显示与MAIN相关的部分)?