WRF4.2安装过程全记录

由于本人安装过多次、多个版本的WRF程序,走了许多弯路,不忍心大家再像我一样浪费时间,所以整理一些可用经验。参考Compiling WRF (ucar.edu)

  • 系统环境配置 

1、首先确保有没有安装好编译语言gfortran、gcc、g++以及cpp。

2、创建WRF工作文件及其后续可能用得上的子文件。之所以选择在~/目录下直接建立WRF工作站,主要是方便所有人访问,不需要host/sudo权限。

which gfortran
which cpp
which gcc
sudo apt install gfortran gcc cpp g++ make
gcc --version
gfortran --version
cpp --version


mkdir ~/WRF_WorkStation
mkdir ~/WRF_WorkStation/Libraries
mkdir ~/WRF_WorkStation/netcdf
mkdir ~/WRF_WorkStation/grib2
mkdir ~/WRF_WorkStation/mpich
mkdir ~/WRF_WorkStation/test

3、进入~/WRF_WorkStation/test文件中,将下载好的Fortran and C Tests Tar File 解压。具体的测试成功与否请参照Compiling WRF (ucar.edu)

tar -xf 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
./TEST_csh.csh
./TEST_perl.pl
./TEST_sh.sh

其他的unix命令可以后续需要的时候下载!命令下载方式是

sudo apt install command


  • 创建库

1、进入到WRF工作文件夹下的Libraries目录下。

cd ~/WRF_WorkStation/Libraries

mpich-3.0.4
netcdf-4.1.3
Jasper-1.900.1
libpng-1.2.50
zlib-1.2.7

五个压缩包下载到其中,后续可以删掉,也可以保留,随个人喜好。

2、修改~/.bashrc环境配置,这一步必须有!!!注意###后的内容全部都应该在~/.bashrc的尾部加入,然后用source ~/.bashrc生效。

vi ~/.bashrc

###-----------------------WRF installation-----------------###
export DIR=/home/hsy/WRF_WORKSTATION/LIBRARIES
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include

source ~/.bashrc

3、配置netcdf。

tar xzvf netcdf-4.1.3.tar.gz     #or just .tar if no .gz present
cd netcdf-4.1.3
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
make
make install

vi ~/.bashrc

###--->netcdf<---###
export NETCDF=$DIR/netcdf
export PATH=$NETCDF/bin:$PATH

source ~/.bashrc

nc-config

netcdf安装过程可能会有各种各样的问题,请小心操作,一定要谨慎,不能弄错一步!错了也不要害怕,通过make clean消除编译文件后继续重来。直到看见Congratulations! You have successfully installed netCDF!字眼,且Libraries/netcdf/include/netcdf.inc存在,nc-config --help能用!

4、配置mpich

tar xzvf mpich-3.0.4.tar.gz     #or just .tar if no .gz present
cd mpich-3.0.4
./configure --prefix=$DIR/mpich
make
make install
make check #可省略此步


vi ~/.bashrc

###--->mpich<---###
export MPICH=$DIR/mpich
export PATH=$MPICH/bin:$PATH

source ~/.bashrc

5、配置zlib、jasper以及libpng

tar xzvf zlib-1.2.7.tar.gz     #or just .tar if no .gz present
cd zlib-1.2.7
./configure --prefix=$DIR/grib2
make
make install


tar xzvf libpng-1.2.50.tar.gz     #or just .tar if no .gz present
cd libpng-1.2.50
./configure --prefix=$DIR/grib2
make
make install


tar xzvf jasper-1.900.1.tar.gz     #or just .tar if no .gz present
cd jasper-1.900.1
./configure --prefix=$DIR/grib2
make
make install

进入各自的解压包下,首先配置路径到grib2文件下,./configure --prefix,再make -> make install->make check(可省略)。

最后的库的编译环境(~/.bashrc)如下:


###-----------------------WRF installation-----------------###
export DIR=/home/hsy/WRF_WORKSTATION/LIBRARIES
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include

###--->netcdf<---###
export NETCDF=$DIR/netcdf
export PATH=$NETCDF/bin:$PATH

###--->mpich<---###
export MPICH=$DIR/mpich
 

###--->zlib<---###
export ZLIB=$DIR/grib2
export PATH=$ZLIB/bin:$PATH

###--->libpng<---###
export LIBPNG=$DIR/grib2
export PATH=$LIBPNG/bin:$PATH

###--->jasper<---###
export JASPER=$DIR/grib2
export PATH=$JASPER/bin:$PATH

###--->WPS Compiler<---###
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
export LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH

zlib、libpng以及jasper的配置环境可以省略,因为前面已存在。


  • 库的兼容性测试

首先下载Fortran_C_NETCDF_MPI_tests.tar并解压,然后开始进行两个测试,一个是netcdf的测试,另一个是mpich的测试。

这里注意把设置的NETCDF路径下的netcdf.inc复制到test文件夹下。

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

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

  • 创建WRF

1、首先进入WRF与WPS下载目录下,将WRFv4.2与WPSv4.2安装包解压到WRF工作文件夹下,注意两者一定要在同一文件目录下,即保证解压后的WPSV4.2/与WRFV4.2/均在WRF_WORKSTATION文件目录下。

unzip WPS-4.2.zip -d ~/WRF_WORKSTATION/WPSV4.2/

unzip WRF-4.2.zip -d ~/WRF_WORKSTATION/WRFV4.2/

2、配置编译WRF(必须先编译WRF,才可以编译WPS),首先进入WRFV4.2文件目录下,输入./configure进行配置,选择34(dmpar GNU组合),再选择1(basic),然后再编译。

注意如果这里WRF ./configure报错:libimf.so无法链接,那么参考下面这篇文章可以解决。

error while loading shared libraries: libimf.so: - Intel CommunitiesHi. I cannot complie my program using the makefile. However, if I type the complie command, it can complie. I donot know why this situation happens.icon-default.png?t=M7J4https://community.intel.com/t5/Intel-Fortran-Compiler/error-while-loading-shared-libraries-libimf-so/td-p/740546​​​​​​​

./configure
34
1
./compile em_real >& log.compile
ls -ls main/*.exe

3、等20min左右,直到出现wrf.exe (model executable)
real.exe (real data initialization)
ndown.exe (one-way nesting)
tc.exe (for tc bogusing--serial only)则证明wrf的real case编译成功了。​​​​​​​


  • 创建WPS

1、首先进入WPSV4.2中, ./clean清除WPS文件目录。

2、配置WRF,选择dmpar gfortran。

3、编译WPS。

cd WPSV4.2
./clean
export WRF_DIR=../WRFV4.2

vi ~/.bashrc
###---------- WRF compile -----------###
export WRFIO_NCD_LARGE_FILE_SUPPORT=1

source ~/.bashrc

./configure
3
./compile
ls -ls *.exe

出现三个.exe文件即为成功!

  • 3
    点赞
  • 45
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
安装WRF需要按照一定的步骤进行,其中包括下载和配置必要的软件和库文件。根据引用中的链接,你可以在whuhpcdocs.wiki上找到关于WRF-WPS的安装指南。 首先,你需要下载安装所需的依赖库和软件,如NetCDF、HDF5、MPICH等。你可以根据文档中提供的链接去下载这些软件,并按照相应的安装指南进行安装安装完成后,你需要配置一些环境变量,以确保WRF可以正确地编译和运行。你可以根据文档中的指引,设置PATH、NETCDF和MPI的环境变量。 接下来,你需要下载WRF源代码,并解压到你的工作目录中。然后,进入WRF源代码目录,运行configure命令进行配置。在配置过程中,你可以选择安装WRF的版本、编译选项和模式等。 配置完成后,运行编译命令来编译WRF。编译过程可能需要一些时间,取决于你的系统配置和编译选项。 完成编译后,你可以进行一些可选的测试来验证WRF的安装是否成功。文档中提供了一些测试案例,你可以按照指引进行测试。 最后,如果一切顺利,你就可以使用已安装的WRF进行气象模拟了。 需要注意的是,WRF的安装过程可能因系统环境和个人需求而略有差异。因此,在安装过程中,你可能需要根据实际情况进行适当的调整和修改。 希望以上信息能够帮助你安装intel版本的WRF。如果你还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值