前言
天气研究和预报(WRF)模型是一种中尺度数值天气预报系统,在全球范围内用于业务预报和研究目的。
这是在基于Intel的i7(12核)Linux Ubuntu 20.04 LTS系统上安装WRF 4.2.1的版本。这将有助于初学者在普通台式机上实现安装并测试WRF。
一、依赖软件快速安装
(1)基础软件安装
这里我们主要通过ubuntu系统的apt install 快速安装,避免源码安装失败:)
sudo apt install csh gfortran m4 mpich libhdf5-mpich-dev libpng-dev libnetcdff-dev netcdf-bin ncl-ncarg build-essential
(2)Jasperlib软件安装
wget https://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.29.tar.gz
tar xvf jasper-1.900.29.tar.gz
cd jasper-1.900.29/
./configure --prefix=/opt/jasper-1.900.29
make
sudo make install
注意: 如果存在编译错误,则可以执行以下修复:
sed -i 's/char *optstr/const char *optstr/g' src/libjasper/jpg/jpg_dummy.c
二、编译安装WRF
(1) 获取WRF代码包
wget https://github.com/wrf-model/WRF/archive/v4.2.1.tar.gz
tar xvf v4.2.1.tar.gz
cd WRF-4.2.1/
注意:如果下载不下来,文后有博主下载好的进行下载。
(2)开始安装
在终端输入以下语句:
export NETCDF=/usr
export NETCDF_classic=1
./configure
输出 :
checking for perl5... no checking for perl... found /usr/bin/perl (perl) Will use NETCDF in dir: /usr HDF5 not set in environment. Will configure WRF for use without. PHDF5 not set in environment. Will configure WRF for use without. Will use 'time' to report timing information $JASPERLIB or $JASPERINC not found in environment, configuring to build without grib2 I/O... ------------------------------------------------------------------------ Please select from among the following Linux x86_64 options: 1. (serial) 2. (smpar) 3. (dmpar) 4. (dm+sm) PGI (pgf90/gcc) 5. (serial) 6. (smpar) 7. (dmpar) 8. (dm+sm) PGI (pgf90/pgcc): SGI MPT 9. (serial) 10. (smpar) 11. (dmpar) 12. (dm+sm) PGI (pgf90/gcc): PGI accelerator 13. (serial) 14. (smpar) 15. (dmpar) 16. (dm+sm) INTEL (ifort/icc) 17. (dm+sm) INTEL (ifort/icc): Xeon Phi (MIC architecture) 18. (serial) 19. (smpar) 20. (dmpar) 21. (dm+sm) INTEL (ifort/icc): Xeon (SNB with AVX mods) 22. (serial) 23. (smpar) 24. (dmpar) 25. (dm+sm) INTEL (ifort/icc): SGI MPT 26. (serial) 27. (smpar) 28. (dmpar) 29. (dm+sm) INTEL (ifort/icc): IBM POE 30. (serial) 31. (dmpar) PATHSCALE (pathf90/pathcc) 32. (serial) 33. (smpar) 34. (dmpar) 35. (dm+sm) GNU (gfortran/gcc) 36. (serial) 37. (smpar) 38. (dmpar) 39. (dm+sm) IBM (xlf90_r/cc_r) 40. (serial) 41. (smpar) 42. (dmpar) 43. (dm+sm) PGI (ftn/gcc): Cray XC CLE 44. (serial) 45. (smpar) 46. (dmpar) 47. (dm+sm) CRAY CCE (ftn $(NOOMP)/cc): Cray XE and XC 48. (serial) 49. (smpar) 50. (dmpar) 51. (dm+sm) INTEL (ftn/icc): Cray XC 52. (serial) 53. (smpar) 54. (dmpar) 55. (dm+sm) PGI (pgf90/pgcc) 56. (serial) 57. (smpar) 58. (dmpar) 59. (dm+sm) PGI (pgf90/gcc): -f90=pgf90 60. (serial) 61. (smpar) 62. (dmpar) 63. (dm+sm) PGI (pgf90/pgcc): -f90=pgf90 64. (serial) 65. (smpar) 66. (dmpar) 67. (dm+sm) INTEL (ifort/icc): HSW/BDW 68. (serial) 69. (smpar) 70. (dmpar) 71. (dm+sm) INTEL (ifort/icc): KNL MIC 72. (serial) 73. (smpar) 74. (dmpar) 75. (dm+sm) FUJITSU (frtpx/fccpx): FX10/FX100 SPARC64 IXfx/Xlfx Enter selection [1-75] : 33 ------------------------------------------------------------------------ Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: Configuration successful! ------------------------------------------------------------------------ testing for fseeko and fseeko64 fseeko64 is supported ------------------------------------------------------------------------ ...
(3) 用自带的编辑器编辑WRF4.2中configure.wrf这个文件并修改
修改这句话:
LIB_EXTERNAL = \
-L$(WRF_SRC_ROOT_DIR)/external/io_netcdf -lwrfio_nf -L/usr/lib -lnetcdff -lnetcdf
(4)开始编译
./compile -j 2 em_real 2>&1 | tee compile.log
编译成功输出如下:
---> Executables successfully built <---
-rwxrwxr-x 1 wrf wrf 40691640 Jul 30 12:35 main/ndown.exe
-rwxrwxr-x 1 wrf wrf 40572760 Jul 30 12:35 main/real.exe
-rwxrwxr-x 1 wrf wrf 40048888 Jul 30 12:35 main/tc.exe
-rwxrwxr-x 1 wrf wrf 44609360 Jul 30 12:35 main/wrf.exe
==========================================================================
三、编译安装WPS
(1) 软件下载
cd ../
wget https://github.com/wrf-model/WPS/archive/v4.2.tar.gz
tar xvf v4.2.tar.gz
cd WPS-4.2/
注意: 如果下载不下来,文后有博主下载好的进行下载。
(2) 配置
在终端输入下面语句:
export WRF_DIR=../WRF-4.2.1/
export JASPERLIB=/opt/jasper-1.900.29/lib/
export JASPERINC=/opt/jasper-1.900.29/include/
./configure
输出:
------------------------------------------------------------------------ Please select from among the following supported platforms. 1. Linux x86_64, gfortran (serial) 2. Linux x86_64, gfortran (serial_NO_GRIB2) 3. Linux x86_64, gfortran (dmpar) 4. Linux x86_64, gfortran (dmpar_NO_GRIB2) 5. Linux x86_64, PGI compiler (serial) 6. Linux x86_64, PGI compiler (serial_NO_GRIB2) 7. Linux x86_64, PGI compiler (dmpar) 8. Linux x86_64, PGI compiler (dmpar_NO_GRIB2) 9. Linux x86_64, PGI compiler, SGI MPT (serial) 10. Linux x86_64, PGI compiler, SGI MPT (serial_NO_GRIB2) 11. Linux x86_64, PGI compiler, SGI MPT (dmpar) 12. Linux x86_64, PGI compiler, SGI MPT (dmpar_NO_GRIB2) 13. Linux x86_64, IA64 and Opteron (serial) 14. Linux x86_64, IA64 and Opteron (serial_NO_GRIB2) 15. Linux x86_64, IA64 and Opteron (dmpar) 16. Linux x86_64, IA64 and Opteron (dmpar_NO_GRIB2) 17. Linux x86_64, Intel compiler (serial) 18. Linux x86_64, Intel compiler (serial_NO_GRIB2) 19. Linux x86_64, Intel compiler (dmpar) 20. Linux x86_64, Intel compiler (dmpar_NO_GRIB2) 21. Linux x86_64, Intel compiler, SGI MPT (serial) 22. Linux x86_64, Intel compiler, SGI MPT (serial_NO_GRIB2) 23. Linux x86_64, Intel compiler, SGI MPT (dmpar) 24. Linux x86_64, Intel compiler, SGI MPT (dmpar_NO_GRIB2) 25. Linux x86_64, Intel compiler, IBM POE (serial) 26. Linux x86_64, Intel compiler, IBM POE (serial_NO_GRIB2) 27. Linux x86_64, Intel compiler, IBM POE (dmpar) 28. Linux x86_64, Intel compiler, IBM POE (dmpar_NO_GRIB2) 29. Linux x86_64 g95 compiler (serial) 30. Linux x86_64 g95 compiler (serial_NO_GRIB2) 31. Linux x86_64 g95 compiler (dmpar) 32. Linux x86_64 g95 compiler (dmpar_NO_GRIB2) 33. Cray XE/XC CLE/Linux x86_64, Cray compiler (serial) 34. Cray XE/XC CLE/Linux x86_64, Cray compiler (serial_NO_GRIB2) 35. Cray XE/XC CLE/Linux x86_64, Cray compiler (dmpar) 36. Cray XE/XC CLE/Linux x86_64, Cray compiler (dmpar_NO_GRIB2) 37. Cray XC CLE/Linux x86_64, Intel compiler (serial) 38. Cray XC CLE/Linux x86_64, Intel compiler (serial_NO_GRIB2) 39. Cray XC CLE/Linux x86_64, Intel compiler (dmpar) 40. Cray XC CLE/Linux x86_64, Intel compiler (dmpar_NO_GRIB2) Enter selection [1-40] : 1 ------------------------------------------------------------------------ Configuration successful. To build the WPS, type: compile ------------------------------------------------------------------------
(3) 用自带的编辑器编辑WPS中configure.wps这个文件并修改
修改的地方如下:
WRF_LIB = -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \
-L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
-L$(WRF_DIR)/external/io_int -lwrfio_int \
-L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
-L$(NETCDF)/lib -lnetcdf -lnetcdff
(4) 编译
./compile 2>&1 | tee compile.log
输出:
ls -rlt
出现下图,则表示安装成功:
WPS程序ungrib执行串行操作,而geogrid和metgrid可以并行模式运行。
(5)运行
/.ungrib.exe
要运行WPS,必须将LD_LIBRARY_PATH添加到.bashrc中。
打开你的~/.bashrc或您选择的任何其他文本编辑器。
在文件末尾添加此行:
export LD_LIBRARY_PATH=$LD_LIBRORY_PATH:/opt/jasper-1.900.29/lib/
写入并保存编辑,然后退出。
现在,在终端中输入:
source ~/.bashrc
补充说明:
文中提到的WRF4.2.1与WPS4.2如果下载不下来,可以提供博主下载好的版本,如下:
https://download.csdn.net/download/u010329292/87250165