Skip to content

Compiling WRF and related tools

Warning

It is quite likely that the installation process described below will not work if you are working in an environment where conda is activated. We therefore recommand to

  • not automatically activate a conda environment in your ~/.bashrc file
  • deactivate any activated conda environment, if any, before proceeding further

Compile WRF

Basic usage

Use the compile_WRF.py script provided in WRF-infra to download and compile WRF:

cd WRF-infra/compile
python compile_WRF.py

This compiles WRF-Chem-Polar with chemistry activated. Compilation takes roughly an hour and a half. You can check that compilation was successful by looking for the following message at the end of compilation.log in your installation directory:

--->                  Executables successfully built                  <---

The default configuration of this script is based on the WRF-Chem-Polar team's most frequent use-case. Subsections below explain how to use different settings (see also this technical documentation for a description of all the existing options).

Compile upstream WRF

Use the --upstream switch to compile the upstream version of WRF or WRF-Chem:

python compile_WRF.py --upstream

Compile WRF without WRF-Chem

To use WRF in meteorology-only mode, tell the script not to compile any extra components:

python compile_WRF.py --components ""

(the default value of this parameter is "kpp,chem").

Choose where to install WRF

By default, the script installs WRF in a directory named "WRF". Use the option --destination to install it to a directory of your choice, for instance:

python compile_WRF.py --destination=/path/to/my/wrf

Using a scheduler (or not)

By default, the compile script sends all the work to the host's scheduler (eg. slurm). You can prevent this behaviour using:

python compile_WRF.py --scheduler no

On some machines, the scheduler requires that a project name be specified when running a job, which you can do using:

python compile_WRF.py --scheduler-opt account ${my-account-name}

More generally, you can set any scheduler option using the following syntax:

python compile_WRF.py --scheduler-opt ${option-name} ${option-value}

Compile WPS

Although it is a pre-processor, WPS needs to be compiled after WRF because it depends on it. Use the compile_WPS.py script to download and compile the latest WPS version:

python compile_WPS.py

Compilation of WPS typically takes one or two minutes. You can verify that compilation was successful by checking for the presence of the following binaries in the installation directory (presence of the actual binaries in the */src directories and of the simlinks at the root of the directory):

  • geogrid.exe -> geogrid/src/geogrid.exe
  • metgrid.exe -> metgrid/src/metgrid.exe
  • ungrib.exe -> ungrib/src/ungrib.exe

Just as for WRF, you can use the parameter --destination to specify where WPS should be installed. Additionally, if you installed WRF in a non-default location, you will have to use the option --wrfdir to point to where WRF is installed, for example:

python compile_WPS.py --destination=/path/to/my/wps --wrfdir=/path/to/my/wrf

Note that patches are required to compile WPS v4.6.0:

python compile_WPS.py --commit v4.6.0 --patches ./patches/WPS/v4.6.0