<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Noe+clement</id>
		<title>Planets - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Noe+clement"/>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Special:Contributions/Noe_clement"/>
		<updated>2026-06-13T03:18:10Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.7</generator>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3185</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3185"/>
				<updated>2026-01-14T11:15:27Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@gitlab.in2p3.fr:aymeric.spiga/les_mars_project.git&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
NB: The old name of 'LES_planet_workflow' is 'les_mars_project', the original address can not be modified.&lt;br /&gt;
&lt;br /&gt;
NB2: You may need to ask for access to Aymeric's repository before.&lt;br /&gt;
&lt;br /&gt;
NB3: Cloning with 'ssh' is better than cloning with 'https' (for later commits)&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
git checkout wrfv4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --cpus-per-task=1&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3184</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3184"/>
				<updated>2026-01-14T11:09:28Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
git checkout wrfv4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --cpus-per-task=1&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3183</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3183"/>
				<updated>2026-01-14T11:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;. &amp;quot;git checkout wrfv4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --cpus-per-task=1&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3182</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3182"/>
				<updated>2026-01-14T10:58:17Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;. &amp;quot;git checkout wrfv4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=/absolute_path_to_your_LES_planet_workflow/code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --cpus-per-task=1&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3179</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3179"/>
				<updated>2026-01-13T15:19:17Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;. &amp;quot;git checkout wrfv4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --cpus-per-task=1&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3171</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3171"/>
				<updated>2026-01-09T15:18:54Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --cpus-per-task=1&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3170</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3170"/>
				<updated>2026-01-08T13:50:48Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
First, &amp;quot;source mesoscale.env&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And then execute, one by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3169</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=3169"/>
				<updated>2026-01-08T13:42:24Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and the two others are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2894</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2894"/>
				<updated>2025-09-17T15:14:07Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Terrestrial WRF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
echo 15 &amp;gt; configure_inputs&lt;br /&gt;
echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2893</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2893"/>
				<updated>2025-09-17T15:13:17Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2892</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2892"/>
				<updated>2025-09-17T15:11:30Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Installing &amp;amp; Compiling the Generic PCM + WRF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
source mesoscale.env&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2891</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2891"/>
				<updated>2025-09-17T15:08:38Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Downloading/Cloning the parent repository */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Set this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2890</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2890"/>
				<updated>2025-09-17T14:34:05Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can be like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2889</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2889"/>
				<updated>2025-09-17T14:33:20Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you need to put an additional line in ''namelist.input&lt;br /&gt;
with for example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2888</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2888"/>
				<updated>2025-09-17T14:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with an additional line in ''namelist.input&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2887</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2887"/>
				<updated>2025-09-17T14:29:27Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional for additional outputs&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
with an additional line in namelist.input&lt;br /&gt;
&lt;br /&gt;
iofields_filename = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
+:h:0:DQVAP,DQICE,WW,TT&lt;br /&gt;
-:h:0:QH2O&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2886</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2886"/>
				<updated>2025-09-17T14:27:48Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
List of needed .def files:&lt;br /&gt;
&lt;br /&gt;
To launch the simulation:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
Optional:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt # for additional outputs with an additional line in namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iofields_filename                   = &amp;quot;my_iofields_list.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2885</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2885"/>
				<updated>2025-09-17T14:25:50Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
List of needed .def files:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra # to launch the simulation!  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
WRF specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Generic PCM specific:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Executables:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
Optional:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt # for additional outputs with an additional line '' in namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2884</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2884"/>
				<updated>2025-09-17T14:23:29Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
List of needed .def files:&lt;br /&gt;
 &amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra # to launch the simulation!  &amp;lt;/li&amp;gt;&lt;br /&gt;
### WRF specific&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### Generic PCM specific&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### Executables&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### Optional&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt # for additional outputs &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2883</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2883"/>
				<updated>2025-09-17T14:22:54Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Files in the folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
List of needed .def files:&lt;br /&gt;
 &amp;lt;ul&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; batch_adastra # to launch the simulation!  &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### WRF specific&lt;br /&gt;
  &amp;lt;li&amp;gt; planet_constant &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_sounding  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; input_coord  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; namelist.input &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### Generic PCM specific&lt;br /&gt;
  &amp;lt;li&amp;gt; run.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; callphys.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; gases.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; traceur.def &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### Executables&lt;br /&gt;
  &amp;lt;li&amp;gt; ideal.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt; wrf.exe &amp;lt;/li&amp;gt;&lt;br /&gt;
  ### Optional&lt;br /&gt;
  &amp;lt;li&amp;gt; my_iofields_list.txt # for additional outputs &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2882</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2882"/>
				<updated>2025-09-17T14:04:46Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
gravity (m/s2)&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature (K)&lt;br /&gt;
bottom pressure (Pa)&lt;br /&gt;
radius (m)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
    batch_adastra # to launch the simulation!&lt;br /&gt;
    ### WRF specific&lt;br /&gt;
    planet_constant&lt;br /&gt;
    input_sounding&lt;br /&gt;
    input_coord&lt;br /&gt;
    namelist.input&lt;br /&gt;
    ### Generic PCM specific&lt;br /&gt;
    run.def&lt;br /&gt;
    callphys.def&lt;br /&gt;
    gases.def&lt;br /&gt;
    traceur.def&lt;br /&gt;
    ### Executables&lt;br /&gt;
    ideal.exe&lt;br /&gt;
    wrf.exe&lt;br /&gt;
    ### Optional&lt;br /&gt;
    my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2881</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2881"/>
				<updated>2025-09-17T14:03:38Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&lt;br /&gt;
    gravity (m/s2)&lt;br /&gt;
    heat capacity (J/kg/K)&lt;br /&gt;
    molar mass (g/mol)&lt;br /&gt;
    reference temperature (K)&lt;br /&gt;
    bottom pressure (Pa)&lt;br /&gt;
    radius (m)&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
    11.15&lt;br /&gt;
    10200.&lt;br /&gt;
    2.3&lt;br /&gt;
    175.&lt;br /&gt;
    10.e5&lt;br /&gt;
    24622.0e3&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
#SBATCH --job-name=batch_adastra&lt;br /&gt;
#SBATCH --account=cin0391&lt;br /&gt;
#SBATCH --constraint=GENOA&lt;br /&gt;
#SBATCH --nodes=1&lt;br /&gt;
#SBATCH --ntasks-per-node=20&lt;br /&gt;
#SBATCH --threads-per-core=1 # --hint=nomultithread&lt;br /&gt;
#SBATCH --output=batch_adastra.out&lt;br /&gt;
#SBATCH --time=06:00:00&lt;br /&gt;
&lt;br /&gt;
source ../mesoscale.env&lt;br /&gt;
&lt;br /&gt;
srun --cpu-bind=threads --label  ideal.exe&lt;br /&gt;
srun --cpu-bind=threads --label  wrf.exe&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfout_d01* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
mv wrfrst* wrfout_results_$SLURM_JOB_ID&lt;br /&gt;
&lt;br /&gt;
cp -rf namelist.input wrfout_results_$SLURM_JOB_ID/used_namelist.input&lt;br /&gt;
cp -rf callphys.def wrfout_results_$SLURM_JOB_ID/used_callphys.def&lt;br /&gt;
cp input_sounding wrfout_results_$SLURM_JOB_ID/used_input_sounding&lt;br /&gt;
&lt;br /&gt;
mkdir wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv batch_adastra.out wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
mv rsl.* wrfout_results_$SLURM_JOB_ID/messages_simulations&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
    batch_adastra # to launch the simulation!&lt;br /&gt;
    ### WRF specific&lt;br /&gt;
    planet_constant&lt;br /&gt;
    input_sounding&lt;br /&gt;
    input_coord&lt;br /&gt;
    namelist.input&lt;br /&gt;
    ### Generic PCM specific&lt;br /&gt;
    run.def&lt;br /&gt;
    callphys.def&lt;br /&gt;
    gases.def&lt;br /&gt;
    traceur.def&lt;br /&gt;
    ### Executables&lt;br /&gt;
    ideal.exe&lt;br /&gt;
    wrf.exe&lt;br /&gt;
    ### Optional&lt;br /&gt;
    my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2871</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2871"/>
				<updated>2025-09-17T13:43:41Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: /* Download repositories */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download child repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&lt;br /&gt;
    gravity (m/s2)&lt;br /&gt;
    heat capacity (J/kg/K)&lt;br /&gt;
    molar mass (g/mol)&lt;br /&gt;
    reference temperature (K)&lt;br /&gt;
    bottom pressure (Pa)&lt;br /&gt;
    radius (m)&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
    11.15&lt;br /&gt;
    10200.&lt;br /&gt;
    2.3&lt;br /&gt;
    175.&lt;br /&gt;
    10.e5&lt;br /&gt;
    24622.0e3&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
    batch_adastra # to launch the simulation!&lt;br /&gt;
    ### WRF specific&lt;br /&gt;
    planet_constant&lt;br /&gt;
    input_sounding&lt;br /&gt;
    input_coord&lt;br /&gt;
    namelist.input&lt;br /&gt;
    ### Generic PCM specific&lt;br /&gt;
    run.def&lt;br /&gt;
    callphys.def&lt;br /&gt;
    gases.def&lt;br /&gt;
    traceur.def&lt;br /&gt;
    ### Executables&lt;br /&gt;
    ideal.exe&lt;br /&gt;
    wrf.exe&lt;br /&gt;
    ### Optional&lt;br /&gt;
    my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2870</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2870"/>
				<updated>2025-09-17T13:40:32Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&lt;br /&gt;
    gravity (m/s2)&lt;br /&gt;
    heat capacity (J/kg/K)&lt;br /&gt;
    molar mass (g/mol)&lt;br /&gt;
    reference temperature (K)&lt;br /&gt;
    bottom pressure (Pa)&lt;br /&gt;
    radius (m)&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
    11.15&lt;br /&gt;
    10200.&lt;br /&gt;
    2.3&lt;br /&gt;
    175.&lt;br /&gt;
    10.e5&lt;br /&gt;
    24622.0e3&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== WRF Settings: 'namelist.input' file ====&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
==== batch file for slurm ====&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
    batch_adastra # to launch the simulation!&lt;br /&gt;
    ### WRF specific&lt;br /&gt;
    planet_constant&lt;br /&gt;
    input_sounding&lt;br /&gt;
    input_coord&lt;br /&gt;
    namelist.input&lt;br /&gt;
    ### Generic PCM specific&lt;br /&gt;
    run.def&lt;br /&gt;
    callphys.def&lt;br /&gt;
    gases.def&lt;br /&gt;
    traceur.def&lt;br /&gt;
    ### Executables&lt;br /&gt;
    ideal.exe&lt;br /&gt;
    wrf.exe&lt;br /&gt;
    ### Optional&lt;br /&gt;
    my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2869</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2869"/>
				<updated>2025-09-17T13:37:42Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
&lt;br /&gt;
    gravity&lt;br /&gt;
    heat capacity (J/kg/K)&lt;br /&gt;
    molar mass (g/mol)&lt;br /&gt;
    reference temperature&lt;br /&gt;
    bottom pressure&lt;br /&gt;
    radius&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
&lt;br /&gt;
    11.15&lt;br /&gt;
    10200.&lt;br /&gt;
    2.3&lt;br /&gt;
    175.&lt;br /&gt;
    10.e5&lt;br /&gt;
    24622.0e3&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
batch_adastra # to launche the simulation&lt;br /&gt;
&lt;br /&gt;
    # WRF specific&lt;br /&gt;
    planet_constant&lt;br /&gt;
    input_sounding&lt;br /&gt;
    input_coord&lt;br /&gt;
    namelist.input&lt;br /&gt;
    # Generic PCM specific&lt;br /&gt;
    run.def&lt;br /&gt;
    callphys.def&lt;br /&gt;
    gases.def&lt;br /&gt;
    traceur.def&lt;br /&gt;
    # Executables&lt;br /&gt;
    ideal.exe&lt;br /&gt;
    wrf.exe&lt;br /&gt;
    # Optional&lt;br /&gt;
    my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
=== WRF Settings: 'namelist.input' file ===&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2868</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2868"/>
				<updated>2025-09-17T13:35:22Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' file ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
gravity&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature&lt;br /&gt;
bottom pressure&lt;br /&gt;
radius&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&lt;br /&gt;
==== 'input_coord' file ====&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
batch_adastra # to launche the simulation&lt;br /&gt;
&lt;br /&gt;
* WRF specific&lt;br /&gt;
&lt;br /&gt;
planet_constant&lt;br /&gt;
&lt;br /&gt;
input_sounding&lt;br /&gt;
&lt;br /&gt;
input_coord&lt;br /&gt;
&lt;br /&gt;
namelist.input&lt;br /&gt;
&lt;br /&gt;
* Generic PCM specific&lt;br /&gt;
&lt;br /&gt;
run.def&lt;br /&gt;
&lt;br /&gt;
callphys.def&lt;br /&gt;
&lt;br /&gt;
gases.def&lt;br /&gt;
&lt;br /&gt;
traceur.def&lt;br /&gt;
&lt;br /&gt;
* Executables&lt;br /&gt;
&lt;br /&gt;
ideal.exe&lt;br /&gt;
&lt;br /&gt;
wrf.exe&lt;br /&gt;
&lt;br /&gt;
* Optional&lt;br /&gt;
&lt;br /&gt;
my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
=== WRF Settings: 'namelist.input' file ===&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2867</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2867"/>
				<updated>2025-09-17T13:30:52Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
==== 'input_sounding' ====&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains: the bottom pressure (in mbar), the bottom temperature (K), and &amp;quot;0.0&amp;quot;&lt;br /&gt;
For example, for Neptune:  10000.0  166.6004857302868    0.0&lt;br /&gt;
&lt;br /&gt;
5 columns are profiles for: equivalent altitude, potential temperature, vapor, ice, and X (?)&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
==== 'planet_constant' file ====&lt;br /&gt;
gravity&lt;br /&gt;
heat capacity (J/kg/K)&lt;br /&gt;
molar mass (g/mol)&lt;br /&gt;
reference temperature&lt;br /&gt;
bottom pressure&lt;br /&gt;
radius&lt;br /&gt;
&lt;br /&gt;
For example, for Neptune:&lt;br /&gt;
11.15&lt;br /&gt;
10200.&lt;br /&gt;
2.3&lt;br /&gt;
175.&lt;br /&gt;
10.e5&lt;br /&gt;
24622.0e3&lt;br /&gt;
&lt;br /&gt;
==== Files in the folder ====&lt;br /&gt;
&lt;br /&gt;
batch_adastra&lt;br /&gt;
# WRF specific&lt;br /&gt;
planet_constant&lt;br /&gt;
input_sounding&lt;br /&gt;
input_coord&lt;br /&gt;
namelist.input&lt;br /&gt;
# Generic PCM specific&lt;br /&gt;
run.def&lt;br /&gt;
callphys.def&lt;br /&gt;
gases.def&lt;br /&gt;
traceur.def&lt;br /&gt;
# Executables&lt;br /&gt;
ideal.exe&lt;br /&gt;
wrf.exe&lt;br /&gt;
&lt;br /&gt;
# Optional:&lt;br /&gt;
my_iofields_list.txt # for additional outputs&lt;br /&gt;
&lt;br /&gt;
The run.def file is required even if unused (no need to change it).&lt;br /&gt;
&lt;br /&gt;
=== WRF Settings ===&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2866</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2866"/>
				<updated>2025-09-17T13:10:20Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
Building the 'input_sounding' file.&lt;br /&gt;
This file has a header with 3 parameters, followed by 5 columns&lt;br /&gt;
&lt;br /&gt;
The header contains &lt;br /&gt;
&lt;br /&gt;
[https://perso.astrophy.u-bordeaux.fr/~jleconte/exo_k-doc/index.html exo_k] will help you!&lt;br /&gt;
&lt;br /&gt;
You need to run a 1D simulation and use the diagfi.nc file to initialize fields for the input_sounding&lt;br /&gt;
&lt;br /&gt;
=== Settings ===&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2865</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2865"/>
				<updated>2025-09-17T13:06:04Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Running a simulation ==&lt;br /&gt;
&lt;br /&gt;
=== Initializing a simulation ===&lt;br /&gt;
&lt;br /&gt;
Building the 'input_sounding' file.&lt;br /&gt;
&lt;br /&gt;
exo_k can help you!&lt;br /&gt;
&lt;br /&gt;
=== Settings ===&lt;br /&gt;
&lt;br /&gt;
'namelist.input' file&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2864</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2864"/>
				<updated>2025-09-17T13:01:58Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (which will be named 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2863</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2863"/>
				<updated>2025-09-17T10:54:34Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
In 'LES_planet_workflow', modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2862</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2862"/>
				<updated>2025-09-17T10:52:05Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put this repo on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one above by inserting it in the LES_planet_workflow, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh file to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2861</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2861"/>
				<updated>2025-09-17T10:49:56Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one below by inserting it in the LES_planet_workflow, for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks if it does not work ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2860</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2860"/>
				<updated>2025-09-17T10:48:20Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing &amp;amp; Compiling the Generic PCM + WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one below by inserting it in the LES_planet_workflow, for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2859</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2859"/>
				<updated>2025-09-17T10:47:34Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one below by inserting it in the LES_planet_workflow, for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
=== Download repositories ===&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
=== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ===&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
=== Put the 3 repositories on the right branch/commit ===&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
=== Execute installing and compiling files ===&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2858</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2858"/>
				<updated>2025-09-17T10:45:26Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one below by inserting it in the LES_planet_workflow, for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
==== Terrestrial WRF ====&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model. (!!! For developers, this has to be corrected and put in the master branch !!!)&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2857</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2857"/>
				<updated>2025-09-17T10:42:47Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one below by inserting it in the LES_planet_workflow, for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
==== Terrestrial WRF ====&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the 0_defining.sh file at lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the numbers/options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2856</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2856"/>
				<updated>2025-09-17T10:40:35Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
If you work on Adastra, you can directly use the one below by inserting it in the LES_planet_workflow, for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Terrestrial WRF ====&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source the &amp;quot;mesoscale.env&amp;quot; file:&lt;br /&gt;
&lt;br /&gt;
    source mesoscale.env&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2855</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2855"/>
				<updated>2025-09-17T10:35:19Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA, the following one works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Terrestrial WRF ====&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 (or in the LES_planet_workflow), for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2854</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2854"/>
				<updated>2025-09-17T10:32:15Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading (i.e. cloning) the parent repository 'LES_planet_workflow' from Aymeric Spiga's git (you will download the other two later).&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 (or in the LES_planet_workflow), for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2853</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2853"/>
				<updated>2025-09-17T10:30:33Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
==== Review of the repositories ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics)&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
==== Downloading/Cloning the parent repository ====&lt;br /&gt;
&lt;br /&gt;
The first step is downloading the parent repository 'LES_planet_workflow' (you will download the other two later).&lt;br /&gt;
Put it on the branch &amp;quot;wrfv4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 (or in the LES_planet_workflow), for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download (i.e. clone) the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download (i.e. clone) the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory (keep the name &amp;quot;WRFV4&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo (already done normally)&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2852</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2852"/>
				<updated>2025-09-17T10:26:24Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ===&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
The 3 repositories are managed by git. You will need to do a little juggling between these repositories to be sure they are on the right branches for your project (see later).&lt;br /&gt;
&lt;br /&gt;
The first step is downloading the first repository (you will download the other two later).&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step to check if the environment is working.&lt;br /&gt;
&lt;br /&gt;
Somewhere else in your work directory, do:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 (or in the LES_planet_workflow), for example, and calling it &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Download repositories ====&lt;br /&gt;
&lt;br /&gt;
Execute the 1_downloading.sh to download the 'git-trunk' repository (it takes the name 'code').&lt;br /&gt;
&lt;br /&gt;
Download the WRFV4 repository in the 'LES_planet_workflow/code/WRF.COMMON' directory&lt;br /&gt;
&lt;br /&gt;
Now you have the 3 repositories!&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2851</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2851"/>
				<updated>2025-09-17T10:12:52Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files and properly restart the compilation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2850</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2850"/>
				<updated>2025-09-17T10:11:52Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories on the right branch/commit ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2849</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2849"/>
				<updated>2025-09-17T10:11:02Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories are on the right commit/branch ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to have the right physics compiling options, for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2848</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2848"/>
				<updated>2025-09-17T10:10:00Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
=== 3 git repositories to handle ====&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories are on the right commit/branch ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your compiling environment &amp;amp; your modelled planetary atmosphere ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your Intel environment&lt;br /&gt;
&lt;br /&gt;
    archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
Modifications should be made for the physics compiling options for example:&lt;br /&gt;
&lt;br /&gt;
    add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2847</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2847"/>
				<updated>2025-09-17T10:06:52Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing the Generic PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
3 git repositories to handle:&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In the first repository, you have to modify the defining file and set:&lt;br /&gt;
&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== Put the 3 repositories are on the right commit/branch ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== Modify options to fit your modelled planetary atmosphere &amp;amp; your compiling environment ====&lt;br /&gt;
&lt;br /&gt;
Modify the 0_defining.sh file to fit your modelled planetary atmosphere &amp;amp; your Intel environment&lt;br /&gt;
&lt;br /&gt;
Modifications should be made for the physics compiling options.&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== Execute installing and compiling files ====&lt;br /&gt;
&lt;br /&gt;
One by one:&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2846</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2846"/>
				<updated>2025-09-17T10:00:03Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
3 git repositories to handle:&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In the first repository, you have to modify the defining file and set:&lt;br /&gt;
&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== I) Be sure the 3 repositories are on the right commit/branch ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== II) Modify the 0_defining.sh file to fit your modelled planetary atmosphere &amp;amp; your intel environment ====&lt;br /&gt;
&lt;br /&gt;
Modifications should be made for the physics compiling options.&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== III) Execute one by one the: ====&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2845</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2845"/>
				<updated>2025-09-17T09:59:16Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
3 git repositories to handle:&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In the first repository, you have to modify the defining file and set:&lt;br /&gt;
&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== I) Be sure the 3 repositories are on the right commit/branch ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== II) Modify the file 0_defining.sh to fit your modelled planetary atmosphere &amp;amp; your intel environment ====&lt;br /&gt;
&lt;br /&gt;
Modifications should be made for the physics compiling options.&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== III) Execute one by one the: ====&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2844</id>
		<title>WRF dynamical core for LES/mesoscale simulations</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=WRF_dynamical_core_for_LES/mesoscale_simulations&amp;diff=2844"/>
				<updated>2025-09-17T09:57:40Z</updated>
		
		<summary type="html">&lt;p&gt;Noe clement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
WRF is a mesoscale numerical weather prediction system designed for both atmospheric research and operational forecasting applications over the Earth's atmosphere: see [https://www.mmm.ucar.edu/models/wrf WRF presentation].&lt;br /&gt;
&lt;br /&gt;
In the PCM, we take advantage of the dynamical core of the WRF model to run LES (large-eddy simulations) or mesoscale simulations.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
A description of the various equations solved by WRF can be found here: [https://opensky.ucar.edu/islandora/object/technotes%3A588 Skamarock et al. (2019, 2021)].&lt;br /&gt;
&lt;br /&gt;
== Studies with PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
Descriptions of the application of WRF dynamical core with the PCM can be found in:&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-04861192 Noé CLEMENT's PhD thesis] (chapter 3) for the Generic PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-02924996 Maxence Lefevre's PhD thesis] for the Venus PCM.&lt;br /&gt;
&lt;br /&gt;
- [https://theses.hal.science/tel-00347021 Aymeric Spiga's PhD thesis] for the Mars PCM&lt;br /&gt;
&lt;br /&gt;
Studies with the PCM coupled to the WRF dynamical core have been done using WRF V2, WRF V3, WRF V4.&lt;br /&gt;
&lt;br /&gt;
Our aim is now to use WRF V4 as much as possible, which offers significant improvements in terms of numerical schemes in particular.&lt;br /&gt;
&lt;br /&gt;
Here is a list of studies using the PCM coupled to the WRF dynamical core:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Planet&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Reference&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Physical package&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Dynamical core&amp;lt;/th&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1029/2008JE003242 Spiga and Forget (2009)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://rmets.onlinelibrary.wiley.com/doi/10.1002/qj.563 Spiga et al. (2010)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Mars PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2018JE005679 Lefèvre et al. (2018)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://www.sciencedirect.com/science/article/pii/S0019103519301216?via%3Dihub Lefèvre et al. (2020)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Venus PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V2&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://iopscience.iop.org/article/10.3847/1538-4357/abf2c1 Lefèvre et al. (2021)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V3&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Exoplanets&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348928 Leconte et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Uranus, Neptune&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;[https://doi.org/10.1051/0004-6361/202348936 Clément et al. (2024)]&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;Generic PCM&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;WRF V4&amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
For advanced users:&lt;br /&gt;
&lt;br /&gt;
When compiling the model, the flags:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef MESOSCALE&lt;br /&gt;
      use ...&lt;br /&gt;
#else&lt;br /&gt;
      use ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
select lines compiled depending on the configuration.&lt;br /&gt;
&lt;br /&gt;
== WRF equations ==&lt;br /&gt;
&lt;br /&gt;
Below is a synthesis of equations solved by WRF.&lt;br /&gt;
&lt;br /&gt;
[[File:WRF_dynamical_core.png]]&lt;br /&gt;
&lt;br /&gt;
== Installing PCM+WRF ==&lt;br /&gt;
&lt;br /&gt;
3 git repositories to handle:&lt;br /&gt;
&lt;br /&gt;
- LES_planet_workflow&lt;br /&gt;
&lt;br /&gt;
- git-trunk (physics &amp;amp; GCM dynamical core), which takes the name &amp;quot;code&amp;quot; when being cloned&lt;br /&gt;
&lt;br /&gt;
- WRFV4 (dynamics), for now to be manually installed by cloning it (keep the name &amp;quot;WRFV4) in the &amp;quot;code/WRF.COMMON&amp;quot; directory&lt;br /&gt;
&lt;br /&gt;
The first is hosted on [https://gitlab.in2p3.fr/aymeric.spiga/les_mars_project Aymeric Spiga's git], and will download (git clone) the two others, which are part of [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires La communauté des modèles atmosphériques planétaires] repositories.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In the first repository, you have to modify the defining file and set:&lt;br /&gt;
&lt;br /&gt;
archname=&amp;quot;ADASTRA-ifort&amp;quot;  # (or other cluster)&lt;br /&gt;
&lt;br /&gt;
add=&amp;quot;-t 1 -b 20x34 -d 25&amp;quot; # Uranus &amp;amp; Neptune with CH4 visible bands (compilation options are maybe depreciated)&lt;br /&gt;
&lt;br /&gt;
=== .env file ===&lt;br /&gt;
&lt;br /&gt;
!!! For now, only the Intel compiler has been tested and works. !!!&lt;br /&gt;
&lt;br /&gt;
On any cluster, one has to build a file &amp;quot;mesoscale.env&amp;quot; which should look more or less like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source YOUR_ifort_ENV&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO='code/LMDZ.COMMON/libo/YOUR_ARCH_NAME'&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On ADASTRA:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# mesoscale.env file&lt;br /&gt;
&lt;br /&gt;
source code/LMDZ.COMMON/arch/arch-ADASTRA-ifort.env&lt;br /&gt;
&lt;br /&gt;
# for WRFV4&lt;br /&gt;
declare -x WRFIO_NCD_LARGE_FILE_SUPPORT=1&lt;br /&gt;
&lt;br /&gt;
declare -x NETCDF=$NETCDF_DIR&lt;br /&gt;
# alternatively: declare -x NETCDF=`nf-config --prefix`&lt;br /&gt;
declare -x NCDFLIB=$NETCDF/lib&lt;br /&gt;
declare -x NCDFINC=$NETCDF/include&lt;br /&gt;
&lt;br /&gt;
# specific to ADASTRA&lt;br /&gt;
declare -x NETCDF_classic=1&lt;br /&gt;
&lt;br /&gt;
# fix for &amp;quot;undefined symbol: __libm_feature_flag&amp;quot; errors at runtime:&lt;br /&gt;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF_DIR/lib&lt;br /&gt;
&lt;br /&gt;
# PCM/WRFV4 interface&lt;br /&gt;
declare -x LMDZ_LIBO=code/LMDZ.COMMON/libo/ADASTRA-ifort&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file should be sourced before performing compilation steps. Ideally, it will be integrated automatically (no need to source manually).  &lt;br /&gt;
It should also be sourced before executing the compiled files to run simulations.&lt;br /&gt;
&lt;br /&gt;
=== Terrestrial WRF ===&lt;br /&gt;
&lt;br /&gt;
Compiling terrestrial [https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php WRF] is a good first step.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;git clone --recurse-submodules https://github.com/wrf-model/WRF&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before executing the following commands, you have to source a &amp;quot;.env&amp;quot; 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 &amp;quot;mesoscale.env&amp;quot;. It will work for both the WRF terrestrial and the Generic PCM+WRF&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./configure&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the configure step, you will be asked about the compiler, choose &amp;quot;INTEL (ifort/icc) dmpar&amp;quot; (probably number 15), and then about nesting, choose &amp;quot;basic&amp;quot; (=1).&lt;br /&gt;
&lt;br /&gt;
then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./compile em_les&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
WRF compilation can take some time. Consider doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
nohup ./compile em_les &amp;amp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Final built executables are: &amp;quot;ideal.exe&amp;quot; and &amp;quot;wrf.exe&amp;quot; (in the WRF/main directory).&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Generic PCM +WRF ===&lt;br /&gt;
&lt;br /&gt;
==== I) Be sure the 3 repositories are on the right commit/branch ====&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;wrfv4&amp;quot; for LES_planet_workflow repo&lt;br /&gt;
&lt;br /&gt;
- On a branch that matches your physics developments on the git-trunk (=code) repo.&lt;br /&gt;
&lt;br /&gt;
The branch &amp;quot;hackathon_wrfv4&amp;quot; works for Uranus/Neptune test cases.&lt;br /&gt;
&lt;br /&gt;
This [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/0c1280715875b36669271e59655ab4d306296217 commit] shows you what to modify if you want to work with another tracer than water (e.g., CH4).&lt;br /&gt;
&lt;br /&gt;
!!! This has to be corrected !!!&lt;br /&gt;
See this [https://gitlab.in2p3.fr/la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk/-/commit/78c8eedabbad4db120ef6fda3bd912687d412ec0 commit] to fix a little bug with the slab ocean model&lt;br /&gt;
&lt;br /&gt;
- On branch &amp;quot;generic&amp;quot; for WRFV4 workflow&lt;br /&gt;
&lt;br /&gt;
==== II) Modify the 0_defining.sh to fit your modelled planetary atmosphere &amp;amp; your intel environment ====&lt;br /&gt;
&lt;br /&gt;
Modifications should be made for the physics compiling options.&lt;br /&gt;
&lt;br /&gt;
When compiling terrestrial WRF, if you indeed selected 15 and 1, you do not have to modify the following. Otherwise, in the lines:&lt;br /&gt;
&lt;br /&gt;
    echo 15 &amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
    echo 1 &amp;gt;&amp;gt; configure_inputs&lt;br /&gt;
&lt;br /&gt;
Replace 15 &amp;amp; 1 with the options you selected.&lt;br /&gt;
&lt;br /&gt;
==== III) Execute one by one the: ====&lt;br /&gt;
&lt;br /&gt;
- 1_downloading.sh&lt;br /&gt;
&lt;br /&gt;
- 2_preparing.sh&lt;br /&gt;
&lt;br /&gt;
- 3_compiling_physics.sh&lt;br /&gt;
&lt;br /&gt;
- 4_compiling_dynamics.sh&lt;br /&gt;
&lt;br /&gt;
Good luck!&lt;br /&gt;
&lt;br /&gt;
=== Executables ===&lt;br /&gt;
&lt;br /&gt;
If you succeed in compiling the model, executables should be in the 'LES_planet_workflow/code/WRF.COMMON/WRFV4/main' directory.&lt;br /&gt;
Executables of the Generic PCM+WRF have the same name as terrestrial WRF.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ideal.exe&amp;quot; prepares the domain. &amp;quot;wrf.exe&amp;quot; runs the simulation.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Some tricks ===&lt;br /&gt;
&lt;br /&gt;
In case of a failed compilation, the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
./clean -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in the WRFV4 directory allows you to remove intermediate compiled files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Noe clement</name></author>	</entry>

	</feed>