登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
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
- sudo apt-get install tcsh samba cpp m4 quota cvs
复制代码
Install gcc g++ gfortran 4.6- 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
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 50
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 40
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 50
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 40
- sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.6 50
- 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
- gcc --version
- g++ --version
- gfortran --version
复制代码
Here I install zlib hdf5 netcdf-c netcdf-c++ netcdf- fortran in same directory to avoid error like NO zlib found
zlib- wget http://zlib.net/zlib-1.2.8.tar.gz
- tar xf zlib-1.2.8.tar.gz
- cd zlib-1.2.8
- ./configure --prefix=/usr/local/netcdf
- make
- make check
- sudo make install
- cd ..
复制代码
hdf5
- wget https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.14/src/hdf5-1.8.14.tar.gz
- tar xf hdf5-1.8.14.tar.gz
- cd hdf5-1.8.14
- ./configure --prefix=/usr/local/netcdf --enable-shared --enable-hl --with-zlib=/usr/local/netcdf
- make -j 4
- make -j 4 check
- sudo make -j 4 install
- cd ..
复制代码
-j 4 is used to speed up compiling by using multi-cores.
netcdf-c
- wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.3.1.tar.gz
- tar xf netcdf-4.3.3.1.tar.gz
- cd netcdf-4.3.3.1
- LDFLAGS=-L/usr/local/netcdf/lib CPPFLAGS=-I/usr/local/netcdf/include ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local/netcdf
- make
- make check
- sudo make install
- 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.
- wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz
- tar xf netcdf-cxx-4.2.tar.gz
- cd netcdf-cxx-4.2
- LDFLAGS=-L/usr/local/netcdf/lib CPPFLAGS=-I/usr/local/netcdf/include ./configure --enable-shared --prefix=/usr/local/netcdf
- make
- make check
- sudo make install
- cd ..
复制代码
netcdf-fortran
- wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.2.tar.gz
- tar xf netcdf-fortran-4.4.2.tar.gz
- cd netcdf-fortran-4.4.2
- LDFLAGS=-L/usr/local/netcdf/lib CPPFLAGS=-I/usr/local/netcdf/include ./configure --enable-shared --prefix=/usr/local/netcdf
- make
- make check
- sudo make install
- cd ..
复制代码
mpich #if you need run CMAQ with multi-cores
- wget http://www.mpich.org/static/downloads/3.1.4/mpich-3.1.4.tar.gz
- tar xf mpich-3.1.4.tar.gz
- cd mpich-3.1.4
- ./configure --prefix=/usr/local/mpich
- make -j 4
- make -j 4 check
- sudo make -j 4 install
- cd ..
复制代码
If -j 4 does not work well, please delete it.
Set environment variables
gedit ~/.bashrc
Add
- #for netcdf
- export NETCDF=/usr/local/netcdf
- export PATH=$NETCDF/bin:$PATH
- export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
- #for mpich
- export PATH=/usr/local/mpich/bin:${PATH}
- export LD_LIBRARY_PATH=/usr/local/mpich/lib:${LD_LIBRARY_PATH}
- export MANPATH=/usr/local/mpich/share/man:${MANPATH}
复制代码
Save and exit
source ~/.bashrc
Check installation
- which ncdump
- which mpirun
复制代码
If return installation path, OK!
ioapi
Please see
https://gcc.gnu.org/wiki/GfortranBuild#ioapi
Notice: modify downloading site and installation directory
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]
- data/
- bcon/ <<<<<<< empty, to befilled by the user
- cctm/ <<<<<<< empty, to befilled by the user
- crop/
- dust/
- emis/
- icon/ <<<<<<< empty, to befilled by the user
- jproc/ <<<<<<< empty
- lightning/
- mcip/
- ocean/
- procan/
- raw/
- phot/
复制代码
[size=12.8000001907349px]
Enter c-shell before installing CMAQ- cd /home/leo/CMAQv5.0.2/scripts
- 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 exitCopy or link libraries
- cd $M3LIB
- cp –rf /usr/local/netcdf/ ./
- cp –rf /usr/local/mpich/ ./
- 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
- cd $M3HOME/scripts/stenex
- ./bldit.se
- ./bldit.se_noop
复制代码- cd $M3HOME/scripts/pario
- ./bldit.pario
复制代码- cd $M3HOME/scripts/jproc
- 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 Notice:1 you may need install "gomp" and "git"
Notice:2 if report: fatal:Nota git repository (or any of the parent&.... do following:
- cd $M3HOME/models
- git init
- cd $M3HOME/scripts/jproc
- ./bldit.jproc
复制代码
- cd $M3HOME/scripts/build
- ./bldit.bldmake
- cd $M3HOME/scripts/mcip/src
- 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
- cd $M3HOME/scripts/icon
- gedit bldit.icon
复制代码Modify corresponding lines in bldit.icon
set LIB1 = "-lgomp -lnetcdff" set NETCDF = "${M3LIB}/netcdf/lib -lnetcdf-lnetcdff"
Save and exit
- ./bldit.icon
- gedit bldit.bcon
复制代码
Modify corresponding lines in bldit.bcon
set LIBS = "$LIB1 $LIB2 -lgomp -lnetcdff"
Save and exit - cd $M3HOME/scripts/cctm
- 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
- cd $M3HOME/scripts/icon
- ./run.icon
- cd $M3HOME/scripts/bcon
- ./run.bcon
- cd $M3HOME/scripts/cctm
- ./run.cctm
复制代码
Notice: If you need use multi-cores
Before ./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!
|