WRF&WPS环境搭建
0 机器环境
cat /proc/version
uname -a
lsb_release -a
cat /etc/issue
1 工具
yum install -y gcc gcc-gfortran gcc-c++ which perl csh git wget make tar m4 libXrender libXext fontconfig
2 创建目录
cd /opt
mkdir Build_WRF Test
3 测试环境
cd Test
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_tests.tar
tar -xf Fortran_C_tests.tar
3.1 test1
gfortran TEST_1_fortran_only_fixed.f
./a.out
3.2 test2
gfortran TEST_2_fortran_only_free.f90
./a.out
3.3 test3
gcc TEST_3_c_only.c
./a.out
3.4 test4
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
4 Build libraries
4.1 Download compressed files
cd .. /Build_WRF
mkdir LIBRARIES
cd LIBRARIES
mkdir tar untar
cd tar
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/mpich-3.0.4.tar.gz
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/netcdf-4.1.3.tar.gz
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/jasper-1.900.1.tar.gz
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/libpng-1.2.50.tar.gz
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/zlib-1.2.7.tar.gz
wget https://ftp.gnu.org/gnu/time/time-1.9.tar.gz
4.2 Set environment variables
csh
setenv DIR /opt/Build_WRF/LIBRARIES
setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv FCFLAGS -m64
setenv F77 gfortran
setenv FFLAGS -m64
setenv PATH $DIR /netcdf/bin:$PATH
setenv NETCDF $DIR /netcdf
setenv PATH $DIR /mpich/bin:$PATH
setenv GRIB2 $DIR /grib2
setenv JASPERLIB $GRIB2 /lib
setenv JASPERINC $GRIB2 /include
setenv LDFLAGS -L$GRIB2 /lib
setenv CPPFLAGS -I$GRIB2 /include
setenv LD_LIBRARY_PATH $GRIB2 /lib
setenv LD_LIBRARY_PATH $NETCDF /lib
export DIR = /opt/Build_WRF/LIBRARIES
export CC = gcc
export CXX = g++
export FC = gfortran
export FCFLAGS = -m64
export F77 = gfortran
export FFLAGS = -m64
export PATH = $DIR /netcdf/bin:$PATH
export NETCDF = $DIR /netcdf
export PATH = $DIR /mpich/bin:$PATH
export GRIB2 = $DIR /grib2
export JASPERLIB = $GRIB2 /lib
export JASPERINC = $GRIB2 /include
export LDFLAGS = -L$GRIB2 /lib
export CPPFLAGS = -I$GRIB2 /include
export LD_LIBRARY_PATH = $GRIB2 /lib
export LD_LIBRARY_PATH = $GRIB2 /lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH = $NETCDF /lib:$LD_LIBRARY_PATH
source ~/.bashrc
4.3 Compile libraries
cd /opt/Build_WRF/LIBRARIES/tar
tar -xzf netcdf-4.1.3.tar.gz -C /opt/Build_WRF/LIBRARIES/untar
cd .. /untar/netcdf-4.1.3
./configure --prefix= $DIR /netcdf --disable-dap --disable-netcdf-4 --disable-shared
make
make install
cd /opt/Build_WRF/LIBRARIES/tar
tar -zxf mpich-3.0.4.tar.gz -C /opt/Build_WRF/LIBRARIES/untar
cd .. /untar/mpich-3.0.4
./configure --prefix= $DIR /mpich
make
make install
cd /opt/Build_WRF/LIBRARIES/tar
tar -xzf zlib-1.2.7.tar.gz -C /opt/Build_WRF/LIBRARIES/untar
cd .. /untar/zlib-1.2.7
./configure --prefix= $DIR /grib2
make
make install
cd /opt/Build_WRF/LIBRARIES/tar
tar -xzf libpng-1.2.50.tar.gz -C /opt/Build_WRF/LIBRARIES/untar
cd .. /untar/libpng-1.2.50
./configure --prefix= $DIR /grib2
make
make install
cd /opt/Build_WRF/LIBRARIES/tar
tar -xzf jasper-1.900.1.tar.gz -C /opt/Build_WRF/LIBRARIES/untar
cd .. /untar/jasper-1.900.1
./configure --prefix= $DIR /grib2
make
make install
cd /opt/Build_WRF/LIBRARIES/tar
tar -xzf time-1.9.tar.gz -C /opt/Build_WRF/LIBRARIES/untar
cd .. /untar/time-1.9
./configure --prefix= /usr/
make
make install
ls /usr/bin/time
5 Test compatibility of libraries
5.3 Download test files
cd /opt/Test
wget https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_NETCDF_MPI_tests.tar
tar -xf Fortran_C_NETCDF_MPI_tests.tar
5.3.1 Fortran + C + NetCDF
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
5.3.2 Fortran + C + NetCDF + MPI
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 02_fortran+c+netcdf+mpi_c.o -L${NETCDF} /lib -lnetcdff -lnetcdf
mpirun ./a.out
6 Compile WRF and WPS
cd /opt/Build_WRF/LIBRARIES/
git clone https://github.com/wrf-model/WRF
cd WRF
./configure
./compile em_real >& log.compile
ls -lh main/*.exe
cd /opt/Build_WRF/LIBRARIES/
git clone https://github.com/wrf-model/WPS
cd WPS
./clean
./configure
./compile >& log.compile
ls -lh *.exe
7 其他
cd ~
wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
chmod +x Anaconda3-2021.05-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
conda create -n ncl -c conda-forge ncl
conda activate ncl
ncl
python3