- 1 设置环境变量
- 2 zlib编译安装
- 3 hdf5编译安装
- 4 netcdf-c编译安装
- 5 netcdf c++编译安装
- 6 netcdf-fortran编译安装
- 7 mpich编译安装
- 8 test
- 9 IOAPI编译安装
- 10 SMOKE安装
- 10.1安装SMOKEv4.7源码
- 10.2运行测试案例
Linux:RedHat 1 设置环境变量
vim ~/.bashrc # SMOKE #### export NETCDF=/home/gonghaixing/netcdf export PATH=$NETCDF/bin:$PATH export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH export CPPFLAGS='-I/home/gonghaixing/netcdf/include' export LDFLAGS='-L/home/gonghaixing/netcdf/lib' export SMK_INST=$models/smoke export SMK_LOCAL=$models/smoke_local export MGN_HOME=$models/megan31 export EIT_HOME=$models/EIT_HOME ##### source ~/.bashrc2 zlib编译安装
zlib:使用zlib库压缩特定类型的数据
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8/ ./configure --prefix=/home/gonghaixing/netcdf make make check make install3 hdf5编译安装
hdf5:跨平台传输的文件格式,存储图像的数据
tar -zxvf hdf5-1.8.13.tar.gz cd hdf5-1.8.13/ ./configure --prefix=/home/gonghaixing/netcdf --with-zlib=/home/gonghaixing/netcdf make make check make install4 netcdf-c编译安装
tar -zxvf netcdf-4.3.2.tar.gz cd netcdf-4.3.2/ ./configure --prefix=/home/gonghaixing/netcdf --disable-dap make make check make install5 netcdf c++编译安装
tar -zxvf netcdf-cxx4-4.3.0.tar.gz cd netcdf-cxx4-4.3.0/ ./configure --enable-shared --prefix=/home/gonghaixing/netcdf make make check make install6 netcdf-fortran编译安装
tar -zxvf netcdf-fortran-4.4.0.tar.gz cd netcdf-fortran-4.4.0/ ./configure --prefix=/home/gonghaixing/netcdf make make check make install
安装完成后输入命令
nc-config --all nf-config --all
构建MPI编程环境,从而进行并行程序的开发
tar xf mpich-3.3.tar.gz cd mpich-3.3/ ./configure --prefix=/home/gonghaixing/mpich make make check make install
设置mpich环境变量
# mpich
export PATH=/home/gonghaixing/mpich/bin:${PATH}
export LD_LIBRARY_PATH=/home/gonghaixing/mpich/lib:${LD_LIBRARY_PATH}
export MANPATH=/home/gonghaixing/mpich/share/man:${MANPATH}
8 test
cd /home/gonghaixing/TESTS/
wget http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_NETCDF_MPI_tests.tar
tar -xvf Fortran_C_NETCDF_MPI_tests.tar
# Test 1: Fortran + C + NetCDF
cp ${NETCDF}/include/netcdf.inc .
gfortran -c 01_fortran+c+netcdf_f.f
gcc -c 01_fortran+c+netcdf_c.c
gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf
./a.out
# Test 2: Fortran + C + NetCDF + MPI
cp ${NETCDF}/include/netcdf.inc .
mpif90 -c 02_fortran+c+netcdf+mpi_f.f
mpicc -c 02_fortran+c+netcdf+mpi_c.c
mpif90 02_fortran+c+netcdf+mpi_f.o 02_fortran+c+netcdf+mpi_c.o -L/home/gonghaixing/mpich/lib -lnetcdff -lnetcdf
mpirun -np 2 ./a.out
tar -xzvf ioapi-3.2.tar.gz cd ioapi-3.2/ioapi cp Makefile.nocpl Makefile cd ../m3tools cp Makefile.nocpl Makefile cd ../ cp Makefile.template Makefile vim Makefile
注意:lnetcdff必须要在lnetcdf前面
setenv BIN Linux2_x86_64gfort mkdir $BIN cd $BIN cp /home/gonghaixing/netcdf/lib/lib* ./ cd .. make configure make
# 检查 cd Linux2_x86_64gfort # 分别输入以下命令,查看是否有相应文件,有则成功 ls *.mod ls libioapi.a
检查程序及库文件
cd /home/gonghaixing/ioapi-3.2-install/Linux2_x86_64/ ls jul2greg datshift juldate libioapi.a
测试程序
./datshift 2020221 1 ./jul2greg 2020221 ./juldate 8 8 2020
注意:如果没安装成功,在ioapi中运行make clean,修改后重新make
10 SMOKE安装切换SHELL并设置环境变量
export SMK_INST=$models/smoke export SMK_LOCAL=$models/smoke_local
csh setenv SMK_HOME $SMK_INST # /home/gonghaixing/aqm/smoke10.1安装SMOKEv4.7源码
export smoke=/home/gonghaixing/model/smoke cd $smoke/smoke4.7/ chmod +x smoke_install_v47.csh ./smoke_install_v47.csh10.2运行测试案例
cd /home/gonghaixing/aqm/smoke/subsys/smoke/assigns/ source ASSIGNS.nctox.cmaq.cb05_soa.us12-nc # 配置文件,类似于输入的界面化窗口,所有的输入输出窗口都在其中
运行污染源处理模块
将ORL文本文件(点源、线源、面源处理成CMAQ能够读取的nc文件)
cd $SCRIPTS/run #/home/gonghaixing/aqm/smoke/subsys/smoke/scripts/run ./smk_area_nctox.csh ./smk_bg_nctox.csh ./smk_nonroad_nctox.csh ./smk_point_nctox.csh ./smk_rateperdistance_nctox.csh ./smk_ratepervehicle_nctox.csh ./smk_rateperprofile_nctox.csh ./smk_rateperhour_nctox.csh ./smk_mrgall_nctox.csh
cd /home/gonghaixing/aqm/smoke/data/run_nctox/output/cmaq_cb05_soa ncview cmaq_cb05_soa]$ ncview agts_l.area.20050710.1.us12-nc.nctox.ncf
成功!!!
检查测试案例
cd $LOGS # /home/gonghaixing/aqm/smoke/data/run_nctox/static/logs grep ERROR * cd $SCRIPTS/install # /home/gonghaixing/aqm/smoke/subsys/smoke/scripts/install ./check_smk_install # 用于检查的脚本 # Differences between your installation and correct answers exist! # Please refer to file $SMKROOT/doc/install_diffs.txt for details.
检查测试案例对比结果
vim $SMK_HOME/subsys/smoke/doc/install_diffs.txt
到此预编译完成
官网给的参考过程只到了预编译
如果移植到自己的服务器,预编译会有问题
通过SMOKE安装手册对SMOKE4.7进行进一步编译安装
主要包括依赖库软链接
$SMKROOT/src里的Makeinclude里的一些问题修改
包括GNU和ifort问题,依赖库链接
因为在安装过程中出了许多bug,所以一边查询资料一边修正
所以很多细节问题就没有做出整理,大家可以参考官方手册
或者针对指定问题用谷歌搜索
cd $SMK_HOME/subsys/smoke/assigns source ASSIGNS.nctox.cmaq.cb05_soa.us12-nc cd $SMKROOT/src vi Makeinclude # 出现的许多问题主要在Makeinclude里面 # 执行编译 make # 大概3-5分钟 # 如果失败,重新编译(make)前需要把之前的生成的文件全部删除make clean cd $SMKROOT/Linux2_x86_64gfort ls # 会生成这些程序
到此为止,SMOKE完整编译安装完成!!!
参考博客:
[1] https://blog.csdn.net/oZuoYu123/article/details/90285971/
[2]SMOKE安装手册
https://www.cmascenter.org/smoke/documentation/4.8.1/html/
[3]SMOKE安装
https://github.com/CEMPD/SMOKE/tags



