Background
I'm working on compiling MCIP which mean Meteorology Chemistry Interface Processor in centos 5.9 system.
I use gcc -version 4.9 to implement the process.
Setting
Here is some configuration setting in ~/.bashrc:
export DIR=/disk2/hyf/lib ## All lib ar installed under this path
# NetCDF setting
export PATH="$DIR/netcdf/bin:$PATH"
export NETCDF="$DIR/netcdf"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF/lib
# IOAPI
export BIN=Linux2_x86_64gfort
export BASEDIR=/disk2/hyf/backup/software/ioapi
export PATH=$DIR/ioapi-3.1/bin:$PATH
export LD_LIBRARY_PATH=$DIR/ioapi-3.1/lib:$LD_LIBRARY_PATH
# Set M3LIB for the model
export M3LIB=/disk2/hyf/cmaq/CMAQv5.1/lib
I also do soft link for the CMAQ model as these:
ln -s $NETCDF $(M3LIB)/x86_64/gcc/netcdf
ln -s $IOAPI $(M3LIB)/x86_64/gcc/ioapi
Makefile
Here is some subroutine in the Makefile:
# Requirements: set M3LIB before running this script
.SUFFIXES:
.SUFFIXES: .o .f90 .F90
MODEL = mcip.exe
#...gfortran
FC = gfortran
NETCDF = $(M3LIB)/netcdf
IOAPI_ROOT = $(M3LIB)/ioapi
FFLAGS = -O3 -gdwarf-2 -gstrict-dwarf -I$(NETCDF)/include - I$(IOAPI_ROOT)/include \
-ffpe-trap='invalid','zero','overflow','underflow'
##FFLAGS = -g -O0 \
-ffpe-trap='invalid','zero','overflow','underflow' \
-I$(NETCDF)/include -I$(IOAPI_ROOT)/include
LIBS = -L$(IOAPI_ROOT)/lib -lioapi \
-L$(NETCDF)/lib -lnetcdf -lgomp
DEFS =
MODULES =\
const_mod.o \
const_pbl_mod.o \
coord_mod.o \
date_time_mod.o \
date_pack_mod.o \
files_mod.o \
groutcom_mod.o \
luvars_mod.o \
mcipparm_mod.o \
mcoutcom_mod.o \
mdoutcom_mod.o \
metinfo_mod.o \
metvars_mod.o \
vgrd_mod.o \
wrf_netcdf_mod.o \
xvars_mod.o \
sat2mcip_mod.o
OBJS =\
mcip.o \
alloc_ctm.o \
alloc_met.o \
alloc_x.o \
bcldprc_ak.o \
blddesc.o \
chkwpshdr.o \
chkwrfhdr.o \
close_files.o \
collapx.o \
comheader.o \
cori.o \
dealloc_ctm.o \
dealloc_met.o \
dealloc_x.o \
detangle_soil_px.o \
e_aerk.o \
dynflds.o \
getgist.o \
getluse.o \
getmet.o \
getpblht.o \
getsdt.o \
getversion.o \
graceful_stop.o \
gridout.o \
init_io.o \
init_met.o \
init_x.o \
julian.o \
layht.o \
ll2xy_lam.o \
.......
ERROR
The output after I make shows like:
make[1]: Entering directory `/disk2/hyf/cmaq/CMAQv5.1/scripts/mcip/src'
gfortran -g -O0 -gdwarf-2 -gstrict-dwarf \
-I/disk2/hyf/cmaq/CMAQv5.1/lib/x86_64/gcc/netcdf/include \
-I/disk2/hyf/cmaq/CMAQv5.1/lib/x86_64/gcc/ioapi/include -c const_mod.f90
......
chkwpshdr.o: In function `chkwpshdr_':
/disk2/hyf/cmaq/CMAQv5.1/scripts/mcip/src/chkwpshdr.f90:109: \
undefined reference to `__netcdf_MOD_nf90_get_att_one_fourbyteint'
(a lot of these code showing the same mistake 'undefined reference')
/disk2/hyf/cmaq/CMAQv5.1/lib/x86_64/gcc/ioapi/lib/libioapi.a(open3.o): In
function `open3_':
open3.F:(.text+0x1531): undefined reference to `ncclos_'
.........
I think the compiler may have some conflicts with the .F and .f90 files in some case. But I don't know why. The gcc andhas already successfully installed with $PATH defined.
ln -s $netcdf_PATH $(M3LIB)/x86_64/gcc/netcdf