<?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=Jbclement</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=Jbclement"/>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Special:Contributions/Jbclement"/>
		<updated>2026-06-11T04:04:37Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.7</generator>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3240</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3240"/>
				<updated>2026-03-30T09:00:40Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the PEM dedicated to the Mars planet; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./pem_workflow.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to resume a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''pem_workflow.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_pcm.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'' and ''start.nc''/''start1D.txt'';&lt;br /&gt;
* the necessary PEM files: ''pem_workflow.sh'', ''pem_workflow_lib.sh'', ''pcm_run.job'', ''pem_run.job'', ''run_pem.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagevo.def'' to define the PEM variables to be ouputted and ''startevo.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''pem_workflow.sh'', the user has to specify:&lt;br /&gt;
#* '''n_planetary_years''' or '''n_earth_years''': the number of planetary/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''n_pcm_runs_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''n_pcm_runs''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''exec_mode''': the execution mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''pcm_run.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pcm_exe''', the name of the PCM executable file should be adapted.&lt;br /&gt;
#* '''exec_cmd''', the execution command should also be adapted according to the set-up.&lt;br /&gt;
# In ''pem_run.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pem_exe''', the name of the PEM executable file should be adapted.&lt;br /&gt;
#* '''pem_arg''' which is an optional argument for the PEM executable. It should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_pem.def'', ''run_pcm.def'' and ''callphys.def'' which must be consistent. In particular, ''run_pem.def'' needs to include some definitions in file ''run_pcm.def'' and ''callphys.def'' with &amp;lt;code&amp;gt;INCLUDEDEF=run_pcm.def&amp;lt;/code&amp;gt;.&lt;br /&gt;
The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''ini_pem_orbit.sh''' can do it automatically reading ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc''/''restart1D.txt'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''xoutdaily4pem*.nc''/''xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''pem_workflow.log'', ''pem_workflow.sts'' and possibly ''kill_pem_workflow.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''restartevo.nc'', ''restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagevo.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_pem_workflow.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3234</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3234"/>
				<updated>2026-03-05T09:19:21Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the PEM dedicated to the Mars planet; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./pem_workflow.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to resume a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''pem_workflow.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_pcm.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'' and ''start.nc''/''start1D.txt'';&lt;br /&gt;
* the necessary PEM files: ''pem_workflow.sh'', ''pem_workflow_lib.sh'', ''pcm_run.job'', ''pem_run.job'', ''run_pem.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagevo.def'' to define the PEM variables to be ouputted and ''startevo.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''pem_workflow.sh'', the user has to specify:&lt;br /&gt;
#* '''n_planetary_years''' or '''n_earth_years''': the number of planetary/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''n_pcm_runs_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''n_pcm_runs''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''exec_mode''': the execution mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''pcm_run.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pcm_exe''', the name of the PCM executable file should be adapted.&lt;br /&gt;
#* '''exec_cmd''', the execution command should also be adapted according to the set-up.&lt;br /&gt;
# In ''pem_run.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pem_exe''', the name of the PEM executable file should be adapted.&lt;br /&gt;
#* '''pem_arg''' which is an optional argument for the PEM executable. It should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_pem.def'', ''run_pcm.def'' and ''callphys.def'' which must be consistent. In particular, ''run_pem.def'' needs to include some definitions in file ''run_pcm.def'' and ''callphys.def'' with &amp;lt;code&amp;gt;INCLUDEDEF=run_pcm.def&amp;lt;/code&amp;gt;.&lt;br /&gt;
The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''ini_pem_orbit.sh''' can do it automatically reading ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc''/''restart1D.txt'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''pem_workflow.log'', ''pem_workflow.sts'' and possibly ''kill_pem_workflow.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''restartevo.nc'', ''restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagevo.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_pem_workflow.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3233</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3233"/>
				<updated>2026-03-05T09:18:21Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the PEM dedicated to the Mars planet; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./pem_workflow.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to resume a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''pem_workflow.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_pcm.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'' and ''start.nc''/''start1D.txt'';&lt;br /&gt;
* the necessary PEM files: ''pem_workflow.sh'', ''pem_workflow_lib.sh'', ''pcm_run.job'', ''pem_run.job'', ''run_pem.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagevo.def'' to define the PEM variables to be ouputted and ''startevo.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''pem_workflow.sh'', the user has to specify:&lt;br /&gt;
#* '''n_planetary_years''' or '''n_earth_years''': the number of planetary/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''n_pcm_runs_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''n_pcm_runs''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''exec_mode''': the execution mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''pcm_run.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pcm_exe''', the name of the PCM executable file should be adapted.&lt;br /&gt;
#* '''exec_cmd''', the execution command should also be adapted according to the set-up.&lt;br /&gt;
# In ''pem_run.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pem_exe''', the name of the PEM executable file should be adapted.&lt;br /&gt;
#* '''pem_arg''' which is an optional argument for the PEM executable. It should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_pem.def'', ''run_pcm.def'' and ''callphys.def'' which must be consistent. In particular, ''run_pem.def'' needs to include some definitions in file ''run_pcm.def'' and &amp;quot;callphys.def&amp;quot; with &amp;lt;code&amp;gt;INCLUDEDEF=run_pcm.def&amp;lt;/code&amp;gt;.&lt;br /&gt;
The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''ini_pem_orbit.sh''' can do it automatically reading ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc''/''restart1D.txt'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''pem_workflow.log'', ''pem_workflow.sts'' and possibly ''kill_pem_workflow.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''restartevo.nc'', ''restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagevo.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_pem_workflow.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=3232</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=3232"/>
				<updated>2026-03-04T09:23:36Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;ini_pem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering_evo.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Pre-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Cleaning of files ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
=== Initialization of orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;ini_pem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file ''startfi.nc'' from Laskar's data contained in ''obl_ecc_lsp.asc'' according to the initial date 'year_earth_bp_ini' defined in ''run_PEM.def''. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting the orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file ''startfi.nc''. They should be consistent with Laskar's data in ''obl_ecc_lsp.asc'' at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;ini_pem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting a variable in a NetCDF file ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file ''startfi.nc''.&lt;br /&gt;
&lt;br /&gt;
=== Lauching multiple simulations ===&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Post-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Merging the PEM outputs ===&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.py&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the ''diagevo'' files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the ''startevo.nc'' files.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization over time ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering_evo.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the ''startevo.nc'' files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3231</id>
		<title>Mars 1D testphys1d program</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3231"/>
				<updated>2026-03-03T10:55:32Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to run the Mars PCM in a &amp;quot;single-column&amp;quot; configuration: this is the so-called 1D Mars PCM whose program is '''testphys1d'''. It is quite useful for some studies and or when developing and testing parametrizations.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
The main program '''testphys1d''' is compiled using the same compilation script, [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]], as for the 3D Mars PCM. Nevertheless, there are few modifications:&lt;br /&gt;
* the ''-d'' option requires only one argument, the number of vertical levels;&lt;br /&gt;
* the main program to compile is ''testphys1d'' rather than ''gcm''.&lt;br /&gt;
So for instance to compile a case for 54 vertical levels one would run something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
makelmdz_fcm -arch somearch -d 54 -p mars testphys1d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
Like the ''gcm'' program, the ''testphys1d'' program needs some inputs to be able to run. The needed files are:&lt;br /&gt;
* &amp;lt;code&amp;gt;z2sig.def&amp;lt;/code&amp;gt; for the definition of vertical levels;&lt;br /&gt;
* &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt; for the definition of tracers that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;callphys.def&amp;lt;/code&amp;gt; for the definition of parametrizations that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt; for the run configuration, which is similar to the one for the 3D PCM described here [[The run.def Input File]]. It has to be be adapted to the 1D case. An example file, called &amp;lt;code&amp;gt;run.def.1d&amp;lt;/code&amp;gt;, is available in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Unlike the ''gcm'' program, the ''testphys1d'' program can run without start files, that is without &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is the case by default (&amp;lt;code&amp;gt;startfiles_1D=.false.&amp;lt;/code&amp;gt;). In this setup, one can (and often needs) needs to provide initial profiles of each tracer. These consist in files called ''profile_sometracername'' containing column-wise the initial values of the considered tracer. Then, the first line corresponds to the surface tracer and the following lines correspond to the layers. In addition one can also provide a similar ''profile_temp'' file containing an initial temperature profile (first line should then contain the surface temperature value).&lt;br /&gt;
When the program ends, it will produce by its own a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file initialized with the default settings.&lt;br /&gt;
&lt;br /&gt;
In the case of &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; set in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, the program will look for starting files, that is a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; file. If the starting files are present, it will read them to initialize the run accordingly. Otherwise, it will start as in the previous (default) case. In any cases, the program will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run.&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; is specific to the 1D model. An example can be found in &amp;lt;code&amp;gt;LMDZ.MARS/startfiles&amp;lt;/code&amp;gt;. The content is organized such that each line holds a header, to make the file human readable, and then values.&lt;br /&gt;
* First line is for pressure variables with header '''ps''' and the values are ''ps'', ''pa'' and ''preff''.&lt;br /&gt;
* The following lines define each tracer, in the same apparition order used in &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt;. The header is the '''tracer name''' and the values are the ones for each atmospheric layer.&lt;br /&gt;
* Next two lines are for winds. The headers are '''u''' and '''v''' for zonal and meridional wind respectively, and the values are the ones for each atmospheric layer.&lt;br /&gt;
* Last line is for potential temperature with header '''teta''' and values are the ones for each atmospheric layer.&lt;br /&gt;
When the values describe the atmospheric profile, then there must be as many as atmospheric layers defined by the user (vertical resolution).&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
The program ''testphys1d'' can output &amp;lt;code&amp;gt;diagfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.nc&amp;lt;/code&amp;gt; files. Just like for the 3D PCM model, the optional &amp;lt;code&amp;gt;diagfi.def&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.def&amp;lt;/code&amp;gt; files can be respectively added to specify which variables need be outputted.&lt;br /&gt;
&lt;br /&gt;
As described in the previous section, if &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, then ''testphys1d'' will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run. &lt;br /&gt;
This option is particularly useful when one wants to make chained simulations with the 1D model.&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Mars-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3230</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3230"/>
				<updated>2026-03-03T09:48:54Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the PEM dedicated to the Mars planet; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./pem_workflow.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to resume a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''pem_workflow.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_pcm.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'' and ''start.nc''/''start1D.txt'';&lt;br /&gt;
* the necessary PEM files: ''pem_workflow.sh'', ''pem_workflow_lib.sh'', ''pcm_run.job'', ''pem_run.job'', ''run_pem.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagevo.def'' to define the PEM variables to be ouputted and ''startevo.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''pem_workflow.sh'', the user has to specify:&lt;br /&gt;
#* '''n_planetary_years''' or '''n_earth_years''': the number of planetary/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''n_pcm_runs_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''n_pcm_runs''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''exec_mode''': the execution mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''pcm_run.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pcm_exe''', the name of the PCM executable file should be adapted.&lt;br /&gt;
#* '''exec_cmd''', the execution command should also be adapted according to the set-up.&lt;br /&gt;
# In ''pem_run.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pem_exe''', the name of the PEM executable file should be adapted.&lt;br /&gt;
#* '''pem_arg''' which is an optional argument for the PEM executable. It should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_pem.def'', ''run_pcm.def'' and ''callphys.def'' which must be consistent. In particular, ''run_pem.def'' needs to include some definitions for the physics in file ''run_pcm.def'' with &amp;lt;code&amp;gt;INCLUDEDEF=run_pcm.def&amp;lt;/code&amp;gt;.&lt;br /&gt;
The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''ini_pem_orbit.sh''' can do it automatically reading ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc''/''restart1D.txt'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''pem_workflow.log'', ''pem_workflow.sts'' and possibly ''kill_pem_workflow.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''restartevo.nc'', ''restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagevo.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_pem_workflow.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=3229</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=3229"/>
				<updated>2026-03-03T09:48:11Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;ini_pem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Pre-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Cleaning of files ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
=== Initialization of orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;ini_pem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file ''startfi.nc'' from Laskar's data contained in ''obl_ecc_lsp.asc'' according to the initial date 'year_earth_bp_ini' defined in ''run_PEM.def''. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting the orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file ''startfi.nc''. They should be consistent with Laskar's data in ''obl_ecc_lsp.asc'' at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;ini_pem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting a variable in a NetCDF file ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file ''startfi.nc''.&lt;br /&gt;
&lt;br /&gt;
=== Lauching multiple simulations ===&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Post-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Merging the PEM outputs ===&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.py&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the ''diagevo'' files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization over time ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the ''startevo.nc'' files.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the ''startevo.nc'' files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3228</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3228"/>
				<updated>2026-02-27T09:08:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the PEM dedicated to the Mars planet; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./pem_workflow.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to resume a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''pem_workflow.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_pcm.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'' and ''start.nc''/''start1D.txt'';&lt;br /&gt;
* the necessary PEM files: ''pem_workflow.sh'', ''pem_workflow_lib.sh'', ''pcm_run.job'', ''pem_run.job'', ''run_pem.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagevol.def'' to define the PEM variables to be ouputted and ''startevol.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''pem_workflow.sh'', the user has to specify:&lt;br /&gt;
#* '''n_planetary_years''' or '''n_earth_years''': the number of planetary/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''n_pcm_runs_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''n_pcm_runs''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''exec_mode''': the execution mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''pcm_run.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pcm_exe''', the name of the PCM executable file should be adapted.&lt;br /&gt;
#* '''exec_cmd''', the execution command should also be adapted according to the set-up.&lt;br /&gt;
# In ''pem_run.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source the arch file''' should be adapted to the machine.&lt;br /&gt;
#* '''pem_exe''', the name of the PEM executable file should be adapted.&lt;br /&gt;
#* '''pem_arg''' which is an optional argument for the PEM executable. It should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_pem.def'', ''run_pcm.def'' and ''callphys.def'' which must be consistent. In particular, ''run_pem.def'' needs to include some definitions for the physics in file ''run_pcm.def'' with &amp;lt;code&amp;gt;INCLUDEDEF=run_pcm.def&amp;lt;/code&amp;gt;.&lt;br /&gt;
The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''ini_pem_orbit.sh''' can do it automatically reading ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc''/''restart1D.txt'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''pem_workflow.log'', ''pem_workflow.sts'' and possibly ''kill_pem_workflow.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''restartevol.nc'', ''restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagevol.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_pem_workflow.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=3227</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=3227"/>
				<updated>2026-02-26T17:15:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;ini_pem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Pre-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Cleaning of files ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
=== Initialization of orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;ini_pem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file ''startfi.nc'' from Laskar's data contained in ''obl_ecc_lsp.asc'' according to the initial date 'year_earth_bp_ini' defined in ''run_PEM.def''. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting the orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file ''startfi.nc''. They should be consistent with Laskar's data in ''obl_ecc_lsp.asc'' at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;ini_pem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting a variable in a NetCDF file ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file ''startfi.nc''.&lt;br /&gt;
&lt;br /&gt;
=== Lauching multiple simulations ===&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Post-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Merging the PEM outputs ===&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.py&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the ''diagpem'' files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization over time ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the ''startpem.nc'' files.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the ''startpem.nc'' files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PEM&amp;diff=3226</id>
		<title>Advanced Topics Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PEM&amp;diff=3226"/>
				<updated>2026-02-26T17:08:55Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: Replaced content with &amp;quot;  Category:Planetary-Evolution-Model&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3222</id>
		<title>Mars 1D testphys1d program</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3222"/>
				<updated>2026-02-26T09:48:07Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Inputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to run the Mars PCM in a &amp;quot;single-column&amp;quot; configuration: this is the so-called 1D Mars PCM whose program is '''testphys1d'''. It is quite useful for some studies and or when developing and testing parametrizations.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
The main program '''testphys1d''' is compiled using the same compilation script, [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]], as for the 3D Mars PCM. Nevertheless, there are few modifications:&lt;br /&gt;
* the ''-d'' option requires only one argument, the number of vertical levels;&lt;br /&gt;
* the main program to compile is ''testphys1d'' rather than ''gcm''.&lt;br /&gt;
So for instance to compile a case for 54 vertical levels one would run something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
makelmdz_fcm -arch somearch -d 54 -p mars testphys1d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
Like the ''gcm'' program, the ''testphys1d'' program needs some inputs to be able to run. The needed files are:&lt;br /&gt;
* &amp;lt;code&amp;gt;z2sig.def&amp;lt;/code&amp;gt; for the definition of vertical levels;&lt;br /&gt;
* &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt; for the definition of tracers that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;callphys.def&amp;lt;/code&amp;gt; for the definition of parametrizations that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt; for the run configuration, which is similar to the one for the 3D PCM described here [[The run.def Input File]]. It has to be be adapted to the 1D case. An example file, called &amp;lt;code&amp;gt;run.def.1d&amp;lt;/code&amp;gt;, is available in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Unlike the ''gcm'' program, the ''testphys1d'' program can run without start files, that is without &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is the case by default (&amp;lt;code&amp;gt;startfiles_1D=.false.&amp;lt;/code&amp;gt;). In this setup, one can (and often needs) needs to provide initial profiles of each tracer. These consist in files called ''profile_sometracername'' containing column-wise the initial values of the considered tracer. Then, the first line corresponds to the surface tracer and the following lines correspond to the layers. In addition one can also provide a similar ''profile_temp'' file containing an initial temperature profile (first line should then contain the surface temperature value).&lt;br /&gt;
When the program ends, it will produce by its own a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file initialized with the default settings.&lt;br /&gt;
&lt;br /&gt;
In the case of &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; set in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, the program will look for starting files, that is a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; file. If the starting files are present, it will read them to initialize the run accordingly. Otherwise, it will start as in the previous (default) case. In any cases, the program will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run.&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; is specific to the 1D model. An example can be found in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;. The content is organized such that each line holds a header, to make the file human readable, and then values.&lt;br /&gt;
* First line is for pressure variables with header '''ps''' and the values are ''ps'', ''pa'' and ''preff''.&lt;br /&gt;
* The following lines define each tracer, in the same apparition order used in &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt;. The header is the '''tracer name''' and the values are the ones for each atmospheric layer.&lt;br /&gt;
* Next two lines are for winds. The headers are '''u''' and '''v''' for zonal and meridional wind respectively, and the values are the ones for each atmospheric layer.&lt;br /&gt;
* Last line is for potential temperature with header '''teta''' and values are the ones for each atmospheric layer.&lt;br /&gt;
When the values describe the atmospheric profile, then there must be as many as atmospheric layers defined by the user (vertical resolution).&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
The program ''testphys1d'' can output &amp;lt;code&amp;gt;diagfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.nc&amp;lt;/code&amp;gt; files. Just like for the 3D PCM model, the optional &amp;lt;code&amp;gt;diagfi.def&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.def&amp;lt;/code&amp;gt; files can be respectively added to specify which variables need be outputted.&lt;br /&gt;
&lt;br /&gt;
As described in the previous section, if &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, then ''testphys1d'' will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run. &lt;br /&gt;
This option is particularly useful when one wants to make chained simulations with the 1D model.&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Mars-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3221</id>
		<title>Mars 1D testphys1d program</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3221"/>
				<updated>2026-02-26T09:34:15Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Inputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to run the Mars PCM in a &amp;quot;single-column&amp;quot; configuration: this is the so-called 1D Mars PCM whose program is '''testphys1d'''. It is quite useful for some studies and or when developing and testing parametrizations.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
The main program '''testphys1d''' is compiled using the same compilation script, [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]], as for the 3D Mars PCM. Nevertheless, there are few modifications:&lt;br /&gt;
* the ''-d'' option requires only one argument, the number of vertical levels;&lt;br /&gt;
* the main program to compile is ''testphys1d'' rather than ''gcm''.&lt;br /&gt;
So for instance to compile a case for 54 vertical levels one would run something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
makelmdz_fcm -arch somearch -d 54 -p mars testphys1d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
Like the ''gcm'' program, the ''testphys1d'' program needs some inputs to be able to run. The needed files are:&lt;br /&gt;
* &amp;lt;code&amp;gt;z2sig.def&amp;lt;/code&amp;gt; for the definition of vertical levels;&lt;br /&gt;
* &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt; for the definition of tracers that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;callphys.def&amp;lt;/code&amp;gt; for the definition of parametrizations that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt; for the run configuration, which is similar to the one for the 3D PCM described here [[The run.def Input File]]. It has to be be adapted to the 1D case. An example file, called &amp;lt;code&amp;gt;run.def.1d&amp;lt;/code&amp;gt;, is available in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Unlike the ''gcm'' program, the ''testphys1d'' program can run without start files, that is without &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is the case by default (&amp;lt;code&amp;gt;startfiles_1D=.false.&amp;lt;/code&amp;gt;). In this setup, one can (and often needs) needs to provide initial profiles of each tracer. These consist in files called ''profile_sometracername'' containing column-wise the initial values of the considered tracer. Then, the first line corresponds to the surface tracer and the following lines correspond to the layers. In addition one can also provide a similar ''profile_temp'' file containing an initial temperature profile (first line should then contain the surface temperature value).&lt;br /&gt;
When the program ends, it will produce by its own a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file initialized with the default settings.&lt;br /&gt;
&lt;br /&gt;
In the case of &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; set in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, the program will look for starting files, that is a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; file. If the starting files are present, it will read them to initialize the run accordingly. Otherwise, it will start as in the previous (default) case. In any cases, the program will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run.&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; is specific to the 1D model. An example can be found in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;. The content is organized such that each line holds a header, to make the file human readable, and then values. First line is for pressure variables with header '''ps''' and the values are ''ps'', ''pa'' and ''preff''. The following lines account for each tracer, in the same apparition order used in &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt;. The header is the '''tracer name''' and the values are the ones for each atmospheric layer. Next two lines are for winds. The headers are '''u''' and '''v''' for zonal and meridional wind respectively, and the values are the ones for each atmospheric layer. Last line is for potential temperature with header '''teta''' and values are the ones for each atmospheric layer.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
The program ''testphys1d'' can output &amp;lt;code&amp;gt;diagfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.nc&amp;lt;/code&amp;gt; files. Just like for the 3D PCM model, the optional &amp;lt;code&amp;gt;diagfi.def&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.def&amp;lt;/code&amp;gt; files can be respectively added to specify which variables need be outputted.&lt;br /&gt;
&lt;br /&gt;
As described in the previous section, if &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, then ''testphys1d'' will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run. &lt;br /&gt;
This option is particularly useful when one wants to make chained simulations with the 1D model.&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Mars-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3220</id>
		<title>Mars 1D testphys1d program</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Mars_1D_testphys1d_program&amp;diff=3220"/>
				<updated>2026-02-26T09:33:04Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Inputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It is possible to run the Mars PCM in a &amp;quot;single-column&amp;quot; configuration: this is the so-called 1D Mars PCM whose program is '''testphys1d'''. It is quite useful for some studies and or when developing and testing parametrizations.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
The main program '''testphys1d''' is compiled using the same compilation script, [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]], as for the 3D Mars PCM. Nevertheless, there are few modifications:&lt;br /&gt;
* the ''-d'' option requires only one argument, the number of vertical levels;&lt;br /&gt;
* the main program to compile is ''testphys1d'' rather than ''gcm''.&lt;br /&gt;
So for instance to compile a case for 54 vertical levels one would run something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
makelmdz_fcm -arch somearch -d 54 -p mars testphys1d&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Inputs ==&lt;br /&gt;
Like the ''gcm'' program, the ''testphys1d'' program needs some inputs to be able to run. The needed files are:&lt;br /&gt;
* &amp;lt;code&amp;gt;z2sig.def&amp;lt;/code&amp;gt; for the definition of vertical levels;&lt;br /&gt;
* &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt; for the definition of tracers that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;callphys.def&amp;lt;/code&amp;gt; for the definition of parametrizations that the user wants the model to run with;&lt;br /&gt;
* &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt; for the run configuration, which is similar to the one for the 3D PCM described here [[The run.def Input File]]. It has to be be adapted to the 1D case. An example file, called &amp;lt;code&amp;gt;run.def.1d&amp;lt;/code&amp;gt;, is available in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Unlike the ''gcm'' program, the ''testphys1d'' program can run without start files, that is without &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is the case by default (&amp;lt;code&amp;gt;startfiles_1D=.false.&amp;lt;/code&amp;gt;). In this setup, one can (and often needs) needs to provide initial profiles of each tracer. These consist in files called ''profile_sometracername'' containing column-wise the initial values of the considered tracer. Then, the first line corresponds to the surface tracer and the following lines correspond to the layers. In addition one can also provide a similar ''profile_temp'' file containing an initial temperature profile (first line should then contain the surface temperature value).&lt;br /&gt;
When the program ends, it will produce by its own a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file initialized with the default settings.&lt;br /&gt;
&lt;br /&gt;
In the case of &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; set in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, the program will look for starting files, that is a &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; file. If the starting files are present, it will read them to initialize the run accordingly. Otherwise, it will start as in the previous (default) case. In any cases, the program will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run.&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;code&amp;gt;start1D.txt&amp;lt;/code&amp;gt; is specific to the 1D model. An example can be found in &amp;lt;code&amp;gt;LMDZ.MARS/deftank&amp;lt;/code&amp;gt;. The content is organized such that each line holds a header, to make the file human readable, and then values. First line is for pressure variables with header '''ps''' and the values are ''ps'', ''pa'' and ''preff''. The following lines account for each tracer, in the same apparition order used in &amp;lt;code&amp;gt;traceur.def&amp;lt;/code&amp;gt;. The header is the '''tracer name''' and the values are the one for each atmospheric layer. Next two lines are for winds. The headers are '''u''' and '''v''' for zonal and meridional wind respectively, and the values are the one for each atmospheric layer. Last line is for potential temperature with header '''teta''' and values are the one for each atmospheric layer.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
The program ''testphys1d'' can output &amp;lt;code&amp;gt;diagfi.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.nc&amp;lt;/code&amp;gt; files. Just like for the 3D PCM model, the optional &amp;lt;code&amp;gt;diagfi.def&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stats.def&amp;lt;/code&amp;gt; files can be respectively added to specify which variables need be outputted.&lt;br /&gt;
&lt;br /&gt;
As described in the previous section, if &amp;lt;code&amp;gt;startfiles_1D=.true.&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;run.def&amp;lt;/code&amp;gt;, then ''testphys1d'' will create a &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; file and a &amp;lt;code&amp;gt;restart1D.txt&amp;lt;/code&amp;gt; file at the end of the run. &lt;br /&gt;
This option is particularly useful when one wants to make chained simulations with the 1D model.&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Mars-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3209</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3209"/>
				<updated>2026-02-12T11:22:03Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM executable''' file should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''launchPEM.info'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3208</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3208"/>
				<updated>2026-02-12T11:10:05Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''launchPEM_lib.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM executable''' file should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''launchPEM.info'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3005</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=3005"/>
				<updated>2025-11-28T16:58:27Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM executable''' file should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''launchPEM.info'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2974</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2974"/>
				<updated>2025-11-27T14:01:19Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Outputs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM years count&amp;quot;; any other values = &amp;quot;PCM years are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM executable''' file should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''launchPEM.info'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2973</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2973"/>
				<updated>2025-11-26T09:42:27Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM years count&amp;quot;; any other values = &amp;quot;PCM years are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM executable''' file should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2972</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2972"/>
				<updated>2025-11-26T09:41:45Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM years count&amp;quot;; any other values = &amp;quot;PCM years are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2971</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2971"/>
				<updated>2025-11-26T09:41:02Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM and the PEM with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM years count&amp;quot;; any other values = &amp;quot;PCM years are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2970</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2970"/>
				<updated>2025-11-26T09:39:35Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The PEM main program is '''pem.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM years count&amp;quot;; any other values = &amp;quot;PCM years are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM: ''Xoutdaily4pem*.nc''/''Xoutyearly4pem*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2934</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2934"/>
				<updated>2025-11-12T15:54:30Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The two PEM programs are '''pem.F90''' and '''reshape_XIOS_output.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a dedicated reshaping tool with consistent options. To compile it, in LMDZ_COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 reshape_XIOS_output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To run the PEM, you also need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io xios -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM years (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM years between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM years count&amp;quot;; any other values = &amp;quot;PCM years are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM, then reshaped: ''Xdiurnalave.nc''/''data2reshape*.nc''/''data_PCM_Y*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2917</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2917"/>
				<updated>2025-10-24T10:09:01Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: Undo revision 2916 by Jbclement (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The two PEM programs are '''pem.F90''' and '''reshape_XIOS_output.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a dedicated reshaping tool with consistent options. To compile it, in LMDZ_COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 reshape_XIOS_output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To run the PEM, you also need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io XIOS -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM runs (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM runs between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM runs count&amp;quot;; any other values = &amp;quot;PCM runs are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM, then reshaped: ''Xdiurnalave.nc''/''data2reshape*.nc''/''data_PCM_Y*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2916</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2916"/>
				<updated>2025-10-24T10:08:04Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The two PEM programs are '''pem.F90''' and '''reshape_XIOS_output.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a dedicated reshaping tool with consistent options. To compile it, in LMDZ_COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 reshape_XIOS_output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To run the PEM, you also need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io XIOS -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM runs (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM runs between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM runs count&amp;quot;; any other values = &amp;quot;PCM runs are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# In addition, the user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM, then reshaped: ''Xdiurnalave.nc''/''data2reshape*.nc''/''data_PCM_Y*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2915</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2915"/>
				<updated>2025-10-24T10:05:12Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The two PEM programs are '''pem.F90''' and '''reshape_XIOS_output.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a dedicated reshaping tool with consistent options. To compile it, in LMDZ_COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 reshape_XIOS_output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To run the PEM, you also need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io XIOS -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters/options:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM runs (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM runs between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM runs count&amp;quot;; any other values = &amp;quot;PCM runs are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# The user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can do it automatically with ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM, then reshaped: ''Xdiurnalave.nc''/''data2reshape*.nc''/''data_PCM_Y*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2914</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2914"/>
				<updated>2025-10-24T09:57:15Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The two PEM programs are '''pem.F90''' and '''reshape_XIOS_output.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a dedicated reshaping tool with consistent options. To compile it, in LMDZ_COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 reshape_XIOS_output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To run the PEM, you also need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io XIOS -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder, where a ''README'' file recaps everything.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM runs (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM runs between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM runs count&amp;quot;; any other values = &amp;quot;PCM runs are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# In addition, the user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can set them automatically according to ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM, then reshaped: ''Xdiurnalave.nc''/''data2reshape*.nc''/''data_PCM_Y*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2913</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2913"/>
				<updated>2025-10-24T09:53:12Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Pre-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Cleaning of files ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
=== Initialization of orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file ''startfi.nc'' from Laskar's data contained in ''obl_ecc_lsp.asc'' according to the initial date 'year_earth_bp_ini' defined in ''run_PEM.def''. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting the orbital parameters ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file ''startfi.nc''. They should be consistent with Laskar's data in ''obl_ecc_lsp.asc'' at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Setting a variable in a NetCDF file ===&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file ''startfi.nc''.&lt;br /&gt;
&lt;br /&gt;
=== Lauching multiple simulations ===&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Post-processing ==&lt;br /&gt;
&lt;br /&gt;
=== Merging the PEM outputs ===&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.py&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the ''diagpem'' files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization over time ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the ''startpem.nc'' files.&lt;br /&gt;
&lt;br /&gt;
=== Layering visualization ===&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the ''startpem.nc'' files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2912</id>
		<title>Quick Install and Run Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Quick_Install_and_Run_Mars_PEM&amp;diff=2912"/>
				<updated>2025-10-24T09:45:00Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page, we give a hopefully exhaustive enough overview of the necessary prerequisites and steps to download, compile and run a simple simulation with the PEM, set up on a Linux computer. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
The PEM is downloaded alongside the '''LMDZ.COMMON''' repository of your trunk, following the same step described in the related section of [[Quick Install and Run Mars PCM]]. The Fortran code is in the following directory: &amp;lt;code&amp;gt;trunk/LMDZ.COMMON/libf/evolution/&amp;lt;/code&amp;gt;. The two PEM programs are '''pem.F90''' and '''reshape_XIOS_output.F90'''.&lt;br /&gt;
&lt;br /&gt;
== Compilation  ==&lt;br /&gt;
&lt;br /&gt;
To compile the PEM, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 pem&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options with example:&lt;br /&gt;
# [local]: ''root name of arch files'', assuming that they have been set up for your configuration;&lt;br /&gt;
# [planet]: ''mars'' to use the Mars planet physics package; &lt;br /&gt;
# [dimensions]: ''64x48x54'' to define the grid you want to use (longitude x latitude x atmospheric layers).&lt;br /&gt;
To run the PEM, you need a dedicated reshaping tool with consistent options. To compile it, in LMDZ_COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -d [dimensions] -j 8 reshape_XIOS_output&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To run the PEM, you also need a PCM working with XIOS and consistent options. To compile it, in LMDZ.COMMON, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch [local] -p [planet] -parallel mpi_omp -io XIOS -d [dimensions] -j 8 gcm&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After compilation, the executable file can be found in the &amp;quot;bin&amp;quot; sub-directory.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To run a PEM simulation, do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./launchPEM.sh [options]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Options:&lt;br /&gt;
# None: to start a simulation from scratch;&lt;br /&gt;
# 're': to relaunch a simulation from a starting point (interactive prompt).&lt;br /&gt;
&lt;br /&gt;
The Bash file ''launchPEM.sh'' is the master script to launch the PEM chained simulation. It checks if necessary files and required options for your simulation are ok.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
To run the PEM, you can create a folder in which you need the following files:&lt;br /&gt;
* your executable files for the PCM, the PEM and the reshaping tool with consistent options;&lt;br /&gt;
* the xml files for XIOS which can be found in the PCM deftank folder: ''iodef.xml'', ''context_lmdz_physics.xml'', ''file_def_physics_mars.xml'' and ''field_def_physics_mars.xml'';&lt;br /&gt;
* the def files you want to run the PCM: ''run.def'', ''callphys.def'', ''traceur.def'', etc. '''Be careful, do not forget to rename the PCM ''run.def'' into ''run_PCM.def''''';&lt;br /&gt;
* the starting files you want to run the PCM: ''startfi.nc'', ''start.nc''/''start1D.txt''/profiles;&lt;br /&gt;
* the necessary PEM files: ''launchPEM.sh'', ''lib_launchPEM.sh'', ''PCMrun.job'', ''PEMrun.job'', ''run_PEM.def'' and ''obl_ecc_lsp.asc'';&lt;br /&gt;
* the optional PEM files ''diagpem.def'' to define the PEM variables to be ouputted and ''startpem.nc'' to set the initial state of the PEM.&lt;br /&gt;
&lt;br /&gt;
The PEM files can be found in the deftank folder.&lt;br /&gt;
&lt;br /&gt;
Before a simulation, you have to set up some parameters:&lt;br /&gt;
# In ''launchPEM.sh'', the user has to specify:&lt;br /&gt;
#* '''n_mars_years''', '''n_earth_years''': the number of Mars/Earth years to be simulated in total (&amp;gt; 0);&lt;br /&gt;
#* '''nPCM_ini''': the number of initial PCM runs (&amp;gt;= 2);&lt;br /&gt;
#* '''nPCM''': the number of PCM runs between each PEM run (&amp;gt;= 2, usually 2);&lt;br /&gt;
#* '''counting''': the counting method for the number of years to be simulated (0 = &amp;quot;only PEM runs count&amp;quot;; any other values = &amp;quot;PCM runs are taken into account&amp;quot;). The former option is the usual one;&lt;br /&gt;
#* '''mode''': the launching mode (0 = &amp;quot;processing scripts&amp;quot;; any other values = &amp;quot;submitting jobs&amp;quot;). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE.&lt;br /&gt;
# In ''PCMrun.job'', the user has to specify:&lt;br /&gt;
#* the '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PCM executable''' file should be adapted.&lt;br /&gt;
#* The '''execution command''' should also be adapted according to the set-up.&lt;br /&gt;
# In ''PEMrun.job'', the user has to specify:&lt;br /&gt;
#* The '''headers''' correspond to the ADASTRA supercomputer and should be changed for other machines and job schedulers. In case of &amp;quot;processing scripts&amp;quot; launching mode, the headers are naturally omitted.&lt;br /&gt;
#* The '''path to source''' the arch file should be adapted to the machine.&lt;br /&gt;
#* The '''name of the PEM and Reshaping executable''' files should be adapted.&lt;br /&gt;
#* The PEM executable can have an '''optional argument''' which should be specified according to the set-up (&amp;quot;--auto-exit&amp;quot; for SLURM and PBS/TORQUE | &amp;quot;&amp;quot; when the script is not run as a job).&lt;br /&gt;
# The user has to specify the wanted options in the '''def files''', especially for ''run_PEM.def'', ''run_PCM.def'', ''callphys.def''.&lt;br /&gt;
# In addition, the user has to provide a ''startfi.nc'' whose orbital parameters are consistent with the initial date set in ''run_PEM.def''. The script '''inipem_orbit.sh''' can set them automatically according to ''obl_ecc_lsp.asc''.&lt;br /&gt;
&lt;br /&gt;
== Outputs ==&lt;br /&gt;
&lt;br /&gt;
The PEM simulation generates the following files:&lt;br /&gt;
* the usual outputs of the PCM: ''restartfi.nc'', ''restart.nc'', ''diagfi.nc'', etc;&lt;br /&gt;
* the XIOS outputs of the PCM, then reshaped: ''Xdiurnalave.nc''/''data2reshape*.nc''/''data_PCM_Y*.nc'';&lt;br /&gt;
* the outputs of the chained simulation: ''launchPEM.log'', ''info_PEM.txt'' and possibly ''kill_launchPEM.sh'';&lt;br /&gt;
* the usual outputs of the PEM: ''&amp;quot;restartfi.nc'', ''restart.nc''/''restart1D.txt'' and ''diagpem.nc''.&lt;br /&gt;
&lt;br /&gt;
During the simulation, the PCM/PEM run files are renamed conveniently and stored in the sub-directories '''logs''' (log files), '''starts''' (starting files) and '''diags''' (diagnostic files).&lt;br /&gt;
&lt;br /&gt;
If you run a simulation by submitting jobs, the script ''kill_launchPEM.sh'' is automatically generated. It can be used to kill in the queue of the job scheduler the jobs related to your chained simulation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2911</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2911"/>
				<updated>2025-10-23T15:11:15Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Merging the PEM outputs (post-processing) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.py&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; from Laskar's data contained in &amp;quot;obl_ecc_lsp.asc&amp;quot; according to the initial date 'year_earth_bp_ini' defined in &amp;quot;run_PEM.def&amp;quot;. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file &amp;quot;startfi.nc&amp;quot;. They should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2910</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2910"/>
				<updated>2025-10-23T14:52:53Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Merging the PEM outputs (post-processing) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.sh&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; from Laskar's data contained in &amp;quot;obl_ecc_lsp.asc&amp;quot; according to the initial date 'year_earth_bp_ini' defined in &amp;quot;run_PEM.def&amp;quot;. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file &amp;quot;startfi.nc&amp;quot;. They should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2909</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2909"/>
				<updated>2025-10-23T14:52:26Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_pem.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script &amp;lt;code&amp;gt;concat_pem.&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; from Laskar's data contained in &amp;quot;obl_ecc_lsp.asc&amp;quot; according to the initial date 'year_earth_bp_ini' defined in &amp;quot;run_PEM.def&amp;quot;. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file &amp;quot;startfi.nc&amp;quot;. They should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PEM&amp;diff=2908</id>
		<title>Advanced Topics Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PEM&amp;diff=2908"/>
				<updated>2025-10-23T14:49:35Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Running the PEM in 1D */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Running the PEM with the launching script ==&lt;br /&gt;
&lt;br /&gt;
The script ''launchPEM.sh'' can take an argument:&lt;br /&gt;
      # If there is no argument, then the script initiates a PEM simulation from scratch.&lt;br /&gt;
      # If the argument is 're', then the script relaunches an existing PEM simulation. It will ask for parameters to know the starting point that you want to. &lt;br /&gt;
&lt;br /&gt;
== Running the PEM in 1D ==&lt;br /&gt;
&lt;br /&gt;
One can run the PEM in a single column configuration, i.e. as a 1D model. Compilation is done using the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] script except that only a number of vertical layers needs be specified. For example, to compile a version of 32 vertical layers, one would run the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch somearch -p mars -d 32 -j 8 pem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To work with the 1D PEM, you must use the related PCM in 1D. For example, for the Mars PCM, see [[Mars 1D testphys1d program]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PCM&amp;diff=2907</id>
		<title>Advanced Topics Mars PCM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PCM&amp;diff=2907"/>
				<updated>2025-10-23T14:46:40Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Other Mars PCM configurations worth knowing about */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Running in parallel ==&lt;br /&gt;
&lt;br /&gt;
For large simulation (long runs, high resolution etc...), the computational cost can be huge and hence the run time quite long.&lt;br /&gt;
To somewhat overcome this issue, the model can be run in parallel. This however requires a few extra steps (compared to compiling and running the serial version of the code, as described in the [[Quick Install and Run Mars PCM]] page).&lt;br /&gt;
&lt;br /&gt;
=== Various comments and disambiguations around parallelism and related tools ===&lt;br /&gt;
For users not used to compilers and/or compiling and running codes in parallel, there is often some confusion which hopefully the following paragraph might help clarify:&lt;br /&gt;
* the compiler (typically gfortran, ifort, pgfortran, etc.) is the required tool to compile the Fortran source code and generate an executable. It is strongly recommended that libraries used by a program are also compiled using the same compiler. Thus if you plan to use different compilers to compile the model, note that you should also have at hand versions of the libraries it uses also compiled with these compilers.&lt;br /&gt;
* A first level of parallelism is obtained using MPI. The MPI (Message Passing Interface) library is a library used to solve problems using multiple processes by enabling message-passing between the otherwise independent processes. There are a number of available MPI libraries out there, e.g. OpenMPI, MPICH or IntelMPI to name a few (you can check out the [[Building an MPI library]] page for some information about installing an MPI library). The important point here is that on a given machine the MPI library is related to a given compiler and that it provides related wrappers to compile and run with. Typically (but not always) the compiler wrapper is '''mpif90''' and the execution wrapper is '''mpirun'''. If you want to know which compiler is wrapped in the '''mpif90''' compiler wrapper, check out the output of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpif90 --version&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* In addition a second type of parallelism, shared memory parallelism known as OpenMP, is also implemented in the code. In contradistinction to MPI, OpenMP does not require an external library but is instead implemented as a compiler feature. At run time one must then specify some dedicated environment variables (such as OMP_NUM_THREADS and OMP_STACKSIZE) to specify the number of threads to use per process.&lt;br /&gt;
&lt;br /&gt;
=== Compiling the Mars PCM ===&lt;br /&gt;
* In practice one should favor compiling and running with both MPI and OPenMP enabled, and therefore compile with the &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-parallel mpi_omp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
option of the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] compilation script&lt;br /&gt;
* It is also advised (but not mandatory) to use the XIOS library for outputs when in parallel, in which case one should also compile with the&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-io xios&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
option of the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] compilation script&lt;br /&gt;
&lt;br /&gt;
=== Running the Mars PCM in Parallel ===&lt;br /&gt;
Check out pages like [[Parallelism]] for an overview of how it's done.&lt;br /&gt;
&lt;br /&gt;
== Other Mars PCM configurations worth knowing about ==&lt;br /&gt;
&lt;br /&gt;
=== Running the 1D version of the Mars PCM ===&lt;br /&gt;
One can run the PCM in a single column configuration, i.e. as a 1D model. It is the same physics package that is used in 1D than in 3D. Compilation is also done using the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] script except that only a number of vertical layers needs be specified and that the main program is called &amp;quot;testphys1d&amp;quot;. For example, to compile a version of 32 vertical layers of &amp;quot;testphys1d&amp;quot;, one would run the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch somearch -p mars -d 32 -j 8 testphys1d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See the dedicated page: [[Mars 1D testphys1d program]] for more.&lt;br /&gt;
&lt;br /&gt;
=== Running with the DYNAMICO dynamical core ===&lt;br /&gt;
TODO: Some intro and link to relevent pages here.&lt;br /&gt;
&lt;br /&gt;
=== Running with the WRF dynamical core ===&lt;br /&gt;
TODO: Some intro and link to relevent pages here.&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PEM&amp;diff=2906</id>
		<title>Advanced Topics Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Advanced_Topics_Mars_PEM&amp;diff=2906"/>
				<updated>2025-10-23T14:46:35Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Running the PEM with the launching script ==&lt;br /&gt;
&lt;br /&gt;
The script ''launchPEM.sh'' can take an argument:&lt;br /&gt;
      # If there is no argument, then the script initiates a PEM simulation from scratch.&lt;br /&gt;
      # If the argument is 're', then the script relaunches an existing PEM simulation. It will ask for parameters to know the starting point that you want to. &lt;br /&gt;
&lt;br /&gt;
== Running the PEM in 1D ==&lt;br /&gt;
&lt;br /&gt;
One can run the PEM in a single column configuration, i.e. as a 1D model. Compilation is done using the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] script except that only a number of vertical layers needs be specified. For example, to compile a version of 32 vertical layers, one would run the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch somearch -p mars -d 32 -j 8 pem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Help_Mars_PEM&amp;diff=2905</id>
		<title>Help Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Help_Mars_PEM&amp;diff=2905"/>
				<updated>2025-10-23T07:50:22Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This mediawiki site hosts a collection of pages dedicated to various aspects of the PEM, such as its installation or its use.&lt;br /&gt;
&lt;br /&gt;
For a first glimpse or even an initial use of the model, the links in the menu of the left panel on this page, under &amp;quot;Planetary Evolution Model&amp;quot;, should be good starting points.&lt;br /&gt;
&lt;br /&gt;
Beyond that, you have the following possibilities:&lt;br /&gt;
* Check out the [[Category:Planetary-Evolution-Model| dedicated category page]] referencing individual pages tagged with &amp;quot;Planetary-Evolution-Model&amp;quot;;&lt;br /&gt;
* Check out the [[Special:AllPages| dedicated page]] referencing all the pages in this mediawiki site;&lt;br /&gt;
* Use the '''Search Box''' at the top right-hand corner of the page with keywords.&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Dust_Cycle_in_Mars_PCM5&amp;diff=2812</id>
		<title>Dust Cycle in Mars PCM5</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Dust_Cycle_in_Mars_PCM5&amp;diff=2812"/>
				<updated>2025-08-26T14:07:25Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: Addition of explanations about Conrath dust&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page details at different levels how to use and what is featured in the dust cycle in Mars PCM5.&lt;br /&gt;
&lt;br /&gt;
== Brief Overview ==&lt;br /&gt;
The reference work leading to the implementation in the PCM is the PhD work of J.-B. Madeleine; check out his PhD manuscript and 2011 JGR article&lt;br /&gt;
&amp;quot;Revisiting the radiative impact of dust on Mars using the LMD Global Climate Model&amp;quot; https://doi.org/10.1029/2011JE003855&lt;br /&gt;
&lt;br /&gt;
The main features and concepts on how the dust is handled are:&lt;br /&gt;
* Dust is modeled as a log-normal population (varying in size), which in the end requires managing only two ''tracers'', the first two moments of the distribution, which are the dust mass mixing ratio and number (tracers ''dust_mass'' and ''dust_number'').&lt;br /&gt;
* All the physical processes like large scale advection, mixing by the turbulence in the planetary boundary layer, sedimentation, etc. are modeled.&lt;br /&gt;
* How the dust gets injected in the atmosphere (i.e. the details of dust lifting from the surface) is not modeled; instead we use a simple assumption that there is always some injection of dust from the surface (most of it simply falling back down; but some of it, when the conditions are right, propagates)&lt;br /&gt;
* In addition, the dust in each column is rescaled so that its column opacity then matches that of a driving dust scenario (typically derived from observations).&lt;br /&gt;
&lt;br /&gt;
== Flags concerning the dust cycle in a PCM version 5 setup ==&lt;br /&gt;
A setup including adequate flags and parameters for a PCM5 dust cycle can be found in the reference [[callphys.def.GCM5|https://trac.lmd.jussieu.fr/Planeto/browser/trunk/LMDZ.MARS/deftank/callphys.def.GCM5] reference provided in deftank.&lt;br /&gt;
&lt;br /&gt;
As mentioned above, there should be the 2 dedicated tracers (dust moments) at hand (i.e. in the traceur.def file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dust_mass&lt;br /&gt;
dust_number&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice the relevant callphys.def parameters are:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#Directory where external input files are:&lt;br /&gt;
datadir=/users/lmdz/WWW/planets/mars/datadir&lt;br /&gt;
&lt;br /&gt;
## Dust scenario. Used if the dust is prescribed (i.e. if active=F)&lt;br /&gt;
## ~~~~~~~~~~~~~&lt;br /&gt;
#  =1 Dust opt.deph read in startfi; =2 Viking scenario; =3 MGS scenario,&lt;br /&gt;
#  =4 Mars Year 24 from TES assimilation (old version of MY24; dust_tes.nc file)&lt;br /&gt;
#  =6 &amp;quot;cold&amp;quot; (low dust) scenario ; =7 &amp;quot;warm&amp;quot; (high dust) scenario&lt;br /&gt;
#  =8 &amp;quot;climatology&amp;quot; (our best guess of a typical Mars year) scenario&lt;br /&gt;
#  =24 Mars Year 24  ; =25 Mars Year 25 (year with a global dust storm) ; ...&lt;br /&gt;
#  =30 Mars Year 30 &lt;br /&gt;
iaervar = 26&lt;br /&gt;
# Dust opacity at 610 Pa (when constant, i.e. for the iaervar=1 case)&lt;br /&gt;
tauvis=0.2&lt;br /&gt;
# Dust vertical distribution: &lt;br /&gt;
# (=0: old distrib. (Pollack90), =1: top set by &amp;quot;topdustref&amp;quot;,&lt;br /&gt;
#  =2: Viking scenario; =3 MGS scenario)&lt;br /&gt;
iddist  = 3&lt;br /&gt;
# Dust top altitude (km). (Matters only if iddist=1)&lt;br /&gt;
topdustref = 55.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''iaervar''' points to the driving dust scenario (daily maps; netcdf files located under '''datadir''') to use: e.g. ''dust_clim.nc'' if &amp;lt;code&amp;gt;iaervar=8&amp;lt;/code&amp;gt;, ''dust_MY30.nc'' if &amp;lt;code&amp;gt;iaervar=30&amp;lt;/code&amp;gt;, etc. In the special case where &amp;lt;code&amp;gt;iaervar=1&amp;lt;/code&amp;gt; then the driving dust column opacity is constant (over space and time) to the value specified by flag '''tauvis'''.&lt;br /&gt;
* '''tauvis''' is only used when &amp;lt;code&amp;gt;iaervar=1&amp;lt;/code&amp;gt; in which case it is the imposed value of the column dust opacity (at reference pressure of 610Pa).&lt;br /&gt;
* '''iddist''' and '''topdustref''' are not used (date back to even simpler setup)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
## Tracer (dust water, ice and/or chemical species) options :&lt;br /&gt;
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;
# DUST: Transported dust ? (if &amp;gt;0, use 'dustbin' dust bins)&lt;br /&gt;
dustbin    = 2&lt;br /&gt;
# DUST: Radiatively active dust ? (matters if dustbin&amp;gt;0)&lt;br /&gt;
active  = .true.&lt;br /&gt;
# DUST: use mass and number mixing ratios to predict dust size ?&lt;br /&gt;
doubleq   = .true.&lt;br /&gt;
# DUST: use a small population of dust particules (submicron dust)?&lt;br /&gt;
submicron = .false.&lt;br /&gt;
# DUST: lifted by GCM surface winds ?&lt;br /&gt;
lifting = .true.&lt;br /&gt;
# DUST: lifted by dust devils ?&lt;br /&gt;
callddevil = .false.&lt;br /&gt;
# DUST: Scavenging by H2O/CO2 snowfall ?&lt;br /&gt;
scavenging = .true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''dustbin''' should be 2, because using the 2-moment scheme (with &amp;lt;code&amp;gt;doubleq=.true.&amp;lt;/code&amp;gt;).&lt;br /&gt;
* '''active''' should definitely be set to &amp;lt;code&amp;gt;.true.&amp;lt;/code&amp;gt;, to account for the radiative effect of dust.&lt;br /&gt;
* '''doubleq'''  should be &amp;lt;code&amp;gt;.true.&amp;lt;/code&amp;gt; (with &amp;lt;code&amp;gt;dustbin=2&amp;lt;/code&amp;gt;), to use the two-moment scheme&lt;br /&gt;
* '''submicron''' should be &amp;lt;code&amp;gt;.false.&amp;lt;/code&amp;gt;; was put there to eventually have a second distribution of small particles around. Not used nor validated.&lt;br /&gt;
* '''lifting''' should be &amp;lt;code&amp;gt;.true.&amp;lt;/code&amp;gt;, to impose continuous dust injection from the surface into the first atmospheric layer.&lt;br /&gt;
* '''callddevil''' should be &amp;lt;code&amp;gt;.false.&amp;lt;/code&amp;gt;; was put there to eventually account for dust injection via dust devils. Not used nor validated.&lt;br /&gt;
* '''scavenging ''' should be &amp;lt;code&amp;gt;.true.&amp;lt;/code&amp;gt; to include scavenging of dust by H2O and or CO2 snowfall (assuming CO2 and/or H2O cycles are also computed). Significant effect in the polar night.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# SCATTERERS: set number of scatterers. must be compliant with preceding options.&lt;br /&gt;
naerkind = 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* '''nearkind ''' is the number of radiatively active scatterers. Dust is one of them (if &amp;lt;code&amp;gt;active=.true.&amp;lt;/code&amp;gt;) so nearkind should be at least 1; and if the water cycle is also computed with radiatively active clouds (&amp;lt;code&amp;gt;water=.true.&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;activice=.true.&amp;lt;/code&amp;gt;) then &amp;lt;code&amp;gt;naerkind=2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== More technical stuff, and how/where it is managed in the Mars PCM code ==&lt;br /&gt;
....TODO....&lt;br /&gt;
&lt;br /&gt;
=== Routines ===&lt;br /&gt;
* initracer : Initialize some dust properties stored in the '''tracer_mod''' module: dedicated tracer indexes &amp;lt;code&amp;gt;igcm_dust_mass&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;igcm_dust_number&amp;lt;/code&amp;gt;, reference dust density &amp;lt;code&amp;gt;rho_q(igcm_dust_mass)&amp;lt;/code&amp;gt;, variance of the lifted/injected dust distribution &amp;lt;code&amp;gt;varian&amp;lt;/code&amp;gt;, reference effective radius of the lifted dust &amp;lt;code&amp;gt;reff_lift&amp;lt;/code&amp;gt; and injection/lifting coefficient &amp;lt;code&amp;gt;alpha_lift(igcm_dust_mass)&amp;lt;/code&amp;gt;&lt;br /&gt;
* aeropacity : where the optical depth of the aerosols is computed (see e.g. the &amp;quot;dust_doubleq&amp;quot; case for dust) and the call to compute_dustscaling is done&lt;br /&gt;
* compute_dustscaling (in dust_scaling_mod) : where &amp;quot;tauscaling&amp;quot;, the dust rescaling coefficient, is computed&lt;br /&gt;
* vdifc : where the dust is lifted/injected from the surface into the atmosphere&lt;br /&gt;
&lt;br /&gt;
=== Parameters and variables in the code ===&lt;br /&gt;
* '''tauscaling''' : dust rescaling coefficient (one value per column) &lt;br /&gt;
* '''tau_pref_gcm''' : dust column opacity at 610 Pa (should be equal to &amp;quot;tau_pref_scenario&amp;quot;, the dust column opacity from the driving scenario)&lt;br /&gt;
* '''freedust''' : this parameter should be &amp;lt;code&amp;gt;freedust=.false.&amp;lt;/code&amp;gt;, so that there is rescaling of the dust using the &amp;quot;tauscaling&amp;quot; coefficient&lt;br /&gt;
* '''dustscaling_mode''' : this parameter should be &amp;lt;code&amp;gt;dustscaling_mode=1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using an old but simple dust scheme ==&lt;br /&gt;
&lt;br /&gt;
If one wants to use a very simple scheme for dust instead of the usual 'doubleq' (and 'active') dust, it is possible to use an old parametrization based on '''&amp;quot;Conrath dust&amp;quot;'''. In this case, the dust follows the &amp;quot;Conrath profile&amp;quot; and the radiative effect of dust is still included. This simple parametrization can be useful for some tests under idealized conditions like for the 1D model.&lt;br /&gt;
&lt;br /&gt;
In &amp;quot;callphys.def&amp;quot;, the necessary flags are &amp;lt;code&amp;gt;doubleq = .false.&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dustbin = 0&amp;lt;/code&amp;gt;. So there is no dust-related tracer in &amp;quot;traceur.def&amp;quot; and &amp;lt;code&amp;gt;naerkind = 1&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is actually the default choice for the main scatterer. The &amp;quot;Conrath dust&amp;quot; can be used with different dust scenarios (&amp;lt;code&amp;gt;iaervar&amp;lt;/code&amp;gt;) and dust vertical distributions (&amp;lt;code&amp;gt;iddist&amp;lt;/code&amp;gt;). In line with the aim to get the simplest case, one can choose &amp;lt;code&amp;gt;iddist = 0&amp;lt;/code&amp;gt; to set the old dust vertical distribution function (pollack90) depending only on the dust scenario (for example &amp;lt;code&amp;gt;iaervar = 1&amp;lt;/code&amp;gt; to define a simple case).&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Overview_of_the_Mars_PEM&amp;diff=2798</id>
		<title>Overview of the Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Overview_of_the_Mars_PEM&amp;diff=2798"/>
				<updated>2025-07-21T12:19:25Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview of the Planetary Evolution Model ==&lt;br /&gt;
&lt;br /&gt;
The aim of the '''Planetary Evolution Model''' (PEM) is to simulate and understand the past environments of a planet and it's long term evolution. It's also useful to explain the observed landforms etc.&lt;br /&gt;
&lt;br /&gt;
[[File:PEM.png|thumb|PEM schematic view ; credit: Francois Forget]]&lt;br /&gt;
&lt;br /&gt;
To accurately simulate the climate and the fate of volatiles for thousands to millions of years we must couple&lt;br /&gt;
physical processes with very different timescale, ranging from clouds microphysics and atmospheric&lt;br /&gt;
dynamics (represented in the GCM) to the evolution of lakes, glacier accumulation, and subsurface ice&lt;br /&gt;
evolution.&lt;br /&gt;
&lt;br /&gt;
Given the diversity and the complexity of the Martian paleoclimates, the model use an “asynchronous coupling” between&lt;br /&gt;
the slow ice and water reservoirs models and the GCM. In practice the Planetary evolution model&lt;br /&gt;
use a horizontal grid identical to that of the PCM, and include the same representation of the microclimate on slopes. &lt;br /&gt;
In our case, we run the Planetary Evolution Model with an adaptive time step,&lt;br /&gt;
depending upon the dynamics of the modelled system (smaller timesteps must first be used so that the&lt;br /&gt;
different volatile reservoirs reach a quasi-equilibrium, then the timestep will depends on the evolution of the&lt;br /&gt;
forcing, which is slow in the case of obliquity, for instance) . At each timestep, the inputs from the&lt;br /&gt;
atmosphere (e.g. mean precipitation, sublimation and evaporation, temperatures, dust deposition) is obtained through a multi-annual run of the Global Climate model using the outcome of the Mars Evolution Model as initial state.&lt;br /&gt;
&lt;br /&gt;
== The two modes of simulations ==&lt;br /&gt;
&lt;br /&gt;
The PEM can work in two modes:&lt;br /&gt;
* '''Mode 1 (M1)''': Search of the steady state given an external forcing and an initial situation;&lt;br /&gt;
* '''Mode 2 (M2)''': Realistic monitoring according to an orbital forcing.&lt;br /&gt;
&lt;br /&gt;
For M1, we always apply the same external forcing (the GCM is always called at the same obliquity for example). The PEM will run to find a steady state. Be careful that it can oscillate around the steady state so all the stopping criteria needs to be chosen wisely.&lt;br /&gt;
For M1, be also careful that the uniqueness of the steady state is not proven for this model. This means that for a given external forcing it is possible that the steady state is not unique and could depend on the initial condition and other parameters.&lt;br /&gt;
&lt;br /&gt;
For M2, we follow a predefined orbit. It is read in the file obl_ecc_lsp.asc. Stopping criterion specific to orbital change can be specified in run_PEM.def. The steady state is not necessary reached for all the orbit configuration as it could take more time to reach it than the time spent in this orbital configuration.&lt;br /&gt;
&lt;br /&gt;
== Stopping criteria ==&lt;br /&gt;
&lt;br /&gt;
For both modes, the PEM will run and extrapolate tendencies 'as long as it is meaningfull'. This means that for the different modelled physical processes, a stopping criterion is computed to express how much the system has changed. The PEM compares it to an acceptance rate and decides to stop or continue.&lt;br /&gt;
The criteria are the following: &lt;br /&gt;
* '''Water ice''': Ratio of the surface of water ice that is sublimating at the time step t over the surface of water ice that is sublimating from the GCM run;&lt;br /&gt;
* '''CO2 ice''': Ratio of the surface of CO2 ice that is sublimating at the time step t over the surface of co2 ice that is sublimating from the GCM run; &lt;br /&gt;
* '''Pressure''': Ratio of the planet averaged surface pressure at iteration t over the planet averaged surface pressure at the end of the last GCM run;&lt;br /&gt;
* '''Orbital parameters''': A maximum absolute value of change is set in the PEM for the variation of obliquity, eccentricity and Ls perihelion;&lt;br /&gt;
* '''Maximum number of years''': A maximum number of years can be defined.&lt;br /&gt;
&lt;br /&gt;
== Overview of a PEM run ==&lt;br /&gt;
&lt;br /&gt;
In either mode, a run works like this:&lt;br /&gt;
* Run 2 years of GCM: From this, we extract data such as daily average pressure, daily averaged vmr of atmospheric components, daily minimum of ice etc... You thus need to use '''XIOS''' &lt;br /&gt;
* The GCM restart file are renamed to be read by the PEM. They will be modified by the PEM to be able to start a new GCM simulation.&lt;br /&gt;
* If we are in a M2 configuration mode, a beginning year needs to be specified in the run_PEM.def, and the file ob_ex_lsp.asc needs to be present.&lt;br /&gt;
* The PEM is launched.&lt;br /&gt;
* GCM tendencies are computed from the data of the first item. They are applied to the start files and can be adapted to the situation (change of surface pressure etc...). All the physical processes also take place.&lt;br /&gt;
* The stopping criterion are checked and it either stop the time iteration or apply again the tendencies and run the physical processes&lt;br /&gt;
* GCM like start files are written.&lt;br /&gt;
* GCM is run again for 2 years and it loops again from the beginning.&lt;br /&gt;
&lt;br /&gt;
== Physical processes modelled ==&lt;br /&gt;
&lt;br /&gt;
The PEM is still in development, so far, the physical processes modeled are quite specific to Mars at low obliquity.&lt;br /&gt;
&lt;br /&gt;
'''Current processes that have been validated:'''&lt;br /&gt;
&lt;br /&gt;
✅ Ice accumulation &lt;br /&gt;
&lt;br /&gt;
✅ CO2 / H_2O adsorption &lt;br /&gt;
&lt;br /&gt;
✅ Soil temperature from the surface to ten's of kms.&lt;br /&gt;
&lt;br /&gt;
✅  Glacier flow for CO2&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Current processes that are in validation:'''&lt;br /&gt;
&lt;br /&gt;
∼ Subsurface Ground Ice at equilibrium &lt;br /&gt;
&lt;br /&gt;
∼ Orbital Forcing (RV &amp;amp; LL)&lt;br /&gt;
&lt;br /&gt;
'''Future works:'''&lt;br /&gt;
&lt;br /&gt;
❌ Exchange between subsurface reservoirs and atmosphere / Formation of a lag deposit(will be done by Simon Neviere, Futur intern of Lucas)&lt;br /&gt;
&lt;br /&gt;
❌ Dynamical Ice Table&lt;br /&gt;
&lt;br /&gt;
❌ Hydrology: lake, river, ocean, etc. (Alexandre Gauvain)&lt;br /&gt;
&lt;br /&gt;
❌ Photochemistry&lt;br /&gt;
&lt;br /&gt;
Index name for loops through:&lt;br /&gt;
* '''physical grid''' : ig (max ngrid)&lt;br /&gt;
* '''tracer''' : iq (max nq)&lt;br /&gt;
* '''subslopes''' : islope (max nslope)&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2797</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2797"/>
				<updated>2025-07-21T12:16:37Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Initialization of orbital parameters (pre-processing) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_diagpem.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;concat_diagpem.sh&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; sets the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; from Laskar's data contained in &amp;quot;obl_ecc_lsp.asc&amp;quot; according to the initial date 'year_earth_bp_ini' defined in &amp;quot;run_PEM.def&amp;quot;. See also &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file &amp;quot;startfi.nc&amp;quot;. They should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2796</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2796"/>
				<updated>2025-07-21T12:15:42Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Setting the orbital parameters (pre-processing) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_diagpem.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;concat_diagpem.sh&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; modifies the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; according to the date set in the file &amp;quot;run_PEM.def&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify orbital parameters in the file &amp;quot;startfi.nc&amp;quot;. They should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; at the same date if orbital parameters are meant to vary during the simulation. See also &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2795</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2795"/>
				<updated>2025-07-21T12:14:09Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Setting a variable in a NetCDF file (pre-processing) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_diagpem.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;concat_diagpem.sh&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; modifies the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; according to the date set in the file &amp;quot;run_PEM.def&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify the orbital parameters in a &amp;quot;startfi.nc&amp;quot; file, that is obliquity, eccentricity, Ls perihelion and the initial Ls. It is useful when one wants a chained simulation to start at a specific date. In this case, the orbital parameters should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; which can be found in the PEM deftank.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=PEM_(Planetary_Evolution_Model)&amp;diff=2794</id>
		<title>PEM (Planetary Evolution Model)</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=PEM_(Planetary_Evolution_Model)&amp;diff=2794"/>
				<updated>2025-07-21T12:12:14Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview of the PEM (Planetary Evolution Model) ==&lt;br /&gt;
&lt;br /&gt;
The objective of the “Planetary Evolution Model” is to simulate and understand the past environments of a planet and it's long term evolution. It's also usefull to explain the observed landforms etc.&lt;br /&gt;
&lt;br /&gt;
[[File:PEM.png|thumb|PEM schematic view ; credit: Francois Forget]]&lt;br /&gt;
&lt;br /&gt;
To accurately simulate the climate and the fate of volatiles for thousands to millions of years we must couple&lt;br /&gt;
physical processes with very different timescale, ranging from clouds microphysics and atmospheric&lt;br /&gt;
dynamics (represented in the GCM) to the evolution of lakes, glacier accumulation, and subsurface ice&lt;br /&gt;
evolution.&lt;br /&gt;
&lt;br /&gt;
Given the diversity and the complexity of the Martian paleoclimates, the model use an “asynchronous coupling” between&lt;br /&gt;
the slow ice and water reservoirs models and the GCM. In practice the Planetary evolution model&lt;br /&gt;
use a horizontal grid identical to that of the PCM, and include the same representation of the microclimate on slopes. &lt;br /&gt;
In our case, we run the Planetary Evolution Model with an adaptative time step,&lt;br /&gt;
depending upon the dynamics of the modeled system (smaller timesteps must first be used so that the&lt;br /&gt;
different volatile reservoirs reach a quasi-equilibrium, then the timestep will depends on the evolution of the&lt;br /&gt;
forcing, which is slow in the case of obliquity, for instance) . At each timestep, the inputs from the&lt;br /&gt;
atmosphere (e.g. mean precipitation, sublimation and evaporation, temperatures, dust deposition) is obtained through a multi-annual run of the Global Climate model using the outcome of the Mars Evolution Model as initial state.&lt;br /&gt;
&lt;br /&gt;
== The two modes of simulations ==&lt;br /&gt;
&lt;br /&gt;
The PEM can works in two modes:&lt;br /&gt;
* M1 : Search of the steady state given an external forcing and an initial situation&lt;br /&gt;
* M2 : Realistic following of orbital forcing&lt;br /&gt;
&lt;br /&gt;
For M1, we always apply the same external forcing (the GCM is always called at the same obliquity for example). The PEM will run to find a steady state. Be carefull that it can oscillate around the steady state so all the stopping criterions needs to be choosen wisely.&lt;br /&gt;
For M1, be also carefull that the uniquity of the steady state is not proven for this model. This means that for a given external forcing it is possible that the steady state is not unique and could depend on the initial condition and other parameters.&lt;br /&gt;
&lt;br /&gt;
For M2, we follow a predefined orbit. It is read in the file ob_ex_lsp.asc. Stopping criterion specific to orbital change can be specified in run_pem.def. The steady state is not necessary reached for all the orbit configuration as it could take more time to reach it than the time spent in this orbital configuration.&lt;br /&gt;
&lt;br /&gt;
== Stopping criterion ==&lt;br /&gt;
&lt;br /&gt;
For both modes, the PEM will run and extrapolate tendencies 'as long as it is meaningfull'. This means that for the different physical processes modelled, a criterion is computed. This criterion express how much the system has changed. The PEM compares it to an acceptance rate and decides to stop or continue.&lt;br /&gt;
The criterions are the following: &lt;br /&gt;
* '''Water ice ''' : Ratio of the surface of water ice that is sublimating at the time step t over the surface of water ice that is sublimating from the GCM run. &lt;br /&gt;
* '''CO2_ice ''' : Ratio of the surface of co2 ice that is sublimating at the time step t over the surface of co2 ice that is sublimating from the GCM run. &lt;br /&gt;
* '''Pressure''' : Ratio of the planet averaged surface pressure at iteration t over the planet averaged surface pressure at the end of the last GCM run.&lt;br /&gt;
* '''Orbital parameter''' : Multiple possibility; Percentage of change of a each orbital parameter, maximum absolute value of change, maximum number of years...&lt;br /&gt;
&lt;br /&gt;
== Overview of a PEM run ==&lt;br /&gt;
&lt;br /&gt;
In either mode, a run works like this:&lt;br /&gt;
* Run 2 years of GCM: From this, we extract data such as daily average pressure, daily averaged vmr of atmospheric components, daily minimum of ice etc... You thus need to use '''XIOS''' &lt;br /&gt;
* The GCM restart file are renamed to be read by the PEM. They will be modified by the PEM to be able to start a new GCM simulation.&lt;br /&gt;
* If we are in a M2 configuration mode, a beginning year needs to be specified in the run_PEM.def, and the file ob_ex_lsp.asc needs to be present.&lt;br /&gt;
* The PEM is launched.&lt;br /&gt;
* GCM tendencies are computed from the data of the first item. They are applied to the start files and can be adapted to the situation (change of surface pressure etc...). All the physical processes also take place.&lt;br /&gt;
* The stopping criterion are checked and it either stop the time iteration or apply again the tendencies and run the physical processes&lt;br /&gt;
* GCM like start files are written.&lt;br /&gt;
* GCM is run again for 2 years and it loops again from the beginning.&lt;br /&gt;
&lt;br /&gt;
== Physical processes modelled ==&lt;br /&gt;
&lt;br /&gt;
The PEM is still in development, so far, the physical processes modeled are quite specific to Mars at low obliquity.&lt;br /&gt;
&lt;br /&gt;
'''Current processes that have been validated:'''&lt;br /&gt;
&lt;br /&gt;
✅ Ice accumulation &lt;br /&gt;
&lt;br /&gt;
✅ CO2 / H_2O adsorption &lt;br /&gt;
&lt;br /&gt;
✅ Soil temperature from the surface to ten's of kms.&lt;br /&gt;
&lt;br /&gt;
✅  Glacier flow for CO2&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Current processes that are in validation:'''&lt;br /&gt;
&lt;br /&gt;
∼ Subsurface Ground Ice at equilibrium &lt;br /&gt;
&lt;br /&gt;
∼ Orbital Forcing (RV &amp;amp; LL)&lt;br /&gt;
&lt;br /&gt;
'''Future works:'''&lt;br /&gt;
&lt;br /&gt;
❌ Exchange between subsurface reservoirs and atmosphere / Formation of a lag deposit(will be done by Simon Neviere, Futur intern of Lucas)&lt;br /&gt;
&lt;br /&gt;
❌ Dynamical Ice Table&lt;br /&gt;
&lt;br /&gt;
❌ Hydrology: lake, river, ocean, etc. (Alexandre Gauvain)&lt;br /&gt;
&lt;br /&gt;
❌ Photochemistry&lt;br /&gt;
&lt;br /&gt;
== PEM inputs and outputs ==&lt;br /&gt;
&lt;br /&gt;
Inputs:&lt;br /&gt;
* '''start_evol.nc''' A Dynamical GCM start file&lt;br /&gt;
* '''startfi_evol.nc''' A physic GCM start file&lt;br /&gt;
* '''startfi_PEM.nc''' A start file specific to the PEM (optional)&lt;br /&gt;
* '''run.def''' and '''run_PEM.def''' txt files specifying run parameters such as the initial year, the acceptance rate for each criterion etc...&lt;br /&gt;
* '''z2sig.def''' A txt file specifying the vertical grid&lt;br /&gt;
* '''tracer.def''' A txt file specifyng which tracers we are modelling.&lt;br /&gt;
* '''ob_ex_lsp.asc''' A txt files specifying orbit parameters (optional - only needed for M2)&lt;br /&gt;
* '''data_GCM_Y1.nc''' A netcdf file containing information about the first typical year run by the GCM&lt;br /&gt;
* '''data_GCM_Y2.nc''' A netcdf file containing information about the second typical year run by the GCM&lt;br /&gt;
&lt;br /&gt;
Outputs:&lt;br /&gt;
* '''restart_evol.nc''' A Dynamical GCM start file to start the next GCM iteration run&lt;br /&gt;
* '''restartfi_evol.nc''' A physic GCM start file to start the next GCM iteration run&lt;br /&gt;
* '''restartfi_PEM.nc''' A start file specific to the PEM to start the next PCM run&lt;br /&gt;
* '''diagfi_PEM.nc''' (optional) A netcdf file containing physical information about the PCM run&lt;br /&gt;
&lt;br /&gt;
== Naming convention of variables ==&lt;br /&gt;
&lt;br /&gt;
Some variables comes from the GCM run. There are 3 cases:&lt;br /&gt;
* '''Constant variables''' : Some variable are not changed during the PEM run, they are named var_cGCM. ex:???&lt;br /&gt;
* '''Adapted variables''' : Some variables are adapted to the current state and recomputed through the PEM run, they are named var_aGCM. ex:???&lt;br /&gt;
* '''Tendencies from GCM''' : Some variables are tendencies obtained from the GCM run, they are named var_tGCM. ex:???&lt;br /&gt;
&lt;br /&gt;
Some variables coming from the GCM can be shaped as the dynamical grid but needs to be used in the physical grid. The change is done via the subroutine grid_dyn_phys. In this routine, the name is changed:&lt;br /&gt;
* '''Dynamical to physical grid''' the variable is renamed from var to var_phys&lt;br /&gt;
&lt;br /&gt;
Variables that exists in the GCM but that here belong to the PEM are named:&lt;br /&gt;
* '''Exist in the GCM but belong to the PEM ''' var_PEM&lt;br /&gt;
&lt;br /&gt;
Variables that are specific to the PEM are not named following a special convention.&lt;br /&gt;
&lt;br /&gt;
Index name for loops through:&lt;br /&gt;
* '''physical grid''' : ig (max ngrid)&lt;br /&gt;
* '''tracer''' : iq (max nq)&lt;br /&gt;
* '''subslopes''' : islope (max nslope)&lt;br /&gt;
&lt;br /&gt;
TO DO:&lt;br /&gt;
* Rename variables&lt;br /&gt;
* Tendencies from the GCM : qsurf_GCM_tend&lt;br /&gt;
&lt;br /&gt;
* Remove _slope&lt;br /&gt;
&lt;br /&gt;
*ini_qsurf&lt;br /&gt;
&lt;br /&gt;
*min_qsurf&lt;br /&gt;
&lt;br /&gt;
== Choices of parameters (run_PEM.def) ==&lt;br /&gt;
&lt;br /&gt;
Parameters of the PEM run can be specified in run_PEM.def. This file is included at the end of the run.def. For now, these are the possible parameters:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''General parameters for the run '''&lt;br /&gt;
&lt;br /&gt;
* evol_orbit_pem: [Boolean] Do you want to follow an orbital forcing predefined (read in ob_ex_lsp.asc for example)? (default=false)&lt;br /&gt;
** If evol_orbit_pem is set to true, year_bp_ini needs to be specified&lt;br /&gt;
** year_bp_ini: [Integer] Number of (Earth) year before present to start the pem run if evol_orbit_pem=.true. , default=0&lt;br /&gt;
** var_obl: [Boolean] Do you want to vary the obliquity when following ob_ex_lsp.asc? Default =.true.&lt;br /&gt;
** var_ex: [Boolean] Do you want to vary the excenticity when following ob_ex_lsp.asc? Default =.true.&lt;br /&gt;
** var_lsp: [Boolean] Do you want to vary the ls perihelie when following ob_ex_lsp.asc? Default =.true.&lt;br /&gt;
* Max_iter_pem: [Integer] Maximal number of iteration if none of the stopping criterion is reached and if evol_orbit_pem=.false., default=99999999&lt;br /&gt;
* dt_pem: [Integer] Time step of the PEM in year, default=1&lt;br /&gt;
* ice_criterion: [Real] Acceptance rate of sublimating ice surface change, default=0.2&lt;br /&gt;
* ps_criterion: [Real] Acceptance rate of pressure surface change, default=0.15&lt;br /&gt;
&lt;br /&gt;
'''Subsurface'''&lt;br /&gt;
&lt;br /&gt;
* soil_pem: [Boolean]. Do you want to run with subsurface physical processes in the PEM? default=.true.&lt;br /&gt;
* adsorption_pem: [Boolean]. Do you want to run with adsoprtion in the PEM? default=.true.&lt;br /&gt;
* reg_thprop_dependp: [Boolean]. Do you want to modify the soil thermal properties with the pressure ? default=.false.&lt;br /&gt;
''Layering:''&lt;br /&gt;
* fluxgeo: [Real]. Value of the geothermal flux? default= 0.&lt;br /&gt;
* depth_breccia: [Real]. Depth at which the breccia layer begins? default= 50 m&lt;br /&gt;
* depth_bedrock: [Real]. Depth at which the bedrock layer begins? default= 1000 m&lt;br /&gt;
&lt;br /&gt;
''' Reservoirs '''&lt;br /&gt;
* water_reservoir_nom: [Real]. Value of the available water in the subsurface. default =1e4 in kg/m^2&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2775</id>
		<title>Tool Box</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2775"/>
				<updated>2025-07-07T13:01:58Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pre-processing Tools ==&lt;br /&gt;
=== newstart: a fortran program to modify start files ===&lt;br /&gt;
&lt;br /&gt;
Newstart is an interactive tool to modify the start files (''start.nc'' and ''startfi.nc''). &lt;br /&gt;
&lt;br /&gt;
To be usable, ''newstart'' should be compile in the ''LMDZ.COMMON'' directory by using the following command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 newstart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the example, my_arch_file is the name the arch files (see [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_Target_Architecture_(%22arch%22)_Files arch] ) and 64x48x30 is the resolution of the physical grid.&lt;br /&gt;
Then copy the executable from the ''LMDZ.COMMON/bin'' directory to your bench directory.&lt;br /&gt;
&lt;br /&gt;
When you execute newstart, you can use both a ''start2archive'' file or the start files (''start.nc'' and ''startfi.nc''). Then the interactive interface will propose to modify several physical quantities such as the gravity, the surface pressure or the rotation of the planet. At the end of the procedure, two files are created: '' '''re'''start.nc'' and '' '''re'''startfi.nc''. They can be renamed and used as start files to initialize a new simulation.&lt;br /&gt;
&lt;br /&gt;
We have prepared a simple tutorial to learn how to modify ''start.nc'' and ''startfi.nc'' files (= the the initial conditions) for the Generic PCM: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Modify_start_Files&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
&lt;br /&gt;
The start2archive tool is similar to newstart in the sense that it can be used to modify the start files. But start2archive can modify the resolution of the physical grid, the topography and the surface thermal inertia while newstart cannot. It is also useful to create an archive of different starting states, then extractable as start files.&lt;br /&gt;
The command line to compile start2archive is similar to the one used for newstart:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 start2archive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To modify the resolution, you should first create a start_archive (by using start2archive) file at the used resolution, then compile a newstart file at the new resolution. Newstart will interpolate all the physical quantities on the new grid.&lt;br /&gt;
&lt;br /&gt;
=== other third party scripts and tools ===&lt;br /&gt;
&lt;br /&gt;
You can easily modify start.nc and startfi.nc netcdf files with the xarray Python library. Below you can find an easy example where we modify the surface temperature field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from    numpy import *&lt;br /&gt;
import  numpy                 as        np&lt;br /&gt;
import  matplotlib.pyplot     as        mpl&lt;br /&gt;
import  math&lt;br /&gt;
import xarray as xr&lt;br /&gt;
&lt;br /&gt;
#FIRST WE GET THE DATA FROM THE GCM SIMULATION&lt;br /&gt;
nc = xr.open_dataset('startfi.nc',decode_times=False) # can be any netcdf file (e.g. start/startfi.nc files)&lt;br /&gt;
&lt;br /&gt;
# BELOW PHYSICAL VARIABLES&lt;br /&gt;
physical_points=nc['physical_points']&lt;br /&gt;
lat=nc['latitude']&lt;br /&gt;
lon=nc['longitude']&lt;br /&gt;
aire_GCM=nc['area']&lt;br /&gt;
&lt;br /&gt;
# BELOW THE VARIABLE WE WANT TO UPDATE&lt;br /&gt;
tsurf=nc['tsurf']&lt;br /&gt;
new_tsurf = np.empty(len(physical_points))&lt;br /&gt;
&lt;br /&gt;
# LOOP TO MODIFY THE VARIABLE&lt;br /&gt;
for i in range(0,len(physical_points),1):&lt;br /&gt;
    new_tsurf[i]=300. # here you put whatever you want ; in this exemple, we assume an isothermal temperature distribution&lt;br /&gt;
&lt;br /&gt;
nc['tsurf'].values = new_tsurf&lt;br /&gt;
nc.to_netcdf('restartfi.nc')&lt;br /&gt;
&lt;br /&gt;
# SANITY CHECK PLOTS&lt;br /&gt;
&lt;br /&gt;
fig = mpl.figure(1)&lt;br /&gt;
mpl.plot(physical_points,tsurf)&lt;br /&gt;
mpl.plot(physical_points,new_tsurf)&lt;br /&gt;
mpl.xlabel('GCM Physical Points')&lt;br /&gt;
mpl.ylabel('Tsurf (K)')&lt;br /&gt;
mpl.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Post-processing tools ==&lt;br /&gt;
=== zrecast ===&lt;br /&gt;
&lt;br /&gt;
With this program you can recast atmospheric (i.e.: 4D-dimentional longitude-latitude-altitude-time) data from&lt;br /&gt;
GCM outputs (e.g. as given in diagfi.nc files) onto either ''pressure'' or ''altitude'' above ''areoid vertical'' coordinates.&lt;br /&gt;
Since integrating the hydrostatic equation is required to recast the data, the input file must contain surface pressure&lt;br /&gt;
and atmospheric temperature, as well as the ground geopotential.&lt;br /&gt;
If recasting data onto ''pressure'' coordinates, then the output file name is given by the input file name to which ''_P.nc'' will be appened. If recasting data onto altitude above areoid coordinates, then a ''_A.nc'' will be appened.&lt;br /&gt;
&lt;br /&gt;
=== mass stream function ===&lt;br /&gt;
&lt;br /&gt;
The mass stream function (and the total angular momentum) can be computed from a diagfi.nc or a stats.nc, using the '''streamfunction.F90''' script. The script is located at&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trunk/LMDZ.GENERIC/utilities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the script, open the ''compile'' file in the same directory and do the following:&lt;br /&gt;
* Replace &amp;quot;pgf90&amp;quot; with your favorite fortran compiler &lt;br /&gt;
* replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/lib&amp;quot; with the lib address and directory that contains your NetCDF library (file ''libnetcdf.a'').&lt;br /&gt;
* Replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/include&amp;quot; with the address of the directory that contains the NetCDF include file (''netcdf.inc'').&lt;br /&gt;
* You can mess with the compiling options but it is not mandatory.&lt;br /&gt;
&lt;br /&gt;
Once the script is compiled, copy it in the same directory as your '''.nc''' file and run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./streamfunction.e&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will ask you for the name of your '''.nc''' file, and will run and produce a new '''nameofyourfile_stream.nc''' file.&lt;br /&gt;
&lt;br /&gt;
'''Be careful''' : In this new file, all fields are temporally and zonally averaged.&lt;br /&gt;
&lt;br /&gt;
If you want to use '''python''' instead of '''fortran''', you can take a look at this [https://github.com/aymeric-spiga/dynanalysis repo]. It hosts a tool to perform dynamical analysis of GCM simulations (and therefore, it computes the mass stream function and a lot of other stuff), but it is tailored for Dynamico only. This repo also takes care of recasting (it does the job of both ''zrecast.F90'' and ''streamfunction.F90'')&lt;br /&gt;
&lt;br /&gt;
== Continuing Simulations ==&lt;br /&gt;
&lt;br /&gt;
=== manually ===&lt;br /&gt;
&lt;br /&gt;
At the end of a simulation, the model generates restart files (files 'restart.nc' and 'restartfi.nc') which contain the final state of the model. The 'restart.nc' and 'restartfi.nc' files have the same format as the 'start.nc' and 'startfi.nc' files, respectively. &lt;br /&gt;
&lt;br /&gt;
These files can in fact be used as initial states to continue the simulation, using the following renaming command lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mv restart.nc start.nc&lt;br /&gt;
mv restartfi.nc startfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running a simulation with these start files will in fact resume the simulation from where the previous run ended.&lt;br /&gt;
&lt;br /&gt;
=== with bash scripts ===&lt;br /&gt;
&lt;br /&gt;
We have set up very simple bash scripts to automatize the launching of chain simulations. Here is an example of bash script that does the job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
###########################################################################&lt;br /&gt;
# Script to perform several chained LMD Mars GCM simulations&lt;br /&gt;
# SET HERE the maximum total number of simulations&lt;br /&gt;
&lt;br /&gt;
nummax=100&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;STARTING LOOP RUN&amp;quot;&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
dir=`pwd`&lt;br /&gt;
machine=`hostname`&lt;br /&gt;
address=`whoami`&lt;br /&gt;
&lt;br /&gt;
# Look for file &amp;quot;num_run&amp;quot; which should contain &lt;br /&gt;
# the value of the previously computed season&lt;br /&gt;
# (defaults to 0 if file &amp;quot;num_run&amp;quot; does not exist)&lt;br /&gt;
if [[ -r num_run ]] ; then&lt;br /&gt;
  echo &amp;quot;found file num_run&amp;quot;&lt;br /&gt;
  numold=`cat num_run`&lt;br /&gt;
else&lt;br /&gt;
  numold=0&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;numold is set to&amp;quot; ${numold}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set value of current season &lt;br /&gt;
(( numnew = ${numold} + 1 ))&lt;br /&gt;
echo &amp;quot;numnew is set to&amp;quot; ${numnew}&lt;br /&gt;
&lt;br /&gt;
# Look for initialization data files (exit if none found)&lt;br /&gt;
if [[ ( -r start${numold}.nc  &amp;amp;&amp;amp;  -r startfi${numold}.nc ) ]] ; then&lt;br /&gt;
   \cp -f start${numold}.nc start.nc&lt;br /&gt;
   \cp -f startfi${numold}.nc startfi.nc&lt;br /&gt;
else&lt;br /&gt;
   if (( ${numold} == 99999 )) ; then&lt;br /&gt;
    echo &amp;quot;No run because previous run crashed ! (99999 in num_run)&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
   else&lt;br /&gt;
   echo &amp;quot;Where is file start&amp;quot;${numold}&amp;quot;.nc??&amp;quot;&lt;br /&gt;
   exit&lt;br /&gt;
   fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Run GCM -- THIS LINE NEEDS TO BE MODIFIED WITH THE CORRECT GCM EXECUTION COMMAND&lt;br /&gt;
mpirun -np 8 gcm_64x48x26_phystd_para.e &amp;lt; diagfi.def &amp;gt; lrun${numnew}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Check if run ended normaly and copy datafiles&lt;br /&gt;
if [[ ( -r restartfi.nc  &amp;amp;&amp;amp;  -r restart.nc ) ]] ; then&lt;br /&gt;
  echo &amp;quot;Run seems to have ended normaly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  \mv -f restart.nc start${numnew}.nc&lt;br /&gt;
  \mv -f restartfi.nc startfi${numnew}.nc  &lt;br /&gt;
    &lt;br /&gt;
else&lt;br /&gt;
  if [[ -r num_run ]] ; then&lt;br /&gt;
    \mv -f num_run num_run.crash&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;No file num_run to build num_run.crash from !!&amp;quot;&lt;br /&gt;
    # Impose a default value of 0 for num_run&lt;br /&gt;
    echo 0 &amp;gt; num_run.crash&lt;br /&gt;
  fi&lt;br /&gt;
 echo 99999 &amp;gt; num_run&lt;br /&gt;
 exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Copy other datafiles that may have been generated&lt;br /&gt;
if [[ -r diagfi.nc ]] ; then&lt;br /&gt;
  \mv -f diagfi.nc diagfi${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r diagsoil.nc ]] ; then&lt;br /&gt;
  \mv -f diagsoil.nc diagsoil${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r stats.nc ]] ; then&lt;br /&gt;
  \mv -f stats.nc stats${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -f profiles.dat ]] ; then&lt;br /&gt;
  \mv -f profiles.dat profiles${numnew}.dat&lt;br /&gt;
  \mv -f profiles.hdr profiles${numnew}.hdr&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Prepare things for upcoming runs by writing&lt;br /&gt;
# value of computed season in file num_run&lt;br /&gt;
echo ${numnew} &amp;gt; num_run&lt;br /&gt;
&lt;br /&gt;
# If we are over nummax : stop&lt;br /&gt;
if (( $numnew + 1 &amp;gt; $nummax )) ; then&lt;br /&gt;
   exit&lt;br /&gt;
# If not : restart the loop (copy the executable and run the copy)&lt;br /&gt;
else&lt;br /&gt;
   \cp -f run_gnome exe_mars&lt;br /&gt;
   ./exe_mars&lt;br /&gt;
fi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Summary of what this bash script does''':&lt;br /&gt;
&lt;br /&gt;
* It reads the file 'num_run' which contains the step of the simulation. &lt;br /&gt;
If num_run is&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
then the script expects to read start5.nc and startfi5.nc.&lt;br /&gt;
* It modifies start5.nc and startfi5.nc into start.nc and startfi.nc, respectively.&lt;br /&gt;
* It runs the GCM.&lt;br /&gt;
* It modifies restart.nc and restartfi.nc into start6.nc and startfi6.nc&lt;br /&gt;
* It rewrite num_run as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It restarts the loop until num_run reaches the value (defined in nummax):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Printing the code version of a program ==&lt;br /&gt;
&lt;br /&gt;
Details about compilation and code version (SVN or Git) are embedded in the executable file. This feature helps track code builds and their exact compilation context directly from the executable.&lt;br /&gt;
Use the command-line option &amp;quot;--version [file]&amp;quot; when running your program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./myprogram.e --version [file]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will write compilation and version details into the specified [file]. If [file] is omitted, the default name &amp;quot;pgrm_version_details.txt&amp;quot; will be used. The file contains compilation details, the version control information (SVN or Git), the status and the diff result if applicable, for the sub-folders of your trunk.&lt;br /&gt;
&lt;br /&gt;
This feature is available for every program of the Mars model, the Generic model and the PEM. If you want to extend it to other models, please add the following code section at the beginning of your main programs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
! Parse command-line options&lt;br /&gt;
call parse_args()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't forget to add the required module as well:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
use parse_args_mod, only: parse_args&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing Output Files with NCOs ==&lt;br /&gt;
&lt;br /&gt;
NCOs (NetCdf OperatorS) are a set of powerful command-line utilities – available on Linux, Mac and PC – that allow to perform useful (and very fast!) post-processing operations on netCDF GCM output files. Full documentation can be found on http://research.jisao.washington.edu/data_sets/nco/, but we provide below a few examples of command lines.&lt;br /&gt;
&lt;br /&gt;
* How to calculate a time mean of a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncra -F -d Time,1,,1 diagfi.nc diagfi_MEAN.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Subsetting time in a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncea -F -d Time,first,last diagfi.nc diagfi_subset.nc # format is &amp;quot;-d dimension,minimum,maximum&amp;quot; ; we recall you can type &amp;quot;ncdump -v time diagfi.nc&amp;quot; to see the Time values in the netCDF file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Decimating a netCDF 'diagfi.nc' file in time&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -F -d Time,1,,8 diagfi.nc diagfi_decimated.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot; ; In this example, this means that data is extracted 1 time every 8 time steps, starting from the first time step (number 1), ending at the last time step).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Extract a variable from a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -v tsurf,temp,p diagfi.nc diagfi_out.nc # Here we created a new file named 'diagfi_out.nc' in which we only kept variables named 'tsurf' (surface temperatures), 'temp' (atmospheric temperatures) and p (atmospheric pressures).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, more examples can be found on http://research.jisao.washington.edu/data_sets/nco/ .&lt;br /&gt;
&lt;br /&gt;
== Data Handling and Visualization Software ==&lt;br /&gt;
&lt;br /&gt;
There are several data handling and visualization tools that can be used to analyse and plot the results from GCM simulations (using the diagfi.nc NetCDF files). We provide below a panorama of most widely used solutions.&lt;br /&gt;
&lt;br /&gt;
=== panoply ===&lt;br /&gt;
Panoply is a user-friendly tool for viewing raw NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/ . It is very convenient to make pretty visuals (see an example for the exoplanet TRAPPIST-1e). There are many options that can be used (map projections, masks, colorbars, shadows, etc.) to make your plots fancy. However, the tool is not very well suited for manipulating data (compute averages, statistics, etc.).&lt;br /&gt;
&lt;br /&gt;
* Installation on Linux:&lt;br /&gt;
You simply need to download and untar the Package from the Panoply website. Note that to work it requires that Java and related Java Runtime environment (JRE) be installed on your system (otherwise it will simply look as if &amp;quot;nothing is happening&amp;quot; when you try to launch Panoply via the &amp;quot;panoply.sh&amp;quot; script), which on Ubuntu simply requires something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install java&lt;br /&gt;
sudo apt install default-jre&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run on Linux (assuming the panoply.sh script is in a directory included in your PATH environment variable):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
panoply.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example panoply.png|thumb|Screenshot of panoply showing here Generic PCM results for the exoplanet TRAPPIST-1e (surface temperatures)]]&lt;br /&gt;
&lt;br /&gt;
=== ncview ===&lt;br /&gt;
ncview is another useful user-friendly tool for viewing raw NetCDF data. This is kind of a very archaic version of panoply, but it is convenient because it allows to have a very quick first look at netCDF data files.&lt;br /&gt;
&lt;br /&gt;
Command line tool to visualize NetCDF data:&lt;br /&gt;
* Installation on Linux-Ubuntu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ncview&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run on Linux:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncview diagfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example ncview.png|thumb|Screenshot of ncview showing here Generic PCM results for the exoplanet Proxima b (OLR - Thermal Emission)]]&lt;br /&gt;
&lt;br /&gt;
=== python scripts ===&lt;br /&gt;
&lt;br /&gt;
Python scripts provide a very useful mean to analyse and visualize netCDF files.&lt;br /&gt;
&lt;br /&gt;
==== NETCDF4 python library (old school) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can use the netCDF4 python library to open a netCDF file and put data in tables that can then be manipulated and plotted.&lt;br /&gt;
&lt;br /&gt;
Here is an exemple of how to open and read a netCDF file with Python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
from netCDF4 import Dataset&lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
nc = Dataset('diagfi.nc')&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=nc.variables['Time'][:]&lt;br /&gt;
lat=nc.variables['latitude'][:]&lt;br /&gt;
lon=nc.variables['longitude'][:]&lt;br /&gt;
al=nc.variables['altitude'][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=nc.variables['aire'][:][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=nc.variables['tsurf'][:][:][:] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=nc.variables['temp'][:][:][:][:] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is an exemple of how to manipulate the netCDF data (here to compute the time averaged surface temperatures):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
from numpy import *&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
mean_tsurf=np.zeros((len(lat),len(lon)),dtype='f')&lt;br /&gt;
&lt;br /&gt;
for i in range(0,len(Time)):&lt;br /&gt;
    for j in range(0,len(lat)):&lt;br /&gt;
        for k in range(0,len(lon)):&lt;br /&gt;
            mean_tsurf[j,k]=mean_tsurf[j,k]+tsurf[i,j,k]*(1./len(Time))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is a last exemple of how to plot the data (using matplotlib):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.contourf(lon_GCM,lat_GCM,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== XARRAY python library (more modern) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another useful library to deal with netcdf files is ''xarray''. We provide a code snippet below, doing the same thing as the snippets above.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import xarray as xr &lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
data = xr.open_dataset('diagfi.nc',&lt;br /&gt;
                       decode_times=False)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=data['Time']&lt;br /&gt;
lat=data['latitude']&lt;br /&gt;
lon=data['longitude']&lt;br /&gt;
al=data['altitude']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=data['aire']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=data['tsurf'] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=data['temp'] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
## let's take the time-averaged surface temperature&lt;br /&gt;
mean_tsurf = np.mean(tsurf,axis=0)&lt;br /&gt;
&lt;br /&gt;
##Let's plot a lon-lat map&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
plt.contourf(lon,lat,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't hesitate to use the function called ''.values'' to transform any ''xarray'' into a numpy array, especially in case of calculation time problems. &lt;br /&gt;
For more examples on how to use ''xarray'', take a look at the [https://docs.xarray.dev/en/stable/index.html documentation]. &lt;br /&gt;
Here is another example of how one can use xarray with multiples netcdfiles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
# your folder where output files are stored&lt;br /&gt;
FOLDER = './your_folder_with_output_files/'&lt;br /&gt;
&lt;br /&gt;
# take back the files from your FOLDER&lt;br /&gt;
list_files_folder=os.listdir(FOLDER)&lt;br /&gt;
&lt;br /&gt;
# If there are several files.&lt;br /&gt;
# Sort your simulation files by date,&lt;br /&gt;
# so beginning of simulation will be top of the list&lt;br /&gt;
# and end of simulation will be end of the list.&lt;br /&gt;
list_files_folder.sort()&lt;br /&gt;
&lt;br /&gt;
files = [FOLDER+str(f) for f in list_files_folder]&lt;br /&gt;
# if you want to keep only files of special_year you can add this option :&lt;br /&gt;
# files = [FOLDER+str(f) for f in list_files_folder if f.startswith(&amp;quot;special_year&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
# xarray will magically concatenate your outfiles by 'Time' (or any other 'concat_dime' you want)&lt;br /&gt;
nc=xr.open_mfdataset(files,decode_times=False, concat_dim='Time', combine='nested')&lt;br /&gt;
&lt;br /&gt;
# to check your keys&lt;br /&gt;
for key in nc.keys():&lt;br /&gt;
    print(key)&lt;br /&gt;
&lt;br /&gt;
# to load keys (example here with keys for a mesoscale simulation)&lt;br /&gt;
Times = nc['Times'][:]&lt;br /&gt;
PTOT = nc['PTOT'][:]&lt;br /&gt;
T = nc['T'][:]&lt;br /&gt;
W = nc['W'][:]&lt;br /&gt;
&lt;br /&gt;
# you can use some functions to make averages etc&lt;br /&gt;
&lt;br /&gt;
T_moy = T.mean(dim=['Time','south_north','west_east'])&lt;br /&gt;
&lt;br /&gt;
# other functions&lt;br /&gt;
# .cumsum (cumulative sum)&lt;br /&gt;
# .rename (change the name of the object)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One cool thing about xarray is that it is well optimized, and can do whatever you want to do on your data, but better than you. See for instance, the example below to plot a temperature lon-lat map. Xarray handles it in 5 lines of code, where you would need a lot more to set-up you plot in traditional matplotlib. And the results look almost good enough for a paper plot. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
##Load your data and print it &lt;br /&gt;
file = '/home/lteinturier/Documents/PhD/wasp43b/chemistry_project/input_5xsolar.nc'&lt;br /&gt;
data = xr.open_dataset(file,decode_times=False)&lt;br /&gt;
print(data)&lt;br /&gt;
##extracting the altitude level #20 for the whole file&lt;br /&gt;
data = data.isel(altitude=20)&lt;br /&gt;
##let's assume that data hold a time-series of the temperature. Let's average it in time&lt;br /&gt;
temp = data['temp'].mean(&amp;quot;Time&amp;quot;,keep_attrs=True) #we keep the attribute when averaging to conserve the DataArray structure&lt;br /&gt;
##now we plot &lt;br /&gt;
fig = temp.plot.contourf(cmap='gnuplot',levels=50) #choose the colormap and the number of contourf levels &lt;br /&gt;
fig.ax.set_title(&amp;quot;P = {:.2e} mbar&amp;quot;.format(data.p.mean().values)) ##set-up your title. If you don't change it, the title will be the altitude in km of your atmospheric level&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This is only a fraction of what Xarray can do. Check the [https://docs.xarray.dev/en/stable/user-guide/index.html documentation] for more.&lt;br /&gt;
&lt;br /&gt;
==== Python tutorials to make pretty visuals ====&lt;br /&gt;
&lt;br /&gt;
We provide a tutorial on how to make pretty visuals using Generic PCM 3-D simulations [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Plots_With_PyVista here].&lt;br /&gt;
&lt;br /&gt;
=== Planetoplot ===&lt;br /&gt;
&lt;br /&gt;
Planetoplot is a in-house, python based library developped to vizualize Generic PCM data.&lt;br /&gt;
&lt;br /&gt;
The code and documentation can be found at: https://nbviewer.org/github/aymeric-spiga/planetoplot/blob/master/tutorial/planetoplot_tutorial.ipynb&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Generic-LMDZ]]&lt;br /&gt;
[[Category:Generic-DYNAMICO]]&lt;br /&gt;
[[Category:Generic-WRF]]&lt;br /&gt;
[[Category:Generic-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2774</id>
		<title>Tool Box</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2774"/>
				<updated>2025-07-07T13:00:04Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pre-processing Tools ==&lt;br /&gt;
=== newstart: a fortran program to modify start files ===&lt;br /&gt;
&lt;br /&gt;
Newstart is an interactive tool to modify the start files (''start.nc'' and ''startfi.nc''). &lt;br /&gt;
&lt;br /&gt;
To be usable, ''newstart'' should be compile in the ''LMDZ.COMMON'' directory by using the following command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 newstart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the example, my_arch_file is the name the arch files (see [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_Target_Architecture_(%22arch%22)_Files arch] ) and 64x48x30 is the resolution of the physical grid.&lt;br /&gt;
Then copy the executable from the ''LMDZ.COMMON/bin'' directory to your bench directory.&lt;br /&gt;
&lt;br /&gt;
When you execute newstart, you can use both a ''start2archive'' file or the start files (''start.nc'' and ''startfi.nc''). Then the interactive interface will propose to modify several physical quantities such as the gravity, the surface pressure or the rotation of the planet. At the end of the procedure, two files are created: '' '''re'''start.nc'' and '' '''re'''startfi.nc''. They can be renamed and used as start files to initialize a new simulation.&lt;br /&gt;
&lt;br /&gt;
We have prepared a simple tutorial to learn how to modify ''start.nc'' and ''startfi.nc'' files (= the the initial conditions) for the Generic PCM: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Modify_start_Files&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
&lt;br /&gt;
The start2archive tool is similar to newstart in the sense that it can be used to modify the start files. But start2archive can modify the resolution of the physical grid, the topography and the surface thermal inertia while newstart cannot. It is also useful to create an archive of different starting states, then extractable as start files.&lt;br /&gt;
The command line to compile start2archive is similar to the one used for newstart:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 start2archive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To modify the resolution, you should first create a start_archive (by using start2archive) file at the used resolution, then compile a newstart file at the new resolution. Newstart will interpolate all the physical quantities on the new grid.&lt;br /&gt;
&lt;br /&gt;
=== other third party scripts and tools ===&lt;br /&gt;
&lt;br /&gt;
You can easily modify start.nc and startfi.nc netcdf files with the xarray Python library. Below you can find an easy example where we modify the surface temperature field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from    numpy import *&lt;br /&gt;
import  numpy                 as        np&lt;br /&gt;
import  matplotlib.pyplot     as        mpl&lt;br /&gt;
import  math&lt;br /&gt;
import xarray as xr&lt;br /&gt;
&lt;br /&gt;
#FIRST WE GET THE DATA FROM THE GCM SIMULATION&lt;br /&gt;
nc = xr.open_dataset('startfi.nc',decode_times=False) # can be any netcdf file (e.g. start/startfi.nc files)&lt;br /&gt;
&lt;br /&gt;
# BELOW PHYSICAL VARIABLES&lt;br /&gt;
physical_points=nc['physical_points']&lt;br /&gt;
lat=nc['latitude']&lt;br /&gt;
lon=nc['longitude']&lt;br /&gt;
aire_GCM=nc['area']&lt;br /&gt;
&lt;br /&gt;
# BELOW THE VARIABLE WE WANT TO UPDATE&lt;br /&gt;
tsurf=nc['tsurf']&lt;br /&gt;
new_tsurf = np.empty(len(physical_points))&lt;br /&gt;
&lt;br /&gt;
# LOOP TO MODIFY THE VARIABLE&lt;br /&gt;
for i in range(0,len(physical_points),1):&lt;br /&gt;
    new_tsurf[i]=300. # here you put whatever you want ; in this exemple, we assume an isothermal temperature distribution&lt;br /&gt;
&lt;br /&gt;
nc['tsurf'].values = new_tsurf&lt;br /&gt;
nc.to_netcdf('restartfi.nc')&lt;br /&gt;
&lt;br /&gt;
# SANITY CHECK PLOTS&lt;br /&gt;
&lt;br /&gt;
fig = mpl.figure(1)&lt;br /&gt;
mpl.plot(physical_points,tsurf)&lt;br /&gt;
mpl.plot(physical_points,new_tsurf)&lt;br /&gt;
mpl.xlabel('GCM Physical Points')&lt;br /&gt;
mpl.ylabel('Tsurf (K)')&lt;br /&gt;
mpl.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Post-processing tools ==&lt;br /&gt;
=== zrecast ===&lt;br /&gt;
&lt;br /&gt;
With this program you can recast atmospheric (i.e.: 4D-dimentional longitude-latitude-altitude-time) data from&lt;br /&gt;
GCM outputs (e.g. as given in diagfi.nc files) onto either ''pressure'' or ''altitude'' above ''areoid vertical'' coordinates.&lt;br /&gt;
Since integrating the hydrostatic equation is required to recast the data, the input file must contain surface pressure&lt;br /&gt;
and atmospheric temperature, as well as the ground geopotential.&lt;br /&gt;
If recasting data onto ''pressure'' coordinates, then the output file name is given by the input file name to which ''_P.nc'' will be appened. If recasting data onto altitude above areoid coordinates, then a ''_A.nc'' will be appened.&lt;br /&gt;
&lt;br /&gt;
=== mass stream function ===&lt;br /&gt;
&lt;br /&gt;
The mass stream function (and the total angular momentum) can be computed from a diagfi.nc or a stats.nc, using the '''streamfunction.F90''' script. The script is located at&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trunk/LMDZ.GENERIC/utilities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the script, open the ''compile'' file in the same directory and do the following:&lt;br /&gt;
* Replace &amp;quot;pgf90&amp;quot; with your favorite fortran compiler &lt;br /&gt;
* replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/lib&amp;quot; with the lib address and directory that contains your NetCDF library (file ''libnetcdf.a'').&lt;br /&gt;
* Replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/include&amp;quot; with the address of the directory that contains the NetCDF include file (''netcdf.inc'').&lt;br /&gt;
* You can mess with the compiling options but it is not mandatory.&lt;br /&gt;
&lt;br /&gt;
Once the script is compiled, copy it in the same directory as your '''.nc''' file and run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./streamfunction.e&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will ask you for the name of your '''.nc''' file, and will run and produce a new '''nameofyourfile_stream.nc''' file.&lt;br /&gt;
&lt;br /&gt;
'''Be careful''' : In this new file, all fields are temporally and zonally averaged.&lt;br /&gt;
&lt;br /&gt;
If you want to use '''python''' instead of '''fortran''', you can take a look at this [https://github.com/aymeric-spiga/dynanalysis repo]. It hosts a tool to perform dynamical analysis of GCM simulations (and therefore, it computes the mass stream function and a lot of other stuff), but it is tailored for Dynamico only. This repo also takes care of recasting (it does the job of both ''zrecast.F90'' and ''streamfunction.F90'')&lt;br /&gt;
&lt;br /&gt;
== Continuing Simulations ==&lt;br /&gt;
&lt;br /&gt;
=== manually ===&lt;br /&gt;
&lt;br /&gt;
At the end of a simulation, the model generates restart files (files 'restart.nc' and 'restartfi.nc') which contain the final state of the model. The 'restart.nc' and 'restartfi.nc' files have the same format as the 'start.nc' and 'startfi.nc' files, respectively. &lt;br /&gt;
&lt;br /&gt;
These files can in fact be used as initial states to continue the simulation, using the following renaming command lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mv restart.nc start.nc&lt;br /&gt;
mv restartfi.nc startfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running a simulation with these start files will in fact resume the simulation from where the previous run ended.&lt;br /&gt;
&lt;br /&gt;
=== with bash scripts ===&lt;br /&gt;
&lt;br /&gt;
We have set up very simple bash scripts to automatize the launching of chain simulations. Here is an example of bash script that does the job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
###########################################################################&lt;br /&gt;
# Script to perform several chained LMD Mars GCM simulations&lt;br /&gt;
# SET HERE the maximum total number of simulations&lt;br /&gt;
&lt;br /&gt;
nummax=100&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;STARTING LOOP RUN&amp;quot;&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
dir=`pwd`&lt;br /&gt;
machine=`hostname`&lt;br /&gt;
address=`whoami`&lt;br /&gt;
&lt;br /&gt;
# Look for file &amp;quot;num_run&amp;quot; which should contain &lt;br /&gt;
# the value of the previously computed season&lt;br /&gt;
# (defaults to 0 if file &amp;quot;num_run&amp;quot; does not exist)&lt;br /&gt;
if [[ -r num_run ]] ; then&lt;br /&gt;
  echo &amp;quot;found file num_run&amp;quot;&lt;br /&gt;
  numold=`cat num_run`&lt;br /&gt;
else&lt;br /&gt;
  numold=0&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;numold is set to&amp;quot; ${numold}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set value of current season &lt;br /&gt;
(( numnew = ${numold} + 1 ))&lt;br /&gt;
echo &amp;quot;numnew is set to&amp;quot; ${numnew}&lt;br /&gt;
&lt;br /&gt;
# Look for initialization data files (exit if none found)&lt;br /&gt;
if [[ ( -r start${numold}.nc  &amp;amp;&amp;amp;  -r startfi${numold}.nc ) ]] ; then&lt;br /&gt;
   \cp -f start${numold}.nc start.nc&lt;br /&gt;
   \cp -f startfi${numold}.nc startfi.nc&lt;br /&gt;
else&lt;br /&gt;
   if (( ${numold} == 99999 )) ; then&lt;br /&gt;
    echo &amp;quot;No run because previous run crashed ! (99999 in num_run)&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
   else&lt;br /&gt;
   echo &amp;quot;Where is file start&amp;quot;${numold}&amp;quot;.nc??&amp;quot;&lt;br /&gt;
   exit&lt;br /&gt;
   fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Run GCM -- THIS LINE NEEDS TO BE MODIFIED WITH THE CORRECT GCM EXECUTION COMMAND&lt;br /&gt;
mpirun -np 8 gcm_64x48x26_phystd_para.e &amp;lt; diagfi.def &amp;gt; lrun${numnew}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Check if run ended normaly and copy datafiles&lt;br /&gt;
if [[ ( -r restartfi.nc  &amp;amp;&amp;amp;  -r restart.nc ) ]] ; then&lt;br /&gt;
  echo &amp;quot;Run seems to have ended normaly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  \mv -f restart.nc start${numnew}.nc&lt;br /&gt;
  \mv -f restartfi.nc startfi${numnew}.nc  &lt;br /&gt;
    &lt;br /&gt;
else&lt;br /&gt;
  if [[ -r num_run ]] ; then&lt;br /&gt;
    \mv -f num_run num_run.crash&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;No file num_run to build num_run.crash from !!&amp;quot;&lt;br /&gt;
    # Impose a default value of 0 for num_run&lt;br /&gt;
    echo 0 &amp;gt; num_run.crash&lt;br /&gt;
  fi&lt;br /&gt;
 echo 99999 &amp;gt; num_run&lt;br /&gt;
 exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Copy other datafiles that may have been generated&lt;br /&gt;
if [[ -r diagfi.nc ]] ; then&lt;br /&gt;
  \mv -f diagfi.nc diagfi${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r diagsoil.nc ]] ; then&lt;br /&gt;
  \mv -f diagsoil.nc diagsoil${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r stats.nc ]] ; then&lt;br /&gt;
  \mv -f stats.nc stats${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -f profiles.dat ]] ; then&lt;br /&gt;
  \mv -f profiles.dat profiles${numnew}.dat&lt;br /&gt;
  \mv -f profiles.hdr profiles${numnew}.hdr&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Prepare things for upcoming runs by writing&lt;br /&gt;
# value of computed season in file num_run&lt;br /&gt;
echo ${numnew} &amp;gt; num_run&lt;br /&gt;
&lt;br /&gt;
# If we are over nummax : stop&lt;br /&gt;
if (( $numnew + 1 &amp;gt; $nummax )) ; then&lt;br /&gt;
   exit&lt;br /&gt;
# If not : restart the loop (copy the executable and run the copy)&lt;br /&gt;
else&lt;br /&gt;
   \cp -f run_gnome exe_mars&lt;br /&gt;
   ./exe_mars&lt;br /&gt;
fi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Summary of what this bash script does''':&lt;br /&gt;
&lt;br /&gt;
* It reads the file 'num_run' which contains the step of the simulation. &lt;br /&gt;
If num_run is&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
then the script expects to read start5.nc and startfi5.nc.&lt;br /&gt;
* It modifies start5.nc and startfi5.nc into start.nc and startfi.nc, respectively.&lt;br /&gt;
* It runs the GCM.&lt;br /&gt;
* It modifies restart.nc and restartfi.nc into start6.nc and startfi6.nc&lt;br /&gt;
* It rewrite num_run as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It restarts the loop until num_run reaches the value (defined in nummax):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Printing the code version of a program ==&lt;br /&gt;
&lt;br /&gt;
Details about compilation and code version (SVN or Git) are embedded in the executable file. This feature helps track code builds and their exact compilation context directly from the executable.&lt;br /&gt;
Use the command-line option &amp;quot;--version [file]&amp;quot; when running your program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./myprogram.e --version [file]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will write compilation and version details into the specified [file]. If [file] is omitted, the default name &amp;quot;pgrm_version_details.txt&amp;quot; will be used. The file contains compilation details, the version control information (SVN or Git), the status and the diff result if applicable, for the sub-folders of your trunk.&lt;br /&gt;
&lt;br /&gt;
This feature is available for every program of the Mars model, the Generic model and the PEM. If you want to extend it to other models, please add the following code section at the beginning of your main programs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
! Parse command-line options&lt;br /&gt;
call parse_args()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't forget to add the module as well:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
use parse_args_mod, only: parse_args&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing Output Files with NCOs ==&lt;br /&gt;
&lt;br /&gt;
NCOs (NetCdf OperatorS) are a set of powerful command-line utilities – available on Linux, Mac and PC – that allow to perform useful (and very fast!) post-processing operations on netCDF GCM output files. Full documentation can be found on http://research.jisao.washington.edu/data_sets/nco/, but we provide below a few examples of command lines.&lt;br /&gt;
&lt;br /&gt;
* How to calculate a time mean of a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncra -F -d Time,1,,1 diagfi.nc diagfi_MEAN.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Subsetting time in a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncea -F -d Time,first,last diagfi.nc diagfi_subset.nc # format is &amp;quot;-d dimension,minimum,maximum&amp;quot; ; we recall you can type &amp;quot;ncdump -v time diagfi.nc&amp;quot; to see the Time values in the netCDF file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Decimating a netCDF 'diagfi.nc' file in time&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -F -d Time,1,,8 diagfi.nc diagfi_decimated.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot; ; In this example, this means that data is extracted 1 time every 8 time steps, starting from the first time step (number 1), ending at the last time step).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Extract a variable from a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -v tsurf,temp,p diagfi.nc diagfi_out.nc # Here we created a new file named 'diagfi_out.nc' in which we only kept variables named 'tsurf' (surface temperatures), 'temp' (atmospheric temperatures) and p (atmospheric pressures).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, more examples can be found on http://research.jisao.washington.edu/data_sets/nco/ .&lt;br /&gt;
&lt;br /&gt;
== Data Handling and Visualization Software ==&lt;br /&gt;
&lt;br /&gt;
There are several data handling and visualization tools that can be used to analyse and plot the results from GCM simulations (using the diagfi.nc NetCDF files). We provide below a panorama of most widely used solutions.&lt;br /&gt;
&lt;br /&gt;
=== panoply ===&lt;br /&gt;
Panoply is a user-friendly tool for viewing raw NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/ . It is very convenient to make pretty visuals (see an example for the exoplanet TRAPPIST-1e). There are many options that can be used (map projections, masks, colorbars, shadows, etc.) to make your plots fancy. However, the tool is not very well suited for manipulating data (compute averages, statistics, etc.).&lt;br /&gt;
&lt;br /&gt;
* Installation on Linux:&lt;br /&gt;
You simply need to download and untar the Package from the Panoply website. Note that to work it requires that Java and related Java Runtime environment (JRE) be installed on your system (otherwise it will simply look as if &amp;quot;nothing is happening&amp;quot; when you try to launch Panoply via the &amp;quot;panoply.sh&amp;quot; script), which on Ubuntu simply requires something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install java&lt;br /&gt;
sudo apt install default-jre&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run on Linux (assuming the panoply.sh script is in a directory included in your PATH environment variable):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
panoply.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example panoply.png|thumb|Screenshot of panoply showing here Generic PCM results for the exoplanet TRAPPIST-1e (surface temperatures)]]&lt;br /&gt;
&lt;br /&gt;
=== ncview ===&lt;br /&gt;
ncview is another useful user-friendly tool for viewing raw NetCDF data. This is kind of a very archaic version of panoply, but it is convenient because it allows to have a very quick first look at netCDF data files.&lt;br /&gt;
&lt;br /&gt;
Command line tool to visualize NetCDF data:&lt;br /&gt;
* Installation on Linux-Ubuntu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ncview&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run on Linux:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncview diagfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example ncview.png|thumb|Screenshot of ncview showing here Generic PCM results for the exoplanet Proxima b (OLR - Thermal Emission)]]&lt;br /&gt;
&lt;br /&gt;
=== python scripts ===&lt;br /&gt;
&lt;br /&gt;
Python scripts provide a very useful mean to analyse and visualize netCDF files.&lt;br /&gt;
&lt;br /&gt;
==== NETCDF4 python library (old school) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can use the netCDF4 python library to open a netCDF file and put data in tables that can then be manipulated and plotted.&lt;br /&gt;
&lt;br /&gt;
Here is an exemple of how to open and read a netCDF file with Python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
from netCDF4 import Dataset&lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
nc = Dataset('diagfi.nc')&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=nc.variables['Time'][:]&lt;br /&gt;
lat=nc.variables['latitude'][:]&lt;br /&gt;
lon=nc.variables['longitude'][:]&lt;br /&gt;
al=nc.variables['altitude'][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=nc.variables['aire'][:][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=nc.variables['tsurf'][:][:][:] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=nc.variables['temp'][:][:][:][:] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is an exemple of how to manipulate the netCDF data (here to compute the time averaged surface temperatures):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
from numpy import *&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
mean_tsurf=np.zeros((len(lat),len(lon)),dtype='f')&lt;br /&gt;
&lt;br /&gt;
for i in range(0,len(Time)):&lt;br /&gt;
    for j in range(0,len(lat)):&lt;br /&gt;
        for k in range(0,len(lon)):&lt;br /&gt;
            mean_tsurf[j,k]=mean_tsurf[j,k]+tsurf[i,j,k]*(1./len(Time))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is a last exemple of how to plot the data (using matplotlib):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.contourf(lon_GCM,lat_GCM,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== XARRAY python library (more modern) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another useful library to deal with netcdf files is ''xarray''. We provide a code snippet below, doing the same thing as the snippets above.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import xarray as xr &lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
data = xr.open_dataset('diagfi.nc',&lt;br /&gt;
                       decode_times=False)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=data['Time']&lt;br /&gt;
lat=data['latitude']&lt;br /&gt;
lon=data['longitude']&lt;br /&gt;
al=data['altitude']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=data['aire']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=data['tsurf'] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=data['temp'] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
## let's take the time-averaged surface temperature&lt;br /&gt;
mean_tsurf = np.mean(tsurf,axis=0)&lt;br /&gt;
&lt;br /&gt;
##Let's plot a lon-lat map&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
plt.contourf(lon,lat,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't hesitate to use the function called ''.values'' to transform any ''xarray'' into a numpy array, especially in case of calculation time problems. &lt;br /&gt;
For more examples on how to use ''xarray'', take a look at the [https://docs.xarray.dev/en/stable/index.html documentation]. &lt;br /&gt;
Here is another example of how one can use xarray with multiples netcdfiles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
# your folder where output files are stored&lt;br /&gt;
FOLDER = './your_folder_with_output_files/'&lt;br /&gt;
&lt;br /&gt;
# take back the files from your FOLDER&lt;br /&gt;
list_files_folder=os.listdir(FOLDER)&lt;br /&gt;
&lt;br /&gt;
# If there are several files.&lt;br /&gt;
# Sort your simulation files by date,&lt;br /&gt;
# so beginning of simulation will be top of the list&lt;br /&gt;
# and end of simulation will be end of the list.&lt;br /&gt;
list_files_folder.sort()&lt;br /&gt;
&lt;br /&gt;
files = [FOLDER+str(f) for f in list_files_folder]&lt;br /&gt;
# if you want to keep only files of special_year you can add this option :&lt;br /&gt;
# files = [FOLDER+str(f) for f in list_files_folder if f.startswith(&amp;quot;special_year&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
# xarray will magically concatenate your outfiles by 'Time' (or any other 'concat_dime' you want)&lt;br /&gt;
nc=xr.open_mfdataset(files,decode_times=False, concat_dim='Time', combine='nested')&lt;br /&gt;
&lt;br /&gt;
# to check your keys&lt;br /&gt;
for key in nc.keys():&lt;br /&gt;
    print(key)&lt;br /&gt;
&lt;br /&gt;
# to load keys (example here with keys for a mesoscale simulation)&lt;br /&gt;
Times = nc['Times'][:]&lt;br /&gt;
PTOT = nc['PTOT'][:]&lt;br /&gt;
T = nc['T'][:]&lt;br /&gt;
W = nc['W'][:]&lt;br /&gt;
&lt;br /&gt;
# you can use some functions to make averages etc&lt;br /&gt;
&lt;br /&gt;
T_moy = T.mean(dim=['Time','south_north','west_east'])&lt;br /&gt;
&lt;br /&gt;
# other functions&lt;br /&gt;
# .cumsum (cumulative sum)&lt;br /&gt;
# .rename (change the name of the object)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One cool thing about xarray is that it is well optimized, and can do whatever you want to do on your data, but better than you. See for instance, the example below to plot a temperature lon-lat map. Xarray handles it in 5 lines of code, where you would need a lot more to set-up you plot in traditional matplotlib. And the results look almost good enough for a paper plot. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
##Load your data and print it &lt;br /&gt;
file = '/home/lteinturier/Documents/PhD/wasp43b/chemistry_project/input_5xsolar.nc'&lt;br /&gt;
data = xr.open_dataset(file,decode_times=False)&lt;br /&gt;
print(data)&lt;br /&gt;
##extracting the altitude level #20 for the whole file&lt;br /&gt;
data = data.isel(altitude=20)&lt;br /&gt;
##let's assume that data hold a time-series of the temperature. Let's average it in time&lt;br /&gt;
temp = data['temp'].mean(&amp;quot;Time&amp;quot;,keep_attrs=True) #we keep the attribute when averaging to conserve the DataArray structure&lt;br /&gt;
##now we plot &lt;br /&gt;
fig = temp.plot.contourf(cmap='gnuplot',levels=50) #choose the colormap and the number of contourf levels &lt;br /&gt;
fig.ax.set_title(&amp;quot;P = {:.2e} mbar&amp;quot;.format(data.p.mean().values)) ##set-up your title. If you don't change it, the title will be the altitude in km of your atmospheric level&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This is only a fraction of what Xarray can do. Check the [https://docs.xarray.dev/en/stable/user-guide/index.html documentation] for more.&lt;br /&gt;
&lt;br /&gt;
==== Python tutorials to make pretty visuals ====&lt;br /&gt;
&lt;br /&gt;
We provide a tutorial on how to make pretty visuals using Generic PCM 3-D simulations [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Plots_With_PyVista here].&lt;br /&gt;
&lt;br /&gt;
=== Planetoplot ===&lt;br /&gt;
&lt;br /&gt;
Planetoplot is a in-house, python based library developped to vizualize Generic PCM data.&lt;br /&gt;
&lt;br /&gt;
The code and documentation can be found at: https://nbviewer.org/github/aymeric-spiga/planetoplot/blob/master/tutorial/planetoplot_tutorial.ipynb&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Generic-LMDZ]]&lt;br /&gt;
[[Category:Generic-DYNAMICO]]&lt;br /&gt;
[[Category:Generic-WRF]]&lt;br /&gt;
[[Category:Generic-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2773</id>
		<title>Tool Box</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2773"/>
				<updated>2025-07-07T12:57:54Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: Update about version argument for programs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pre-processing Tools ==&lt;br /&gt;
=== newstart: a fortran program to modify start files ===&lt;br /&gt;
&lt;br /&gt;
Newstart is an interactive tool to modify the start files (''start.nc'' and ''startfi.nc''). &lt;br /&gt;
&lt;br /&gt;
To be usable, ''newstart'' should be compile in the ''LMDZ.COMMON'' directory by using the following command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 newstart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the example, my_arch_file is the name the arch files (see [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_Target_Architecture_(%22arch%22)_Files arch] ) and 64x48x30 is the resolution of the physical grid.&lt;br /&gt;
Then copy the executable from the ''LMDZ.COMMON/bin'' directory to your bench directory.&lt;br /&gt;
&lt;br /&gt;
When you execute newstart, you can use both a ''start2archive'' file or the start files (''start.nc'' and ''startfi.nc''). Then the interactive interface will propose to modify several physical quantities such as the gravity, the surface pressure or the rotation of the planet. At the end of the procedure, two files are created: '' '''re'''start.nc'' and '' '''re'''startfi.nc''. They can be renamed and used as start files to initialize a new simulation.&lt;br /&gt;
&lt;br /&gt;
We have prepared a simple tutorial to learn how to modify ''start.nc'' and ''startfi.nc'' files (= the the initial conditions) for the Generic PCM: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Modify_start_Files&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
&lt;br /&gt;
The start2archive tool is similar to newstart in the sense that it can be used to modify the start files. But start2archive can modify the resolution of the physical grid, the topography and the surface thermal inertia while newstart cannot. It is also useful to create an archive of different starting states, then extractable as start files.&lt;br /&gt;
The command line to compile start2archive is similar to the one used for newstart:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 start2archive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To modify the resolution, you should first create a start_archive (by using start2archive) file at the used resolution, then compile a newstart file at the new resolution. Newstart will interpolate all the physical quantities on the new grid.&lt;br /&gt;
&lt;br /&gt;
=== other third party scripts and tools ===&lt;br /&gt;
&lt;br /&gt;
You can easily modify start.nc and startfi.nc netcdf files with the xarray Python library. Below you can find an easy example where we modify the surface temperature field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from    numpy import *&lt;br /&gt;
import  numpy                 as        np&lt;br /&gt;
import  matplotlib.pyplot     as        mpl&lt;br /&gt;
import  math&lt;br /&gt;
import xarray as xr&lt;br /&gt;
&lt;br /&gt;
#FIRST WE GET THE DATA FROM THE GCM SIMULATION&lt;br /&gt;
nc = xr.open_dataset('startfi.nc',decode_times=False) # can be any netcdf file (e.g. start/startfi.nc files)&lt;br /&gt;
&lt;br /&gt;
# BELOW PHYSICAL VARIABLES&lt;br /&gt;
physical_points=nc['physical_points']&lt;br /&gt;
lat=nc['latitude']&lt;br /&gt;
lon=nc['longitude']&lt;br /&gt;
aire_GCM=nc['area']&lt;br /&gt;
&lt;br /&gt;
# BELOW THE VARIABLE WE WANT TO UPDATE&lt;br /&gt;
tsurf=nc['tsurf']&lt;br /&gt;
new_tsurf = np.empty(len(physical_points))&lt;br /&gt;
&lt;br /&gt;
# LOOP TO MODIFY THE VARIABLE&lt;br /&gt;
for i in range(0,len(physical_points),1):&lt;br /&gt;
    new_tsurf[i]=300. # here you put whatever you want ; in this exemple, we assume an isothermal temperature distribution&lt;br /&gt;
&lt;br /&gt;
nc['tsurf'].values = new_tsurf&lt;br /&gt;
nc.to_netcdf('restartfi.nc')&lt;br /&gt;
&lt;br /&gt;
# SANITY CHECK PLOTS&lt;br /&gt;
&lt;br /&gt;
fig = mpl.figure(1)&lt;br /&gt;
mpl.plot(physical_points,tsurf)&lt;br /&gt;
mpl.plot(physical_points,new_tsurf)&lt;br /&gt;
mpl.xlabel('GCM Physical Points')&lt;br /&gt;
mpl.ylabel('Tsurf (K)')&lt;br /&gt;
mpl.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Post-processing tools ==&lt;br /&gt;
=== zrecast ===&lt;br /&gt;
&lt;br /&gt;
With this program you can recast atmospheric (i.e.: 4D-dimentional longitude-latitude-altitude-time) data from&lt;br /&gt;
GCM outputs (e.g. as given in diagfi.nc files) onto either ''pressure'' or ''altitude'' above ''areoid vertical'' coordinates.&lt;br /&gt;
Since integrating the hydrostatic equation is required to recast the data, the input file must contain surface pressure&lt;br /&gt;
and atmospheric temperature, as well as the ground geopotential.&lt;br /&gt;
If recasting data onto ''pressure'' coordinates, then the output file name is given by the input file name to which ''_P.nc'' will be appened. If recasting data onto altitude above areoid coordinates, then a ''_A.nc'' will be appened.&lt;br /&gt;
&lt;br /&gt;
=== mass stream function ===&lt;br /&gt;
&lt;br /&gt;
The mass stream function (and the total angular momentum) can be computed from a diagfi.nc or a stats.nc, using the '''streamfunction.F90''' script. The script is located at&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trunk/LMDZ.GENERIC/utilities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the script, open the ''compile'' file in the same directory and do the following:&lt;br /&gt;
* Replace &amp;quot;pgf90&amp;quot; with your favorite fortran compiler &lt;br /&gt;
* replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/lib&amp;quot; with the lib address and directory that contains your NetCDF library (file ''libnetcdf.a'').&lt;br /&gt;
* Replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/include&amp;quot; with the address of the directory that contains the NetCDF include file (''netcdf.inc'').&lt;br /&gt;
* You can mess with the compiling options but it is not mandatory.&lt;br /&gt;
&lt;br /&gt;
Once the script is compiled, copy it in the same directory as your '''.nc''' file and run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./streamfunction.e&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will ask you for the name of your '''.nc''' file, and will run and produce a new '''nameofyourfile_stream.nc''' file.&lt;br /&gt;
&lt;br /&gt;
'''Be careful''' : In this new file, all fields are temporally and zonally averaged.&lt;br /&gt;
&lt;br /&gt;
If you want to use '''python''' instead of '''fortran''', you can take a look at this [https://github.com/aymeric-spiga/dynanalysis repo]. It hosts a tool to perform dynamical analysis of GCM simulations (and therefore, it computes the mass stream function and a lot of other stuff), but it is tailored for Dynamico only. This repo also takes care of recasting (it does the job of both ''zrecast.F90'' and ''streamfunction.F90'')&lt;br /&gt;
&lt;br /&gt;
== Continuing Simulations ==&lt;br /&gt;
&lt;br /&gt;
=== manually ===&lt;br /&gt;
&lt;br /&gt;
At the end of a simulation, the model generates restart files (files 'restart.nc' and 'restartfi.nc') which contain the final state of the model. The 'restart.nc' and 'restartfi.nc' files have the same format as the 'start.nc' and 'startfi.nc' files, respectively. &lt;br /&gt;
&lt;br /&gt;
These files can in fact be used as initial states to continue the simulation, using the following renaming command lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mv restart.nc start.nc&lt;br /&gt;
mv restartfi.nc startfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running a simulation with these start files will in fact resume the simulation from where the previous run ended.&lt;br /&gt;
&lt;br /&gt;
=== with bash scripts ===&lt;br /&gt;
&lt;br /&gt;
We have set up very simple bash scripts to automatize the launching of chain simulations. Here is an example of bash script that does the job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
###########################################################################&lt;br /&gt;
# Script to perform several chained LMD Mars GCM simulations&lt;br /&gt;
# SET HERE the maximum total number of simulations&lt;br /&gt;
&lt;br /&gt;
nummax=100&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;STARTING LOOP RUN&amp;quot;&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
dir=`pwd`&lt;br /&gt;
machine=`hostname`&lt;br /&gt;
address=`whoami`&lt;br /&gt;
&lt;br /&gt;
# Look for file &amp;quot;num_run&amp;quot; which should contain &lt;br /&gt;
# the value of the previously computed season&lt;br /&gt;
# (defaults to 0 if file &amp;quot;num_run&amp;quot; does not exist)&lt;br /&gt;
if [[ -r num_run ]] ; then&lt;br /&gt;
  echo &amp;quot;found file num_run&amp;quot;&lt;br /&gt;
  numold=`cat num_run`&lt;br /&gt;
else&lt;br /&gt;
  numold=0&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;numold is set to&amp;quot; ${numold}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set value of current season &lt;br /&gt;
(( numnew = ${numold} + 1 ))&lt;br /&gt;
echo &amp;quot;numnew is set to&amp;quot; ${numnew}&lt;br /&gt;
&lt;br /&gt;
# Look for initialization data files (exit if none found)&lt;br /&gt;
if [[ ( -r start${numold}.nc  &amp;amp;&amp;amp;  -r startfi${numold}.nc ) ]] ; then&lt;br /&gt;
   \cp -f start${numold}.nc start.nc&lt;br /&gt;
   \cp -f startfi${numold}.nc startfi.nc&lt;br /&gt;
else&lt;br /&gt;
   if (( ${numold} == 99999 )) ; then&lt;br /&gt;
    echo &amp;quot;No run because previous run crashed ! (99999 in num_run)&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
   else&lt;br /&gt;
   echo &amp;quot;Where is file start&amp;quot;${numold}&amp;quot;.nc??&amp;quot;&lt;br /&gt;
   exit&lt;br /&gt;
   fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Run GCM -- THIS LINE NEEDS TO BE MODIFIED WITH THE CORRECT GCM EXECUTION COMMAND&lt;br /&gt;
mpirun -np 8 gcm_64x48x26_phystd_para.e &amp;lt; diagfi.def &amp;gt; lrun${numnew}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Check if run ended normaly and copy datafiles&lt;br /&gt;
if [[ ( -r restartfi.nc  &amp;amp;&amp;amp;  -r restart.nc ) ]] ; then&lt;br /&gt;
  echo &amp;quot;Run seems to have ended normaly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  \mv -f restart.nc start${numnew}.nc&lt;br /&gt;
  \mv -f restartfi.nc startfi${numnew}.nc  &lt;br /&gt;
    &lt;br /&gt;
else&lt;br /&gt;
  if [[ -r num_run ]] ; then&lt;br /&gt;
    \mv -f num_run num_run.crash&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;No file num_run to build num_run.crash from !!&amp;quot;&lt;br /&gt;
    # Impose a default value of 0 for num_run&lt;br /&gt;
    echo 0 &amp;gt; num_run.crash&lt;br /&gt;
  fi&lt;br /&gt;
 echo 99999 &amp;gt; num_run&lt;br /&gt;
 exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Copy other datafiles that may have been generated&lt;br /&gt;
if [[ -r diagfi.nc ]] ; then&lt;br /&gt;
  \mv -f diagfi.nc diagfi${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r diagsoil.nc ]] ; then&lt;br /&gt;
  \mv -f diagsoil.nc diagsoil${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r stats.nc ]] ; then&lt;br /&gt;
  \mv -f stats.nc stats${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -f profiles.dat ]] ; then&lt;br /&gt;
  \mv -f profiles.dat profiles${numnew}.dat&lt;br /&gt;
  \mv -f profiles.hdr profiles${numnew}.hdr&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Prepare things for upcoming runs by writing&lt;br /&gt;
# value of computed season in file num_run&lt;br /&gt;
echo ${numnew} &amp;gt; num_run&lt;br /&gt;
&lt;br /&gt;
# If we are over nummax : stop&lt;br /&gt;
if (( $numnew + 1 &amp;gt; $nummax )) ; then&lt;br /&gt;
   exit&lt;br /&gt;
# If not : restart the loop (copy the executable and run the copy)&lt;br /&gt;
else&lt;br /&gt;
   \cp -f run_gnome exe_mars&lt;br /&gt;
   ./exe_mars&lt;br /&gt;
fi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Summary of what this bash script does''':&lt;br /&gt;
&lt;br /&gt;
* It reads the file 'num_run' which contains the step of the simulation. &lt;br /&gt;
If num_run is&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
then the script expects to read start5.nc and startfi5.nc.&lt;br /&gt;
* It modifies start5.nc and startfi5.nc into start.nc and startfi.nc, respectively.&lt;br /&gt;
* It runs the GCM.&lt;br /&gt;
* It modifies restart.nc and restartfi.nc into start6.nc and startfi6.nc&lt;br /&gt;
* It rewrite num_run as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It restarts the loop until num_run reaches the value (defined in nummax):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Identifying the code version of an executable file ==&lt;br /&gt;
&lt;br /&gt;
Details about compilation and code version (SVN or Git) are embedded in the executable file. This feature helps track code builds and their exact compilation context directly from the executable.&lt;br /&gt;
Use the command-line option &amp;quot;--version [file]&amp;quot; when running your program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./myprogram.e --version [file]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will write compilation and version details into the specified [file]. If [file] is omitted, the default name &amp;quot;pgrm_version_details.txt&amp;quot; will be used. The file contains compilation details, the version control information (SVN or Git), the status and the diff result if applicable, for the sub-folders of your trunk.&lt;br /&gt;
&lt;br /&gt;
This feature is available for every program of the Mars model, the Generic model and the PEM. If you want to extend it to other models, please add the following code section at the beginning of your main programs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
! Parse command-line options&lt;br /&gt;
call parse_args()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't forget to add the module as well:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
use parse_args_mod, only: parse_args&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing Output Files with NCOs ==&lt;br /&gt;
&lt;br /&gt;
NCOs (NetCdf OperatorS) are a set of powerful command-line utilities – available on Linux, Mac and PC – that allow to perform useful (and very fast!) post-processing operations on netCDF GCM output files. Full documentation can be found on http://research.jisao.washington.edu/data_sets/nco/, but we provide below a few examples of command lines.&lt;br /&gt;
&lt;br /&gt;
* How to calculate a time mean of a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncra -F -d Time,1,,1 diagfi.nc diagfi_MEAN.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Subsetting time in a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncea -F -d Time,first,last diagfi.nc diagfi_subset.nc # format is &amp;quot;-d dimension,minimum,maximum&amp;quot; ; we recall you can type &amp;quot;ncdump -v time diagfi.nc&amp;quot; to see the Time values in the netCDF file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Decimating a netCDF 'diagfi.nc' file in time&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -F -d Time,1,,8 diagfi.nc diagfi_decimated.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot; ; In this example, this means that data is extracted 1 time every 8 time steps, starting from the first time step (number 1), ending at the last time step).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Extract a variable from a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -v tsurf,temp,p diagfi.nc diagfi_out.nc # Here we created a new file named 'diagfi_out.nc' in which we only kept variables named 'tsurf' (surface temperatures), 'temp' (atmospheric temperatures) and p (atmospheric pressures).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, more examples can be found on http://research.jisao.washington.edu/data_sets/nco/ .&lt;br /&gt;
&lt;br /&gt;
== Data Handling and Visualization Software ==&lt;br /&gt;
&lt;br /&gt;
There are several data handling and visualization tools that can be used to analyse and plot the results from GCM simulations (using the diagfi.nc NetCDF files). We provide below a panorama of most widely used solutions.&lt;br /&gt;
&lt;br /&gt;
=== panoply ===&lt;br /&gt;
Panoply is a user-friendly tool for viewing raw NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/ . It is very convenient to make pretty visuals (see an example for the exoplanet TRAPPIST-1e). There are many options that can be used (map projections, masks, colorbars, shadows, etc.) to make your plots fancy. However, the tool is not very well suited for manipulating data (compute averages, statistics, etc.).&lt;br /&gt;
&lt;br /&gt;
* Installation on Linux:&lt;br /&gt;
You simply need to download and untar the Package from the Panoply website. Note that to work it requires that Java and related Java Runtime environment (JRE) be installed on your system (otherwise it will simply look as if &amp;quot;nothing is happening&amp;quot; when you try to launch Panoply via the &amp;quot;panoply.sh&amp;quot; script), which on Ubuntu simply requires something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install java&lt;br /&gt;
sudo apt install default-jre&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run on Linux (assuming the panoply.sh script is in a directory included in your PATH environment variable):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
panoply.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example panoply.png|thumb|Screenshot of panoply showing here Generic PCM results for the exoplanet TRAPPIST-1e (surface temperatures)]]&lt;br /&gt;
&lt;br /&gt;
=== ncview ===&lt;br /&gt;
ncview is another useful user-friendly tool for viewing raw NetCDF data. This is kind of a very archaic version of panoply, but it is convenient because it allows to have a very quick first look at netCDF data files.&lt;br /&gt;
&lt;br /&gt;
Command line tool to visualize NetCDF data:&lt;br /&gt;
* Installation on Linux-Ubuntu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ncview&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run on Linux:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncview diagfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example ncview.png|thumb|Screenshot of ncview showing here Generic PCM results for the exoplanet Proxima b (OLR - Thermal Emission)]]&lt;br /&gt;
&lt;br /&gt;
=== python scripts ===&lt;br /&gt;
&lt;br /&gt;
Python scripts provide a very useful mean to analyse and visualize netCDF files.&lt;br /&gt;
&lt;br /&gt;
==== NETCDF4 python library (old school) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can use the netCDF4 python library to open a netCDF file and put data in tables that can then be manipulated and plotted.&lt;br /&gt;
&lt;br /&gt;
Here is an exemple of how to open and read a netCDF file with Python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
from netCDF4 import Dataset&lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
nc = Dataset('diagfi.nc')&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=nc.variables['Time'][:]&lt;br /&gt;
lat=nc.variables['latitude'][:]&lt;br /&gt;
lon=nc.variables['longitude'][:]&lt;br /&gt;
al=nc.variables['altitude'][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=nc.variables['aire'][:][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=nc.variables['tsurf'][:][:][:] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=nc.variables['temp'][:][:][:][:] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is an exemple of how to manipulate the netCDF data (here to compute the time averaged surface temperatures):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
from numpy import *&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
mean_tsurf=np.zeros((len(lat),len(lon)),dtype='f')&lt;br /&gt;
&lt;br /&gt;
for i in range(0,len(Time)):&lt;br /&gt;
    for j in range(0,len(lat)):&lt;br /&gt;
        for k in range(0,len(lon)):&lt;br /&gt;
            mean_tsurf[j,k]=mean_tsurf[j,k]+tsurf[i,j,k]*(1./len(Time))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is a last exemple of how to plot the data (using matplotlib):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.contourf(lon_GCM,lat_GCM,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== XARRAY python library (more modern) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another useful library to deal with netcdf files is ''xarray''. We provide a code snippet below, doing the same thing as the snippets above.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import xarray as xr &lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
data = xr.open_dataset('diagfi.nc',&lt;br /&gt;
                       decode_times=False)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=data['Time']&lt;br /&gt;
lat=data['latitude']&lt;br /&gt;
lon=data['longitude']&lt;br /&gt;
al=data['altitude']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=data['aire']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=data['tsurf'] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=data['temp'] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
## let's take the time-averaged surface temperature&lt;br /&gt;
mean_tsurf = np.mean(tsurf,axis=0)&lt;br /&gt;
&lt;br /&gt;
##Let's plot a lon-lat map&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
plt.contourf(lon,lat,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't hesitate to use the function called ''.values'' to transform any ''xarray'' into a numpy array, especially in case of calculation time problems. &lt;br /&gt;
For more examples on how to use ''xarray'', take a look at the [https://docs.xarray.dev/en/stable/index.html documentation]. &lt;br /&gt;
Here is another example of how one can use xarray with multiples netcdfiles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
# your folder where output files are stored&lt;br /&gt;
FOLDER = './your_folder_with_output_files/'&lt;br /&gt;
&lt;br /&gt;
# take back the files from your FOLDER&lt;br /&gt;
list_files_folder=os.listdir(FOLDER)&lt;br /&gt;
&lt;br /&gt;
# If there are several files.&lt;br /&gt;
# Sort your simulation files by date,&lt;br /&gt;
# so beginning of simulation will be top of the list&lt;br /&gt;
# and end of simulation will be end of the list.&lt;br /&gt;
list_files_folder.sort()&lt;br /&gt;
&lt;br /&gt;
files = [FOLDER+str(f) for f in list_files_folder]&lt;br /&gt;
# if you want to keep only files of special_year you can add this option :&lt;br /&gt;
# files = [FOLDER+str(f) for f in list_files_folder if f.startswith(&amp;quot;special_year&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
# xarray will magically concatenate your outfiles by 'Time' (or any other 'concat_dime' you want)&lt;br /&gt;
nc=xr.open_mfdataset(files,decode_times=False, concat_dim='Time', combine='nested')&lt;br /&gt;
&lt;br /&gt;
# to check your keys&lt;br /&gt;
for key in nc.keys():&lt;br /&gt;
    print(key)&lt;br /&gt;
&lt;br /&gt;
# to load keys (example here with keys for a mesoscale simulation)&lt;br /&gt;
Times = nc['Times'][:]&lt;br /&gt;
PTOT = nc['PTOT'][:]&lt;br /&gt;
T = nc['T'][:]&lt;br /&gt;
W = nc['W'][:]&lt;br /&gt;
&lt;br /&gt;
# you can use some functions to make averages etc&lt;br /&gt;
&lt;br /&gt;
T_moy = T.mean(dim=['Time','south_north','west_east'])&lt;br /&gt;
&lt;br /&gt;
# other functions&lt;br /&gt;
# .cumsum (cumulative sum)&lt;br /&gt;
# .rename (change the name of the object)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One cool thing about xarray is that it is well optimized, and can do whatever you want to do on your data, but better than you. See for instance, the example below to plot a temperature lon-lat map. Xarray handles it in 5 lines of code, where you would need a lot more to set-up you plot in traditional matplotlib. And the results look almost good enough for a paper plot. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
##Load your data and print it &lt;br /&gt;
file = '/home/lteinturier/Documents/PhD/wasp43b/chemistry_project/input_5xsolar.nc'&lt;br /&gt;
data = xr.open_dataset(file,decode_times=False)&lt;br /&gt;
print(data)&lt;br /&gt;
##extracting the altitude level #20 for the whole file&lt;br /&gt;
data = data.isel(altitude=20)&lt;br /&gt;
##let's assume that data hold a time-series of the temperature. Let's average it in time&lt;br /&gt;
temp = data['temp'].mean(&amp;quot;Time&amp;quot;,keep_attrs=True) #we keep the attribute when averaging to conserve the DataArray structure&lt;br /&gt;
##now we plot &lt;br /&gt;
fig = temp.plot.contourf(cmap='gnuplot',levels=50) #choose the colormap and the number of contourf levels &lt;br /&gt;
fig.ax.set_title(&amp;quot;P = {:.2e} mbar&amp;quot;.format(data.p.mean().values)) ##set-up your title. If you don't change it, the title will be the altitude in km of your atmospheric level&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This is only a fraction of what Xarray can do. Check the [https://docs.xarray.dev/en/stable/user-guide/index.html documentation] for more.&lt;br /&gt;
&lt;br /&gt;
==== Python tutorials to make pretty visuals ====&lt;br /&gt;
&lt;br /&gt;
We provide a tutorial on how to make pretty visuals using Generic PCM 3-D simulations [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Plots_With_PyVista here].&lt;br /&gt;
&lt;br /&gt;
=== Planetoplot ===&lt;br /&gt;
&lt;br /&gt;
Planetoplot is a in-house, python based library developped to vizualize Generic PCM data.&lt;br /&gt;
&lt;br /&gt;
The code and documentation can be found at: https://nbviewer.org/github/aymeric-spiga/planetoplot/blob/master/tutorial/planetoplot_tutorial.ipynb&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Generic-LMDZ]]&lt;br /&gt;
[[Category:Generic-DYNAMICO]]&lt;br /&gt;
[[Category:Generic-WRF]]&lt;br /&gt;
[[Category:Generic-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2317</id>
		<title>Tool Box</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2317"/>
				<updated>2025-01-23T08:38:44Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Identifying the code version of an executable file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pre-processing Tools ==&lt;br /&gt;
=== newstart: a fortran program to modify start files ===&lt;br /&gt;
&lt;br /&gt;
Newstart is an interactive tool to modify the start files (''start.nc'' and ''startfi.nc''). &lt;br /&gt;
&lt;br /&gt;
To be usable, ''newstart'' should be compile in the ''LMDZ.COMMON'' directory by using the following command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 newstart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the example, my_arch_file is the name the arch files (see [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_Target_Architecture_(%22arch%22)_Files arch] ) and 64x48x30 is the resolution of the physical grid.&lt;br /&gt;
Then copy the executable from the ''LMDZ.COMMON/bin'' directory to your bench directory.&lt;br /&gt;
&lt;br /&gt;
When you execute newstart, you can use both a ''start2archive'' file or the start files (''start.nc'' and ''startfi.nc''). Then the interactive interface will propose to modify several physical quantities such as the gravity, the surface pressure or the rotation of the planet. At the end of the procedure, two files are created: '' '''re'''start.nc'' and '' '''re'''startfi.nc''. They can be renamed and used as start files to initialize a new simulation.&lt;br /&gt;
&lt;br /&gt;
We have prepared a simple tutorial to learn how to modify ''start.nc'' and ''startfi.nc'' files (= the the initial conditions) for the Generic PCM: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Modify_start_Files&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
&lt;br /&gt;
The start2archive tool is similar to newstart in the sense that it can be used to modify the start files. But start2archive can modify the resolution of the physical grid, the topography and the surface thermal inertia while newstart cannot. It is also useful to create an archive of different starting states, then extractable as start files.&lt;br /&gt;
The command line to compile start2archive is similar to the one used for newstart:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 start2archive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To modify the resolution, you should first create a start_archive (by using start2archive) file at the used resolution, then compile a newstart file at the new resolution. Newstart will interpolate all the physical quantities on the new grid.&lt;br /&gt;
&lt;br /&gt;
=== other third party scripts and tools ===&lt;br /&gt;
&lt;br /&gt;
You can easily modify start.nc and startfi.nc netcdf files with the xarray Python library. Below you can find an easy example where we modify the surface temperature field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from    numpy import *&lt;br /&gt;
import  numpy                 as        np&lt;br /&gt;
import  matplotlib.pyplot     as        mpl&lt;br /&gt;
import  math&lt;br /&gt;
import xarray as xr&lt;br /&gt;
&lt;br /&gt;
#FIRST WE GET THE DATA FROM THE GCM SIMULATION&lt;br /&gt;
nc = xr.open_dataset('startfi.nc',decode_times=False) # can be any netcdf file (e.g. start/startfi.nc files)&lt;br /&gt;
&lt;br /&gt;
# BELOW PHYSICAL VARIABLES&lt;br /&gt;
physical_points=nc['physical_points']&lt;br /&gt;
lat=nc['latitude']&lt;br /&gt;
lon=nc['longitude']&lt;br /&gt;
aire_GCM=nc['area']&lt;br /&gt;
&lt;br /&gt;
# BELOW THE VARIABLE WE WANT TO UPDATE&lt;br /&gt;
tsurf=nc['tsurf']&lt;br /&gt;
new_tsurf = np.empty(len(physical_points))&lt;br /&gt;
&lt;br /&gt;
# LOOP TO MODIFY THE VARIABLE&lt;br /&gt;
for i in range(0,len(physical_points),1):&lt;br /&gt;
    new_tsurf[i]=300. # here you put whatever you want ; in this exemple, we assume an isothermal temperature distribution&lt;br /&gt;
&lt;br /&gt;
nc['tsurf'].values = new_tsurf&lt;br /&gt;
nc.to_netcdf('restartfi.nc')&lt;br /&gt;
&lt;br /&gt;
# SANITY CHECK PLOTS&lt;br /&gt;
&lt;br /&gt;
fig = mpl.figure(1)&lt;br /&gt;
mpl.plot(physical_points,tsurf)&lt;br /&gt;
mpl.plot(physical_points,new_tsurf)&lt;br /&gt;
mpl.xlabel('GCM Physical Points')&lt;br /&gt;
mpl.ylabel('Tsurf (K)')&lt;br /&gt;
mpl.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Post-processing tools ==&lt;br /&gt;
=== zrecast ===&lt;br /&gt;
&lt;br /&gt;
With this program you can recast atmospheric (i.e.: 4D-dimentional longitude-latitude-altitude-time) data from&lt;br /&gt;
GCM outputs (e.g. as given in diagfi.nc files) onto either ''pressure'' or ''altitude'' above ''areoid vertical'' coordinates.&lt;br /&gt;
Since integrating the hydrostatic equation is required to recast the data, the input file must contain surface pressure&lt;br /&gt;
and atmospheric temperature, as well as the ground geopotential.&lt;br /&gt;
If recasting data onto ''pressure'' coordinates, then the output file name is given by the input file name to which ''_P.nc'' will be appened. If recasting data onto altitude above areoid coordinates, then a ''_A.nc'' will be appened.&lt;br /&gt;
&lt;br /&gt;
=== mass stream function ===&lt;br /&gt;
&lt;br /&gt;
The mass stream function (and the total angular momentum) can be computed from a diagfi.nc or a stats.nc, using the '''streamfunction.F90''' script. The script is located at&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trunk/LMDZ.GENERIC/utilities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the script, open the ''compile'' file in the same directory and do the following:&lt;br /&gt;
* Replace &amp;quot;pgf90&amp;quot; with your favorite fortran compiler &lt;br /&gt;
* replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/lib&amp;quot; with the lib address and directory that contains your NetCDF library (file ''libnetcdf.a'').&lt;br /&gt;
* Replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/include&amp;quot; with the address of the directory that contains the NetCDF include file (''netcdf.inc'').&lt;br /&gt;
* You can mess with the compiling options but it is not mandatory.&lt;br /&gt;
&lt;br /&gt;
Once the script is compiled, copy it in the same directory as your '''.nc''' file and run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./streamfunction.e&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will ask you for the name of your '''.nc''' file, and will run and produce a new '''nameofyourfile_stream.nc''' file.&lt;br /&gt;
&lt;br /&gt;
'''Be careful''' : In this new file, all fields are temporally and zonally averaged.&lt;br /&gt;
&lt;br /&gt;
If you want to use '''python''' instead of '''fortran''', you can take a look at this [https://github.com/aymeric-spiga/dynanalysis repo]. It hosts a tool to perform dynamical analysis of GCM simulations (and therefore, it computes the mass stream function and a lot of other stuff), but it is tailored for Dynamico only. This repo also takes care of recasting (it does the job of both ''zrecast.F90'' and ''streamfunction.F90'')&lt;br /&gt;
&lt;br /&gt;
== Continuing Simulations ==&lt;br /&gt;
&lt;br /&gt;
=== manually ===&lt;br /&gt;
&lt;br /&gt;
At the end of a simulation, the model generates restart files (files 'restart.nc' and 'restartfi.nc') which contain the final state of the model. The 'restart.nc' and 'restartfi.nc' files have the same format as the 'start.nc' and 'startfi.nc' files, respectively. &lt;br /&gt;
&lt;br /&gt;
These files can in fact be used as initial states to continue the simulation, using the following renaming command lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mv restart.nc start.nc&lt;br /&gt;
mv restartfi.nc startfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running a simulation with these start files will in fact resume the simulation from where the previous run ended.&lt;br /&gt;
&lt;br /&gt;
=== with bash scripts ===&lt;br /&gt;
&lt;br /&gt;
We have set up very simple bash scripts to automatize the launching of chain simulations. Here is an example of bash script that does the job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
###########################################################################&lt;br /&gt;
# Script to perform several chained LMD Mars GCM simulations&lt;br /&gt;
# SET HERE the maximum total number of simulations&lt;br /&gt;
&lt;br /&gt;
nummax=100&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;STARTING LOOP RUN&amp;quot;&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
dir=`pwd`&lt;br /&gt;
machine=`hostname`&lt;br /&gt;
address=`whoami`&lt;br /&gt;
&lt;br /&gt;
# Look for file &amp;quot;num_run&amp;quot; which should contain &lt;br /&gt;
# the value of the previously computed season&lt;br /&gt;
# (defaults to 0 if file &amp;quot;num_run&amp;quot; does not exist)&lt;br /&gt;
if [[ -r num_run ]] ; then&lt;br /&gt;
  echo &amp;quot;found file num_run&amp;quot;&lt;br /&gt;
  numold=`cat num_run`&lt;br /&gt;
else&lt;br /&gt;
  numold=0&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;numold is set to&amp;quot; ${numold}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set value of current season &lt;br /&gt;
(( numnew = ${numold} + 1 ))&lt;br /&gt;
echo &amp;quot;numnew is set to&amp;quot; ${numnew}&lt;br /&gt;
&lt;br /&gt;
# Look for initialization data files (exit if none found)&lt;br /&gt;
if [[ ( -r start${numold}.nc  &amp;amp;&amp;amp;  -r startfi${numold}.nc ) ]] ; then&lt;br /&gt;
   \cp -f start${numold}.nc start.nc&lt;br /&gt;
   \cp -f startfi${numold}.nc startfi.nc&lt;br /&gt;
else&lt;br /&gt;
   if (( ${numold} == 99999 )) ; then&lt;br /&gt;
    echo &amp;quot;No run because previous run crashed ! (99999 in num_run)&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
   else&lt;br /&gt;
   echo &amp;quot;Where is file start&amp;quot;${numold}&amp;quot;.nc??&amp;quot;&lt;br /&gt;
   exit&lt;br /&gt;
   fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Run GCM -- THIS LINE NEEDS TO BE MODIFIED WITH THE CORRECT GCM EXECUTION COMMAND&lt;br /&gt;
mpirun -np 8 gcm_64x48x26_phystd_para.e &amp;lt; diagfi.def &amp;gt; lrun${numnew}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Check if run ended normaly and copy datafiles&lt;br /&gt;
if [[ ( -r restartfi.nc  &amp;amp;&amp;amp;  -r restart.nc ) ]] ; then&lt;br /&gt;
  echo &amp;quot;Run seems to have ended normaly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  \mv -f restart.nc start${numnew}.nc&lt;br /&gt;
  \mv -f restartfi.nc startfi${numnew}.nc  &lt;br /&gt;
    &lt;br /&gt;
else&lt;br /&gt;
  if [[ -r num_run ]] ; then&lt;br /&gt;
    \mv -f num_run num_run.crash&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;No file num_run to build num_run.crash from !!&amp;quot;&lt;br /&gt;
    # Impose a default value of 0 for num_run&lt;br /&gt;
    echo 0 &amp;gt; num_run.crash&lt;br /&gt;
  fi&lt;br /&gt;
 echo 99999 &amp;gt; num_run&lt;br /&gt;
 exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Copy other datafiles that may have been generated&lt;br /&gt;
if [[ -r diagfi.nc ]] ; then&lt;br /&gt;
  \mv -f diagfi.nc diagfi${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r diagsoil.nc ]] ; then&lt;br /&gt;
  \mv -f diagsoil.nc diagsoil${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r stats.nc ]] ; then&lt;br /&gt;
  \mv -f stats.nc stats${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -f profiles.dat ]] ; then&lt;br /&gt;
  \mv -f profiles.dat profiles${numnew}.dat&lt;br /&gt;
  \mv -f profiles.hdr profiles${numnew}.hdr&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Prepare things for upcoming runs by writing&lt;br /&gt;
# value of computed season in file num_run&lt;br /&gt;
echo ${numnew} &amp;gt; num_run&lt;br /&gt;
&lt;br /&gt;
# If we are over nummax : stop&lt;br /&gt;
if (( $numnew + 1 &amp;gt; $nummax )) ; then&lt;br /&gt;
   exit&lt;br /&gt;
# If not : restart the loop (copy the executable and run the copy)&lt;br /&gt;
else&lt;br /&gt;
   \cp -f run_gnome exe_mars&lt;br /&gt;
   ./exe_mars&lt;br /&gt;
fi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Summary of what this bash script does''':&lt;br /&gt;
&lt;br /&gt;
* It reads the file 'num_run' which contains the step of the simulation. &lt;br /&gt;
If num_run is&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
then the script expects to read start5.nc and startfi5.nc.&lt;br /&gt;
* It modifies start5.nc and startfi5.nc into start.nc and startfi.nc, respectively.&lt;br /&gt;
* It runs the GCM.&lt;br /&gt;
* It modifies restart.nc and restartfi.nc into start6.nc and startfi6.nc&lt;br /&gt;
* It rewrite num_run as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It restarts the loop until num_run reaches the value (defined in nummax):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Identifying the code version of an executable file ==&lt;br /&gt;
&lt;br /&gt;
Details about compilation and code version (SVN or Git) are embedded in the executable file. To display these information, put the argument 'version' as an option when executing the code such as:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./executable.e version&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It shows in the terminal the date and the command of compilation as well as the version control information for the sub-folders of your trunk if applicable. In addition, it creates a file called &amp;quot;version_stat-diff.txt&amp;quot; containing the result of status and diff commands between the code repository and your local copy which produced the executable file.&lt;br /&gt;
&lt;br /&gt;
This feature is available for every program of the Mars model, the Generic model and the PEM. If you want to extend it to other models, please add the following code section at the beginning of your main programs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if (command_argument_count() &amp;gt; 0) then ! Get the number of command-line arguments&lt;br /&gt;
    call get_command_argument(1,arg) ! Read the argument given to the program&lt;br /&gt;
    select case (trim(adjustl(arg)))&lt;br /&gt;
        case('version')&lt;br /&gt;
            call print_version_info()&lt;br /&gt;
            stop&lt;br /&gt;
        case default&lt;br /&gt;
            error stop &amp;quot;The argument given to the program is unknown!&amp;quot;&lt;br /&gt;
    end select&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As well as the necessary declaration and module:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
use version_info_mod, only: print_version_info&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
character(100) :: arg ! To read command-line arguments&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing Output Files with NCOs ==&lt;br /&gt;
&lt;br /&gt;
NCOs (NetCdf OperatorS) are a set of powerful command-line utilities – available on Linux, Mac and PC – that allow to perform useful (and very fast!) post-processing operations on netCDF GCM output files. Full documentation can be found on http://research.jisao.washington.edu/data_sets/nco/, but we provide below a few examples of command lines.&lt;br /&gt;
&lt;br /&gt;
* How to calculate a time mean of a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncra -F -d Time,1,,1 diagfi.nc diagfi_MEAN.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Subsetting time in a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncea -F -d Time,first,last diagfi.nc diagfi_subset.nc # format is &amp;quot;-d dimension,minimum,maximum&amp;quot; ; we recall you can type &amp;quot;ncdump -v time diagfi.nc&amp;quot; to see the Time values in the netCDF file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Decimating a netCDF 'diagfi.nc' file in time&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -F -d Time,1,,8 diagfi.nc diagfi_decimated.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot; ; In this example, this means that data is extracted 1 time every 8 time steps, starting from the first time step (number 1), ending at the last time step).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Extract a variable from a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -v tsurf,temp,p diagfi.nc diagfi_out.nc # Here we created a new file named 'diagfi_out.nc' in which we only kept variables named 'tsurf' (surface temperatures), 'temp' (atmospheric temperatures) and p (atmospheric pressures).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, more examples can be found on http://research.jisao.washington.edu/data_sets/nco/ .&lt;br /&gt;
&lt;br /&gt;
== Data Handling and Visualization Software ==&lt;br /&gt;
&lt;br /&gt;
There are several data handling and visualization tools that can be used to analyse and plot the results from GCM simulations (using the diagfi.nc NetCDF files). We provide below a panorama of most widely used solutions.&lt;br /&gt;
&lt;br /&gt;
=== panoply ===&lt;br /&gt;
Panoply is a user-friendly tool for viewing raw NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/ . It is very convenient to make pretty visuals (see an example for the exoplanet TRAPPIST-1e). There are many options that can be used (map projections, masks, colorbars, shadows, etc.) to make your plots fancy. However, the tool is not very well suited for manipulating data (compute averages, statistics, etc.).&lt;br /&gt;
&lt;br /&gt;
* Installation on Linux:&lt;br /&gt;
You simply need to download and untar the Package from the Panoply website. Note that to work it requires that Java and related Java Runtime environment (JRE) be installed on your system (otherwise it will simply look as if &amp;quot;nothing is happening&amp;quot; when you try to launch Panoply via the &amp;quot;panoply.sh&amp;quot; script), which on Ubuntu simply requires something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install java&lt;br /&gt;
sudo apt install default-jre&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run on Linux (assuming the panoply.sh script is in a directory included in your PATH environment variable):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
panoply.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example panoply.png|thumb|Screenshot of panoply showing here Generic PCM results for the exoplanet TRAPPIST-1e (surface temperatures)]]&lt;br /&gt;
&lt;br /&gt;
=== ncview ===&lt;br /&gt;
ncview is another useful user-friendly tool for viewing raw NetCDF data. This is kind of a very archaic version of panoply, but it is convenient because it allows to have a very quick first look at netCDF data files.&lt;br /&gt;
&lt;br /&gt;
Command line tool to visualize NetCDF data:&lt;br /&gt;
* Installation on Linux-Ubuntu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ncview&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run on Linux:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncview diagfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example ncview.png|thumb|Screenshot of ncview showing here Generic PCM results for the exoplanet Proxima b (OLR - Thermal Emission)]]&lt;br /&gt;
&lt;br /&gt;
=== python scripts ===&lt;br /&gt;
&lt;br /&gt;
Python scripts provide a very useful mean to analyse and visualize netCDF files.&lt;br /&gt;
&lt;br /&gt;
==== NETCDF4 python library (old school) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can use the netCDF4 python library to open a netCDF file and put data in tables that can then be manipulated and plotted.&lt;br /&gt;
&lt;br /&gt;
Here is an exemple of how to open and read a netCDF file with Python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
from netCDF4 import Dataset&lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
nc = Dataset('diagfi.nc')&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=nc.variables['Time'][:]&lt;br /&gt;
lat=nc.variables['latitude'][:]&lt;br /&gt;
lon=nc.variables['longitude'][:]&lt;br /&gt;
al=nc.variables['altitude'][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=nc.variables['aire'][:][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=nc.variables['tsurf'][:][:][:] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=nc.variables['temp'][:][:][:][:] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is an exemple of how to manipulate the netCDF data (here to compute the time averaged surface temperatures):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
from numpy import *&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
mean_tsurf=np.zeros((len(lat),len(lon)),dtype='f')&lt;br /&gt;
&lt;br /&gt;
for i in range(0,len(Time)):&lt;br /&gt;
    for j in range(0,len(lat)):&lt;br /&gt;
        for k in range(0,len(lon)):&lt;br /&gt;
            mean_tsurf[j,k]=mean_tsurf[j,k]+tsurf[i,j,k]*(1./len(Time))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is a last exemple of how to plot the data (using matplotlib):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.contourf(lon_GCM,lat_GCM,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== XARRAY python library (more modern) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another useful library to deal with netcdf files is ''xarray''. We provide a code snippet below, doing the same thing as the snippets above.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import xarray as xr &lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
data = xr.open_dataset('diagfi.nc',&lt;br /&gt;
                       decode_times=False)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=data['Time']&lt;br /&gt;
lat=data['latitude']&lt;br /&gt;
lon=data['longitude']&lt;br /&gt;
al=data['altitude']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=data['aire']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=data['tsurf'] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=data['temp'] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
## let's take the time-averaged surface temperature&lt;br /&gt;
mean_tsurf = np.mean(tsurf,axis=0)&lt;br /&gt;
&lt;br /&gt;
##Let's plot a lon-lat map&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
plt.contourf(lon,lat,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't hesitate to use the function called ''.values'' to transform any ''xarray'' into a numpy array, especially in case of calculation time problems. &lt;br /&gt;
For more examples on how to use ''xarray'', take a look at the [https://docs.xarray.dev/en/stable/index.html documentation]. &lt;br /&gt;
Here is another example of how one can use xarray with multiples netcdfiles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
# your folder where output files are stored&lt;br /&gt;
FOLDER = './your_folder_with_output_files/'&lt;br /&gt;
&lt;br /&gt;
# take back the files from your FOLDER&lt;br /&gt;
list_files_folder=os.listdir(FOLDER)&lt;br /&gt;
&lt;br /&gt;
# If there are several files.&lt;br /&gt;
# Sort your simulation files by date,&lt;br /&gt;
# so beginning of simulation will be top of the list&lt;br /&gt;
# and end of simulation will be end of the list.&lt;br /&gt;
list_files_folder.sort()&lt;br /&gt;
&lt;br /&gt;
files = [FOLDER+str(f) for f in list_files_folder]&lt;br /&gt;
# if you want to keep only files of special_year you can add this option :&lt;br /&gt;
# files = [FOLDER+str(f) for f in list_files_folder if f.startswith(&amp;quot;special_year&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
# xarray will magically concatenate your outfiles by 'Time' (or any other 'concat_dime' you want)&lt;br /&gt;
nc=xr.open_mfdataset(files,decode_times=False, concat_dim='Time', combine='nested')&lt;br /&gt;
&lt;br /&gt;
# to check your keys&lt;br /&gt;
for key in nc.keys():&lt;br /&gt;
    print(key)&lt;br /&gt;
&lt;br /&gt;
# to load keys (example here with keys for a mesoscale simulation)&lt;br /&gt;
Times = nc['Times'][:]&lt;br /&gt;
PTOT = nc['PTOT'][:]&lt;br /&gt;
T = nc['T'][:]&lt;br /&gt;
W = nc['W'][:]&lt;br /&gt;
&lt;br /&gt;
# you can use some functions to make averages etc&lt;br /&gt;
&lt;br /&gt;
T_moy = T.mean(dim=['Time','south_north','west_east'])&lt;br /&gt;
&lt;br /&gt;
# other functions&lt;br /&gt;
# .cumsum (cumulative sum)&lt;br /&gt;
# .rename (change the name of the object)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One cool thing about xarray is that it is well optimized, and can do whatever you want to do on your data, but better than you. See for instance, the example below to plot a temperature lon-lat map. Xarray handles it in 5 lines of code, where you would need a lot more to set-up you plot in traditional matplotlib. And the results look almost good enough for a paper plot. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
##Load your data and print it &lt;br /&gt;
file = '/home/lteinturier/Documents/PhD/wasp43b/chemistry_project/input_5xsolar.nc'&lt;br /&gt;
data = xr.open_dataset(file,decode_times=False)&lt;br /&gt;
print(data)&lt;br /&gt;
##extracting the altitude level #20 for the whole file&lt;br /&gt;
data = data.isel(altitude=20)&lt;br /&gt;
##let's assume that data hold a time-series of the temperature. Let's average it in time&lt;br /&gt;
temp = data['temp'].mean(&amp;quot;Time&amp;quot;,keep_attrs=True) #we keep the attribute when averaging to conserve the DataArray structure&lt;br /&gt;
##now we plot &lt;br /&gt;
fig = temp.plot.contourf(cmap='gnuplot',levels=50) #choose the colormap and the number of contourf levels &lt;br /&gt;
fig.ax.set_title(&amp;quot;P = {:.2e} mbar&amp;quot;.format(data.p.mean().values)) ##set-up your title. If you don't change it, the title will be the altitude in km of your atmospheric level&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This is only a fraction of what Xarray can do. Check the [https://docs.xarray.dev/en/stable/user-guide/index.html documentation] for more.&lt;br /&gt;
&lt;br /&gt;
==== Python tutorials to make pretty visuals ====&lt;br /&gt;
&lt;br /&gt;
We provide a tutorial on how to make pretty visuals using Generic PCM 3-D simulations [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Plots_With_PyVista here].&lt;br /&gt;
&lt;br /&gt;
=== Planetoplot ===&lt;br /&gt;
&lt;br /&gt;
Planetoplot is a in-house, python based library developped to vizualize Generic PCM data.&lt;br /&gt;
&lt;br /&gt;
The code and documentation can be found at: https://nbviewer.org/github/aymeric-spiga/planetoplot/blob/master/tutorial/planetoplot_tutorial.ipynb&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Generic-LMDZ]]&lt;br /&gt;
[[Category:Generic-DYNAMICO]]&lt;br /&gt;
[[Category:Generic-WRF]]&lt;br /&gt;
[[Category:Generic-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2316</id>
		<title>Tool Box</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2316"/>
				<updated>2025-01-23T08:37:41Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: /* Identifying the code version of an executable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pre-processing Tools ==&lt;br /&gt;
=== newstart: a fortran program to modify start files ===&lt;br /&gt;
&lt;br /&gt;
Newstart is an interactive tool to modify the start files (''start.nc'' and ''startfi.nc''). &lt;br /&gt;
&lt;br /&gt;
To be usable, ''newstart'' should be compile in the ''LMDZ.COMMON'' directory by using the following command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 newstart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the example, my_arch_file is the name the arch files (see [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_Target_Architecture_(%22arch%22)_Files arch] ) and 64x48x30 is the resolution of the physical grid.&lt;br /&gt;
Then copy the executable from the ''LMDZ.COMMON/bin'' directory to your bench directory.&lt;br /&gt;
&lt;br /&gt;
When you execute newstart, you can use both a ''start2archive'' file or the start files (''start.nc'' and ''startfi.nc''). Then the interactive interface will propose to modify several physical quantities such as the gravity, the surface pressure or the rotation of the planet. At the end of the procedure, two files are created: '' '''re'''start.nc'' and '' '''re'''startfi.nc''. They can be renamed and used as start files to initialize a new simulation.&lt;br /&gt;
&lt;br /&gt;
We have prepared a simple tutorial to learn how to modify ''start.nc'' and ''startfi.nc'' files (= the the initial conditions) for the Generic PCM: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Modify_start_Files&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
&lt;br /&gt;
The start2archive tool is similar to newstart in the sense that it can be used to modify the start files. But start2archive can modify the resolution of the physical grid, the topography and the surface thermal inertia while newstart cannot. It is also useful to create an archive of different starting states, then extractable as start files.&lt;br /&gt;
The command line to compile start2archive is similar to the one used for newstart:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 start2archive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To modify the resolution, you should first create a start_archive (by using start2archive) file at the used resolution, then compile a newstart file at the new resolution. Newstart will interpolate all the physical quantities on the new grid.&lt;br /&gt;
&lt;br /&gt;
=== other third party scripts and tools ===&lt;br /&gt;
&lt;br /&gt;
You can easily modify start.nc and startfi.nc netcdf files with the xarray Python library. Below you can find an easy example where we modify the surface temperature field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from    numpy import *&lt;br /&gt;
import  numpy                 as        np&lt;br /&gt;
import  matplotlib.pyplot     as        mpl&lt;br /&gt;
import  math&lt;br /&gt;
import xarray as xr&lt;br /&gt;
&lt;br /&gt;
#FIRST WE GET THE DATA FROM THE GCM SIMULATION&lt;br /&gt;
nc = xr.open_dataset('startfi.nc',decode_times=False) # can be any netcdf file (e.g. start/startfi.nc files)&lt;br /&gt;
&lt;br /&gt;
# BELOW PHYSICAL VARIABLES&lt;br /&gt;
physical_points=nc['physical_points']&lt;br /&gt;
lat=nc['latitude']&lt;br /&gt;
lon=nc['longitude']&lt;br /&gt;
aire_GCM=nc['area']&lt;br /&gt;
&lt;br /&gt;
# BELOW THE VARIABLE WE WANT TO UPDATE&lt;br /&gt;
tsurf=nc['tsurf']&lt;br /&gt;
new_tsurf = np.empty(len(physical_points))&lt;br /&gt;
&lt;br /&gt;
# LOOP TO MODIFY THE VARIABLE&lt;br /&gt;
for i in range(0,len(physical_points),1):&lt;br /&gt;
    new_tsurf[i]=300. # here you put whatever you want ; in this exemple, we assume an isothermal temperature distribution&lt;br /&gt;
&lt;br /&gt;
nc['tsurf'].values = new_tsurf&lt;br /&gt;
nc.to_netcdf('restartfi.nc')&lt;br /&gt;
&lt;br /&gt;
# SANITY CHECK PLOTS&lt;br /&gt;
&lt;br /&gt;
fig = mpl.figure(1)&lt;br /&gt;
mpl.plot(physical_points,tsurf)&lt;br /&gt;
mpl.plot(physical_points,new_tsurf)&lt;br /&gt;
mpl.xlabel('GCM Physical Points')&lt;br /&gt;
mpl.ylabel('Tsurf (K)')&lt;br /&gt;
mpl.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Post-processing tools ==&lt;br /&gt;
=== zrecast ===&lt;br /&gt;
&lt;br /&gt;
With this program you can recast atmospheric (i.e.: 4D-dimentional longitude-latitude-altitude-time) data from&lt;br /&gt;
GCM outputs (e.g. as given in diagfi.nc files) onto either ''pressure'' or ''altitude'' above ''areoid vertical'' coordinates.&lt;br /&gt;
Since integrating the hydrostatic equation is required to recast the data, the input file must contain surface pressure&lt;br /&gt;
and atmospheric temperature, as well as the ground geopotential.&lt;br /&gt;
If recasting data onto ''pressure'' coordinates, then the output file name is given by the input file name to which ''_P.nc'' will be appened. If recasting data onto altitude above areoid coordinates, then a ''_A.nc'' will be appened.&lt;br /&gt;
&lt;br /&gt;
=== mass stream function ===&lt;br /&gt;
&lt;br /&gt;
The mass stream function (and the total angular momentum) can be computed from a diagfi.nc or a stats.nc, using the '''streamfunction.F90''' script. The script is located at&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trunk/LMDZ.GENERIC/utilities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the script, open the ''compile'' file in the same directory and do the following:&lt;br /&gt;
* Replace &amp;quot;pgf90&amp;quot; with your favorite fortran compiler &lt;br /&gt;
* replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/lib&amp;quot; with the lib address and directory that contains your NetCDF library (file ''libnetcdf.a'').&lt;br /&gt;
* Replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/include&amp;quot; with the address of the directory that contains the NetCDF include file (''netcdf.inc'').&lt;br /&gt;
* You can mess with the compiling options but it is not mandatory.&lt;br /&gt;
&lt;br /&gt;
Once the script is compiled, copy it in the same directory as your '''.nc''' file and run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./streamfunction.e&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will ask you for the name of your '''.nc''' file, and will run and produce a new '''nameofyourfile_stream.nc''' file.&lt;br /&gt;
&lt;br /&gt;
'''Be careful''' : In this new file, all fields are temporally and zonally averaged.&lt;br /&gt;
&lt;br /&gt;
If you want to use '''python''' instead of '''fortran''', you can take a look at this [https://github.com/aymeric-spiga/dynanalysis repo]. It hosts a tool to perform dynamical analysis of GCM simulations (and therefore, it computes the mass stream function and a lot of other stuff), but it is tailored for Dynamico only. This repo also takes care of recasting (it does the job of both ''zrecast.F90'' and ''streamfunction.F90'')&lt;br /&gt;
&lt;br /&gt;
== Continuing Simulations ==&lt;br /&gt;
&lt;br /&gt;
=== manually ===&lt;br /&gt;
&lt;br /&gt;
At the end of a simulation, the model generates restart files (files 'restart.nc' and 'restartfi.nc') which contain the final state of the model. The 'restart.nc' and 'restartfi.nc' files have the same format as the 'start.nc' and 'startfi.nc' files, respectively. &lt;br /&gt;
&lt;br /&gt;
These files can in fact be used as initial states to continue the simulation, using the following renaming command lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mv restart.nc start.nc&lt;br /&gt;
mv restartfi.nc startfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running a simulation with these start files will in fact resume the simulation from where the previous run ended.&lt;br /&gt;
&lt;br /&gt;
=== with bash scripts ===&lt;br /&gt;
&lt;br /&gt;
We have set up very simple bash scripts to automatize the launching of chain simulations. Here is an example of bash script that does the job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
###########################################################################&lt;br /&gt;
# Script to perform several chained LMD Mars GCM simulations&lt;br /&gt;
# SET HERE the maximum total number of simulations&lt;br /&gt;
&lt;br /&gt;
nummax=100&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;STARTING LOOP RUN&amp;quot;&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
dir=`pwd`&lt;br /&gt;
machine=`hostname`&lt;br /&gt;
address=`whoami`&lt;br /&gt;
&lt;br /&gt;
# Look for file &amp;quot;num_run&amp;quot; which should contain &lt;br /&gt;
# the value of the previously computed season&lt;br /&gt;
# (defaults to 0 if file &amp;quot;num_run&amp;quot; does not exist)&lt;br /&gt;
if [[ -r num_run ]] ; then&lt;br /&gt;
  echo &amp;quot;found file num_run&amp;quot;&lt;br /&gt;
  numold=`cat num_run`&lt;br /&gt;
else&lt;br /&gt;
  numold=0&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;numold is set to&amp;quot; ${numold}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set value of current season &lt;br /&gt;
(( numnew = ${numold} + 1 ))&lt;br /&gt;
echo &amp;quot;numnew is set to&amp;quot; ${numnew}&lt;br /&gt;
&lt;br /&gt;
# Look for initialization data files (exit if none found)&lt;br /&gt;
if [[ ( -r start${numold}.nc  &amp;amp;&amp;amp;  -r startfi${numold}.nc ) ]] ; then&lt;br /&gt;
   \cp -f start${numold}.nc start.nc&lt;br /&gt;
   \cp -f startfi${numold}.nc startfi.nc&lt;br /&gt;
else&lt;br /&gt;
   if (( ${numold} == 99999 )) ; then&lt;br /&gt;
    echo &amp;quot;No run because previous run crashed ! (99999 in num_run)&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
   else&lt;br /&gt;
   echo &amp;quot;Where is file start&amp;quot;${numold}&amp;quot;.nc??&amp;quot;&lt;br /&gt;
   exit&lt;br /&gt;
   fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Run GCM -- THIS LINE NEEDS TO BE MODIFIED WITH THE CORRECT GCM EXECUTION COMMAND&lt;br /&gt;
mpirun -np 8 gcm_64x48x26_phystd_para.e &amp;lt; diagfi.def &amp;gt; lrun${numnew}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Check if run ended normaly and copy datafiles&lt;br /&gt;
if [[ ( -r restartfi.nc  &amp;amp;&amp;amp;  -r restart.nc ) ]] ; then&lt;br /&gt;
  echo &amp;quot;Run seems to have ended normaly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  \mv -f restart.nc start${numnew}.nc&lt;br /&gt;
  \mv -f restartfi.nc startfi${numnew}.nc  &lt;br /&gt;
    &lt;br /&gt;
else&lt;br /&gt;
  if [[ -r num_run ]] ; then&lt;br /&gt;
    \mv -f num_run num_run.crash&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;No file num_run to build num_run.crash from !!&amp;quot;&lt;br /&gt;
    # Impose a default value of 0 for num_run&lt;br /&gt;
    echo 0 &amp;gt; num_run.crash&lt;br /&gt;
  fi&lt;br /&gt;
 echo 99999 &amp;gt; num_run&lt;br /&gt;
 exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Copy other datafiles that may have been generated&lt;br /&gt;
if [[ -r diagfi.nc ]] ; then&lt;br /&gt;
  \mv -f diagfi.nc diagfi${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r diagsoil.nc ]] ; then&lt;br /&gt;
  \mv -f diagsoil.nc diagsoil${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r stats.nc ]] ; then&lt;br /&gt;
  \mv -f stats.nc stats${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -f profiles.dat ]] ; then&lt;br /&gt;
  \mv -f profiles.dat profiles${numnew}.dat&lt;br /&gt;
  \mv -f profiles.hdr profiles${numnew}.hdr&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Prepare things for upcoming runs by writing&lt;br /&gt;
# value of computed season in file num_run&lt;br /&gt;
echo ${numnew} &amp;gt; num_run&lt;br /&gt;
&lt;br /&gt;
# If we are over nummax : stop&lt;br /&gt;
if (( $numnew + 1 &amp;gt; $nummax )) ; then&lt;br /&gt;
   exit&lt;br /&gt;
# If not : restart the loop (copy the executable and run the copy)&lt;br /&gt;
else&lt;br /&gt;
   \cp -f run_gnome exe_mars&lt;br /&gt;
   ./exe_mars&lt;br /&gt;
fi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Summary of what this bash script does''':&lt;br /&gt;
&lt;br /&gt;
* It reads the file 'num_run' which contains the step of the simulation. &lt;br /&gt;
If num_run is&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
then the script expects to read start5.nc and startfi5.nc.&lt;br /&gt;
* It modifies start5.nc and startfi5.nc into start.nc and startfi.nc, respectively.&lt;br /&gt;
* It runs the GCM.&lt;br /&gt;
* It modifies restart.nc and restartfi.nc into start6.nc and startfi6.nc&lt;br /&gt;
* It rewrite num_run as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It restarts the loop until num_run reaches the value (defined in nummax):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Identifying the code version of an executable file ==&lt;br /&gt;
&lt;br /&gt;
Details about compilation and code version (SVN or Git) are embedded in the executable file. To display these information, put the argument 'version' as an option when executing the code such as:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./executable.e version&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It shows in the terminal the date and the command of compilation as well as the version control information for the sub-folders of your trunk if applicable. In addition, it creates a file called &amp;quot;version_stat-diff.txt&amp;quot; containing the result of status and diff commands between the code repository and the local copy which produced the executable file.&lt;br /&gt;
This feature is available for every program of the Mars model, the Generic model and the PEM. If you want to extend it to other models, please add the following code section at the beginning of your main programs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if (command_argument_count() &amp;gt; 0) then ! Get the number of command-line arguments&lt;br /&gt;
    call get_command_argument(1,arg) ! Read the argument given to the program&lt;br /&gt;
    select case (trim(adjustl(arg)))&lt;br /&gt;
        case('version')&lt;br /&gt;
            call print_version_info()&lt;br /&gt;
            stop&lt;br /&gt;
        case default&lt;br /&gt;
            error stop &amp;quot;The argument given to the program is unknown!&amp;quot;&lt;br /&gt;
    end select&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As well as the necessary declaration and module:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
use version_info_mod, only: print_version_info&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
character(100) :: arg ! To read command-line arguments&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing Output Files with NCOs ==&lt;br /&gt;
&lt;br /&gt;
NCOs (NetCdf OperatorS) are a set of powerful command-line utilities – available on Linux, Mac and PC – that allow to perform useful (and very fast!) post-processing operations on netCDF GCM output files. Full documentation can be found on http://research.jisao.washington.edu/data_sets/nco/, but we provide below a few examples of command lines.&lt;br /&gt;
&lt;br /&gt;
* How to calculate a time mean of a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncra -F -d Time,1,,1 diagfi.nc diagfi_MEAN.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Subsetting time in a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncea -F -d Time,first,last diagfi.nc diagfi_subset.nc # format is &amp;quot;-d dimension,minimum,maximum&amp;quot; ; we recall you can type &amp;quot;ncdump -v time diagfi.nc&amp;quot; to see the Time values in the netCDF file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Decimating a netCDF 'diagfi.nc' file in time&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -F -d Time,1,,8 diagfi.nc diagfi_decimated.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot; ; In this example, this means that data is extracted 1 time every 8 time steps, starting from the first time step (number 1), ending at the last time step).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Extract a variable from a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -v tsurf,temp,p diagfi.nc diagfi_out.nc # Here we created a new file named 'diagfi_out.nc' in which we only kept variables named 'tsurf' (surface temperatures), 'temp' (atmospheric temperatures) and p (atmospheric pressures).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, more examples can be found on http://research.jisao.washington.edu/data_sets/nco/ .&lt;br /&gt;
&lt;br /&gt;
== Data Handling and Visualization Software ==&lt;br /&gt;
&lt;br /&gt;
There are several data handling and visualization tools that can be used to analyse and plot the results from GCM simulations (using the diagfi.nc NetCDF files). We provide below a panorama of most widely used solutions.&lt;br /&gt;
&lt;br /&gt;
=== panoply ===&lt;br /&gt;
Panoply is a user-friendly tool for viewing raw NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/ . It is very convenient to make pretty visuals (see an example for the exoplanet TRAPPIST-1e). There are many options that can be used (map projections, masks, colorbars, shadows, etc.) to make your plots fancy. However, the tool is not very well suited for manipulating data (compute averages, statistics, etc.).&lt;br /&gt;
&lt;br /&gt;
* Installation on Linux:&lt;br /&gt;
You simply need to download and untar the Package from the Panoply website. Note that to work it requires that Java and related Java Runtime environment (JRE) be installed on your system (otherwise it will simply look as if &amp;quot;nothing is happening&amp;quot; when you try to launch Panoply via the &amp;quot;panoply.sh&amp;quot; script), which on Ubuntu simply requires something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install java&lt;br /&gt;
sudo apt install default-jre&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run on Linux (assuming the panoply.sh script is in a directory included in your PATH environment variable):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
panoply.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example panoply.png|thumb|Screenshot of panoply showing here Generic PCM results for the exoplanet TRAPPIST-1e (surface temperatures)]]&lt;br /&gt;
&lt;br /&gt;
=== ncview ===&lt;br /&gt;
ncview is another useful user-friendly tool for viewing raw NetCDF data. This is kind of a very archaic version of panoply, but it is convenient because it allows to have a very quick first look at netCDF data files.&lt;br /&gt;
&lt;br /&gt;
Command line tool to visualize NetCDF data:&lt;br /&gt;
* Installation on Linux-Ubuntu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ncview&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run on Linux:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncview diagfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example ncview.png|thumb|Screenshot of ncview showing here Generic PCM results for the exoplanet Proxima b (OLR - Thermal Emission)]]&lt;br /&gt;
&lt;br /&gt;
=== python scripts ===&lt;br /&gt;
&lt;br /&gt;
Python scripts provide a very useful mean to analyse and visualize netCDF files.&lt;br /&gt;
&lt;br /&gt;
==== NETCDF4 python library (old school) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can use the netCDF4 python library to open a netCDF file and put data in tables that can then be manipulated and plotted.&lt;br /&gt;
&lt;br /&gt;
Here is an exemple of how to open and read a netCDF file with Python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
from netCDF4 import Dataset&lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
nc = Dataset('diagfi.nc')&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=nc.variables['Time'][:]&lt;br /&gt;
lat=nc.variables['latitude'][:]&lt;br /&gt;
lon=nc.variables['longitude'][:]&lt;br /&gt;
al=nc.variables['altitude'][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=nc.variables['aire'][:][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=nc.variables['tsurf'][:][:][:] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=nc.variables['temp'][:][:][:][:] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is an exemple of how to manipulate the netCDF data (here to compute the time averaged surface temperatures):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
from numpy import *&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
mean_tsurf=np.zeros((len(lat),len(lon)),dtype='f')&lt;br /&gt;
&lt;br /&gt;
for i in range(0,len(Time)):&lt;br /&gt;
    for j in range(0,len(lat)):&lt;br /&gt;
        for k in range(0,len(lon)):&lt;br /&gt;
            mean_tsurf[j,k]=mean_tsurf[j,k]+tsurf[i,j,k]*(1./len(Time))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is a last exemple of how to plot the data (using matplotlib):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.contourf(lon_GCM,lat_GCM,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== XARRAY python library (more modern) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another useful library to deal with netcdf files is ''xarray''. We provide a code snippet below, doing the same thing as the snippets above.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import xarray as xr &lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
data = xr.open_dataset('diagfi.nc',&lt;br /&gt;
                       decode_times=False)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=data['Time']&lt;br /&gt;
lat=data['latitude']&lt;br /&gt;
lon=data['longitude']&lt;br /&gt;
al=data['altitude']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=data['aire']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=data['tsurf'] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=data['temp'] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
## let's take the time-averaged surface temperature&lt;br /&gt;
mean_tsurf = np.mean(tsurf,axis=0)&lt;br /&gt;
&lt;br /&gt;
##Let's plot a lon-lat map&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
plt.contourf(lon,lat,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't hesitate to use the function called ''.values'' to transform any ''xarray'' into a numpy array, especially in case of calculation time problems. &lt;br /&gt;
For more examples on how to use ''xarray'', take a look at the [https://docs.xarray.dev/en/stable/index.html documentation]. &lt;br /&gt;
Here is another example of how one can use xarray with multiples netcdfiles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
# your folder where output files are stored&lt;br /&gt;
FOLDER = './your_folder_with_output_files/'&lt;br /&gt;
&lt;br /&gt;
# take back the files from your FOLDER&lt;br /&gt;
list_files_folder=os.listdir(FOLDER)&lt;br /&gt;
&lt;br /&gt;
# If there are several files.&lt;br /&gt;
# Sort your simulation files by date,&lt;br /&gt;
# so beginning of simulation will be top of the list&lt;br /&gt;
# and end of simulation will be end of the list.&lt;br /&gt;
list_files_folder.sort()&lt;br /&gt;
&lt;br /&gt;
files = [FOLDER+str(f) for f in list_files_folder]&lt;br /&gt;
# if you want to keep only files of special_year you can add this option :&lt;br /&gt;
# files = [FOLDER+str(f) for f in list_files_folder if f.startswith(&amp;quot;special_year&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
# xarray will magically concatenate your outfiles by 'Time' (or any other 'concat_dime' you want)&lt;br /&gt;
nc=xr.open_mfdataset(files,decode_times=False, concat_dim='Time', combine='nested')&lt;br /&gt;
&lt;br /&gt;
# to check your keys&lt;br /&gt;
for key in nc.keys():&lt;br /&gt;
    print(key)&lt;br /&gt;
&lt;br /&gt;
# to load keys (example here with keys for a mesoscale simulation)&lt;br /&gt;
Times = nc['Times'][:]&lt;br /&gt;
PTOT = nc['PTOT'][:]&lt;br /&gt;
T = nc['T'][:]&lt;br /&gt;
W = nc['W'][:]&lt;br /&gt;
&lt;br /&gt;
# you can use some functions to make averages etc&lt;br /&gt;
&lt;br /&gt;
T_moy = T.mean(dim=['Time','south_north','west_east'])&lt;br /&gt;
&lt;br /&gt;
# other functions&lt;br /&gt;
# .cumsum (cumulative sum)&lt;br /&gt;
# .rename (change the name of the object)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One cool thing about xarray is that it is well optimized, and can do whatever you want to do on your data, but better than you. See for instance, the example below to plot a temperature lon-lat map. Xarray handles it in 5 lines of code, where you would need a lot more to set-up you plot in traditional matplotlib. And the results look almost good enough for a paper plot. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
##Load your data and print it &lt;br /&gt;
file = '/home/lteinturier/Documents/PhD/wasp43b/chemistry_project/input_5xsolar.nc'&lt;br /&gt;
data = xr.open_dataset(file,decode_times=False)&lt;br /&gt;
print(data)&lt;br /&gt;
##extracting the altitude level #20 for the whole file&lt;br /&gt;
data = data.isel(altitude=20)&lt;br /&gt;
##let's assume that data hold a time-series of the temperature. Let's average it in time&lt;br /&gt;
temp = data['temp'].mean(&amp;quot;Time&amp;quot;,keep_attrs=True) #we keep the attribute when averaging to conserve the DataArray structure&lt;br /&gt;
##now we plot &lt;br /&gt;
fig = temp.plot.contourf(cmap='gnuplot',levels=50) #choose the colormap and the number of contourf levels &lt;br /&gt;
fig.ax.set_title(&amp;quot;P = {:.2e} mbar&amp;quot;.format(data.p.mean().values)) ##set-up your title. If you don't change it, the title will be the altitude in km of your atmospheric level&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This is only a fraction of what Xarray can do. Check the [https://docs.xarray.dev/en/stable/user-guide/index.html documentation] for more.&lt;br /&gt;
&lt;br /&gt;
==== Python tutorials to make pretty visuals ====&lt;br /&gt;
&lt;br /&gt;
We provide a tutorial on how to make pretty visuals using Generic PCM 3-D simulations [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Plots_With_PyVista here].&lt;br /&gt;
&lt;br /&gt;
=== Planetoplot ===&lt;br /&gt;
&lt;br /&gt;
Planetoplot is a in-house, python based library developped to vizualize Generic PCM data.&lt;br /&gt;
&lt;br /&gt;
The code and documentation can be found at: https://nbviewer.org/github/aymeric-spiga/planetoplot/blob/master/tutorial/planetoplot_tutorial.ipynb&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Generic-LMDZ]]&lt;br /&gt;
[[Category:Generic-DYNAMICO]]&lt;br /&gt;
[[Category:Generic-WRF]]&lt;br /&gt;
[[Category:Generic-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2315</id>
		<title>Tool Box</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box&amp;diff=2315"/>
				<updated>2025-01-23T08:25:08Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: Explanations of the feature allowing to know the compilation and version details of the executable&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pre-processing Tools ==&lt;br /&gt;
=== newstart: a fortran program to modify start files ===&lt;br /&gt;
&lt;br /&gt;
Newstart is an interactive tool to modify the start files (''start.nc'' and ''startfi.nc''). &lt;br /&gt;
&lt;br /&gt;
To be usable, ''newstart'' should be compile in the ''LMDZ.COMMON'' directory by using the following command line:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 newstart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the example, my_arch_file is the name the arch files (see [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_Target_Architecture_(%22arch%22)_Files arch] ) and 64x48x30 is the resolution of the physical grid.&lt;br /&gt;
Then copy the executable from the ''LMDZ.COMMON/bin'' directory to your bench directory.&lt;br /&gt;
&lt;br /&gt;
When you execute newstart, you can use both a ''start2archive'' file or the start files (''start.nc'' and ''startfi.nc''). Then the interactive interface will propose to modify several physical quantities such as the gravity, the surface pressure or the rotation of the planet. At the end of the procedure, two files are created: '' '''re'''start.nc'' and '' '''re'''startfi.nc''. They can be renamed and used as start files to initialize a new simulation.&lt;br /&gt;
&lt;br /&gt;
We have prepared a simple tutorial to learn how to modify ''start.nc'' and ''startfi.nc'' files (= the the initial conditions) for the Generic PCM: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Modify_start_Files&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
&lt;br /&gt;
The start2archive tool is similar to newstart in the sense that it can be used to modify the start files. But start2archive can modify the resolution of the physical grid, the topography and the surface thermal inertia while newstart cannot. It is also useful to create an archive of different starting states, then extractable as start files.&lt;br /&gt;
The command line to compile start2archive is similar to the one used for newstart:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./makelmdz_fcm -arch my_arch_file -p std -d 64x48x30 start2archive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To modify the resolution, you should first create a start_archive (by using start2archive) file at the used resolution, then compile a newstart file at the new resolution. Newstart will interpolate all the physical quantities on the new grid.&lt;br /&gt;
&lt;br /&gt;
=== other third party scripts and tools ===&lt;br /&gt;
&lt;br /&gt;
You can easily modify start.nc and startfi.nc netcdf files with the xarray Python library. Below you can find an easy example where we modify the surface temperature field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from    numpy import *&lt;br /&gt;
import  numpy                 as        np&lt;br /&gt;
import  matplotlib.pyplot     as        mpl&lt;br /&gt;
import  math&lt;br /&gt;
import xarray as xr&lt;br /&gt;
&lt;br /&gt;
#FIRST WE GET THE DATA FROM THE GCM SIMULATION&lt;br /&gt;
nc = xr.open_dataset('startfi.nc',decode_times=False) # can be any netcdf file (e.g. start/startfi.nc files)&lt;br /&gt;
&lt;br /&gt;
# BELOW PHYSICAL VARIABLES&lt;br /&gt;
physical_points=nc['physical_points']&lt;br /&gt;
lat=nc['latitude']&lt;br /&gt;
lon=nc['longitude']&lt;br /&gt;
aire_GCM=nc['area']&lt;br /&gt;
&lt;br /&gt;
# BELOW THE VARIABLE WE WANT TO UPDATE&lt;br /&gt;
tsurf=nc['tsurf']&lt;br /&gt;
new_tsurf = np.empty(len(physical_points))&lt;br /&gt;
&lt;br /&gt;
# LOOP TO MODIFY THE VARIABLE&lt;br /&gt;
for i in range(0,len(physical_points),1):&lt;br /&gt;
    new_tsurf[i]=300. # here you put whatever you want ; in this exemple, we assume an isothermal temperature distribution&lt;br /&gt;
&lt;br /&gt;
nc['tsurf'].values = new_tsurf&lt;br /&gt;
nc.to_netcdf('restartfi.nc')&lt;br /&gt;
&lt;br /&gt;
# SANITY CHECK PLOTS&lt;br /&gt;
&lt;br /&gt;
fig = mpl.figure(1)&lt;br /&gt;
mpl.plot(physical_points,tsurf)&lt;br /&gt;
mpl.plot(physical_points,new_tsurf)&lt;br /&gt;
mpl.xlabel('GCM Physical Points')&lt;br /&gt;
mpl.ylabel('Tsurf (K)')&lt;br /&gt;
mpl.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Post-processing tools ==&lt;br /&gt;
=== zrecast ===&lt;br /&gt;
&lt;br /&gt;
With this program you can recast atmospheric (i.e.: 4D-dimentional longitude-latitude-altitude-time) data from&lt;br /&gt;
GCM outputs (e.g. as given in diagfi.nc files) onto either ''pressure'' or ''altitude'' above ''areoid vertical'' coordinates.&lt;br /&gt;
Since integrating the hydrostatic equation is required to recast the data, the input file must contain surface pressure&lt;br /&gt;
and atmospheric temperature, as well as the ground geopotential.&lt;br /&gt;
If recasting data onto ''pressure'' coordinates, then the output file name is given by the input file name to which ''_P.nc'' will be appened. If recasting data onto altitude above areoid coordinates, then a ''_A.nc'' will be appened.&lt;br /&gt;
&lt;br /&gt;
=== mass stream function ===&lt;br /&gt;
&lt;br /&gt;
The mass stream function (and the total angular momentum) can be computed from a diagfi.nc or a stats.nc, using the '''streamfunction.F90''' script. The script is located at&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
trunk/LMDZ.GENERIC/utilities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To compile the script, open the ''compile'' file in the same directory and do the following:&lt;br /&gt;
* Replace &amp;quot;pgf90&amp;quot; with your favorite fortran compiler &lt;br /&gt;
* replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/lib&amp;quot; with the lib address and directory that contains your NetCDF library (file ''libnetcdf.a'').&lt;br /&gt;
* Replace &amp;quot;/distrib/local/netcdf/pgi_7.1-6_32/include&amp;quot; with the address of the directory that contains the NetCDF include file (''netcdf.inc'').&lt;br /&gt;
* You can mess with the compiling options but it is not mandatory.&lt;br /&gt;
&lt;br /&gt;
Once the script is compiled, copy it in the same directory as your '''.nc''' file and run &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./streamfunction.e&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The script will ask you for the name of your '''.nc''' file, and will run and produce a new '''nameofyourfile_stream.nc''' file.&lt;br /&gt;
&lt;br /&gt;
'''Be careful''' : In this new file, all fields are temporally and zonally averaged.&lt;br /&gt;
&lt;br /&gt;
If you want to use '''python''' instead of '''fortran''', you can take a look at this [https://github.com/aymeric-spiga/dynanalysis repo]. It hosts a tool to perform dynamical analysis of GCM simulations (and therefore, it computes the mass stream function and a lot of other stuff), but it is tailored for Dynamico only. This repo also takes care of recasting (it does the job of both ''zrecast.F90'' and ''streamfunction.F90'')&lt;br /&gt;
&lt;br /&gt;
== Continuing Simulations ==&lt;br /&gt;
&lt;br /&gt;
=== manually ===&lt;br /&gt;
&lt;br /&gt;
At the end of a simulation, the model generates restart files (files 'restart.nc' and 'restartfi.nc') which contain the final state of the model. The 'restart.nc' and 'restartfi.nc' files have the same format as the 'start.nc' and 'startfi.nc' files, respectively. &lt;br /&gt;
&lt;br /&gt;
These files can in fact be used as initial states to continue the simulation, using the following renaming command lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mv restart.nc start.nc&lt;br /&gt;
mv restartfi.nc startfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running a simulation with these start files will in fact resume the simulation from where the previous run ended.&lt;br /&gt;
&lt;br /&gt;
=== with bash scripts ===&lt;br /&gt;
&lt;br /&gt;
We have set up very simple bash scripts to automatize the launching of chain simulations. Here is an example of bash script that does the job:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
###########################################################################&lt;br /&gt;
# Script to perform several chained LMD Mars GCM simulations&lt;br /&gt;
# SET HERE the maximum total number of simulations&lt;br /&gt;
&lt;br /&gt;
nummax=100&lt;br /&gt;
&lt;br /&gt;
###########################################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
echo &amp;quot;STARTING LOOP RUN&amp;quot;&lt;br /&gt;
echo &amp;quot;---------------------------------------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
dir=`pwd`&lt;br /&gt;
machine=`hostname`&lt;br /&gt;
address=`whoami`&lt;br /&gt;
&lt;br /&gt;
# Look for file &amp;quot;num_run&amp;quot; which should contain &lt;br /&gt;
# the value of the previously computed season&lt;br /&gt;
# (defaults to 0 if file &amp;quot;num_run&amp;quot; does not exist)&lt;br /&gt;
if [[ -r num_run ]] ; then&lt;br /&gt;
  echo &amp;quot;found file num_run&amp;quot;&lt;br /&gt;
  numold=`cat num_run`&lt;br /&gt;
else&lt;br /&gt;
  numold=0&lt;br /&gt;
fi&lt;br /&gt;
echo &amp;quot;numold is set to&amp;quot; ${numold}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Set value of current season &lt;br /&gt;
(( numnew = ${numold} + 1 ))&lt;br /&gt;
echo &amp;quot;numnew is set to&amp;quot; ${numnew}&lt;br /&gt;
&lt;br /&gt;
# Look for initialization data files (exit if none found)&lt;br /&gt;
if [[ ( -r start${numold}.nc  &amp;amp;&amp;amp;  -r startfi${numold}.nc ) ]] ; then&lt;br /&gt;
   \cp -f start${numold}.nc start.nc&lt;br /&gt;
   \cp -f startfi${numold}.nc startfi.nc&lt;br /&gt;
else&lt;br /&gt;
   if (( ${numold} == 99999 )) ; then&lt;br /&gt;
    echo &amp;quot;No run because previous run crashed ! (99999 in num_run)&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
   else&lt;br /&gt;
   echo &amp;quot;Where is file start&amp;quot;${numold}&amp;quot;.nc??&amp;quot;&lt;br /&gt;
   exit&lt;br /&gt;
   fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Run GCM -- THIS LINE NEEDS TO BE MODIFIED WITH THE CORRECT GCM EXECUTION COMMAND&lt;br /&gt;
mpirun -np 8 gcm_64x48x26_phystd_para.e &amp;lt; diagfi.def &amp;gt; lrun${numnew}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Check if run ended normaly and copy datafiles&lt;br /&gt;
if [[ ( -r restartfi.nc  &amp;amp;&amp;amp;  -r restart.nc ) ]] ; then&lt;br /&gt;
  echo &amp;quot;Run seems to have ended normaly&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  \mv -f restart.nc start${numnew}.nc&lt;br /&gt;
  \mv -f restartfi.nc startfi${numnew}.nc  &lt;br /&gt;
    &lt;br /&gt;
else&lt;br /&gt;
  if [[ -r num_run ]] ; then&lt;br /&gt;
    \mv -f num_run num_run.crash&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;No file num_run to build num_run.crash from !!&amp;quot;&lt;br /&gt;
    # Impose a default value of 0 for num_run&lt;br /&gt;
    echo 0 &amp;gt; num_run.crash&lt;br /&gt;
  fi&lt;br /&gt;
 echo 99999 &amp;gt; num_run&lt;br /&gt;
 exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Copy other datafiles that may have been generated&lt;br /&gt;
if [[ -r diagfi.nc ]] ; then&lt;br /&gt;
  \mv -f diagfi.nc diagfi${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r diagsoil.nc ]] ; then&lt;br /&gt;
  \mv -f diagsoil.nc diagsoil${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -r stats.nc ]] ; then&lt;br /&gt;
  \mv -f stats.nc stats${numnew}.nc&lt;br /&gt;
fi&lt;br /&gt;
if [[ -f profiles.dat ]] ; then&lt;br /&gt;
  \mv -f profiles.dat profiles${numnew}.dat&lt;br /&gt;
  \mv -f profiles.hdr profiles${numnew}.hdr&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Prepare things for upcoming runs by writing&lt;br /&gt;
# value of computed season in file num_run&lt;br /&gt;
echo ${numnew} &amp;gt; num_run&lt;br /&gt;
&lt;br /&gt;
# If we are over nummax : stop&lt;br /&gt;
if (( $numnew + 1 &amp;gt; $nummax )) ; then&lt;br /&gt;
   exit&lt;br /&gt;
# If not : restart the loop (copy the executable and run the copy)&lt;br /&gt;
else&lt;br /&gt;
   \cp -f run_gnome exe_mars&lt;br /&gt;
   ./exe_mars&lt;br /&gt;
fi &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Summary of what this bash script does''':&lt;br /&gt;
&lt;br /&gt;
* It reads the file 'num_run' which contains the step of the simulation. &lt;br /&gt;
If num_run is&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
then the script expects to read start5.nc and startfi5.nc.&lt;br /&gt;
* It modifies start5.nc and startfi5.nc into start.nc and startfi.nc, respectively.&lt;br /&gt;
* It runs the GCM.&lt;br /&gt;
* It modifies restart.nc and restartfi.nc into start6.nc and startfi6.nc&lt;br /&gt;
* It rewrite num_run as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It restarts the loop until num_run reaches the value (defined in nummax):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Identifying the code version of an executable ==&lt;br /&gt;
&lt;br /&gt;
It is possible to track compilation and version (SVN or Git) details of the code which produced the executable file. For this, put the argument 'version' as an option when executing the code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./executable.e version&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It shows in the terminal the date and the command of compilation as well as the version control information for the sub-folders of your trunk if applicable. In addition, it creates a file &amp;quot;version_stat-diff.txt&amp;quot; containing the status and diff results between the local copy and the repository of the code which produced the executable file.&lt;br /&gt;
This feature is available for every program of the Mars model, the Generic model and the PEM. If you want to extend it to other models, please add the following code section at the beginning of your main programs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
if (command_argument_count() &amp;gt; 0) then ! Get the number of command-line arguments&lt;br /&gt;
    call get_command_argument(1,arg) ! Read the argument given to the program&lt;br /&gt;
    select case (trim(adjustl(arg)))&lt;br /&gt;
        case('version')&lt;br /&gt;
            call print_version_info()&lt;br /&gt;
            stop&lt;br /&gt;
        case default&lt;br /&gt;
            error stop &amp;quot;The argument given to the program is unknown!&amp;quot;&lt;br /&gt;
    end select&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As well as the necessary declaration and module:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
use version_info_mod, only: print_version_info&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
character(100) :: arg ! To read command-line arguments&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Processing Output Files with NCOs ==&lt;br /&gt;
&lt;br /&gt;
NCOs (NetCdf OperatorS) are a set of powerful command-line utilities – available on Linux, Mac and PC – that allow to perform useful (and very fast!) post-processing operations on netCDF GCM output files. Full documentation can be found on http://research.jisao.washington.edu/data_sets/nco/, but we provide below a few examples of command lines.&lt;br /&gt;
&lt;br /&gt;
* How to calculate a time mean of a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncra -F -d Time,1,,1 diagfi.nc diagfi_MEAN.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Subsetting time in a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncea -F -d Time,first,last diagfi.nc diagfi_subset.nc # format is &amp;quot;-d dimension,minimum,maximum&amp;quot; ; we recall you can type &amp;quot;ncdump -v time diagfi.nc&amp;quot; to see the Time values in the netCDF file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Decimating a netCDF 'diagfi.nc' file in time&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -F -d Time,1,,8 diagfi.nc diagfi_decimated.nc # format is &amp;quot;-d dimension,minimum,maximum,stride&amp;quot; ; In this example, this means that data is extracted 1 time every 8 time steps, starting from the first time step (number 1), ending at the last time step).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Extract a variable from a netCDF 'diagfi.nc' file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncks -v tsurf,temp,p diagfi.nc diagfi_out.nc # Here we created a new file named 'diagfi_out.nc' in which we only kept variables named 'tsurf' (surface temperatures), 'temp' (atmospheric temperatures) and p (atmospheric pressures).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, more examples can be found on http://research.jisao.washington.edu/data_sets/nco/ .&lt;br /&gt;
&lt;br /&gt;
== Data Handling and Visualization Software ==&lt;br /&gt;
&lt;br /&gt;
There are several data handling and visualization tools that can be used to analyse and plot the results from GCM simulations (using the diagfi.nc NetCDF files). We provide below a panorama of most widely used solutions.&lt;br /&gt;
&lt;br /&gt;
=== panoply ===&lt;br /&gt;
Panoply is a user-friendly tool for viewing raw NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/ . It is very convenient to make pretty visuals (see an example for the exoplanet TRAPPIST-1e). There are many options that can be used (map projections, masks, colorbars, shadows, etc.) to make your plots fancy. However, the tool is not very well suited for manipulating data (compute averages, statistics, etc.).&lt;br /&gt;
&lt;br /&gt;
* Installation on Linux:&lt;br /&gt;
You simply need to download and untar the Package from the Panoply website. Note that to work it requires that Java and related Java Runtime environment (JRE) be installed on your system (otherwise it will simply look as if &amp;quot;nothing is happening&amp;quot; when you try to launch Panoply via the &amp;quot;panoply.sh&amp;quot; script), which on Ubuntu simply requires something like:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install java&lt;br /&gt;
sudo apt install default-jre&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run on Linux (assuming the panoply.sh script is in a directory included in your PATH environment variable):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
panoply.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example panoply.png|thumb|Screenshot of panoply showing here Generic PCM results for the exoplanet TRAPPIST-1e (surface temperatures)]]&lt;br /&gt;
&lt;br /&gt;
=== ncview ===&lt;br /&gt;
ncview is another useful user-friendly tool for viewing raw NetCDF data. This is kind of a very archaic version of panoply, but it is convenient because it allows to have a very quick first look at netCDF data files.&lt;br /&gt;
&lt;br /&gt;
Command line tool to visualize NetCDF data:&lt;br /&gt;
* Installation on Linux-Ubuntu:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ncview&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* Run on Linux:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ncview diagfi.nc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Example ncview.png|thumb|Screenshot of ncview showing here Generic PCM results for the exoplanet Proxima b (OLR - Thermal Emission)]]&lt;br /&gt;
&lt;br /&gt;
=== python scripts ===&lt;br /&gt;
&lt;br /&gt;
Python scripts provide a very useful mean to analyse and visualize netCDF files.&lt;br /&gt;
&lt;br /&gt;
==== NETCDF4 python library (old school) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can use the netCDF4 python library to open a netCDF file and put data in tables that can then be manipulated and plotted.&lt;br /&gt;
&lt;br /&gt;
Here is an exemple of how to open and read a netCDF file with Python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
from netCDF4 import Dataset&lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
nc = Dataset('diagfi.nc')&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=nc.variables['Time'][:]&lt;br /&gt;
lat=nc.variables['latitude'][:]&lt;br /&gt;
lon=nc.variables['longitude'][:]&lt;br /&gt;
al=nc.variables['altitude'][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=nc.variables['aire'][:][:]&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=nc.variables['tsurf'][:][:][:] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=nc.variables['temp'][:][:][:][:] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is an exemple of how to manipulate the netCDF data (here to compute the time averaged surface temperatures):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
from numpy import *&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
mean_tsurf=np.zeros((len(lat),len(lon)),dtype='f')&lt;br /&gt;
&lt;br /&gt;
for i in range(0,len(Time)):&lt;br /&gt;
    for j in range(0,len(lat)):&lt;br /&gt;
        for k in range(0,len(lon)):&lt;br /&gt;
            mean_tsurf[j,k]=mean_tsurf[j,k]+tsurf[i,j,k]*(1./len(Time))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And here is a last exemple of how to plot the data (using matplotlib):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
plt.figure(1)&lt;br /&gt;
plt.contourf(lon_GCM,lat_GCM,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== XARRAY python library (more modern) ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another useful library to deal with netcdf files is ''xarray''. We provide a code snippet below, doing the same thing as the snippets above.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import numpy as np&lt;br /&gt;
import xarray as xr &lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
&lt;br /&gt;
# HERE WE OPEN THE NETCDF FILE&lt;br /&gt;
data = xr.open_dataset('diagfi.nc',&lt;br /&gt;
                       decode_times=False)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE VARIABLES (1D OUTPUT)&lt;br /&gt;
Time=data['Time']&lt;br /&gt;
lat=data['latitude']&lt;br /&gt;
lon=data['longitude']&lt;br /&gt;
al=data['altitude']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ THE AREA (2D OUTPUT)&lt;br /&gt;
aire_GCM=data['aire']&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 3D OUTPUTS&lt;br /&gt;
tsurf=data['tsurf'] # this is the surface temperature 3D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
# HERE WE READ 4D OUTPUTS&lt;br /&gt;
temp=data['temp'] # this is the atmospheric temperature 4D field (time, latitude, longitude, altitude)&lt;br /&gt;
&lt;br /&gt;
## let's take the time-averaged surface temperature&lt;br /&gt;
mean_tsurf = np.mean(tsurf,axis=0)&lt;br /&gt;
&lt;br /&gt;
##Let's plot a lon-lat map&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
plt.contourf(lon,lat,mean_tsurf)&lt;br /&gt;
plt.colorbar(label='Surface Temperature (K)')&lt;br /&gt;
plt.xlabel('Longitude ($^{\circ}$)')&lt;br /&gt;
plt.ylabel('Latitude ($^{\circ}$)')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Don't hesitate to use the function called ''.values'' to transform any ''xarray'' into a numpy array, especially in case of calculation time problems. &lt;br /&gt;
For more examples on how to use ''xarray'', take a look at the [https://docs.xarray.dev/en/stable/index.html documentation]. &lt;br /&gt;
Here is another example of how one can use xarray with multiples netcdfiles.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
# your folder where output files are stored&lt;br /&gt;
FOLDER = './your_folder_with_output_files/'&lt;br /&gt;
&lt;br /&gt;
# take back the files from your FOLDER&lt;br /&gt;
list_files_folder=os.listdir(FOLDER)&lt;br /&gt;
&lt;br /&gt;
# If there are several files.&lt;br /&gt;
# Sort your simulation files by date,&lt;br /&gt;
# so beginning of simulation will be top of the list&lt;br /&gt;
# and end of simulation will be end of the list.&lt;br /&gt;
list_files_folder.sort()&lt;br /&gt;
&lt;br /&gt;
files = [FOLDER+str(f) for f in list_files_folder]&lt;br /&gt;
# if you want to keep only files of special_year you can add this option :&lt;br /&gt;
# files = [FOLDER+str(f) for f in list_files_folder if f.startswith(&amp;quot;special_year&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
# xarray will magically concatenate your outfiles by 'Time' (or any other 'concat_dime' you want)&lt;br /&gt;
nc=xr.open_mfdataset(files,decode_times=False, concat_dim='Time', combine='nested')&lt;br /&gt;
&lt;br /&gt;
# to check your keys&lt;br /&gt;
for key in nc.keys():&lt;br /&gt;
    print(key)&lt;br /&gt;
&lt;br /&gt;
# to load keys (example here with keys for a mesoscale simulation)&lt;br /&gt;
Times = nc['Times'][:]&lt;br /&gt;
PTOT = nc['PTOT'][:]&lt;br /&gt;
T = nc['T'][:]&lt;br /&gt;
W = nc['W'][:]&lt;br /&gt;
&lt;br /&gt;
# you can use some functions to make averages etc&lt;br /&gt;
&lt;br /&gt;
T_moy = T.mean(dim=['Time','south_north','west_east'])&lt;br /&gt;
&lt;br /&gt;
# other functions&lt;br /&gt;
# .cumsum (cumulative sum)&lt;br /&gt;
# .rename (change the name of the object)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One cool thing about xarray is that it is well optimized, and can do whatever you want to do on your data, but better than you. See for instance, the example below to plot a temperature lon-lat map. Xarray handles it in 5 lines of code, where you would need a lot more to set-up you plot in traditional matplotlib. And the results look almost good enough for a paper plot. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import xarray as xr&lt;br /&gt;
import matplotlib.pyplot as plt &lt;br /&gt;
##Load your data and print it &lt;br /&gt;
file = '/home/lteinturier/Documents/PhD/wasp43b/chemistry_project/input_5xsolar.nc'&lt;br /&gt;
data = xr.open_dataset(file,decode_times=False)&lt;br /&gt;
print(data)&lt;br /&gt;
##extracting the altitude level #20 for the whole file&lt;br /&gt;
data = data.isel(altitude=20)&lt;br /&gt;
##let's assume that data hold a time-series of the temperature. Let's average it in time&lt;br /&gt;
temp = data['temp'].mean(&amp;quot;Time&amp;quot;,keep_attrs=True) #we keep the attribute when averaging to conserve the DataArray structure&lt;br /&gt;
##now we plot &lt;br /&gt;
fig = temp.plot.contourf(cmap='gnuplot',levels=50) #choose the colormap and the number of contourf levels &lt;br /&gt;
fig.ax.set_title(&amp;quot;P = {:.2e} mbar&amp;quot;.format(data.p.mean().values)) ##set-up your title. If you don't change it, the title will be the altitude in km of your atmospheric level&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This is only a fraction of what Xarray can do. Check the [https://docs.xarray.dev/en/stable/user-guide/index.html documentation] for more.&lt;br /&gt;
&lt;br /&gt;
==== Python tutorials to make pretty visuals ====&lt;br /&gt;
&lt;br /&gt;
We provide a tutorial on how to make pretty visuals using Generic PCM 3-D simulations [https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/Plots_With_PyVista here].&lt;br /&gt;
&lt;br /&gt;
=== Planetoplot ===&lt;br /&gt;
&lt;br /&gt;
Planetoplot is a in-house, python based library developped to vizualize Generic PCM data.&lt;br /&gt;
&lt;br /&gt;
The code and documentation can be found at: https://nbviewer.org/github/aymeric-spiga/planetoplot/blob/master/tutorial/planetoplot_tutorial.ipynb&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Generic-LMDZ]]&lt;br /&gt;
[[Category:Generic-DYNAMICO]]&lt;br /&gt;
[[Category:Generic-WRF]]&lt;br /&gt;
[[Category:Generic-1D]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2313</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2313"/>
				<updated>2025-01-15T08:46:41Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_diagpem.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation and reset the initial starting files to prepare a new simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;concat_diagpem.sh&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; modifies the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; according to the date set in the file &amp;quot;run_PEM.def&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify the orbital parameters in a &amp;quot;startfi.nc&amp;quot; file, that is obliquity, eccentricity, Ls perihelion and the initial Ls. It is useful when one wants a chained simulation to start at a specific date. In this case, the orbital parameters should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; which can be found in the PEM deftank.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Help_Mars_PEM&amp;diff=2312</id>
		<title>Help Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Help_Mars_PEM&amp;diff=2312"/>
				<updated>2025-01-14T08:22:09Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This mediawiki site hosts a collection of pages dedicated to various aspects of the PEM, such as its installation and its use.&lt;br /&gt;
&lt;br /&gt;
For a first glimpse or even an initial use of the model, the links in the menu of the left panel on this page, under &amp;quot;Mars PEM&amp;quot;, should be good starting points.&lt;br /&gt;
&lt;br /&gt;
Beyond that, you have the following possibilities:&lt;br /&gt;
# Check out the [[Category:Planetary-Evolution-Model| dedicated category page]] referencing of individual pages which are tagged with &amp;quot;Planetary-Evolution-Model&amp;quot;;&lt;br /&gt;
# Check out the [[Special:AllPages| dedicated page]] referencing all the pages in this mediawiki site;&lt;br /&gt;
# Use the '''Search Box''' at the top right-hand corner of the page with keywords.&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2311</id>
		<title>Tool Box Mars PEM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PEM&amp;diff=2311"/>
				<updated>2025-01-14T08:19:45Z</updated>
		
		<summary type="html">&lt;p&gt;Jbclement: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are few tools provided along the PEM which can be found in the directory &amp;lt;code&amp;gt;LMDZ.COMMON/libf/evolution/deftank/&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;README&amp;lt;/code&amp;gt; text file gives information about the different files that this directory contains.&lt;br /&gt;
&lt;br /&gt;
The current tools available for the PEM in this directory are:&lt;br /&gt;
* &amp;lt;code&amp;gt;clean.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;concat_diagpem.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;inipem_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_orbit.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;multiple_exec.sh &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_evol_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;visu_layering.py &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purpose of these tools is described in the sections below. Their usage is quite straightforward and all the parameters to be modified by the user are always gathered at the beginning of the file, in the header, with short explanations.&lt;br /&gt;
&lt;br /&gt;
== Cleaning of files (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;clean.sh&amp;lt;/code&amp;gt; cleans the folder after a PEM simulation.&lt;br /&gt;
&lt;br /&gt;
== Merging the PEM outputs (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;concat_diagpem.sh&amp;lt;/code&amp;gt; allows to concatenate along the variable 'Time' all the &amp;quot;diagpem&amp;quot; files (PEM outputs) into one NetCDF file. 'Time' is re-indexed with the numbering of Martian years simulated by the PEM run. It is useful if one wants to visualize and analyse the evolution of variables during all the PEM runs of the chained simulation.&lt;br /&gt;
&lt;br /&gt;
== Initialization of orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;inipem_orbit.sh&amp;lt;/code&amp;gt; modifies the orbital parameters of a file &amp;quot;startfi.nc&amp;quot; according to the date set in the file &amp;quot;run_PEM.def&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Setting the orbital parameters (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_orbit.sh&amp;lt;/code&amp;gt; allows to modify the orbital parameters in a &amp;quot;startfi.nc&amp;quot; file, that is obliquity, eccentricity, Ls perihelion and the initial Ls. It is useful when one wants a chained simulation to start at a specific date. In this case, the orbital parameters should be consistent with Laskar's data in &amp;quot;obl_ecc_lsp.asc&amp;quot; which can be found in the PEM deftank.&lt;br /&gt;
&lt;br /&gt;
== Setting a variable in a NetCDF file (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script file &amp;lt;code&amp;gt;modify_startfi_var.sh &amp;lt;/code&amp;gt; modifies the value of a variable in a file &amp;quot;startfi.nc&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Lauching multiple simulations (pre-processing) ==&lt;br /&gt;
&lt;br /&gt;
The bash script &amp;lt;code&amp;gt;modify_startfi_var.sh&amp;lt;/code&amp;gt; executes multiple scripts in subdirectories. It is useful to launch multiple simulations at once.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization overged time (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_evol_layering.py&amp;lt;/code&amp;gt; outputs the stratification data over time from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
== Layering visualization (post-processing) ==&lt;br /&gt;
&lt;br /&gt;
The Python script file &amp;lt;code&amp;gt;visu_layering.py&amp;lt;/code&amp;gt; outputs the stratification data from the &amp;quot;startpem.nc&amp;quot; files.&lt;br /&gt;
&lt;br /&gt;
[[Category:Planetary-Evolution-Model]]&lt;/div&gt;</summary>
		<author><name>Jbclement</name></author>	</entry>

	</feed>