爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 1902|回复: 1

关于makefile的问题,make命令后总是提示错误

[复制链接]

新浪微博达人勋

发表于 2018-3-30 15:50:23 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
    以下是monortm模式需要编译的makefile,因为对linux不了解,自己可能有编译不对的地方,造成make命令后总是提示错误,makefile(名字为make_monortm)代码如下,其中粉色字体是我自己根据理解加上的,其他都是模式自带的代码,没有修改,模式的说明书提示用make -f make_monortm OPTION这个命令,我用了这个命令提示找不到OPTION,除了这个make_monortm文件,同一个文件夹下还带有一个makefile.common的文件(这个文件是起到解释说明的意思吗,我不太明白,如果有能看懂的大神希望可以指点一下,把makefile.common的代码也一并贴在下面了),模式转不下去了,第一次接触,真的不懂啊,超级超级感谢~~~愁死了

以下是make_monortm的代码 # $Revision: 11217 $
# Makefile for monortm
# From monortm/build directory, type: gmake -f make_monortm <TARGET>

# Include file containing user input. Directory is referenced to
# parent directory and common build rules
include makefile.common

###############################
# Set variables/
###############################
#Set version name.  Used in the default OUTPUT and CDOTO variables.  If you
# change those two variables from what is provided here, no need to set this variable.

# Set directory containing source files, relative to main directory from which
# you are executing the makefile
CPATH = /mnt/d/wenjian/xiangmu/monortm/moshi/monortm/src

include $(CPATH)/versionNum.incl
PRODUCT = monortm
VERSION = v$(subst ',5.4,$(vers))

# Set netcdf output if desired
ifndef NETCDF
NETCDF := no
endif

# Set name of MONORTM executable.  
OUTPUT = ${PRODUCT}_$(VERSION)_$(PLTFRM)_$(FC_TYPE)_$(P_TYPE)

# Set directory for object files.  
CDOTO = /mnt/d/wenjian/xiangmu/monortm/moshi/monortm/build/${PRODUCT}_$(VERSION)_$(PLTFRM)_$(FC_TYPE)_$(P_TYPE).obj
# Set directory for module files.  
FDOTM = /mnt/d/wenjian/xiangmu/monortm/moshi/monortm/build/${PRODUCT}_$(VERSION)_$(PLTFRM)_$(FC_TYPE)_$(P_TYPE).mods

# Files contained in src directory.  If additional .f files are added,
# add to this list.
SRCS = CntnmFactors.f90 lblparams.f90 PhysConstants.f90 struct_types.f90 PlanetEarth.f90 \
contnm.f90 monortm_sub.F90 modm.f90 RTMmono.f90 CloudOptProp.f90 \
lnfl_mod.f90 monortm.f90 tips_2003.f90 lblatm.f90 lblrtm_sub.f90  bufin_sgl.f90 netcdf_helper_mod.F90

# Module dependencies
monortm.o modm.o monortm_sub.o: CntnmFactors.o
lblatm.o lnfl_mod.o contnm.o: lblparams.o
modm.o lnfl_mod.o: struct_types.o
monortm_sub.o modm.o lblatm.o: PhysConstants.o
lblatm.o modm.o: PlanetEarth.o
modm.o: lnfl_mod.o CloudOptProp.o
monortm.o: modm.o
lnfl_mod.o: bufin_sgl.o
monortm.o modm.o monortm_sub.o: RTMmono.o
monortm_sub.o : netcdf_helper_mod.o

INCLUDES:= -I. -I$(FDOTM)

ifeq ($(NETCDF),yes)
   LIB_NETCDF = $(NCL)
   INC_NETCDF = $(NCI)
   INCLUDES += -I$(INC_NETCDF)
   LDFLAG = -L$(LIB_NETCDF) -lnetcdf -lnetcdff
   FCDF = -DUSENETCDF
endif

# Define makefile name
MAKEFILE=make_$(PRODUCT)

# Rule for compiling .o files

%.o:%.f
        $(FC) -c $(FCFLAG) $(INCLUDES)  $< -o ${CDOTO}/$@

%.o:%.f90
        $(FC) -c $(FCDF) $(FCFLAG) $(INCLUDES) $< -o ${CDOTO}/$@

%.o:%.F90
        $(FC) -c $(FCDF) $(FCFLAG) $(INCLUDES) $< -o ${CDOTO}/$@

# Object file names
OBSS:= $(patsubst %.f90,%.o,$(patsubst %.f,%.o,$(patsubst %.F90,%.o,$(SRCS))))
# Prepend the object file path to each file name
OBPATH := $(foreach objt,$(OBSS),$(CDOTO)/$(objt))

build : buildmain sweep debug

buildmain : $(OBSS)
        $(FC) $(FCDF) $(FCFLAG) $(LDFLAG) -o /mnt/d/wenjian/xiangmu/monortm/moshi/monortm/run/$(OUTPUT) $(OBPATH)

.PHONY: sweep

debug:
        echo "FCDF ${FCDF}"
        echo "LDFLAG ${LDFLAG}"
        echo "INCLUDES ${INCLUDES}"
        echo "NETCDF ${NETCDF}"

sweep:
        @#sweep the .mod files so another platform does not confuse them
        find . -maxdepth 1 -name '*.mod' -exec mv {} $(FDOTM)/. \;









~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以下是makefile.commond的代码

#     author:    $Author: vpayne $
#     revision:  $Revision: 11213 $
#     created:   $Date: 2011-03-29 13:49:44 -0400 (Tue, 29 Mar 2011) $

# COMPILE OPTIONS
# THESE OPTIONS CAN BE EXPANDED FOR OTHER SYSTEMS, JUST FOLLOW THE
# GIVEN FORMAT.

# Generic Compiler Options

###############################################
# Start of common material
###############################################

# Search for .o and .f files in given directories
VPATH = $(CPATH): $(CDOTO)

###############################
# Default
###############################

default:
        @echo
        @Echo '-----------------'
        @echo '  $(PRODUCT) $(VERSION) Makefile'
        @echo '-----------------'
        @echo
        @echo 'Please specify desired compiler and precision using'
        @echo
        @echo 'gmake -f make_$(PRODUCT) <target>'
        @echo
        @echo 'current supported targets are:'
        @echo
        @echo 'sunSUNsgl    : Solaris sun studio fortran single precision'
        @echo 'sunSUNdbl    : Solaris sun studio fortran double precision'
        @echo 'linuxGNUsgl  : Linux gfortran single precision'
        @echo 'linuxGNUdbl  : Linux gfortran double precision'
        @echo 'linuxPGIdbl  : linux using pgi fortran and double precision'
        @echo 'linuxPGIsgl  : linux using pgi fortran and single precision'
        @echo 'linuxG95dbl  : Linux using g95 and double precision'
        @echo 'linuxG95sgl  : Linux using g95 and single precision'
        @echo 'linuxINTELdbl: Linux using Intel Fortran and double precision'
        @echo 'linuxINTELsgl: Linux using Intel Fortran and single precision'
        @echo 'sgiMIPSdbl   : SGI using MIPS fortran and double precision'
        @echo 'sgiMIPSsgl   : SGI using MIPS fortran and single precision'
        @echo 'osxINTELdbl  : OSX using Intel Fortran and double precision'
        @echo 'osxINTELsgl  : OSX using Intel Fortran and single precision'
        @echo 'osxABSOFTdbl : OSX using Absoft PRO Fortran and double precision'
        @echo 'osxABSOFTsgl : OSX using Absoft PRO Fortran and single precision'
        @echo 'osxGNUdbl    : OSX using GNU Fortran and double precision'
        @echo 'osxGNUsgl    : OSX using GNU Fortran and single precision'
        @echo 'osxIBMdbl    : OSX using IBM XL Fortran and double precision'
        @echo 'osxIBMsgl    : OSX using IBM XL Fortran and single precision'
        @echo 'mingwGNUdbl' : Window unix shell environment using gfortran and double precision'
        @echo 'mingwGNUsgl' : Window unix shell environment using gfortran and single precision'
        @echo 'aixIBMsgl    : AIX using IBM XL Fortran and double precision'
        @echo 'aixIBMsgl    : AIX using IBM XL Fortran and single precision'
        @echo


###############################
# Load line
###############################

all : intro makedir build conclude

###############################
# Intro information
###############################
intro :
        @echo
        @echo '-----------------'
        @echo '  $(OUTPUT) Makefile'
        @echo '-----------------'
        @echo
        @echo 'This Makefile was designed for the $(PLTFRM) platform.'
        @echo
        @echo 'It uses the $(FC) compiler, with the following options:'
        @echo '      $(FCFLAG)'
        @echo
        @echo 'The source files used are as follows:'
        @echo
        @echo '      $(SRCS)'
        @echo
        @echo
        @echo '$(OUTPUT) make in progress ...'
        @echo


###############################
# Concluding information
###############################

conclude :
        @echo
        @echo '================='
        @echo '  Makefile done'
        @echo '================='

###############################
# Create object file directory
###############################


makedir :
        test -d $(CDOTO) || mkdir $(CDOTO)
        test -d $(FDOTM) || mkdir $(FDOTM)

###############################
# common build rules
###############################

clean:
        -rm -rf *.o
        -rm -rf $(PRODUCT)_$(VERSION)_*.obj
        -rm -rf $(PRODUCT)_$(VERSION)_*.mods
       
cleanall:
        -rm -rf *.o
        -rm -r *_$(VERSION)_*.obj
        -rm -r *_$(VERSION)_*.mods
       
#*************************************************************
# SUN/SOLARIS OPERATING SYSTEM
#*************************************************************

##############################################################
# Sun OS using sun fortran and double precision
##############################################################

sunSUNdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=sunf90 \
        PLTFRM=sun  \
        FC=f90 \
        FCFLAG="-xtypemap=real:64,double:64,integer:64"

##############################################################
# Sun OS using sun fortran and single precision
##############################################################

sunSUNsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=sunf90 \
        PLTFRM=sun \
        FC=f90 \
        FCFLAG=-fast

#*************************************************************
# SGI/IRIX64 OPERATING SYSTEM
#*************************************************************

##############################################################
# SGI using MIPS fortran and double precision
##############################################################
sgiMIPSdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=mips \
        PLTFRM=sgi  \
        FC=f90 \
        FCFLAG="-mips4 -r10000 -lfastm -O3 -r8 -i8 -TENV:X=0"

##############################################################
# SGI using MIPS fortran and single precision
##############################################################
sgiMIPSsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=mips \
        PLTFRM=sgi  \
        FC=f90 \
        FCFLAG="-mips4 -r10000 -lfastm -O3 -TENV:X=0"

#*************************************************************
# LINUX OPERATING SYSTEM
#*************************************************************

##############################################################
# linux using pgi fortran and double precision
##############################################################

linuxPGIdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=pgi PLTFRM=linux \
        FC=pgf90  \
        FCFLAG="-fast -r8 -i8"

##############################################################
# linux using pgi fortran and single precision
##############################################################

linuxPGIsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=pgi PLTFRM=linux \
        FC=pgf90 \
        FCFLAG="-fast"
       
##############################################################
# linux using gfortran and double precision
##############################################################

linuxGNUdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=gnu PLTFRM=linux \
        FC=gfortran  \
        FCFLAG="-fdefault-integer-8 -fdefault-real-8 -Wall -frecord-marker=4"

##############################################################
# linux using gfortran and single precisions
##############################################################

linuxGNUsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=gnu PLTFRM=linux \
        FC=gfortran \
        FCFLAG="-Wall -frecord-marker=4"

##############################################################
# linux using g95 and double precision
##############################################################

linuxG95dbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=g95 PLTFRM=linux \
        FC=g95  \
        FCFLAG="-O3 -r8 -i8"

##############################################################
# linux using g95 and single precision
##############################################################

linuxG95sgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=g95 PLTFRM=linux \
        FC=g95 \
        FCFLAG="-O3"

##############################################################
# linux using Intel Fortran and double precision
##############################################################

linuxINTELdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=intel PLTFRM=linux \
        FC=ifort  \
        FCFLAG="-r8 -i8 -w -Vaxlib"

##############################################################
# linux using Intel Fortran and single precision
##############################################################

linuxINTELsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=intel PLTFRM=linux \
        FC=ifort \
        FCFLAG="-w -Vaxlib"


#*************************************************************
# APPLE MAC/OS_X OPERATING SYSTEM
#*************************************************************

##############################################################
# OSX using Intel Fortran and double precision
##############################################################

osxINTELdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=intel \
        PLTFRM=OS_X  \
        FC=ifort \
        FCFLAG="  -O3 -r8 -i8


##############################################################
# OSX using Intel Fortran and single precision
##############################################################

osxINTELsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=intel \
        PLTFRM=OS_X \
        FC=ifort \
        FCFLAG=" -O3


##############################################################
# OSX using Absoft PRO Fortran and double precision
##############################################################

osxABSOFTdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=intel \
        PLTFRM=OS_X  \
        FC=absoft \
        FCFLAG="-s -O -N11 -i8 -N113"

##############################################################
# OSX using Absoft PRO Fortran and single precision
##############################################################

osxABSOFTsgl:       
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=intel \
        PLTFRM=OS_X \
        FC=absoft \
        FCFLAG="-s -O -N11 -i8 -lU77"

##############################################################
# OSX using GNU Fortran and double precision
##############################################################

osxGNUdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=gnu \
        PLTFRM=OS_X  \
        FC=gfortran \
        FCFLAG=" -fdefault-integer-8 -fdefault-real-8 -Wall -frecord-marker=4"

##############################################################
# OSX using GNU Fortran and single precision
##############################################################

osxGNUsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=gnu \
        PLTFRM=OS_X \
        FC=gfortran \
        FCFLAG="-Wall -frecord-marker=4"

##############################################################
# OSX using IBM XL Fortran and double precision
##############################################################

osxIBMdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=ibm_xl \
        PLTFRM=OS_X  \
        FC=xlf90 \
        FCFLAG="-O2 -qfixed=72 -qmaxmem=-1 -qrealsize=8 -qintsize=8"

##############################################################
# OSX using IBM XL Fortran and single precision
##############################################################
osxIBMsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=ibm_xl \
        PLTFRM=OS_X \
        FC=xlf90 \
        FCFLAG="-O2 -qfixed=72 -qmaxmem=-1"

#*************************************************************
# WINDOWS OPERATING SYSTEM
#*************************************************************

##############################################################
# window unix shell environment using gfortran and double precision
##############################################################

mingwGNUdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=gnu PLTFRM=mingw \
        FC=gfortran  \
        FCFLAG="-fdefault-integer-8 -fdefault-real-8 -Wall -frecord-marker=4"

##############################################################
# window unix shell environment using gfortran and single precision
##############################################################

mingwGNUsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=gnu PLTFRM=mingw \
        FC=gfortran \
        FCFLAG="-Wall -frecord-marker=4"

#*************************************************************
# IBM/AIX OPERATING SYSTEM
#*************************************************************

##############################################################
# AIX using IBM XL Fortran and double precision
##############################################################
aixIBMdbl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=dbl FC_TYPE=ibm_xl \
        PLTFRM=AIX  \
        FC=xlf90 \
        FCFLAG="-O2 -qmaxmem=-1 -qrealsize=8 -qintsize=8"


##############################################################
# AIX using IBM XL Fortran and single precision
##############################################################
aixIBMsgl:
        ${MAKE} -f ${MAKEFILE} all P_TYPE=sgl FC_TYPE=ibm_xl \
        PLTFRM=AIX \
        FC=xlf90 \
        FCFLAG="-O2 -qmaxmem=-1"

# Rule for compiling .o files

%.o:%.f
        $(FC) -c $(FCFLAG)  $< -o ${CDOTO}/$@




密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-3-31 10:20:45 | 显示全部楼层
嗯,自己顶一下吧,这个部分搞明白了,就是输入make -f make_monortm  linuxGNUdbl(linuxGNUdbl这个其实就是代表那个option了),按照自己的版本选择就可以了,希望对以后遇到的人能有所帮助吧,关于这个模式的介绍真的太少了
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表