师哥做了个课题,用FLEXPART分析大气伴飞轨迹,提前先安装这个软件吧。我使用的环境是centos7,看官慢慢看,结尾有彩蛋~
准备工作,flexpart是用Fortran语言写的,以.90结尾的文件就是他的源文件,因此编译需要使用gcc和gcc-c++编译器
yum install gcc
yum install gcc-c++
yum install gcc-gfortran
就行了,gcc编译器可以编译fortran语言的源码
1:安装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
上面需要加上-fPIC这个选项,不然会后面make grib的时候会报错
make
make check
make install
2:安装grib_api
cd /usr/local/
wget https://software.ecmwf.int/wiki/download/attachments/3473437/grib_api-1.26.1-Source.tar.gz
tar -zxvf grib_api-1.26.1-Source.tar.gz
mkdir grib_api
cd grib_api-1.26.1-Source
./configure --prefix=/usr/local/grib_api --with-jasper="/usr/local/jasper"
这里要带上--with-jasper="/usr/local/jasper",不然编译也会报错
make
make check
make install
3:安装flexpart
cd /usr/local/
wget http://archive.ubuntu.com/ubuntu/pool/universe/f/flexpart/flexpart_9.02.orig.tar.gz
tar -zxvf flexpart_9.02.orig.tar.gz
cd flexpart_9.02
vi makefile.gfs_gfortran
修改
INCPATH = /usr/local/grib_api/include
LIBPATH1 = /usr/local/grib_api/lib
LIBPATH2 = /usr/local/jasper/lib
改完:wq保存喏,改错了记得:q!退出再接着改喏。
make -f makefile.gfs_gfortran
生成FLEXPART_GFS_GFORTRAN
------------------------------------------------彩蛋------------------------------------------------
你以为这么简单么?其实有个坑,因为在我这个版本的gcc下编译貌似会出错
报错提示在erf.f90 文件的44行有个错,没接触过fortran,但猜测可能是位数不对,于是这么改了一下源代码,编译通过
real(kind=dp) :: x,tmp,ser,xx,gammln
⇒
real :: gammln
real(kind=dp) :: x,tmp,ser,xx