CMAQ编译和安装

准备工作

  • 预装基础环境,可配置YUM源(mirrors.tuna.tsinghua.edu.cn),简单省事。
$ yum install gcc.x86_64 -y
$ yum install gcc-gfortran.x86_64 –y
$ yum install gcc-c++.x86_64
$ yum install openmpi.x86_64 –y (本文使用mpich)
  • 下载各种所需安装包
# Download CMAQ source code and scripts
$ wget ftp://ftp.unc.edu/pub/cmas/SOFTWARE2/MODELS/CMAQ/5.0.1/CMAQv5.0.1.tar.gz

# Download CMAQ benchmark input data files
$ wget ftp://ftp.unc.edu/pub/cmas/SOFTWARE2/MODELS/CMAQ/5.0.1/DATA.CMAQv5.0.1.tar.gz
# CMAQ benchmark output data:
$ wget ftp://ftp.unc.edu/pub/cmas/SOFTWARE2/MODELS/CMAQ/5.0.1/DATA_REF.CMAQv5.0.1.tar.gz
# HDF5,can be ignore
$ wget ftp://ftp.hdfgroup.org/HDF5/current/src/hdf5-1.8.12.tar.gz
# zlib
$ wget http://zlib.net/zlib-1.2.8.tar.gz
# netcdf
$ wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.1.1.tar.gz
# netcdf-fortran
$ wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-fortran-4.2.tar.gz
# ioapi
$ wget http://www.baronams.com/products/ioapi/ioapi-3.1.tar.gz
# mpich
$ wget http://www.mpich.org/static/downloads/3.1/mpich-3.1.tar.gz
# pvm3,can be igore
$ wget http://www.netlib.org/pvm3/pvm3.4.6.tgz

编译安装

# Install zlib
$ ./configure
$ make
$ make install
# Install HDF5
$ ./configure --prefix=/usr/local/hdf5
$ make
$ make check # run test suite.
$ make install
$ make check-install # verify installation.
# Install NetCDF
$ CPPFLAGS=-I/usr/local/hdf5/include LDFLAGS=-L/usr/local/hdf5/lib ./configure –prefix=/usr/local/netcdf
$ make check install
# Install NetCDF-Fortran
$ export DIR1 = /usr/local/netcdf
$ export LD_LIBRARY_PATH= ${DIR1}/lib:$ LD_LIBRARY_PATH
$ CPPFLAGS=-I${DIR1}/include LDFLAGS=-L${DIR1}/lib ./configure --prefix=${DIR1}
$ make check
$ make install
# Install ioapi
$ export BIN=Linux2_x86_64gfort (uname –a)
$ vim Makefile (top-level)
# CPLMODE=nocpl
# BASEDIR=${HOME}/ioapi
# INSTALL=/usr/local/ioapi
$ ln –s ${NETCDF_HOME}/lib/* ${BIN}/
$ make configure
$ make
# Install mpich
$ ./configure –prefix=/usr/local/mpich
$ make
$ make install
# Install pvm3
$ wget http://www.netlib.org/pvm3/pvm3.4.6.tgz
$ export PVM_ROOT=/root/cmaq/pvm3
$ make install

CMAQ较为复杂,单独拉出来说明。 将CMAQv5.0.1.tar.gz、DATA.CMAQv5.0.1.tar.gz和DATA_REF.CMAQv5.0.1.tar.gz解压后,将里面的内容移动至要安装的目录。

$ mv CMAQv5.0.1 /usr/local/cmaq

目录结构为:

[root@tu043122 cmaq]# ll
总用量 16
drwxr-xr-x. 15 root root 4096 3月 17 19:54 data
drwxr-xr-x. 3 root root 4096 3月 18 14:23 lib
drwxrwxr-x. 13 7596 2518 4096 7月 6 2012 models
drwxrwxr-x. 14 7596 2518 4096 3月 20 15:17 scripts

进入scripts目录,修改config.cmaq内容如下:

#> model archive location
setenv M3HOME /usr/local/cmaq
setenv M3MODEL $M3HOME/models
setenv M3DATA $M3HOME/data

#> architecture & compiler specific settings
#-------------------------------------------------------------------------------
setenv system "`/bin/uname -i`"
setenv bld_os "`/bin/uname -s``/bin/uname -r | cut -d. -f1`"
setenv lib_basedir $M3HOME/lib
setenv extra_lib "-lopa -lmpl -lrt -lpthread -ldl"

##> Gfortran compiler......................................................
setenv compiler gfort
setenv myFC gfortran
setenv myCC gcc
setenv myLINK_FLAG ""
setenv myFFLAGS "-ffixed-form -ffixed-line-length-132 -O3 -funroll-loops -finit-character=32 "
setenv myFRFLAGS "-ffree-form -ffree-line-length-none -O3 -funroll-loops -finit-character=32 "
setenv myCFLAGS "-O2"
setenv extra_lib "$extra_lib -lgomp"
#> automatically generate library location
setenv M3LIB ${lib_basedir}/${system}/${compiler}
#> set executable id
setenv EXECID ${bld_os}_${system}${compiler}
#> set only if CVS archive is on a remote computer
# setenv CVS_REMOTE_MACH address.of.your.computer
# setenv CVS_REMOTE_USER remote_user_name
# setenv CVS_RSH ssh

继续

$ cd $M3HOME
$ mkdir -p $M3LIB
$ cd $M3LIB
# do some soft link
$ ln –s ${MPICH_PATH} mpich
$ ln -s ${NETCDF_PATH} netcdf
$ ln -s ${IOAPI_PATH} ioapi_3.1
# build
$ cd $M3HOME/scripts/build
$ ./bldit.bldmake &> build.log
# stenex
$ cd $M3HOME/scripts/stenex
$ vim bldit.se
# set MPI_INC = /usr/local/mpich/include
$ ./bldit.se_noop &> build_se_noop.log
$ ./bldit.se &> build_se.log
# pario
$ cd $M3HOME/scripts/pario
$ ./bldit.pario &> build.log
# jproc
$ cd $M3HOME/scripts/jproc
$ vim bldit.jproc
# set LIB1 = "-L${IOAPI}"
# set LIB2 = "-L${NETCDF}"
# set LIBS = "$LIB1 $LIB2 -lgomp -lnetcdff"
$ ./bldit.jproc &> build.log
# icon
$ cd $M3HOME/scripts/icon
$ vim bldit.icon
# set LIB1 = "-lgomp -lnetcdff"
# set NETCDF = "${M3LIB}/netcdf/lib -lnetcdf -lnetcdff"
$ ./bldit.icon &> build.log
# bcon
$ cd $M3HOME/scripts/bcon
$ vim bldit.bcon
# set LIBS = "$LIB1 $LIB2 -lgomp -lnetcdff"
$ ./bldit.bcon &> build.log
# mip4
$ cd $M3HOME/scripts/mcip4/src
$ vim Makefile
# select gfortran compiler
# NETCDF = /usr/local/netcdf
# IOAPI_ROOT = /root/alei/ioapi/ioapi
# FC = gfortran
# FFLAGS = -O3 -I$(NETCDF)/include -I$(IOAPI_ROOT)/Linux2_x86_64gfort
# LIBS = -L$(IOAPI_ROOT)/Linux2_x86_64gfort -lioapi \
# -L$(NETCDF)/lib -lnetcdf -lnetcdff \
# -lgomp
$ make
# cctm
$ cd cctm
$ vim bldit.cctm
# set MPI_INC = ${M3LIB}/mpich/include
# set NETCDF = "${M3LIB}/netcdf/lib -lnetcdf -lnetcdff"
$ ./bldit.cctm &> build.log

启动运行

编译完毕,开始运行吧

# Run icon
$ cd $M3HOME/scripts/icon
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CMAQ_HOME/lib/x86_64/gfort/netcdf/lib
$ ./run.icon &> run.log
# Run jproc
$ cd $M3HOME/scripts/jproc && ./run.jproc &> run.log
# Run cctm
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CMAQ_HOME/lib/x86_64/gfort/mpich/lib
$ vim run.cctm
# unlimit memorylocked
# unlimit stacksize¬¬
$ ./run.cctm

注意事项

  • NetCDFNetCDF-Fortran分别安装,依赖NetCDF-Fortran的需要指定-lnetcdff
  • 执行bldt.**时,务必将build日志记录下来,这货出错不会中断,说不定中间就有ERROR产生。
  • HDF5PVM可以忽略,如不装HDF5编译NetCDF时需要增加--disable-netcdf-4选项。另外openmpimpich选其一即可。

参考文档

发表评论