WRF模式安装文档

WRF模式安装文档

  • 可参考官方文档

  • 相关包下载
    mpich-3.0.4
    netcdf-4.1.3
    jasper-1.900.1
    libpng-1.2.50
    zlib-1.2.7

  • 下载环境

    yum -y install gcc-gfortran
    yum -y install gcc
    yum -y install gcc-c++
    yum -y install m4
    
  • 检测环境

    which gfortran
    which cpp
    which gcc
    gfortran --version
    gcc --version
    g++ --version
    
  • 测试环境及编译器(可省略)

    # 在安装WRF的文件夹下创建TESTS。将测试文件拷贝到该文件夹下。
    # 解压文件并测试。
    # 首先对Fortran和C的编译器做测试
    # 测试文件下载(Fortran and C Tests Tar File文件):http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_tests.tar
    gfortran TEST_1_fortran_only_fixed.f
    ./a.out
    
    gfortran TEST_2_fortran_only_free.f90
    ./a.out
    
    gcc TEST_3_c_only.c
    ./a.out
    
    gcc -c -m64 TEST_4_fortran+c_c.c
    gfortran -c -m64 TEST_4_fortran+c_f.f90
    gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o
    ./a.out	
    
    # 接下来测试csh、perl、sh是否可行
    ./TEST_csh.csh
    ./TEST_perl.pl
    ./TEST_sh.sh
    
    # 若未通过,选装相应的安装包
    
  • 安装依赖库

    # 将Build_WRF文件夹及内容拷贝到安装WRF的文件夹下
    # 若无依赖包,需下载依赖包,并将依赖包放在 /Build_WRF/LIBRARIES 下,包括 mpich-3.0.4、netcdf-4.1.3、jasper-1.900.1、libpng-1.2.50、zlib-1.2.7
    cd /Build_WRF/LIBRARIES
    pwd(查看当前路径)
    
    # 1. netcdf安装
    # 这里用netcdf-4.1.3,是因为这个版本未将 netcdf-fortran 和 netcdf-c 拆开,新版本已将二者拆开,需要两个都安装。
    exprot DIR=当前路径
    export CC=gcc
    export CXX=g++
    export FC=gfortran
    export FCFLAGS=-m64
    export F77=gfortran
    export FFLAGS=-m64
    tar zxvf netcdf-4.1.3.tar.gz(解压)
    cd netcdf-4.1.3
    ./configure --prefix=$DIR/netcdf --disable-dap \--disable-netcdf-4 --disable-shared
    make
    make install
    export PATH=$DIR/netcdf/bin:$PATH
    export NETCDF=$DIR/netcdf
    cd ..
    
    # 2. mpich安装
    # 若不需要并行计算,可以不安装这个库
    tar xzvf mpich-3.0.4.tar.gz
    cd mpich-3.0.4
    ./configure --prefix=$DIR/mpich
    make
    make install
    export PATH=$DIR/mpich/bin:$PATH
    cd ..
    
    # 3. zlib安装
    export LDFLAGS=-L$DIR/grib2/lib
    export CPPFLAGS=-I$DIR/grib2/include
    tar xzvf zlib-1.2.7.tar.gz
    cd zlib-1.2.7
    ./configure --prefix=$DIR/grib2
    make
    make install
    cd ..
    
    # 4. libpng安装
    tar xzvf libpng-1.2.50.tar.gz
    cd libpng-1.2.50
    ./configure --prefix=$DIR/grib2
    make
    make install
    cd ..
    
    # 5. jasper安装
    tar xzvf jasper-1.900.1.tar.gz
    cd jasper-1.900.1
    ./configure --prefix=$DIR/grib2
    make
    make install
    cd ..
    
  • 依赖库兼容性测试

    # 进入TESTS文件夹
    # 测试文件名:Fortran_C_NETCDF_MPI_tests.tar
    # 1. Fortran+C+NetCDF
    tar -xf Fortran_C_NETCDF_MPI_tests.tar
    cp ${NETCDF}/include/netcdf.inc .
    gfortran -c 01_fortran+c+netcdf_f.f
    gcc -c 01_fortran+c+netcdf_c.c
    gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o \
         -L${NETCDF}/lib -lnetcdff -lnetcdf
    ./a.out
    
    # 2. Fortran+C+NetCDF+MPI
    cp ${NETCDF}/include/netcdf.inc .
    mpif90 -c 02_fortran+c+netcdf+mpi_f.f
    mpicc -c 02_fortran+c+netcdf+mpi_c.c
    mpif90 02_fortran+c+netcdf+mpi_f.o \
         -L${NETCDF}/lib -lnetcdff -lnetcdf
    mpirun ./a.out
    
  • 编译WRF

    # 将 WPS-4.1.tar.gz 和 WRF-4.1.2.tar.gz 拷贝到 /Build_WRF 文件夹下
    tar xzvf WRF-4.1.2.tar.gz
    cd WRF-4.1.2
    ./configure
    选择341
    ./compile em_real >& log.compile
    # 需等待
    ls -ls main/*.exe
    # 出现4个exe文件,即安装成功
    # ndown.exe   real.exe   tc.exe   wrf.exe
    
  • 编译WPS

    tar xzvf WPS-4.1.tar.gz
    cd WPS-4.1
    ./clean
    export JASPERLIB=$DIR/grib2/lib
    export JASPERINC=$DIR/grib2/include
    ./configure
    选择3
    export WRF_DIR = ../WRFV-4.1.2
    ./compile >& log.compile
    ls -ls *.exe
    # 出现3个exe文件,即安装成功
    # geogrid.exe   metgrid.exe   ungrib.exe
    

你可能感兴趣的:(气象)