WRF dynamical core for LES/mesoscale simulations

From Planets
Revision as of 11:35, 17 September 2025 by Noe clement (talk | contribs)

Jump to: navigation, search

Introduction

WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see WRF presentation.

In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.

To do so, we take the WRF model, remove all its physical packages related to the Earth's atmosphere, and plug in the physical package from the PCM (either Venus, Mars, Titan, or Generic).

A description of the various equations solved by WRF can be found here: Skamarock et al. (2019, 2021).

Studies with PCM+WRF

Descriptions of the application of WRF dynamical core with the PCM can be found in:

- Noé CLEMENT's PhD thesis (chapter 3) for the Generic PCM.

- Maxence Lefevre's PhD thesis for the Venus PCM.

- Aymeric Spiga's PhD thesis for the Mars PCM

Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.

Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.

Here is a list of studies using the PCM coupled to the WRF dynamical core:

Planet Reference Physical package Dynamical core
Mars Spiga and Forget (2009) Mars PCM WRF V2
Mars Spiga et al. (2010) Mars PCM WRF V3
Venus Lefèvre et al. (2018) Venus PCM WRF V3
Venus Lefèvre et al. (2020) Venus PCM WRF V2
Exoplanets Lefèvre et al. (2021) Generic PCM WRF V3
Exoplanets Leconte et al. (2024) Generic PCM WRF V4
Uranus, Neptune Clément et al. (2024) Generic PCM WRF V4

Remarks

For advanced users:

When compiling the model, the flags:

#ifndef MESOSCALE
      use ...
#else
      use ...

select lines compiled depending on the configuration.

WRF equations

Below is a synthesis of equations solved by WRF.

WRF dynamical core.png

Installing PCM+WRF

3 git repositories to handle:

- LES_planet_workflow

- git-trunk (physics & GCM dynamical core), which takes the name "code" when being cloned

- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name "WRFV4) in the "code/WRF.COMMON" directory

The first is hosted on Aymeric Spiga's git, and will download (git clone) the two others, which are part of La communauté des modèles atmosphériques planétaires repositories.

The 3 repositories are managed by git. You need to do a little juggling between these repositories to be sure they are on the right branches for your project.

In the first repository, you have to modify the defining file and set:

archname="ADASTRA-ifort" # (or other cluster)

add="-t 1 -b 20x34 -d 25" # Uranus & Neptune with CH4 visible bands (compilation options are maybe depreciated)

.env file

!!! For now, only the Intel compiler has been tested and works. !!!

On any cluster, one has to build a file "mesoscale.env" which should look more or less like:

# mesoscale.env file

source YOUR_ifort_ENV

# for WRFV4
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1

declare -x NETCDF=`nf-config --prefix`
declare -x NCDFLIB=$NETCDF/lib
declare -x NCDFINC=$NETCDF/include

# PCM/WRFV4 interface
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'

On ADASTRA:

# mesoscale.env file

source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env

# for WRFV4
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1

declare -x NETCDF=$NETCDF_DIR
# alternatively: declare -x NETCDF=`nf-config --prefix`
declare -x NCDFLIB=$NETCDF/lib
declare -x NCDFINC=$NETCDF/include

# specific to ADASTRA
declare -x NETCDF_classic=1

# fix for "undefined symbol: __libm_feature_flag" errors at runtime:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib

# PCM/WRFV4 interface
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort

This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually). It should also be sourced before executing the compiled files to run simulations.

Terrestrial WRF

Compiling terrestrial WRF is a good first step.

"git clone --recurse-submodules https://github.com/wrf-model/WRF"

Before executing the following commands, you have to source a ".env" file, just like the ones above. If you work on Adastra, you can directly use the one below, by inserting it in your home directory for example, and calling it "mesoscale.env". It will work for both the WRF terrestrial and the Generic PCM+WRF

Commands:

./configure

During the configure step, you will be asked about the compiler, choose "INTEL (ifort/icc) dmpar" (probably number 15), and then about nesting, choose "basic" (=1).

then

./compile em_les

WRF compilation can take some time. Consider doing:

nohup ./compile em_les &

Final built executables are: "ideal.exe" and "wrf.exe" (in the WRF/main directory).

Compiling the Generic PCM +WRF

Be sure the 3 repositories are on the right commit

Follow the steps:

Modify the 0-defining.sh to fit your modelled planetary atmosphere.

Execute one by one the:

1_downloading.sh

2_preparing.sh

3_compiling_physics.sh

4_compiling_dynamics.sh

Good luck!

Executables

If you succeed in compiling the model, executables should be in the 'les_workflow/code/WRF.COMMON/WRFV4/main' directory. Executables of the Generic PCM+WRF have the same name as terrestrial WRF.

"ideal.exe" prepares the domain. "wrf.exe" runs the simulation.

The modifications we make in these files during compilation aim to incorporate the Physics of the PCM as a library, as well as the interface between WRF and the PCM.

Some tricks

In case of a failed compilation, the command

./clean -a

in the WRFV4 directory allows you to remove intermediate compiled files.