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

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=The_XIOS_Library&amp;diff=3264</id>
		<title>The XIOS Library</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=The_XIOS_Library&amp;diff=3264"/>
				<updated>2026-04-30T09:57:07Z</updated>
		
		<summary type="html">&lt;p&gt;Jmauxion: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [https://forge.ipsl.jussieu.fr/ioserver/wiki XIOS] (Xml I/O Server) library is based on client-server principles where the server manages the outputs asynchronously from the client (the climate model) so that the bottleneck of writing data is alleviated.&lt;br /&gt;
&lt;br /&gt;
== Installing the XIOS library ==&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
There are a couple of prerequisites to installing and using the XIOS library:&lt;br /&gt;
# An MPI library must be available&lt;br /&gt;
# A NetCDF4-HDF5 library, preferably compiled with MPI enabled, must be available (see, e.g. dedicated section on  [[The_netCDF_library]])&lt;br /&gt;
The rest of this page assume all prerequisites are met. People interested in building an appropriate NetCDF library on their Linux machine might be interested in the following installation script: https://web.lmd.jussieu.fr/~lmdz/pub/script_install/install_netcdf4_hdf5.bash (which might need some adaptations to work in your specific case).&lt;br /&gt;
&lt;br /&gt;
=== Downloading and compiling the XIOS library ===&lt;br /&gt;
The XIOS source code is available for download using svn (subversion). To download it, go to your trunk repository and run the line e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
svn co http://forge.ipsl.fr/ioserver/svn/XIOS/trunk XIOS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* To compile the library, one must first have adequate architecture &amp;quot;arch&amp;quot; files at hand, just like for the GCM (see [[The_Target Architecture_(&amp;quot;arch&amp;quot;)_Files]]). In principle both ''arch.env'' and ''arch.path'' files could be the same as for the GCM; ''arch.fcm'' will of course differ, as XIOS source code is in C++ (along with a Fortran interface). If using a &amp;quot;known&amp;quot; machine (e.g. Occigen, Irene-Rome, Ciclad) then ready-to-use up-to-date arch files for that machine should be present in the ''arch'' directory. If not you will have to create your own (it is advised to use the existing ones as templates!)&lt;br /&gt;
* Assuming ''some_machine'' arch files (i.e. files ''arch-some_machine.env'', ''arch-some_machine.path'', ''arch-some_machine.fcm'') are present in the '''arch''' subdirectory, compiling the XIOS is done using the dedicated ''make_xios'' script, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
./make_xios --prod --arch some_machine --job 8 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the compilation steps went well then the '''lib''' directory should contain file ''libxios.a'' and the '''bin''' directory should contain&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fcm_env.ksh  generic_testcase.exe  xios_server.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== XIOS documentation ===&lt;br /&gt;
Note that the downloaded XIOS distribution includes some documentation in the '''doc''' subdirectory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reference_xml.pdf  XIOS_reference_guide.pdf  XIOS_user_guide.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Definitely worth checking out!&lt;br /&gt;
&lt;br /&gt;
== Compiling the GCM with the XIOS library ==&lt;br /&gt;
&lt;br /&gt;
To compile with XIOS enabled, one must specify the option&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 -io xios&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== XIOS output controls ==&lt;br /&gt;
&lt;br /&gt;
All aspects of the outputs (name, units, file, post-processing operations, etc.) are controlled by dedicated XML files which are read at run-time. Samples of xml files are provided in the &amp;quot;deftank&amp;quot; directory.&lt;br /&gt;
&lt;br /&gt;
=== In a nutshell ===&lt;br /&gt;
* the master file read by XIOS is ''iodef.xml''; and contains specific XIOS parameters such as ''using_server'' to dictate whether XIOS is run in client-server mode (true) or attached (false) mode, ''info_level'' to set the verbosity of XIOS messages (0: none, 100: very verbose), ''print_file'' to set whether XIOS messages will be sent to standard output (false) or dedicated xios_*.out and xios_*.err files (true).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;variable id=&amp;quot;using_server&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;false&amp;lt;/variable&amp;gt;&lt;br /&gt;
                        &amp;lt;variable id=&amp;quot;info_level&amp;quot; type=&amp;quot;int&amp;quot;&amp;gt;0&amp;lt;/variable&amp;gt;&lt;br /&gt;
                        &amp;lt;variable id=&amp;quot;print_file&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt; false &amp;lt;/variable&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* It is common practice to have LMDZ-related definitions and outputs in separate XML files, e.g. ''context_lmdz.xml'' which are included in ''iodef.xml'' via the ''src'' attribute, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;context id=&amp;quot;LMDZ&amp;quot; src=&amp;quot;./context_lmdz_physics.xml&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The ''context_lmdz_physics.xml'' file must then contain all fields/grid/file output definitions, which may be split into multiple XML files, for instance the definition of model variables (i.e. all fields that may be outputed) is often put in a separate file ''field_def_physics.xml'' which is referenced within ''context_lmdz_physics.xml'' as:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;field_definition src=&amp;quot;./field_def_physics.xml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Concerning output files, the current recommended practice is to use separate ''file_def_histsomething_lmdz.xml'' files, one for each ''histsomething.nc'' file to generate, and include these in ''context_lmdz.xml'' using the ''file_definition'' key. e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;!-- Define output files&lt;br /&gt;
              Each file contains the list of variables and their output levels --&amp;gt;&lt;br /&gt;
  &amp;lt;file_definition src=&amp;quot;./file_def_histins.xml&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;file_definition src=&amp;quot;./file_def_specIR.xml&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Some XIOS key concepts ===&lt;br /&gt;
==== calendars ====&lt;br /&gt;
The calendar is set via the Fortran source code (see '''xios_output_mod.F90''' in the physics). Without going into details here, note that it is flexible enough so that day length, year length, etc. may be defined by the user. However a strong limitation is that the calendar time step should be an integer number of seconds.&lt;br /&gt;
&lt;br /&gt;
TODO: refer to specific stuff/settings for Mars, Generic, Venus cases...&lt;br /&gt;
&lt;br /&gt;
==== axes, domains and grids ====&lt;br /&gt;
First a bit of XIOS nomenclature:&lt;br /&gt;
* an '''axis''' is 1D; e.g. pseudo-altitude or pseudo-pressure or sub-surface depth or wavelength or ...&lt;br /&gt;
* a '''domain''' is a horizontal 2D surface; e.g. the globe or some portion of it&lt;br /&gt;
* a '''grid''' is the combination of a domain and one axis (or more); e.g. the atmosphere or the sub-surface of a planet&lt;br /&gt;
Most of the '''axis''' and '''domain''' are defined in the code (since all the information is known there) and only referred to in the XML via dedicated '''id''' values, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;axis_definition&amp;gt;&lt;br /&gt;
        &amp;lt;axis id=&amp;quot;presnivs&amp;quot; &lt;br /&gt;
              standard_name=&amp;quot;Pseudo-pressure of model vertical levels&amp;quot; &lt;br /&gt;
              unit=&amp;quot;Pa&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;/axis&amp;gt;&lt;br /&gt;
        &amp;lt;axis id=&amp;quot;altitude&amp;quot; &lt;br /&gt;
              standard_name=&amp;quot;Pseudo-altitude of model vertical levels&amp;quot; &lt;br /&gt;
              unit=&amp;quot;km&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;/axis&amp;gt;&lt;br /&gt;
    &amp;lt;/axis_definition&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Likewise the global computational domain is defined in the code and known in the XML via its '''id'''(=&amp;quot;dom_glo&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;domain_definition&amp;gt;&lt;br /&gt;
        &amp;lt;domain id=&amp;quot;dom_glo&amp;quot; data_dim=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/domain_definition&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
From there one may generate a grid, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;grid_definition&amp;gt;&lt;br /&gt;
        &amp;lt;!-- toggle axis id below to change output vertical axis --&amp;gt;&lt;br /&gt;
        &amp;lt;grid id=&amp;quot;grid_3d&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;domain id=&amp;quot;dom_glo&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;!-- &amp;lt;axis id=&amp;quot;presnivs&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
            &amp;lt;axis id=&amp;quot;altitude&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/grid&amp;gt;&lt;br /&gt;
    &amp;lt;/grid_definition&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that '''grid_3d''' is defined in the XML file and thus may be changed by the user without having to modify the PCM source code. For instance by simply adding the following definitions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;domain_definition&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
        &amp;lt;domain id=&amp;quot;dom_128_96&amp;quot; ni_glo=&amp;quot;128&amp;quot; nj_glo=&amp;quot;96&amp;quot; type=&amp;quot;rectilinear&amp;quot;  &amp;gt;&lt;br /&gt;
          &amp;lt;generate_rectilinear_domain/&amp;gt;&lt;br /&gt;
          &amp;lt;interpolate_domain order=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/domain&amp;gt;&lt;br /&gt;
    &amp;lt;/domain_definition&amp;gt;&lt;br /&gt;
    &amp;lt;grid_definition&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
        &amp;lt;grid id=&amp;quot;my_grid_3d&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;domain id=&amp;quot;dom_128_96&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;axis id=&amp;quot;altitude&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/grid&amp;gt;&lt;br /&gt;
    &amp;lt;/grid_definition&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Specifying to output variables on grid '''my_grid_3d''' will trigger XIOS interpolations so that the output fields are on a regular 128x96 longitudexlatitude grid.&lt;br /&gt;
&lt;br /&gt;
One can also add some specifications on the longitude and latitude bounds of the domain to generate:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;domain_definition&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
        &amp;lt;domain id=&amp;quot;dom_64_49&amp;quot; ni_glo=&amp;quot;64&amp;quot; nj_glo=&amp;quot;49&amp;quot; type=&amp;quot;rectilinear&amp;quot;  &amp;gt;&lt;br /&gt;
          &amp;lt;generate_rectilinear_domain lat_start=&amp;quot;90&amp;quot; lat_end=&amp;quot;-90&amp;quot; lon_start=&amp;quot;-180&amp;quot; lon_end=&amp;quot;174.375&amp;quot; /&amp;gt;&lt;br /&gt;
          &amp;lt;interpolate_domain order=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/domain&amp;gt;&lt;br /&gt;
    &amp;lt;/domain_definition&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== field definitions ====&lt;br /&gt;
For XIOS a field is defined with and '''id''' and most be assigned to a reference '''grid''' (this is how XIOS knows a field is a simple scalar, or a surface or a volume, and thus to which computational grid it is related to).e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;field_definition prec=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;field_group id=&amp;quot;fields_2D&amp;quot; domain_ref=&amp;quot;dom_glo&amp;quot;&amp;gt;&lt;br /&gt;
           &amp;lt;field id=&amp;quot;aire&amp;quot;&lt;br /&gt;
                   long_name=&amp;quot;Mesh area&amp;quot;&lt;br /&gt;
                   unit=&amp;quot;m2&amp;quot; /&amp;gt;&lt;br /&gt;
           &amp;lt;field id=&amp;quot;phis&amp;quot;&lt;br /&gt;
                   long_name=&amp;quot;Surface geopotential (gz)&amp;quot; &lt;br /&gt;
                   unit=&amp;quot;m2/s2&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field id=&amp;quot;tsol&amp;quot;&lt;br /&gt;
                   long_name=&amp;quot;Surface Temperature&amp;quot; &lt;br /&gt;
                   unit=&amp;quot;K&amp;quot; /&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/field_group&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;field_group id=&amp;quot;fields_3D&amp;quot; grid_ref=&amp;quot;grid_3d&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field id=&amp;quot;temp&amp;quot;&lt;br /&gt;
                   long_name=&amp;quot;Atmospheric temperature&amp;quot;&lt;br /&gt;
                   unit=&amp;quot;K&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field id=&amp;quot;pres&amp;quot;&lt;br /&gt;
                   long_name=&amp;quot;Atmospheric pressure&amp;quot; &lt;br /&gt;
                   unit=&amp;quot;Pa&amp;quot; /&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
       &amp;lt;/field_group&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;/field_definition&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is vital that all the fields which are sent to XIOS via the code are declared in the XML file otherwise there will be a run-time error message of the likes of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In file &amp;quot;object_factory_impl.hpp&amp;quot;, function &amp;quot;static std::shared_ptr&amp;lt;U&amp;gt; xios::CObjectFactory::GetObject(const std::__cxx11::basic_string&amp;lt;char, std::char_traits&amp;lt;char&amp;gt;, std::allocator&amp;lt;char&amp;gt;&amp;gt; &amp;amp;) [with U = xios::CAxis]&amp;quot;,  line 78 -&amp;gt; [ id = weirdvar, U = field ] object was not found.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In the message above XIOS received from the code a variable called &amp;quot;weirdvar&amp;quot; which is not defined in the XML... One must update the XML file with the proper definition (&amp;lt;field id=&amp;quot;weirdvar&amp;quot; ... /&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
==== output file definitions ====&lt;br /&gt;
It is by defining a '''file''' that the user specifies what the output file will be, which variables it will contain, etc. as illustrated with this simple Venusian example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;file_definition&amp;gt;&lt;br /&gt;
        &amp;lt;!-- Instantaneous outputs; every physics time steps --&amp;gt;&lt;br /&gt;
        &amp;lt;file id=&amp;quot;Xins&amp;quot;&lt;br /&gt;
              output_freq=&amp;quot;1ts&amp;quot; &lt;br /&gt;
              type=&amp;quot;one_file&amp;quot;&lt;br /&gt;
              enabled=&amp;quot;.true.&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;!-- VARS 2D --&amp;gt;&lt;br /&gt;
            &amp;lt;field_group operation=&amp;quot;instant&amp;quot;&lt;br /&gt;
                         freq_op=&amp;quot;1ts&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;phis&amp;quot; operation=&amp;quot;once&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;aire&amp;quot; operation=&amp;quot;once&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;tsol&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/field_group&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;!-- VARS 3D --&amp;gt;&lt;br /&gt;
            &amp;lt;field_group operation=&amp;quot;instant&amp;quot;&lt;br /&gt;
                         freq_op=&amp;quot;1ts&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;temp&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;pres&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/field_group&amp;gt;&lt;br /&gt;
        &amp;lt;/file&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It is mandatory to have an '''operation''' attribute defined (this can be either done at the level of the definition of the variable or, as above at the level of the definition of the outputs); there is no default. If this attribute is missing you will get an error message of the likes of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In file &amp;quot;attribute_template_impl.hpp&amp;quot;, function &amp;quot;virtual void xios::CAttributeTemplate&amp;lt;std::basic_string&amp;lt;char&amp;gt;&amp;gt;::checkEmpty() const [T = std::basic_string&amp;lt;char&amp;gt;]&amp;quot;,  line 78 -&amp;gt; On checking attribute with id=operation : data is not initialized &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Thorougher description with illustrative examples ===&lt;br /&gt;
TODO: PUT SOME SIMPLE ILLUSTRATIVE EXAMPLES HERE&lt;br /&gt;
&lt;br /&gt;
See for example the following page: [[controling outputs in the dynamics with DYNAMICO]]&lt;br /&gt;
&lt;br /&gt;
==== Specifying that the time axis should be labeled in days rather than seconds ====&lt;br /&gt;
The default for XIOS is to label temporal axes (&amp;quot;time_instant&amp;quot; and &amp;quot;time_counter&amp;quot;) in seconds. But one may ask that they be labelled in days by setting the optional '''time_unit''' attribute of a file to '''days''', e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;file id=&amp;quot;my_output_file&amp;quot; &lt;br /&gt;
       output_freq=&amp;quot;1ts&amp;quot;&lt;br /&gt;
       time_units=&amp;quot;days&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/file&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Force flushing and writing files every ### time steps ====&lt;br /&gt;
XIOS handles its buffers and only writes to output files when needed. This is quite efficient and worthwhile, except for instance when the model crashes as some data might then not be included in the output files. One may use the '''sync_freq''' (optional) attribute of a file to force XIOS to write to the file at some predefined frequency, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;file id=&amp;quot;my_output_file&amp;quot; &lt;br /&gt;
       output_freq=&amp;quot;1ts&amp;quot;&lt;br /&gt;
       sync_freq=&amp;quot;1ts&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/file&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Very useful when debugging.&lt;br /&gt;
&lt;br /&gt;
==== Specifying an offset (in time) for the outputs ====&lt;br /&gt;
One may use the attribute '''record_offset''' of a file to impose that the outputs in the file begin after a certain number of time steps of the simulation (useful for instance when debugging). For instance if there are 192 time steps per day and the run is 10 days long but one only wants outputs for the last day and at every time step of that day then one should have a '''record_offset''' of -9*192=-1728 (note the ''-''; the value to specify is negative), e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;file id=&amp;quot;my_output_file&amp;quot; &lt;br /&gt;
       output_freq=&amp;quot;1ts&amp;quot;&lt;br /&gt;
       record_offset=&amp;quot;-1728ts&amp;quot;&lt;br /&gt;
       time_units=&amp;quot;days&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field_group operation=&amp;quot;instant&amp;quot;&lt;br /&gt;
                         freq_op=&amp;quot;1ts&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;my_variable&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/field_group&amp;gt;&lt;br /&gt;
 &amp;lt;/file&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The ''time_counter'' values in the file will be from 9.0052 (=9.+1./192.) to 10. (since here the time axis unit is requested to be in days)&lt;br /&gt;
&lt;br /&gt;
An alternative way to have the first n timesteps of a time series excluded from the output is to specify a ''freq_offset'' attribute to the field. For instance, to follow up on the example above, to extract every time step of the final 10th day of simulation with 192 time steps par day one should specify a '''freq_offset''' of 9*192=1728, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;file id=&amp;quot;my_output_file&amp;quot; &lt;br /&gt;
       output_freq=&amp;quot;1ts&amp;quot;&lt;br /&gt;
       time_units=&amp;quot;days&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field_group operation=&amp;quot;instant&amp;quot;&lt;br /&gt;
                         freq_offset=&amp;quot;1728ts&amp;quot;&lt;br /&gt;
                         freq_op=&amp;quot;1ts&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;field field_ref=&amp;quot;my_variable&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;/field_group&amp;gt;&lt;br /&gt;
 &amp;lt;/file&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The main difference, compared to the previous example using the '''record_offset''' file attribute, is that the ''time_counter'' values in the file will this time be from 0.0052 (=1./192) to 1.0.&lt;br /&gt;
&lt;br /&gt;
==== Saving or loading interpolation weights ====&lt;br /&gt;
With the XIOS library one can define output domains (grid) which are different from input domains (grids), and XIOS does the necessary interpolation.&lt;br /&gt;
&lt;br /&gt;
This requires, once source and destination grids are known, to compute some interpolation weights (during the initialization step). For large grids, this can take some time. One can however tell XIOS to save the interpolation weights in a file and use that file (if it is present) rather than recompute them when a new simulation is ran.&lt;br /&gt;
&lt;br /&gt;
In practice one must add extra keys to the &amp;quot;interpolate_domain&amp;quot; tag, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;domain id=&amp;quot;dom_256_192&amp;quot; type=&amp;quot;rectilinear&amp;quot; ni_glo=&amp;quot;256&amp;quot; nj_glo=&amp;quot;192&amp;quot; &amp;gt;&lt;br /&gt;
      &amp;lt;generate_rectilinear_domain/&amp;gt;&lt;br /&gt;
      &amp;lt;interpolate_domain order=&amp;quot;1&amp;quot; write_weight=&amp;quot;true&amp;quot; mode=&amp;quot;read_or_compute&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/domain&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will automatically generate a NetCDF file containing the weights. Default file name will be something like xios_interpolation_weights_CONTEXT_INPUTDOMAIN_OUTPUTDOMAIN.nc , where CONTEXT, INPUTDOMAIN and OUTPUTDOMAIN are inherited from the context (i.e. definitions of these in the xml files).&lt;br /&gt;
&lt;br /&gt;
One can specify the name of the file with the key &amp;quot;weight_filename&amp;quot;, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;domain id=&amp;quot;dom_256_192&amp;quot; type=&amp;quot;rectilinear&amp;quot; ni_glo=&amp;quot;256&amp;quot; nj_glo=&amp;quot;192&amp;quot; &amp;gt;&lt;br /&gt;
      &amp;lt;generate_rectilinear_domain/&amp;gt;&lt;br /&gt;
      &amp;lt;interpolate_domain order=&amp;quot;1&amp;quot; write_weight=&amp;quot;true&amp;quot; mode=&amp;quot;read_or_compute&amp;quot; weight_filename=&amp;quot;xios_weights&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/domain&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Preserving extensive variables ====&lt;br /&gt;
It can also happen that for a given variable (extensive ones for instance) we want the interpolation not to be conservative. For example, a variable like the area of a mesh grid should not be interpolated between different domains. Since the interpolation is specific to a domain (and defined in the &amp;quot;domain id&amp;quot;), we have to create a new domain for all the variable that should be interpolated in another way. For the variable &amp;quot;Area&amp;quot; for example, the syntax is as follow :&lt;br /&gt;
&lt;br /&gt;
* Create the new domain:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;domain id=&amp;quot;dom_64_48_quantity_T&amp;quot; type=&amp;quot;rectilinear&amp;quot; ni_glo=&amp;quot;64&amp;quot; nj_glo=&amp;quot;48&amp;quot;   &amp;gt;&lt;br /&gt;
   &amp;lt;generate_rectilinear_domain/&amp;gt;&lt;br /&gt;
   &amp;lt;interpolate_domain quantity=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/domain&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Assign the variable to this domain:&lt;br /&gt;
Later in the context file, the variable should be outputted using this new domain (note that it still can be outputed in the same file as the other variables) :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field_group domain_ref=&amp;quot;dom_64_48_quantity_T&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;field_group operation=&amp;quot;instant&amp;quot;&lt;br /&gt;
     freq_op=&amp;quot;1ts&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;field field_ref=&amp;quot;area&amp;quot; operation=&amp;quot;once&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/field_group&amp;gt;&lt;br /&gt;
&amp;lt;/field_group&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Examples &amp;amp; adding outputs ===&lt;br /&gt;
&lt;br /&gt;
See [[LMDZ XIOS outputs]] for more details on the outputs generated via XIOS for the LMDZ dynamics/physics.&lt;br /&gt;
&lt;br /&gt;
If you use [[DYNAMICO]], check out the [[Controling outputs in the dynamics with DYNAMICO|DYNAMICO outputs]] page.&lt;br /&gt;
&lt;br /&gt;
== Using the XIOS library in client-server mode ==&lt;br /&gt;
To run with XIOS in client-server mode requires the following:&lt;br /&gt;
* The client-server mode should be activated (in file ''iodef.xml''):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;variable id=&amp;quot;using_server&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/variable&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* The '''xios_server.exe''' executable should be present alongside the GCM executable '''gcm_***.e''' and they should be run together in MPMD (Multiple Programs, Multiple Data) mode : some of the MPI processes being allocated to the GCM and the others to XIOS ; in practice much less are needed by XIOS than the GCM, this however also depends on the amount of outputs and postprocessing computations, e.g. temporal averaging and grid interpolations, that XIOS will have to do. For example if the MPI execution wrapper is ''mpirun'' and that 26 processes are to be used by the GCM ''gcm_64x52x20_phygeneric_para.e'' and 2 by XIOS (i.e. using overall 28 processes):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mpirun -np 26 gcm_64x52x20_phygeneric_para.e &amp;gt; gcm.out 2&amp;gt;&amp;amp;1 : -np 2 xios_server.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Generic-Model]]&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Venus-Model]]&lt;br /&gt;
[[Category:Titan-Model]]&lt;/div&gt;</summary>
		<author><name>Jmauxion</name></author>	</entry>

	<entry>
		<id>http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PCM&amp;diff=2747</id>
		<title>Tool Box Mars PCM</title>
		<link rel="alternate" type="text/html" href="http://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php?title=Tool_Box_Mars_PCM&amp;diff=2747"/>
				<updated>2025-06-16T10:45:17Z</updated>
		
		<summary type="html">&lt;p&gt;Jmauxion: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Post-processing tools provided with the Mars PCM ==&lt;br /&gt;
First and foremost there are a number of postprocessing utilities (self-standing tools) which can be found in the &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LMDZ.MARS/util&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
directory; you certainly want to first read the README file there.&lt;br /&gt;
&lt;br /&gt;
Current contents of this directory is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
aeroptical.def	   expandstartfi.F90	localtime.def	 solzenangle.F90&lt;br /&gt;
aeroptical.F90	   extract.F90		localtime.F90	 startarchive2icosa&lt;br /&gt;
aeropt_mod.F90	   extract.points.def	lslin.def	 streamfunction.F90&lt;br /&gt;
analyse_netcdf.py  extract.profile.def	lslin.F90	 xvik&lt;br /&gt;
compile		   gencol.def		README		 zrecast.auto.def&lt;br /&gt;
concatnc.def	   gencol.F90		simu_MCS.def	 zrecast.F90&lt;br /&gt;
concatnc.F90	   hrecast.def		simu_MCS.F90	 zrecast.manual.def&lt;br /&gt;
display_netcdf.py  hrecast.F90		solzenangle.def&lt;br /&gt;
&amp;lt;/pre&amp;gt;  &lt;br /&gt;
the ''compile'' script is an example of how to compile any of the utilities, which you will have to adapt to your needs (mostly concerns setting the right path to the NetCDF library). All the post-processing tools are meant to be run interactively (asking the user for some instructions), hence the ''*.def'' files as it is most of the time more convenient (once one knows the tools and questions it will ask) to redirect this list of answers to the standard input of the tool, e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
zrecast.e &amp;lt; zrecast.manual.def&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Main programs (other than GCM) but included in the Mars PCM package ==&lt;br /&gt;
There are a few other main programs that are included with the GCM. &lt;br /&gt;
&lt;br /&gt;
Advanced stuff: In practice these main programs are located under ''LMDZ.MARS/dynphy_lonlat/phymars/'' as they are at the interface between lon-lat dynamics and the Mars physics package (i.e. need to use both and thus can only be applied in that context).&lt;br /&gt;
&lt;br /&gt;
=== start2archive ===&lt;br /&gt;
A main program to collect multiple &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; files from a series simulations and store them in a &amp;lt;code&amp;gt;start_archive.nc&amp;lt;/code&amp;gt; file. For this one simply needs to run the &amp;lt;code&amp;gt;startarchive&amp;lt;/code&amp;gt; program in the directory. It will automatically fetch code&amp;gt;start.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; files and generate &amp;lt;code&amp;gt;start_archive.nc&amp;lt;/code&amp;gt;. If a &amp;lt;code&amp;gt;start_archive.nc&amp;lt;/code&amp;gt; file is already present then the current &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; files are added to the &amp;lt;code&amp;gt;start_archive.nc&amp;lt;/code&amp;gt; file (which can contain multiple initial states, as long as they are on the same grid and correspond to different dates.&lt;br /&gt;
&lt;br /&gt;
=== newstart ===&lt;br /&gt;
A main program to:&lt;br /&gt;
* extract (and interpolate) &amp;lt;code&amp;gt;restart.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt; files from a &amp;lt;code&amp;gt;start_archive.nc&amp;lt;/code&amp;gt; file or from a pair of &amp;lt;code&amp;gt;start.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;startfi.nc&amp;lt;/code&amp;gt; files. The subtle difference between the two setup is that grid interpolation (horizontal and/or vertical) is only possible if using a &amp;lt;code&amp;gt;start_archive.nc&amp;lt;/code&amp;gt; input file&lt;br /&gt;
* modify values and fields contained in the initial condition file&lt;br /&gt;
* Compiling &amp;lt;code&amp;gt;newstart&amp;lt;/code&amp;gt; is done using the [[The makelmdz fcm GCM Compilation Script|makelmdz_fcm]] utility. The program is then meant to be run interactively with the user providing options and choices when prompted.&lt;br /&gt;
* Once the program has run and finished without error, it will generate &amp;lt;code&amp;gt;restart.nc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;restartfi.nc&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== xvik ===&lt;br /&gt;
A post-processing utility to analyse the modeled CO2 cycle&lt;br /&gt;
&lt;br /&gt;
== testphys1d ==&lt;br /&gt;
More than a pre- or post-processing tool, this is a 1D (single column) version of the PCM. More about it is on the dedicated page: [[Mars 1D testphys1d program]].&lt;br /&gt;
&lt;br /&gt;
Note that there is also a separate &amp;quot;self-standing&amp;quot; 1D model, the &amp;quot;1D thermal model&amp;quot;, which can be downloaded from this page: [http://www-planets.lmd.jussieu.fr/ http://www-planets.lmd.jussieu.fr/]. This is essentially a frozen version of ''testphys1d'' with some additional tweaks to make it more user-friendly.&lt;br /&gt;
&lt;br /&gt;
== Visualizing the outputs ==&lt;br /&gt;
The GCM and most of the post-processing tools mentioned above produce NetCDF files, which one most likely will need to visualize.&lt;br /&gt;
There are a number of tools available (free or not). Here is a selection:&lt;br /&gt;
* Ncview is a very basic tool, mostly useful for a simple quick look.&lt;br /&gt;
* Panoply is a user-friendly tool for viewing NetCDF data, available here: https://www.giss.nasa.gov/tools/panoply/&lt;br /&gt;
* Ferret is another nice tool for viewing and processing NetCDF data, see their official page: https://ferret.pmel.noaa.gov/Ferret/ and also [[Some Ferret tips and pointers|this page]]&lt;br /&gt;
* Many also like to write up their own python scripts&lt;br /&gt;
&lt;br /&gt;
== Maniuplating NetCDF files with external tools ==&lt;br /&gt;
In addition to the programs that come with the Mars PCM distribution, there are many public tools available that provide more general capabilities.   Here are some selections that you may&lt;br /&gt;
find to be of value:&lt;br /&gt;
* NetCDF Operators (NCO):  This toolbox is a combination of compiled programs and scripts for manipulating NetCDF files, including regridding and interpolating.  This public domain tools was developed at the University of California - Irvine and appears to be actively maintained.  Find it (along with documentation) at the official site: https://nco.sourceforge.net.  A reasonable tutorial, though it is html based and a few years old (like playing an Atari console game), may be downloaded here:  https://www.hydroshare.org/resource/4b5a903a02e64b078d5a581a010f45a4/&lt;br /&gt;
&lt;br /&gt;
[[Category:Mars-Model]]&lt;br /&gt;
[[Category:Mars-1D]]&lt;/div&gt;</summary>
		<author><name>Jmauxion</name></author>	</entry>

	</feed>