美文网首页
FLEXPART安装配置全记录

FLEXPART安装配置全记录

作者: TroyShen | 来源:发表于2020-10-07 11:32 被阅读0次

    0.系统配置

    sudo apt-get update
    sudo apt-get install g++ gfortran
    sudo apt-get install autoconf libtool
     automake flex bison
    sudo apt-get install cmake
    sudo apt-get install python-dev
    python-pip git-core vim
    sudo apt-get install curl
    sudo install -y build-essential libbz2-dev libssl-dev libreadline-dev libsqlite3-dev tk-dev ruby
    

    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
    make
    make check
    make install
    

    2. 安装grib_api

    ECMWF取消了支持,安装包在这里.

    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
    

    3. 安装eccodes

    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
    make
    ctest
    make install
    

    4. 安装 NetCDF

    Note: Modification from Ubuntu 下安装 netcdf4

    4.1 安装 zlib
    v=1.2.8  
    wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-${v}.tar.gz
    tar -xf zlib-${v}.tar.gz && cd zlib-${v}
    ./configure --prefix=/usr/local
    sudo make install
    cd ..
    
    4.2 安装 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
    sudo make
    sudo make install
    
    4.3 安装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
    sudo make -j 2 # 2 for number of procs to be used
    sudo make install
    cd ..
    
    4.4 安装 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 check
    sudo make 
    sudo make install
    cd ..
    
    4.5 python Netcdf4 安装
    # install python's netCDF4
    pip install netCDF4 --upgrade
    

    5. 安装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)
    

    6. 安装flex_extract

    6.1 安装flex_extract
    cd /usr/local
    git clone --single-branch --branch master https://www.flexpart.eu/gitmob/flex_extract
    sudo apt-get install libeccodes-dev
    
    6.2 安装Dependence
    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
    
    pip install cdsapi
    pip install ecmwf-api-client
    
    #python3
    # check in python3 console
    import eccodes
    import genshi
    import numpy
    import cdsapi
    import ecmwfapi
    
    6.3 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
    
    6.4 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.0.0-Source.tar.gz
    cd libemos-4.0.0-Source
    mkdir build ; cd build 
    cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/emoslib /usr/local/libemos-4.0.0-Source
    make
    make install
    
    6.5 安装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}
    
    6.6 修改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
    
    6.7 修改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
    
    6.8 测试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
    

    Updated on 13 November 2020

    相关文章

      网友评论

          本文标题:FLEXPART安装配置全记录

          本文链接:https://www.haomeiwen.com/subject/axlvsktx.html