爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6193|回复: 5

CMAQ v5.0.2 installation tutorial on Ubuntu 15.04 with GCC 4.6

[复制链接]
发表于 2015-8-18 23:05:18 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 lrxwisdom 于 2015-8-19 22:54 编辑

It is the the translation of my previous post: http://bbs.06climate.com/forum.p ... 7293&extra=page%3D1
I hope it could help non-Chinese reader

  • Downgrade GCC to version 4.6.2
Because compiling IOAPI with GCC 4.7 or higher version would cause
Error: 'runspec' of module 'm3utilio', importedat....

I don't know how to solve it. If you know please let me know. Thank you!





Install some neccessary plug-ins
  1. sudo apt-get install tcsh samba cpp m4 quota cvs
复制代码




Install gcc g++ gfortran 4.6
  1. sudo apt-get install gfortran gfortran-multilib gcc-4.6 gcc-4.6-multilib g++-4.6 g++-4.6-multilib gfortran-4.6 gfortran-4.6-multilib
复制代码
adjust priorities among versions
  1. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 50
  2. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 40
  3. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 50
  4. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 40
  5. sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.6 50
  6. sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.9 40
复制代码

Check working gcc version, make sure it is 4.6 now

  1. gcc --version
  2. g++ --version
  3. gfortran --version
复制代码

  • Install libraries


Here I install zlib hdf5 netcdf-c netcdf-c++ netcdf- fortran in same directory to avoid error like NO zlib found

zlib
  1. wget http://zlib.net/zlib-1.2.8.tar.gz
  2. tar xf zlib-1.2.8.tar.gz
  3. cd zlib-1.2.8
  4. ./configure --prefix=/usr/local/netcdf
  5. make
  6. make check
  7. sudo make install
  8. cd ..
复制代码


hdf5
  1. wget https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.14/src/hdf5-1.8.14.tar.gz
  2. tar xf hdf5-1.8.14.tar.gz
  3. cd hdf5-1.8.14
  4. ./configure --prefix=/usr/local/netcdf --enable-shared --enable-hl --with-zlib=/usr/local/netcdf
  5. make -j 4
  6. make -j 4 check
  7. sudo make -j 4 install
  8. cd ..
复制代码


-j 4 is used to speed up compiling by using multi-cores.


netcdf-c


  1. wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.3.1.tar.gz
  2. tar xf netcdf-4.3.3.1.tar.gz
  3. cd netcdf-4.3.3.1
  4. LDFLAGS=-L/usr/local/netcdf/lib CPPFLAGS=-I/usr/local/netcdf/include ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local/netcdf
  5. make
  6. make check
  7. sudo make install
  8. cd ..
复制代码

Do not use -j 4 here! Error may reported!

netcdf-c++  #Many tutorial does not mention this maybe since they use the verison before 4.1.3 in which netcdf-c++ defaultly included.

  1. wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz
  2. tar xf netcdf-cxx-4.2.tar.gz
  3. cd netcdf-cxx-4.2
  4. LDFLAGS=-L/usr/local/netcdf/lib CPPFLAGS=-I/usr/local/netcdf/include ./configure --enable-shared --prefix=/usr/local/netcdf
  5. make
  6. make check
  7. sudo make install
  8. cd ..
复制代码


netcdf-fortran
  1. wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.2.tar.gz
  2. tar xf netcdf-fortran-4.4.2.tar.gz
  3. cd netcdf-fortran-4.4.2
  4. LDFLAGS=-L/usr/local/netcdf/lib CPPFLAGS=-I/usr/local/netcdf/include ./configure --enable-shared --prefix=/usr/local/netcdf
  5. make
  6. make check
  7. sudo make install
  8. cd ..
复制代码



mpich #if you need run CMAQ with multi-cores

  1. wget http://www.mpich.org/static/downloads/3.1.4/mpich-3.1.4.tar.gz
  2. tar xf mpich-3.1.4.tar.gz
  3. cd mpich-3.1.4
  4. ./configure --prefix=/usr/local/mpich
  5. make -j 4
  6. make -j 4 check
  7. sudo make  -j 4 install
  8. cd ..
复制代码



If -j 4 does not work well, please delete it.

Set environment variables
gedit ~/.bashrc
Add
  1. #for netcdf
  2. export NETCDF=/usr/local/netcdf
  3. export PATH=$NETCDF/bin:$PATH
  4. export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
  5. #for mpich
  6. export PATH=/usr/local/mpich/bin:${PATH}
  7. export LD_LIBRARY_PATH=/usr/local/mpich/lib:${LD_LIBRARY_PATH}
  8. export MANPATH=/usr/local/mpich/share/man:${MANPATH}
复制代码




Save and exit
source ~/.bashrc

Check installation
  1. which ncdump
  2. which mpirun
复制代码


If return installation path, OK!

ioapi
Please see
https://gcc.gnu.org/wiki/GfortranBuild#ioapi
Notice: modify downloading site and installation directory

  • install CMAQ v5.0.2
Download source code and benchmark data from:
https://www.cmascenter.org/download/forms/step_1.cfm?CFID=2515215&CFTOKEN=5369c1c2829a158c-8C7B562E-F233-2A36-FF743386F3773A43


unzip them in to same directory then you will see [size=12.8000001907349px]following subdirectories:[size=12.8000001907349px]

  1. data/
  2.       bcon/   <<<<<<< empty, to befilled by the user
  3.       cctm/   <<<<<<< empty, to befilled by the user
  4.       crop/
  5.       dust/
  6.       emis/
  7.       icon/   <<<<<<< empty, to befilled by the user
  8.       jproc/  <<<<<<< empty
  9.       lightning/
  10.       mcip/
  11.       ocean/
  12.       procan/
  13.       raw/
  14.          phot/
复制代码


[size=12.8000001907349px]
Enter c-shell before installing CMAQ
  1. csh
复制代码
  1. cd /home/leo/CMAQv5.0.2/scripts
  2. gedit config.cmaq
复制代码


Modfiy CMAQ home directory and compiler options in config.cmaq


#> config.cmaq
#> sourced from bldit.<model>

#> model repository location
setenv M3HOME /home/leo/CMAQv5.0.2
setenv M3MODEL${M3HOME}/models
setenv M3DATA  ${M3HOME}/data

#===============================================================================

#> architecture & compiler specific settings
#-------------------------------------------------------------------------------

#> set the COMPILER
# setenv COMPILER intel
# setenv COMPILER pgi
setenv COMPILER gcc



Save and exit
  1. source config.cmaq
复制代码
Copy or link libraries
  1. cd $M3LIB
  2. cp –rf /usr/local/netcdf/ ./
  3. cp –rf /usr/local/mpich/ ./
  4. cp –rf /usr/local/ioapi_3.1/ ./
复制代码



Notice:1 you can also use command "ln -s"
Notice:2 if your install directory is not named by netcdf, mpich, ioapi_3.1 please rename it into netcdf, mpich, ioapi_3.1 after copy.


Start building
  1. cd $M3HOME/scripts/stenex
  2. ./bldit.se
  3. ./bldit.se_noop
复制代码
  1. cd $M3HOME/scripts/pario
  2. ./bldit.pario
复制代码
  1. cd $M3HOME/scripts/jproc
  2. gedit bldit.jproc
复制代码





Modify corresponding lines in bldit.jproc

set LIB1 = "-L${IOAPI}"
set LIB2 = "-L${NETCDF}"
set LIBS = "$LIB1 $LIB2 -lgomp -lnetcdff"

Save and exit
  1. ./bldit.jproc
复制代码
Notice:1 you may need install "gomp" and "git"
Notice:2 if report: fatal:Nota git repository (or any of the parent&.... do following:

  1. cd $M3HOME/models
  2. git init
  3. cd $M3HOME/scripts/jproc
  4. ./bldit.jproc
复制代码

  1. cd $M3HOME/scripts/build
  2. ./bldit.bldmake
  3. cd $M3HOME/scripts/mcip/src
  4. gedit Makefile
复制代码



Modify corresponding lines in Makefile
select gfortran compiler
NETCDF = $M3LIB/netcdf
IOAPI_ROOT = $M3LIB/ioapi_3.1
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

If you did not install pvm3, please delete any line about pvm3!
Save and exit
  1. make
复制代码

  1. cd $M3HOME/scripts/icon
  2. gedit bldit.icon
复制代码
Modify corresponding lines in bldit.icon

set LIB1 = "-lgomp -lnetcdff"
set NETCDF = "${M3LIB}/netcdf/lib -lnetcdf-lnetcdff"


Save and exit

  1. ./bldit.icon
  2. gedit bldit.bcon
复制代码

Modify corresponding lines in  bldit.bcon

set LIBS = "$LIB1 $LIB2 -lgomp -lnetcdff"


Save and exit
  1. ./bldit.bcon
复制代码
  1. cd $M3HOME/scripts/cctm
  2. gedit bldit.cctm
复制代码



Modify corresponding lines in  bldit.cctm
set MPI_INC = ${M3LIB}/mpich/include
set NETCDF = "${M3LIB}/netcdf/lib -lnetcdf-lnetcdff"


Save and exit
  1. ./bldit.cctm
复制代码

  • Start to run

  1. cd $M3HOME/scripts/icon
  2. ./run.icon
  3. cd $M3HOME/scripts/bcon
  4. ./run.bcon
  5. cd $M3HOME/scripts/cctm
  6. ./run.cctm
复制代码


Notice: If you need use multi-cores

Before ./run.cctm
  1. gdit run.cctm
复制代码
Modify corresponding lines in run.cctm

set PROC     = mpi
setenv NPCOL_NPROW "2 2"; set NPROCS   = 4


Make sure 2*2 = 4 if you want to use more cores

then ./run.cctm


That's all. May you succeed!






密码修改失败请联系微信:mofangbao
发表于 2015-8-26 16:56:56 | 显示全部楼层
谢谢楼主的分享,学习学习
密码修改失败请联系微信:mofangbao
发表于 2016-3-24 14:54:23 | 显示全部楼层
谢谢楼主分享!
密码修改失败请联系微信:mofangbao
发表于 2016-4-14 18:34:32 | 显示全部楼层
我想问下,跑出来的数据是放到哪儿的
密码修改失败请联系微信:mofangbao
发表于 2016-7-14 20:46:47 | 显示全部楼层
谢谢楼主分享!
密码修改失败请联系微信:mofangbao
发表于 2016-7-14 20:47:45 | 显示全部楼层
楼主辛苦了!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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