FLEXPART安装配置笔记
2021.09.06
参考:https://blog.csdn.net/qq_34777982/article/details/112222088
#重中之重,一定要用18.04版的,我用20.04装了一个星期掉坑无数(旧包不能配最新的版本),安装ubuntu 18.04系统#使用完整的向导安装,参考 :https://www.cnblogs.com/liuqun/p/12655156.html,不能使用快捷方法,否则安装几个包后系统就无法启动,掉坑无数
遇到安装选择[Y/n]输入Y/,后面装包过程中遇到yes/no输入yes,遇到选择路径直接回车就行。
1.安装前准备
说明:
编译安装都安装到/usr/local
python3
pip3
ubantu18.04
'''非常实用的技巧'''
一、使用sudo -s直接用root帐号编写,可以少写sudo
二、可以使用复制粘过去,避免输错,节省时间,ubantu系统用使用复制粘贴为ctr+shift+c和ctr+shift+v
系统配置
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 #check段可能下载时间过长,有部分数据无法下载没有关系
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 #后面如出现 python3 -m eccodes selfcheck不能使用,没有关系。
wget https://software.ecmwf.int/wiki/download/attachments/45757960/eccodes-2.7.3-Source.tar.gz
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" : "791653827@qq.com"
}
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
经过上面的安装flexpart的运行应该是没问题了
但在flex_extract的下载上可能有问题,flex_extract可以下载并准备EC的EI数据可用,经过研究要通过几个办法来解决。
1.通过运行flex_extract里面的Run文件夹下的run_local.sh,发现eccode和gribapi这两个包版本不对,这两个包的代码是python2版的,确装在python3下,要替换一下。
2.替换一下可以解决python代码下eccodes和gribapi运行的问题。但仍可能有缺少cffi的问题。
3.pip3 install cffi。安装后看一下cffi的版本,可能是1.15.0版,这要和numpy的版本要对应上,numpy版本太高,这两又不兼容了,就要再降低numpy的版本.
4.pip3 install findlibs
5.安装fftw-3.3.10这个包,为什么装我忘了。解压后,新建一个fftw文件夹
.configure --prefix=/usr/local/fftw
make
make install
参考:能看懂下面第一个比较重要
https://gmd.copernicus.org/articles/12/4955/2019/#section10
https://www.jianshu.com/p/6bc7cee6c9bf
https://www.jianshu.com/p/314f2a001aa8
FLEXPART安装笔记,ubantu,grib_api,eccodes,NetCDF
最新推荐文章于 2024-03-22 08:31:05 发布