Skip to content

WRF

Weather Research and Forecasting Model (WRF) is used by numerous atmopheric sciences researchers, however, most researchers need to customize it to their needs and as such CHPC does not provide a binary for it. Instead, below we provide instructions how to build WRF and thank Dr. Derek Mallia from the U's Atmospheric Sciences department for creating these instructions.

Update November 2023. With newer versions of the NetCDF and HDF5 libraries and the presence of the operation system installed HDF5, it has become necessary to create a single module that includes NetCDF-C, NetCDF-Fortran and HDF5. The version of this module, called "netcdf", is he same as the parent NetCDF-C. Note that we define the NETCDF environment variable in the module so it does not need to be set. The instructions below reflect this change.

Building WRF (4.2) on CHPC's Rocky 8 Linux OS

Download WRF, uncompress and change to its base directory.

Clean existing installation and purge environment.

ml purge
./clean -a

Load necessary modules and set the proper environment variables.      

module load intel-oneapi-compilers/2021.4.0
module load openmpi/4.1.1
module load netcdf/4.8.1

export WRFIO_NCD_LARGE_FILE_SUPPORT=1

To install WRF-Chem... If using chemical mechs 100-300, WRF-Chem needs the KPP libraries compiled in addition to WRF_CHEM=1 being set. Beware of flags for YACC, this needs to be a special hyphen, else WRF-Chem compilation will complain.  

export WRF_CHEM=1
export WRF_KPP=1
export YACC='/usr/bin/yacc -d'        #This hyphen is different (long) and will work.
export FLEX_LIB_DIR=/usr/lib64/       #(/usr/lib64 on cheyenne)

Configure the installation and select option 15 dmpar for Intel (ifort/icc) and option 1 for basic nesting (NOTE - for many CPU core nodes it may be advantageous to experiment with OpenMP threading as this may provide better performance than running one MPI process per CPU core).

./configure

Edit the configure.wrf and external/io_netcdf/makefile
For configure.wrf

HDF5            = -lhdf5_hl -lhdf5

to

HDF5            = -L$(NETCDF_ROOT)/lib -Wl,-rpath=$(NETCDF_ROOT)/lib -lhdf5_hl -lhdf5 -limf

For external/io_netcdf/makefile.

FFLAGS  =  $(FCFLAGS) -I$(NETCDFPATH)/include -I../ioapi_share
LIBS = $(LIB_LOCAL) -L$(NETCDFPATH)/lib -Wl,-rpath=$(NETCDFPATH)/lib -lnetcdf
LIBFFS = $(LIB_LOCAL) -L$(NETCDFPATH)/lib -Wl,-rpath=$(NETCDFPATH)/lib -lnetcdff -lnetcdf $(NETCDF4_DEP_LIB)

otherwise the NetCDF dynamic libraries can't be found at runtime. Put the path to the combined NetCDF libraries to the link line via the -Wl,-rpath linker flag. Additionally, the NETCDFPATH, which we set to /uufs/chpc.utah.edu/sys/spack/linux-rocky8-nehalem/intel-2021.4.0/netcdf, is passed to the submodules of the WRF, but the -Wl,-rpath that sets the search path for the dynamic libraries is not set, therefore we need to modify also in the wrfio_nf makefile.

Compile WRF

./compile em_real >& logfile &

Building WPS

Next, we need to compile WPS. Since we usually need grib2 support, we need to set the following compression libraries.

export JASPERLIB=/usr/lib64
export JASPERINC=/usr/include

Configure WPS and select Intel compiler (serial), [option 17]

./configure

Compile WPS and save output to a logfile 

./compile >& logfile &

 

Last Updated: 11/16/23