FLEXPART安装配置笔记(成功案例)——筑梦之路

                           FLEXPART 10.4安装配置笔记

2021-1-5  

---------------------------------------------------------------------------------

注意:

1.按照本教程安装10.4版本的一定要使用指定的操作系统版本和依赖包版本

2.随着时间推移,某些依赖包下载地址可能会变化,请自行搜索下载相关依赖包

3.按照本教程在安装过程中遇到问题可以根据参考资料,结合起来去排查解决


操作系统版本:ubuntu 18.04 

(选择ubuntu安装更加简单,centos编译安装依赖库比较难搞)

虚拟机:vmware (不要使用windows的子系统,很多坑)  或者 物理机安装ubuntu18.04

--------------------------------------------------------------------------------

1.安装前准备
说明:
编译安装都安装到/usr/local
python3
pip3


系统配置
sudo apt-get update
sudo apt-get install g++ gfortran autoconf libtool automake flex bison cmake python3-dev python3-pip git vim curl build-essential libbz2-dev libssl-dev libreadline-dev libsqlite3-dev tk-dev ruby

安装依赖
apt-get install python3 (usually already available on GNU/Linux systems)
 apt-get install python3-eccodes
 apt-get install python3-genshi
 apt-get install python3-numpy
 apt-get install gfortran
 apt-get install fftw3-dev
 apt-get install libeccodes-dev
 apt-get install libemos-dev

pip3 install cdsapi
pip3 install ecmwf-api-client

#python3
# check in python3 console
import eccodes
import genshi
import numpy
import cdsapi
import ecmwfapi

2.安装jasper

cd /usr/local
wget http://www.ece.uvic.ca/~mdadams/jasper/software/jasper-1.900.1.zip
unzip jasper-1.900.1.zip
mkdir jasper
cd jasper-1.900.1
CFLAGS="-fPIC" ./configure --prefix=/usr/local/jasper
make
make check
make install

3.安装grib_api
https://links.jianshu.com/go?to=https%3A%2F%2Fpeople.freebsd.org%2F%7Esunpoet%2Fsunpoet%2Fgrib_api-1.28.0-Source.tar.gz

cd /usr/local
wget https://people.freebsd.org/~sunpoet/sunpoet/grib_api-1.28.0-Source.tar.gz
tar xvzf grib_api-1.28.0-Source.tar.gz
mkdir grib_api
cd grib_api-1.28.0-Source
./configure --prefix=/usr/local/grib_api --with-jasper=/usr/local/jasper
make
make check
make install

4.安装eccodes

wget https://software.ecmwf.int/wiki/download/attachments/45757960/eccodes-2.7.3-Source.tar.gz

地址失效

https://confluence.ecmwf.int/download/attachments/45757960/eccodes-2.7.3-Source.tar.gz?api=v2


tar xvzf eccodes-2.7.3-Source.tar.gz
mkdir eccodes
cd eccodes-2.7.3-Source
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/eccodes /usr/local/eccodes-2.7.3-Source -DPYTHON_EXECUTABLE=/usr/bin/python3
make
ctest
make install
export ECCODES_SAMPLES_PATH=$PATH:/usr/local/eccodes/share/eccodes/samples
export ECCODES_DEFINITION_PATH=$PATH:/usr/local/eccodes/share/eccodes/definitions
sudo apt-get install libeccodes-dev
python3 -m eccodes selfcheck
Found: ecCodes v2.6.0.
Your system is ready.

5.安装 NetCDF

sudo apt-get install libnetcdf-dev libnetcdff-dev

安装 zlib
v=1.2.8  
sudo wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-${v}.tar.gz
sudo tar -xf zlib-${v}.tar.gz && cd zlib-${v}
sudo ./configure --prefix=/usr/local
sudo make install
cd ..

安装 szlib
v=2.1
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/szip-${v}.tar.gz
tar -xf szip-${v}.tar.gz && cd szip-${v}
./configure --prefix=/usr/local/szip
make
make install

安装hdf5
v=1.8.13
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-${v}.tar.gz
tar -xf hdf5-${v}.tar.gz && cd hdf5-${v}
prefix="/usr/local/hdf5-$v"

echo "Add HDF5_DIR=$prefix to .bashrc"
echo "" >> ~/.bashrc
echo "# HDF5 libraries for python" >> ~/.bashrc
echo export HDF5_DIR=$prefix  >> ~/.bashrc

./configure --enable-shared --enable-hl --prefix=$HDF5_DIR
make -j 2 # 2 for number of procs to be used
make install
cd ..

安装 netcdf-c
v=4.1.3
wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-${v}.tar.gz
tar -xf netcdf-${v}.tar.gz && cd netcdf-${v}
prefix="/usr/local/"

echo "Add NETCDF4_DIR=$prefix to .bashrc"
echo "" >> ~/.bashrc
echo "# NETCDF4 libraries for python" >> ~/.bashrc
echo export NETCDF4_DIR=$prefix  >> ~/.bashrc

CPPFLAGS=-I$HDF5_DIR/include LDFLAGS=-L$HDF5_DIR/lib ./configure --enable-netcdf-4 --enable-shared --enable-dap --prefix=$NETCDF4_DIR
make 
make install
cd ..

python Netcdf4 安装
# install python's netCDF4
pip3 install netcdf4 --upgrade


6.安装FLEXPART10.4

cd /usr/local
wget https://www.flexpart.eu/downloads/66
tar xvf 66
cd flexpart_v10.4_3d7eebf

cp -r src src2
cd src2
vi makefile
#modified to 
        ROOT_DIR = /usr/local

        F90       = /usr/bin/gfortran
        MPIF90    = /usr/bin/mpifort
         
        INCPATH1  = ${ROOT_DIR}/grib_api/include
        INCPATH2  = ${ROOT_DIR}/jasper/include
        INCPATH3 = /include
        LIBPATH1 = ${ROOT_DIR}/grib_api/lib
        LIBPATH2 = ${ROOT_DIR}/jasper/lib
        LIBPATH3 = /lib
### Enable netCDF output?
ifeq ($(ncf), yes)
        NCOPT = -DUSE_NCF -lnetcdff -lnetcdf
else
        NCOPT = -UUSE_NCF
endif
## LIBRARIES
LIBS = -lgrib_api_f90 -lgrib_api -lm -ljasper $(NCOPT) -lnetcdff

FFLAGS   = -I$(INCPATH1) -I$(INCPATH2) -I$(INCPATH3) -O$(O_LEV) -g -cpp -m64 -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -fmessage-length=0 -flto=jobserver -O$(O_LEV) $(NCOPT) $(FUSER)  #-Warray-bounds -fcheck=all # -march=native

DBGFLAGS = -I$(INCPATH1) -I$(INCPATH2) -I$(INCPATH3) -O$(O_LEV_DBG) -g3 -ggdb3 -cpp -m64 -mcmodel=medium -fconvert=little-endian -frecord-marker=4 -fmessage-length=0 -flto=jobserver -O$(O_LEV_DBG) $(NCOPT) -fbacktrace   -Wall  -fdump-core $(FUSER)  #  -ffpe-trap=invalid,overflow,denormal,underflow,zero  -Warray-bounds -fcheck=all

LDFLAGS  = $(FFLAGS) -L$(LIBPATH1) -Wl,-rpath,$(LIBPATH1) $(LIBS) -L$(LIBPATH2)
-L$(LIBPATH3)
LDDEBUG  = $(DBGFLAGS) -L$(LIBPATH1) $(LIBS) -L$(LIBPATH2) -L$(LIBPATH3)

make ncf=yes
export LD_LIBRARY_PATH=/usr/local/grib_api/lib:$LD_LIBRARY_PATH


7.安装flex_extract

cd /usr/local
git clone --single-branch --branch master https://www.flexpart.eu/gitmob/flex_extract


8.import eccodes 报错处理-安装zlib1.2.9

wget https://sourceforge.net/projects/libpng/files/zlib/1.2.9/zlib-1.2.9.tar.gz
tar -xvf zlib-1.2.9.tar.gz
cd zlib-1.2.9
sudo -s
./configure; make; make install
cd /lib/x86_64-linux-gnu
ln -s -f /usr/local/lib/libz.so.1.2.9/lib libz.so.1
cd ~
rm -rf zlib-1.2.9

9.install emoslib

cd /usr/local
mkdir emoslib
wget https://confluence.ecmwf.int/download/attachments/3473472/libemos-4.5.9-Source.tar.gz
tar -xzf libemos-4.5.9-Source.tar.gz
cd libemos-4.5.9-Source
mkdir build ; cd build 
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/emoslib /usr/local/libemos-4.5.9-Source
make
make install

10.安装ECMWF 与ERA5安装权限

cd 
vim .ecmwfapirc
{
    "url"   : "https://api.ecmwf.int/v1",
    "key"   : "8fb37b516ba233bde068613a8f08c785",
    "email" : "[email protected]"
}
vim .cdsapirc
url: {api-url}
key: {uid}:{api-key}

11.修改makefile_local_gfortran文件

cd /usr/local/flex_extract/Source/Fortran/makefile_local_gfortran
vi makefile_local_gfortran
# change the original path of ECCODES_INCLUDE_DIR to 
ECCODES_INCLUDE_DIR=/usr/include

12.修改makefile_local_gfortran文件

cd /usr/local/flex_extract
./setup_local.sh


成功结果展示:
WARNING: installdir has not been specified
flex_extract will be installed in here by compiling the Fortran source in /usr/local/flex_extract/Source/Fortran
Install flex_extract_v7.1.2 software at local in directory /usr/local/flex_extract

Using makefile: makefile_local_gfortran
gfortran   -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -I. -I/usr/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c    ./rwgrib2.f90
gfortran   -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -I. -I/usr/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c    ./phgrreal.f90
gfortran   -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -I. -I/usr/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c    ./grphreal.f90
gfortran   -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -I. -I/usr/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c    ./ftrafo.f90
gfortran   -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -I. -I/usr/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c    ./calc_etadot.f90
gfortran   -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -I. -I/usr/include -fdefault-real-8 -fopenmp -fconvert=big-endian   -c    ./posnam.f90
gfortran  rwgrib2.o calc_etadot.o ftrafo.o grphreal.o posnam.o phgrreal.o -o calc_etadot_fast.out  -O3  -Bstatic -leccodes_f90 -leccodes -Bdynamic -lm  -lemosR64 -fopenmp
ln -sf calc_etadot_fast.out calc_etadot

lrwxrwxrwx 1 root root 20 Nov 13 20:19 ./calc_etadot -> calc_etadot_fast.out

13.测试flex_extract

cd Testing/Installation/Calc_etadot
# execute the Fortran progam without arguments
../../../Source/Fortran/calc_etadot

成功结果展示:
STATISTICS:          98842.4598  98709.7359   5120.5385
STOP SUCCESSFULLY FINISHED calc_etadot: CONGRATULATIONS



参考资料:
https://www.jianshu.com/p/6bc7cee6c9bf
https://www.jianshu.com/p/314f2a001aa8
---------------------------------------------------
对版本没什么要求的也可以使用:
sudo apt update
sudo apt install flexpart

附录:FLEXPART官网:https://www.flexpart.eu

           FLEXPART样例数据说明:FpInputMetGfs – FLEXPART.EU

           FLEXPART数据下载地址:https://rda.ucar.edu(可以免费注册,注册后方可下载)

           FLEXPART版本一览:FpRoadmap – FLEXPART.EU(确定自己需要的版本,以及对应的依赖)

猜你喜欢

转载自blog.csdn.net/qq_34777982/article/details/112222088#comments_22859221