用Ubuntu在WRF上进行编译

WRF(Weather Research and Forecasting)是一种领域气象模型,用于气象现象的理解研究等。这个模型是由美国的NCAR(National Center for Atmospheric Research)开发的,可以自由地用于商业或非商业用途。然而,在日文中,并没有找到仅使用开源工具来编译WRF的说明,所以我将其留作备忘录。

操作系统 (CZXT)

本文所述标题,我使用的是Ubuntu。这次使用的是22.04.3LTS版本,但我认为其他版本也没问题。
关于Ubuntu的安装,因为有很多信息,在这里就不详细说明了。
我是在一台旧的Intel Mac(i5)上进行的安装。

使用包管理器获取工具。

首先,开始更新。

sudo apt update
sudo apt upgrade 

当现有的软件包更新到最新版本时,可以使用apt从中获取所需的内容。

sudo apt install -y libpng-dev libcairo2-dev libhdf5-dev hdf5-tools hdf5-helpers libhdf5-dev libhdf5-doc libhdf5-serial-dev libnetcdf-dev gfortran jasper libtext-csv-perl m4 csh netcdf-bin openmpi-bin libopenmpi-dev tar

安装netcdf-fortran。

因为在apt上没办法,所以需要进行源代码构建。请根据需要灵活选择版本。
请在~/.bashrc文件中预先添加以下内容。

#NetCDF
export PATH="/usr/local/netcdf-fortran/4.6.1/bin:$PATH"
export NETCDF=/usr/local/netcdf-fortran/4.6.1
export NETCDFHOME=$NETCDF
export NETCDF_LIB=$NETCDF/lib
export NETCDF_INC=$NETCDF/include
export LD_LIBRARY_PATH="$NETCDF/lib:$LD_LIBRARY_PATH"
export NETCDF_classic=1

下载并制作源代码

wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.1/netcdf-fortran-4.6.1.tar.gz
tar -xvf netcdf-fortran-4.6.1.tar.gz
cd netcdf-fortran-4.6.1
./configure --prefix=/usr/local/netcdf-fortran/4.6.1
make check
make install

也许没有 CHECK 也能做的很好?

nf-config --all

用这个以后如果出现解释,则成功。

WRF的编译

<p如果没有 git,也可以使用 wget

git clone https://github.com/wrf-model/WRF
cd WRF
./configure
./compile em_real
bannerAds