爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 13121|回复: 2

Intel编译器安装WRF-CMAQ

[复制链接]

新浪微博达人勋

发表于 2021-7-19 15:23:45 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 阿坝州牦牛 于 2021-12-7 18:18 编辑

本文基于 CentOS7 系统介绍了如何使用英特尔编译器安装 CMAQ-5.3.2 和 WRF-4.1.1,Ubuntu 系统安装过程也可参照本文。下文已提前将所需要的依赖库上传至服务器。
一、安装 CMAQ-5.3.2
目录结构:
|--home
   |- -rain
      |--Build_CMAQ
         |--LIBRARIES
         |--src
         |--CMAQ_Project
1. 安装英特尔编译器(先将文件上传至服务器)
$ cd /home/rain/Build_CMAQ/src
$ bash l_BaseKit_p_2021.4.0.3422_offline.sh -a -c
$ bash l_HPCKit_p_2021.4.0.3347_offline.sh -a -c
$ vi ~/.bashrc # 添加,可以安装依赖库所需要的环境变量也可以一次添加,一次生效

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

$ source ~/.bashrc # 使环境变量生效
$ ifort -v # 出现对应版本号即成功
2. 安装 mpich-3.4.2
$ cd /home/rain/Build_CMAQ/src
$ 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-1.2.11
$ cd /home/rain/Build_CMAQ/src
$ 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-7.77.0
$ cd /home/rain/Build_CMAQ/src
$ 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
$ 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
$ 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 -3.2$ cd /home/rain/Build_CMAQ/src
$ 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/* Linux2_x86_64ifort/
$ cp ioapi/fixed_src/* /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/LIBRARIES/fixioed
        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 NETCDF_INCL_DIR /home/rain/Build_CMAQ/LIBRARIES /netcdf /include /
        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
$ mk_dir
$ 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英特尔
执行完成后生成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
文件修改完成后执行时许,该文件夹下若生成可执行文件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
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. 安装 libpng1.6.37
$ cd /home/rain/Build_WRF/src
$ 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-1.900.1
$ cd /home/rain/Build_WRF/src
$ tar -xvzf jasper-1.900.1.tar.gz
$ ./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.exemetgrid.exeungrib.exe成功




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

新浪微博达人勋

发表于 2023-5-25 10:13:37 | 显示全部楼层
您好,WRF4.1输出无法输入到CMAQ5.3.2有什么解决方法吗?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2024-4-18 09:51:45 | 显示全部楼层
大佬您好,我正在学习您的Intel编译器安装WRF-CMAQ 的帖子,发现安装Intel编译器时,下载到一半就停止了,请问有没有解决办法呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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