目录

一、安装 CMAQ-5.3.2

需要的依赖库: 

目录结构(手动创建):

1. 安装Intel编译器

2. 安装 mpich

3. 安装 zlib

4. 安装 curl

5. 安装 netcdf

6. 安装 ioapi

7. 安装 CMAQ

二、安装 WRF

目录结构(手动创建): 

依赖库: 

1. nefcdf 和 zlib

2. 安装 libpng

3. 安装 jasper

4. 安装 WRF

5. 安装 WPS   


一、安装 CMAQ-5.3.2

需要的依赖库: 

• Intel
• mpich
• zlib
• curl
• netcdf
• ioapi

目录结构(手动创建):

|--home
   |--rain
      |--Build_CMAQ
         |--LIBRARIES
         |--src
         |--CMAQ_Project

1. 安装 Intel 编译器

$ cd /home/rain/Build_CMAQ/src
$ wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18673/l_BaseKit_p_2022.2.0.262_offline.sh
$ wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18679/l_HPCKit_p_2022.2.0.191_offline.sh
$ bash l_BaseKit_p_2022.2.0.262_offline.sh -a -c
$ bash l_HPCKit_p_2022.2.0.191_offline.sh
$ vi ~/.bashrc      # 添加环境变量,下文安装依赖库所需要的环境变量也可以一次添加,一次生效

# intel compiller
source /home/rain/Build_CMAQ/LIBRARIES/intel/oneapi/setvars.sh --force

$ source ~/.bashrc  # 使环境变量生效
$ ifort -v          # 出现对应版本号即成功

2. 安装 mpich

$ cd /home/rain/Build_CMAQ/src
$ wget https://www.mpich.org/static/downloads/3.4.2/mpich-3.4.2.tar.gz
$ tar xzvf mpich-3.4.2.tar.gz
$ cd mpich-3.4.2
$ CC=icc CXX=icc FC=ifort CPP='icpc -E' CPPFLAGS='-fPIC' ./configure --prefix=/home/rain/Build_CMAQ/LIBRARIES/mpich --with-device=ch3  #注意空格
$ make -j4
$ make install
$ vi ~/.bashrc      # 添加mpich的环境变量

# mpich
export PATH=/home/rain/Build_CMAQ/LIBRARIES/mpich/bin:$PATH

$ source ~/.bashrc

3. 安装 zlib

$ cd /home/rain/Build_CMAQ/src
$ wget http://www.zlib.net/fossils/zlib-1.2.11.tar.gz
$ tar xzvf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ CC=icc CXX=icc FC=ifort CPP='icpc -E' CPPFLAGS='-fPIC' ./configure --prefix=/home/rain/Build_CMAQ/LIBRARIES/zlib
$ make -j4
$ make install

4. 安装 curl

$ cd /home/rain/Build_CMAQ/src
$ wget https://curl.se/download/curl-7.77.0.tar.gz
$ tar xzvf curl-7.77.0.tar.gz
$ cd curl-7.77.0
$ CC=icc CXX=icc FC=ifort CPP='icpc -E' CPPFLAGS='-fPIC' ./configure --prefix=/home/rain/Build_CMAQ/LIBRARIES/curl --with-zlib=/home/rain/Build_CMAQ/LIBRARIES/zlib --without-ssl
$ make -j4
$ make install

5. 安装 netcdf

$ cd /home/rain/Build_CMAQ/src
$ wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-c-4.8.0.tar.gz
$ wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.5.3.tar.gz
$ tar xzvf netcdf-c-4.8.0.tar.gz
$ cd netcdf-c-4.8.0
$ CC=icc CXX=icc FC=ifort CPP='icpc -E' CPPFLAGS="-fPIC -I/home/rain/Build_CMAQ/LIBRARIES/curl/include" LDFLAGS="-L/home/rain/Build_CMAQ/LIBRARIES/curl/lib" ./configure --prefix=/home/rain/Build_CMAQ/LIBRARIES/netcdf --disable-netcdf-4

 若显示

configure: error: Can't find or link to the z library. Turn off netCDF-4 and DAP clients with --disable-hdf5 --disable-dap, or see config.log for errors. 
则尝试:
(省略前面字段) ./configure --prefix=....../netcdf --disable-dap --disable-netcdf-4

,则尝试

(省略前面字段) ./configure --prefix=....../netcdf --disable-dap --disable-netcdf-4
$ make -j4
$ make install
$ cd ..
$ tar xzvf netcdf-fortran-4.5.3.tar.gz
$ cd netcdf-fortran-4.5.3
$ CC=icc CXX=icc FC=ifort CPP='icpc -E' CPPFLAGS="-fPIC -I/home/rain/Build_CMAQ/LIBRARIES/netcdf/include" LDFLAGS="-L/home/rain/Build_CMAQ/LIBRARIES/netcdf/lib" LD_LIBRARY_PATH="/home/rain/Build_CMAQ/LIBRARIES/netcdf/lib:$LD_LIBRARY_PATH" ./configure --prefix=/home/rain/Build_CMAQ/LIBRARIES/netcdf
$ make -j4
$ make install
$ vi ~/.bashrc

# netcdf
export PATH=/home/rain/Build_CMAQ/LIBRARIES/netcdf/bin:$PATH
export NETCDF=/home/rain/Build_CMAQ/LIBRARIES/netcdf
export LD_LIBRARY_PATH=/home/rain/Build_CMAQ/LIBRARIES/netcdf/lib:$LD_LIBRARY_PATH

$ source ~/.bashrc

6. 安装 ioapi

$ cd /home/rain/Build_CMAQ/src
$ wget https://www.cmascenter.org/ioapi/download/ioapi-3.2.tar.gz
$ mkdir ioapi
$ cd ioapi
$ tar -xvzf ../ioapi-3.2.tar.gz
$ export BIN=Linux2_x86_64ifort
$ mkdir Linux2_x86_64ifort
$ ln -sf /home/rain/Build_CMAQ/LIBRARIES/netcdf/lib/*.so Linux2_x86_64ifort/
$ cp ioapi/Makefile.nocpl ioapi/Makefile
$ cp m3tools/Makefile.nocpl m3tools/Makefile
$ cp Makefile.template Makefile
$ vi Makefile

BIN = Linux2_x86_64ifort
BASEDIR = ${PWD}
INSTALL = /home/rain/Build_CMAQ/LIBRARIES/ioapi
LIBINST = $(INSTALL)/$(BIN)
BININST = $(INSTALL)/$(BIN)
CPLMODE = nocpl
IOAPIDEFS =
PVMINCL =

$ vi /home/rain/Build_CMAQ/src/ioapi/ioapi/Makeinclude.Linux2_x86_64ifort  # 结合自己路径更改下列内容

AR = ar
CC = mpiicc
CXX = mpiicpc
FC = mpiifort -auto -warn notruncated_source -static-intel
OMPFLAGS = -qopenmp
OMPLIBS = -qopenmp
#ARCHLIB = -Bstatic

$ make configure
$ vi ioapi/Makefile

BASEDIR = /home/rain/Build_CMAQ/src/ioapi
INSTDIR = /home/rain/Build_CMAQ/LIBRARIES/ioapi/Linux2_x86_64ifort

$ vi m3tools/Makefile
BASEDIR = /home/rain/Build_CMAQ/src/ioapi
INSTDIR = /home/rain/Build_CMAQ/LIBRARIES/ioapi/Linux2_x86_64ifort

$ make all
$ mkdir /home/rain/Build_CMAQ/LIBRARIES/ioapi
$ make install
$ cp ioapi/fixed_src/* /home/rain/Build_CMAQ/LIBRARIES/ioapi/fixed_src/
$ cp ioapi/Linux2_x86_64ifort/* /home/rain/Build_CMAQ/LIBRARIES/ioapi/Linux2_x86_64ifort/

7. 安装 CMAQ

$ cd /home/rain/Build_CMAQ/src  # 这里我已下载的CMAQ-5.3.2压缩包上传至虚拟机
$ unzip CMAQ-5.3.2
$ cd CMAQ-5.3.2
$ cp bldit_project.csh bldit_project.csh.old
$ vi bldit_project.csh

set CMAQ_HOME = /home/rain/Build_CMAQ/CMAQ_Project

$ ./bldit_project.csh

$ cd /home/rain/Build_CMAQ/CMAQ_Project
$ cp config_cmaq.csh config_cmaq.csh.old

$ vi config_cmaq.csh

case intel:

        setenv IOAPI_INCL_DIR   /home/rain/Build_CMAQ/src/ioapi/ioapi/fixed_src
        setenv IOAPI_LIB_DIR    /home/rain/Build_CMAQ/LIBRARIES/ioapi/Linux2_x86_64ifort
        setenv NETCDF_LIB_DIR   /home/rain/Build_CMAQ/LIBRARIES/netcdf/lib   
        setenv NETCDF_INCL_DIR  /home/rain/Build_CMAQ/LIBRARIES/netcdf/include   
        setenv NETCDFF_LIB_DIR  /home/rain/Build_CMAQ/LIBRARIES/netcdf/lib 
        setenv NETCDFF_INCL_DIR /home/rain/Build_CMAQ/LIBRARIES/netcdf/include  
        setenv MPI_LIB_DIR      /home/rain/Build_CMAQ/LIBRARIES/mpich/lib     

        setenv myLINK_FLAG "-qopenmp"

$ ./config_cmaq.csh intel
$ cd /home/rain/Build_CMAQ/CMAQ_Project/CCTM/scripts
$ mkdir BLD_CCTM_v532_intel
$ cp /home/rain/Build_CMAQ/LIBRARIES/mpich/include/* BLD_CCTM_v532_intel/
$ ./bldit_cctm.csh intel |& tee bldit.cctm.log
$ ls -al BLD_CCTM_v532_intel/CCTM_*.exe

CCTM_v532.exe 文件,则安装成功

7.1 编译 ICON

$ cd /home/rain/Build_CMAQ/CMAQ_Project/PREP/icon/scripts
$ ./bldit_icon.csh intel

执行完成后生成 BLD_ICON_v532_intel 文件夹。

$ cd BLD_ICON_v532_intel
$ vi Makefile 
将 NETCDF = -L$(LIB)/netcdff/lib -lnetcdff -L$(LIB)/netcdf/lib -lnetcdf -lcurl 修改为
   NETCDF = -L$(LIB)/netcdff/lib -lnetcdff -L$(LIB)/netcdf/lib -lnetcdff -lnetcdf

 然后执行 make ,若该文件夹下若生成可执行文件 ICON_v532.exe ,则编译成功。(BCON操作与此相同)

7.2 编译 BCON

$ cd /home/rain/Build_CMAQ/CMAQ_Project/PREP/bcon/scripts
$ ./bldit_bcon.csh intel

 执行完成后生成 BLD_BCON_v532_intel 文件夹。

$ cd BLD_BCON_v532_intel
$ vi Makefile

 文件修改完成后执行 make ,该文件夹下若生成可执行文件 BCON_v532.exe ,则编译成功。

7.3 编译 MCIP

$ cd /home/rain/Build_CMAQ/CMAQ_Project/PREP/mcip/src
$ vi Makefile

将参数修改为下图所示(参考!注意个人文件路径):

#...Intel Fortran
FC      = ifort
NETCDF = /home/rain/Build_CMAQ/LIBRARIES/netcdf/
IOAPI_ROOT = /home/rain/Build_CMAQ/LIBRARIES/ioapi/
###FFLAGS  = -g -O0 -check all -C -traceback -FR -I$(NETCDF)/include  \
###          -I$(IOAPI_ROOT)/Linux2_x86_64ifort
FFLAGS  = -FR -O3 -traceback -I$(NETCDF)/include -I$(IOAPI_ROOT)/Linux2_x86_64ifort
LIBS    = -L$(IOAPI_ROOT)/Linux2_x86_64ifort -lioapi \
          -L$(NETCDF)/lib -lnetcdff -lnetcdf -qopenmp

之后输入make,执行完成后生成 mcip.exe ,即为编译成功。 

二、安装WRF

目录结构(手动创建): 

 |--home
    |--rain
       |--Build_WRF
          |--LIBRARIES
          |--src

依赖库: 

• netcdf
• libpng
• Jasper

1. nefcdf 和 zlib

将 /home/rain/Build_CMAQ/LIBRARIES 目录下的 nefcdf 和 zlib 文件夹链接到 /home/rain/Build_WRF/LIBRARIES下

$ cd /home/rain/Build_WRF/LIBRARIES
$ ln -sf /home/rain/Build_CMAQ/LIBRARIES/netcdf
$ ln -sf /home/rain/Build_CMAQ/LIBRARIES/zlib

2. 安装 libpng

$ cd /home/rain/Build_WRF/src
$ wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng1.6.37.tar.gz
$ tar xzvf libpng-1.6.37.tar.gz
$ cd libpng-1.6.37
$ CC=icc CXX=icc FC=ifort CPP='icpc -E' CPPFLAGS='-I/home/rain/Build_WRF/LIBRARIES/zlib/include' LDFLAGS='-L/home/rain/Build_WRF/LIBRARIES/zlib/lib' ./configure --prefix=/home/rain/Build_WRF/LIBRARIES/libpng
$ make -j2
$ make install
$ vi ~/.bashrc

# libpng
export LD_LIBRARY_PATH=/home/rain/Build_WRF/LIBRARIES/libpng/lib:$LD_LIBRARY_PATH

$ source ~/.bashrc

3. 安装 jasper

$ cd /home/rain/Build_WRF/src
$ wget https://www.ece.uvic.ca/~frodo/jasper/software/jasper-2.0.10.tar.gz
$ tar -xvzf jasper-2.0.10.tar.gz
$ cmake -G "Unix Makefiles" -H/home/rain/Build_WRF/src/jasper-2.0.10 -B/home/rain/Build_WRF/src/jasper-2.0.10-build -DCMAKE_INSTALL_PREFIX=/home/rain/Build_WRF/LIBRARIES/jasper
$ cd jasper-2.0.10-build
$ make install
$ vi ~/.bashrc

# jasper
export PATH=/home/rain/Build_WRF/LIBRARIES/jasper/bin:$PATH
export LD_LIBRARY_PATH=/home/rain/Build_WRF/LIBRARIES/jasper/lib64:$LD_LIBRARY_PATH

$ source ~/.bashrc

若执行 " cmake -G ...... " 后显示 找不到cmake 指令,可使用 jasper-1.900.1版本,解压后:

$ ./configure --prefix=/home/rain/Build_WRF/LIBRARIES/jasper
$ make
$ make install
$ vi ~/.bashrc

# jasper
export PATH=/home/rain/Build_WRF/LIBRARIES/jasper/bin:$PATH
export LD_LIBRARY_PATH=/home/rain/Build_WRF/LIBRARIES/jasper/lib:$LD_LIBRARY_PATH

$ source ~/.bashrc

4. 安装 WRF

$ ulimit -s unlimited
$ export MALLOC_CHECK_=0
$ export EM_CORE=1
$ export NMM_CORE=0
$ export WRFIO_NCD_LARGE_FILE_SUPPORT=1

$ cd /home/rain/Build_WRF   #此目录下已上传 WRF-4.1.1 和 WPS-4.1
$ tar -xvzf WRF-4.1.1.tar.gz
$ mv WRF-4.1.1 WRF
$ cd WRF
$ ./configure

Enter selection [1-75] : 16  (dm+sm) INTEL (ifort/icc)

Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: 1

$ ./compile -j 2 em_real 2>&1 | tee compile_wrf.log
$ ls -lah main/*.exe

出现 real.exewrf.exe 成功。

5. 安装 WPS   

同样已上传 WPS-4.1

$ cd /home/rain/Build_WRF
$ tar -xvzf WPS-4.1.tar.gz
$ mv WPS-4.1 WPS
$ cd WPS
$ export JASPERLIB=/home/rain/Build_WRF/LIBRARIES/jasper/lib64  # jasper-1.900.1版本为 .../jasper/lib
$ export JASPERINC=/home/rain/Build_WRF/LIBRARIES/jasper/include
$ ./configure

select 19. Linux x86_64, Intel compiler (dmpar)
Enter selection [1-40] : 19

$ vi configure.wps

COMPRESSION_LIBS = -L/home/rain/Build_WRF/LIBRARIES/jasper/lib64 -ljasper -L/home/rain/Build_WRF/LIBRARIES/libpng/lib -lpng -L/home/rain/Build_WRF/LIBRARIES/zlib/lib -lz
COMPRESSION_INC = -I/home/rain/Build_WRF/LIBRARIES/jasper/include -I/home/rain/Build_WRF/LIBRARIES/libpng/include -I/home/rain/Build_WRF/LIBRARIES/zlib/include
DM_FC = mpif90 -f90=$(SFC) -qopenmp -fpp -auto
DM_CC = mpicc -cc=$(SCC)

$ ./compile 2>&1 | tee compile_wps.log
$ ls -lah *.exe

出现 geogrid.exe , metgrid.exe and ungrib.exe 成功


 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐