Weather Research and Forecast (WRF) model

This document is intended to serve as a reference for new users in building and running the WRF and WPS on Keeling. This guide assumes WRF version 4.0.0 and greater.

Acquiring WRF source code

WRF Versions 4.0 and greater are available at the WRF GitHub repository

To acquire the WRF model there are various options:

  • You can clone the WRF repository directly by:

    git clone https://github.com/wrf-model/WRF.git
    
  • Create your own fork the WRF repository through GitHub (or by clicking here) and then acquire the code by:

    git clone https://github.com/<your GitHub username>/WRF.git
    
  • Acquire a specific version as a tarball from the WRF GitHub Release page

    Note

    For example, to acquire a tar file of version 4.4.2:

    wget https://github.com/wrf-model/WRF/releases/download/v4.4.2/v4.4.2.tar.gz
    

    and you can unpack by:

    tar -xvzf v4.4.2.tar.gz
    
  • Older versions (before v4.0) are available for download from the WRF Users Page

Building WRF

Setting up the build environment

  1. There are two compiler options on Keeling to compile WRF: GNU and Intel.

    • If building with GNU compilers, load the following modules:

    module load mpi/openmpi-x86_64
    
    • If building with Intel compilers, load the following modules:

    module load intel/intel-oneapi
    module load intel/intel-mpi
    module load intel/netcdf4-4.9.2-intel-oneapi
    
  2. Set the path to NetCDF:

    export NETCDF=`nc-config --prefix`
    
  3. If you are interested in compiling WRF with chemistry options, WRF-Chem can be enabled on by:

    export WRF_CHEM=1
    

Configuring and compiling WRF

  1. To configure WRF, run the configure process by:

    ./configure
    

    For GNU compilers, select the GNU (gfortran/gcc) option that is distributed memory (DM) (option [34])

    For Intel compileres, select the option that says INTEL (ifx/icx) (option [78] as of version 4.6.1)

    Note

    For older version of WRF, you may have to select INTEL (ifort/icc) option and edit the configure.wrf file to change the compiler to ifx/icx from ifort/icc.

  2. Unless you require moving nesting, select [1] for default nesting.

  3. Upon completion of the configure process a file configure.wrf will be generated that contains all the settings for building WRF. This is the file that one may be required to modify in event of a problem or to further modify compiler options/flags.

  4. To compile WRF to do a real case and send the output to a log file, run the following:

./compile em_real >& compile_WRF.log

Note

WRF also has various idealized cases. These cases are found in the test directory and all available cases can be seen the following command:

./compile -h

with further information regarding each case found in the README files within each case directory within the test directory. As an example, if you wanted to compile the LES scenario found in test/em_les

./compile em_les >& compile_WRF_les.log

Building WRF Pre-Processing System (WPS)

The WRF Pre-Processing System (WPS) is a collection programs that provides data used as input to the real.exe program. WPS is available on GitHub.

  1. Change to the directory where your WRF directory can be found. WPS will need a compiled version of WRF to compile and will be expecting it in this specific location (../ relative to the WPS directory). If you do not wish to do this, you can set the WRF_DIR environment variable to the location of the WRF directory.

  2. Clone WPS repository:

    git clone https://github.com/wrf-model/WPS.git
    
  3. Checkout the major version that matches your version of WRF. For example, if you have compield WRF v4.6.2, checkout the v4.6 branch:

    git checkout -b v4.6 v4.6
    
  4. To configure:

    ./configure
    

    Select the option that matches your WRF compiler choice: option [1] if you used GNU compilers or [17] if you used Intel.

  5. To compile WPS:

    ./compile >& compile_WPS.log
    
  6. Verify that the directory now contains the following executables:

    • geogrid.exe: creates the geography data

    • ungrib.exe: decodes the data using tables and creates an intermediate format

    • metgrid.exe: ingests the data and interpolates the fields to the model domain