我想将 makefile 的编译器从 pgi 更改为 gfortran,我想知道如何更改 FC 和 FFLAGS 以使其工作
Posted
技术标签:
【中文标题】我想将 makefile 的编译器从 pgi 更改为 gfortran,我想知道如何更改 FC 和 FFLAGS 以使其工作【英文标题】:I want to change the compiler of a makefile from pgi to gfortran and I was wondering how I should change the FC and FFLAGS to make it work 【发布时间】:2021-12-14 13:48:02 【问题描述】:我有 5 个为 pgi 编译器设计的 makefile。但是,我的系统正在使用 gfortran,我不知道如何让它们与我的系统一起使用,以及我应该如何更改 FC 和 FFLAGS。我是 Linux 操作系统的新手,我使用的是 Ubuntu 20.04。 以下是文件包含的内容:
SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic
PROGRAM= mgn2mech
LIBS = -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
-L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
-I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
-I$(CURDIR)/INCLDIR
OBJS = \
checkmem.o \
growseason.o \
$(PROGRAM).o
MODULES= *mod.f
#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------
.SUFFIXES : .f .f .o
.f.o:
$(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
$(FC) -c $(FFLAGS) $(INCLUDE) $<
#-----------------------------------------------------------------------
$(PROGRAM): $(OBJS)
$(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)
#-----------------------------------------------------------------------
clean:
rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------
下一个:
FC = /usr/local/pgi/linux86/bin/pgf90
FCFLGS = -O -Mextend -Mbounds -Mlfs -Msecond_underscore
FCFLGS2 = -O -Mbyteswapio -Mextend -Mbounds -Mlfs -Msecond_underscore
LNKFLGS = -Bstatic
OBJCTS = \
met2mgn.o \
readpar.o \
readmcip.o \
micromet.o \
caldate.o \
lcpgeo.o \
interp_lcp.o \
procmm5.o \
readmm5.o \
xtod.o \
vertmap.o \
juldate.o \
utmgeo.o
LIBS = -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
-L/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/lib -lnetcdf -lpthread
INC = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
-I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include
met2mgn: $(OBJCTS)
$(FC) -o met2mgn $(LNKFLGS) $(OBJCTS) $(LIBS)
met2mgn.o:
$(FC) -c $(FCFLGS2) $(INC) met2mgn.f
readpar.o:
$(FC) -c $(FCFLGS) $(INC) readpar.f
readmcip.o:
$(FC) -c $(FCFLGS2) $(INC) readmcip.f
micromet.o:
$(FC) -c $(FCFLGS2) $(INC) micromet.f
caldate.o:
$(FC) -c $(FCFLGS2) $(INC) caldate.f
lcpgeo.o:
$(FC) -c $(FCFLGS2) $INC lcpgeo.f
interp_lcp.o:
$(FC) -c $(FCFLGS2) $INC interp_lcp.f
procmm5.o:
$(FC) -c $(FCFLGS2) $INC procmm5.f
readmm5.o:
$(FC) -c $(FCFLGS2) $INC readmm5.f
xtod.o:
$(FC) -c $(FCFLGS2) $INC xtod.f
vertmap.o:
$(FC) -c $(FCFLGS2) $INC vertmap.f
juldate.o:
$(FC) -c $(FCFLGS2) $INC juldate.f
utmgeo.o:
$(FC) -c $(FCFLGS2) $INC utmgeo.f
clean:
rm -rf *.o met2mgn
下一个:
SHELL = /bin/sh
FC = pgf90
FFLAGS = -O2 -Mdalign -Mnoframe -byteswapio -Mlfs -Bstatic
PROGRAM = ioapi2uam
LIBS = -L/models/MEGAN/MEGANv2.03a/lib/ioapi_3/Linux2_x86pg -lioapi \
-L/models/MEGAN/MEGANv2.03a/lib/netCDF/lib -lnetcdf
INCLUDE = -I/models/MEGAN/MEGANv2.03a/lib/ioapi_3/fixed_src
RAW = $(PROGRAM).o
.f.o:
$(FC) $(FFLAGS) $(INCLUDE) -c -o $@ $<
.F.o:
$(FC) $(FFLAGS) $(INCLUDE) -c -o $@ $<
$(PROGRAM): $(RAW)
$(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(RAW) $(LIBS)
clean:
rm -f $(PROGRAM)
下一个:
SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic
PROGRAM= emproc
LIBS = -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
-L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
-I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
-I$(CURDIR)/INCLDIR
OBJS = \
gamma_etc.o \
checkmem.o \
canopy.o \
solarangle.o \
findlai.o \
soilnox_fx.o \
soilnox.o \
$(PROGRAM).o
MODULES= *mod.f
#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------
.SUFFIXES : .f .f .o
.f.o:
$(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
$(FC) -c $(FFLAGS) $(INCLUDE) $<
#-----------------------------------------------------------------------
$(PROGRAM): $(OBJS)
$(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)
#-----------------------------------------------------------------------
clean:
rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------
最后一个:
SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic
PROGRAM= emproc
LIBS = -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
-L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
-I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
-I$(CURDIR)/INCLDIR
OBJS = \
gamma_etc.o \
checkmem.o \
canopy.o \
solarangle.o \
findlai.o \
soilnox_fx.o \
soilnox.o \
$(PROGRAM).o
MODULES= *mod.f
#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------
.SUFFIXES : .f .f .o
.f.o:
$(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
$(FC) -c $(FFLAGS) $(INCLUDE) $<
#-----------------------------------------------------------------------
$(PROGRAM): $(OBJS)
$(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)
#-----------------------------------------------------------------------
clean:
rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------
【问题讨论】:
您是否遇到错误?如果是这样,哪些错误? 【参考方案1】:看看the I/O API M3Tools Makefile template。
请注意,各种类型的 ioapi/Makeinclude.$BIN 文件——在这种情况下,$BIN=Linux2_x86_64gfort
for gfortran before version 10, or $BIN=Linux2_x86_64gfort10
for gfortran versions 10 or later 将为您提供所需的标志。
还要注意,这个 m3tools/Makefile.template 与底层 Models-3 I/O API 的集成比代码作者提供给您的 API 更好......
【讨论】:
以上是关于我想将 makefile 的编译器从 pgi 更改为 gfortran,我想知道如何更改 FC 和 FFLAGS 以使其工作的主要内容,如果未能解决你的问题,请参考以下文章
新的PGI编译器可将支持GPU的HPC应用从Linux/x86无缝迁移到支持NVLink的OpenPOWER+Tesla