Index: /trunk/LMDZ.PLUTO/deftank/dynamico/run.def
===================================================================
--- /trunk/LMDZ.PLUTO/deftank/dynamico/run.def	(revision 3544)
+++ /trunk/LMDZ.PLUTO/deftank/dynamico/run.def	(revision 3545)
@@ -1,89 +1,2 @@
-#---------------- Mesh ----------------
-
-# Number of subdivisions on a main triangle : integer (default=40)
-nbp = 40
-
-# Number of vertical layers : integer (default=19)
-llm = 27
-
-# Vertical grid : [std|ncar|ncarl30] (default=std)
-# disvert = std
-disvert = plugin
-hybrid = .false.
-
-# Mesh optimisation : number of iterations : integer (default=0)
-optim_it = 1000
-
-# Sub splitting of main rhombus : integer (default=1)
-nsplit_i = 10
-nsplit_j = 10
-
-#number of openmp task on vertical level
-omp_level_size=1
-
-#---------------- Numerics ----------------
-
-# Advection called every itau_adv time steps : integer (default=2)
-itau_adv = 1
-
-# Time step in s : real (default=480)
-# dt = 720
-# Alternative to specifying "dt", specify number of steps per day : day_step
-day_step = 8000
-
-# Number of tracers : integer (default=1)
-nqtot = 7
-
-#---------------- Time and output ----------------
-
-# Time style : [none|dcmip] (default=dcmip)
-time_style = none
-
-# Run length in s : real (default=??)
-# run_length = 100
-# Alternative to specifying "run_length", specify number of days to run : ndays
-ndays=1
-
-# Interval in s between two outputs : integer (default=??)
-write_period = 1000
-
-
-
-#---------------- Planet ----------------
-
-INCLUDEDEF=pluto_const.def
-
-#---------------- Physical parameters ----------------
-
-# Initial state :
-#   [jablonowsky06|academic|dcmip[1-4]|heldsz|dcmip2_schaer_noshear] (default=jablonowsky06)
-etat0 = start_file
-etat0_start_file_colocated=true
-
-# Physics package : [none|held_suarez|dcmip] (default=none)
-# physics = held_suarez
-# physics = none
-physics = phys_external
-
-startphy_file = true
-# startphy_file = false
-
-# Dissipation time for grad(div) : real (default=5000)
-tau_graddiv = 18000
-
-# Exponent of grad(div) disspation : integer (default=1)
-nitergdiv = 2
-
-# Dissipation time for curl(curl) : real (default=5000)
-tau_gradrot = 18000
-
-# Exponent of curl(curl) disspation : integer (default=1)
-nitergrot = 2
-
-# Dissipation time for div(grad) : real (default=5000)
-tau_divgrad = 18000
-
-# Exponent of div(grad) disspation : integer (default=1)
-niterdivgrad = 2
-
+INCLUDEDEF=run_icosa.def
 INCLUDEDEF=callphys.def
Index: unk/LMDZ.PLUTO/deftank/dynamico/run.def.no_startfi
===================================================================
--- /trunk/LMDZ.PLUTO/deftank/dynamico/run.def.no_startfi	(revision 3544)
+++ 	(revision )
@@ -1,90 +1,0 @@
-#---------------- Mesh ----------------
-
-# Number of subdivisions on a main triangle : integer (default=40)
-nbp = 40
-
-# Number of vertical layers : integer (default=19)
-llm = 19
-
-# Vertical grid : [std|ncar|ncarl30] (default=std)
-# disvert = std
-disvert = plugin
-hybrid = .false.
-
-# Mesh optimisation : number of iterations : integer (default=0)
-optim_it = 1000
-
-# Sub splitting of main rhombus : integer (default=1)
-nsplit_i = 10
-nsplit_j = 10
-
-#number of openmp task on vertical level
-omp_level_size=1
-
-#---------------- Numerics ----------------
-
-# Advection called every itau_adv time steps : integer (default=2)
-itau_adv = 1
-
-# Time step in s : real (default=480)
-# dt = 720
-# Alternative to specifying "dt", specify number of steps per day : day_step
-day_step = 12000
-
-# Number of tracers : integer (default=1)
-nqtot = 7
-
-#---------------- Time and output ----------------
-
-# Time style : [none|dcmip] (default=dcmip)
-time_style = none
-
-# Run length in s : real (default=??)
-run_length = 1500
-# Alternative to specifying "run_length", specify number of days to run : ndays
-# ndays=1
-
-# Interval in s between two outputs : integer (default=??)
-write_period = 1000
-
-
-
-#---------------- Planet ----------------
-
-INCLUDEDEF=pluto_const.def
-
-#---------------- Physical parameters ----------------
-
-# Initial state :
-#   [jablonowsky06|academic|dcmip[1-4]|heldsz|dcmip2_schaer_noshear] (default=jablonowsky06)
-etat0 = isothermal
-etat0_isothermal_temp=50
-etat0_ps_white_noise=0.01
-etat0_theta_rhodz_white_noise=0.01
-
-# Physics package : [none|held_suarez|dcmip] (default=none)
-# physics = held_suarez
-# physics = none
-physics = phys_external
-
-startphy_file = false
-
-# Dissipation time for grad(div) : real (default=5000)
-tau_graddiv = 18000
-
-# Exponent of grad(div) disspation : integer (default=1)
-nitergdiv = 2
-
-# Dissipation time for curl(curl) : real (default=5000)
-tau_gradrot = 18000
-
-# Exponent of curl(curl) disspation : integer (default=1)
-nitergrot = 2
-
-# Dissipation time for div(grad) : real (default=5000)
-tau_divgrad = 18000
-
-# Exponent of div(grad) disspation : integer (default=1)
-niterdivgrad = 2
-
-INCLUDEDEF=callphys.def
Index: /trunk/LMDZ.PLUTO/deftank/dynamico/run_icosa.def
===================================================================
--- /trunk/LMDZ.PLUTO/deftank/dynamico/run_icosa.def	(revision 3545)
+++ /trunk/LMDZ.PLUTO/deftank/dynamico/run_icosa.def	(revision 3545)
@@ -0,0 +1,88 @@
+#---------------- Mesh ----------------
+
+# Number of subdivisions on a main triangle : integer (default=40)
+nbp = 40
+
+# Number of vertical layers : integer (default=19)
+llm = 27
+
+# Vertical grid : [std|ncar|ncarl30] (default=std)
+# disvert = std
+disvert = plugin
+hybrid = .false.
+
+# Mesh optimisation : number of iterations : integer (default=0)
+optim_it = 1000
+
+# Sub splitting of main rhombus : integer (default=1)
+nsplit_i = 10
+nsplit_j = 10
+
+#number of openmp task on vertical level
+omp_level_size=1
+
+#---------------- Numerics ----------------
+
+# Advection called every itau_adv time steps : integer (default=2)
+itau_adv = 1
+
+# Time step in s : real (default=480)
+# dt = 720
+# Alternative to specifying "dt", specify number of steps per day : day_step
+day_step = 8000
+
+# Number of tracers : integer (default=1)
+nqtot = 7
+
+#---------------- Time and output ----------------
+
+# Time style : [none|dcmip] (default=dcmip)
+time_style = none
+
+# Run length in s : real (default=??)
+# run_length = 100
+# Alternative to specifying "run_length", specify number of days to run : ndays
+ndays=1
+
+# Interval in s between two outputs : integer (default=??)
+write_period = 1000
+
+
+
+#---------------- Planet ----------------
+
+INCLUDEDEF=pluto_const.def
+
+#---------------- Physical parameters ----------------
+
+# Initial state :
+#   [jablonowsky06|academic|dcmip[1-4]|heldsz|dcmip2_schaer_noshear] (default=jablonowsky06)
+etat0 = start_file
+etat0_start_file_colocated=true
+
+# Physics package : [none|held_suarez|dcmip] (default=none)
+# physics = held_suarez
+# physics = none
+physics = phys_external
+
+startphy_file = true
+# startphy_file = false
+
+# Dissipation time for grad(div) : real (default=5000)
+tau_graddiv = 18000
+
+# Exponent of grad(div) disspation : integer (default=1)
+nitergdiv = 2
+
+# Dissipation time for curl(curl) : real (default=5000)
+tau_gradrot = 18000
+
+# Exponent of curl(curl) disspation : integer (default=1)
+nitergrot = 2
+
+# Dissipation time for div(grad) : real (default=5000)
+tau_divgrad = 18000
+
+# Exponent of div(grad) disspation : integer (default=1)
+niterdivgrad = 2
+
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/README
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/README	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/README	(revision 3545)
@@ -0,0 +1,53 @@
+Making initial condition files for icosa_lmdz.exe from
+an LMDZ start_archive.nc file.
+
+This tutorial should follow https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/LMDZ_to_DYNAMICO_start_files. If it does not, please update it.
+
+What you need to do/know before:
+---------------------------
+Run a dynamico simulation (with startphy_file=false for example) with the desired resolution to get
+start.nc and startfi.nc. These files will be used as reference (rename as *_ref.nc) in the script.
+You can use the files named *_no_start to have an example of files to run without startfiles
+
+job_start_archive2icosa is the file you need to run start_archive2icosa on your platform (update 'arch' accordingly).
+
+Warning: the input start_archive.nc file must include SSO parameters (albedodat, ZMEA, etc) in this version, which is only available with a modified start2archive. Be sure to check if that has been updated or not.
+
+This script is currently under development and still needs to be finalized.
+Any suggestion for improvement is welcome.
+
+In a nutshell:
+--------------
+1) input file start_archive.nc needs some minor adaptations:
+- input file start_archive.nc need be converted to NetCDF4 format
+nccopy -k 4 start_archive.nc start_archive_nc4.nc
+2) script "compile" can be used to compile main tool start_archive2icosa.f90
+   as well as rearrange_startphy.f90
+3) to run, start_archive2icosa needs input files:
+- "start_archive_nc4.nc" : from step 1
+- "start_icosa_ref.nc" : a start.nc file from an icosa_lmdz.exe run (contains
+  all the necessary information about the icosaedral grid at that resolution)
+- "startphy_icosa_ref.nc" : a startfi.nc file from an icosa_lmdz.exe run (contains
+  all the necessary information about colums from physics)
+- "surface_nc4.nc" : topography file (also needs to be in NetCDF4 format)
+NB: interpolation of HR topography requires lots of memory (see job file).
+- "iodef.xml" : information about field names and grids for XIOS
+4) start_archive2icosa outputs files "start_icosa_prefinalize.nc" and "startfi_prefinalize.nc"
+  require a couple of extra modifications. Script "icosa_finalize.bash" does
+  the required changes and generates files "start_icosa.nc" and "startfi.nc" that
+  can be used as inputs by icosa_lmdz.exe
+5) When using these start one must add in run_icosa.def the extra flags
+etat0=start_file
+etat0_start_file_colocated = true
+
+Additional comments:
+--------------------
+- script "compile" assumes XIOS is to be found in "$LMDZ/XIOS",
+  to be adapted to your own settings (set LMDZ variable or change script).
+- "nccopy" is a standard netcdf tool available via e.g.:
+module load intel/17.0 intelmpi/2017.0.098 hdf5/1.8.17 netcdf/4.4.0_fortran-4.4.2
+- "nco" tools (ncrename, ncks, ...) are available via e.g.:
+module load intel/17.0 openmpi/intel/2.0.1 hdf5/1.8.17 netcdf/4.4.0_fortran-4.4.2 nco/4.4.6
+- in start_archive2icosa.f90, rearrange_startphy.f90, iodef.xml and
+  icosa_finalize.bash input/output file names are hard-coded.
+  Modify/adapt with caution!
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/compile
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/compile	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/compile	(revision 3545)
@@ -0,0 +1,27 @@
+#!/usr/bin/bash
+
+LMDZ=${LMDZ:-../../..} # change to your LMDZ install dir
+
+source $LMDZ/XIOS/arch.env
+source $LMDZ/XIOS/arch.path
+
+mpif90 -g -traceback start_archive2icosa.f90 \
+$NETCDF_INCDIR $NETCDF_LIBDIR $NETCDF_LIB \
+$HDF5_INCDIR $HDF5_LIBDIR $HDF5_LIB \
+-I $LMDZ/XIOS/inc \
+-L $LMDZ/XIOS/lib -lxios -lstdc++ \
+-o start_archive2icosa.e
+
+mpif90 -g -traceback rearrange_startphy.f90 \
+$NETCDF_INCDIR $NETCDF_LIBDIR $NETCDF_LIB \
+$HDF5_INCDIR $HDF5_LIBDIR $HDF5_LIB \
+-I $LMDZ/XIOS/inc \
+-L $LMDZ/XIOS/lib -lxios -lstdc++ \
+-o rearrange_startphy.e
+
+#mpif90 -g -traceback rearrange_startphy_tsurf_cst.f90 \
+#$NETCDF_INCDIR $NETCDF_LIBDIR $NETCDF_LIB \
+#$HDF5_INCDIR $HDF5_LIBDIR $HDF5_LIB \
+#-I /scratch/cnt0027/lmd1167/adelavois/models/code/XIOS/inc \
+#-L /scratch/cnt0027/lmd1167/adelavois/models/code/XIOS/lib -lxios -lstdc++ \
+#-o rearrange_startphy_tsurf_cst
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/icosa_finalize.bash
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/icosa_finalize.bash	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/icosa_finalize.bash	(revision 3545)
@@ -0,0 +1,59 @@
+#!/usr/bin/bash
+#
+# Bash script to post-process files startphy_icosa.nc and start_icosa.nc
+# generated by start_archive2icosa and create files
+# start.nc and startphy.nc (usable as inputs for icosa_lmdz.exe)
+
+# load nco module
+module purge
+LMDZ=${LMDZ:-../trunk/}  #You have to adapt to your own path, can be in your bashrc
+source $LMDZ/XIOS/arch.env
+#module load nco/4.7.9-gcc-4.8.5-hdf5-1.8.18-openmpi-2.0.4 #Example of version of the module needed
+module load nco
+
+#conversion to netcdf 3 in order to rename and add variables, not properly done with netcdf4 files
+nccopy -k 'classic' startfi_prefinalize.nc startphy_icosa_nc3.nc
+
+# rename lat and lon variables as latitude and longitude and put result in
+# file startphy.nc
+ncrename -v lon,longitude -v lat,latitude -d cell,physical_points\
+         startphy_icosa_nc3.nc startphy_nc3.nc
+#Temporay soildepth array from Dynamico restartfi
+ncks -A -v soildepth restartfi.nc startphy_nc3.nc #You have to adapt to your own path
+# ncks -A -v subslope_dist restartfi.nc startphy_nc3.nc
+# ncks -A -v def_slope restartfi.nc startphy_nc3.nc
+
+nccopy -k 4 startphy_nc3.nc startfi.nc
+
+#Temporary Time variable from start2archive; should be added with xios
+ncks -O -x -v time_counter startfi.nc startfi.nc_tmp
+ncks -A -v Time start.nc startfi.nc_tmp
+# ncks -A -v flux_geo restartfi.nc startfi.nc_tmp
+# ncks -A -v wstar restartfi.nc startfi.nc_tmp
+# ncks -A -v hmons restartfi.nc startfi.nc_tmp
+# ncks -A -v summit restartfi.nc startfi.nc_tmp
+# ncks -A -v base restartfi.nc startfi.nc_tmp
+cp startfi.nc_tmp startfi.nc
+
+./rearrange_startphy.e > rearrange_startphy.out 2>&1
+
+# make a proper start.nc file based on start_icosa.nc
+cp start_icosa_prefinalize.nc start_icosa.nc
+
+# add u,u_lat,u_lon,bounds_lat_u and bound_lon_u from start_icosa_ref.nc
+ncks -A -v u,lon_u,lat_u,bounds_lon_u,bounds_lat_u \
+     start_icosa_ref.nc start_icosa.nc
+ncrename -d cell,cell_mesh \
+         start_icosa.nc
+ncrename -d nvertex,nvertex_mesh \
+         start_icosa.nc
+ncks -A -v xcell,ycell,zcell \
+     start_icosa_ref.nc start_icosa.nc
+
+ncks -A -v W,geopot,q,nq start_icosa_ref.nc start_icosa.nc
+
+# In the current version of Dynamico, the variable q for tracer is needed but unused.
+# To create this unused variable simply run this short python code
+
+# cleanup
+rm -rf startphy_icosa_nc3.nc startphy_nc3.nc
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/iodef.xml
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/iodef.xml	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/iodef.xml	(revision 3545)
@@ -0,0 +1,287 @@
+<!-- xml example for start_archive2icosa.e -->
+<?xml version="1.0"?>
+<simulation>
+
+ <context id="test">
+   <calendar type="Gregorian"
+             start_date="2012-03-01 15:00:00"
+             time_origin="2012-02-29 15:00:00" />
+
+   <field_definition level="1" >
+    <field_group  id="fields_2D_dst" domain_ref="src_domain_regular_clean" >
+      <!-- 2D fields -->
+      <field id="ps_clean" />
+      <!-- 2D fields -->
+      <field id="tsurf_clean" />
+      <field id="emis_clean" />
+      <field id="ZMEA_clean" />
+      <field id="ZSTD_clean" />
+      <field id="ZSIG_clean" />
+      <field id="ZGAM_clean" />
+      <field id="ZTHE_clean" />
+      <field id="albedodat_clean" />
+
+      <!-- 2D fields associated to tracers-->
+      <field id="n2_surf_clean" />
+      <field id="co_ice_surf_clean" />
+      <field id="co_gas_surf_clean" />
+      <field id="ch4_ice_surf_clean" />
+      <field id="ch4_gas_surf_clean" />
+      <field id="prec_haze_surf_clean" />
+      <field id="haze_surf_clean" />
+    </field_group>
+    <!-- -->
+    <field_group  id="fields_dst">
+      <!-- from topography file -->
+      <field id="topo" domain_ref="src_topo_domain_regular" />
+      <!-- 3D fields -->
+      <field id="temp_clean"
+             grid_ref="src_grid_regular_clean" />
+      <field id="theta_rhodz_clean"
+             grid_ref="src_grid_regular_clean" />
+      <field id="u_clean" grid_ref="src_grid_regular_clean" />
+      <field id="v_clean" grid_ref="src_grid_regular_clean" />
+      <!-- tracers -->
+      <field id="n2_clean" grid_ref="src_grid_regular_clean" />
+      <field id="co_ice_clean" grid_ref="src_grid_regular_clean" />
+      <field id="co_gas_clean" grid_ref="src_grid_regular_clean" />
+      <field id="ch4_ice_clean" grid_ref="src_grid_regular_clean" />
+      <field id="ch4_gas_clean" grid_ref="src_grid_regular_clean" />
+      <field id="prec_haze_clean" grid_ref="src_grid_regular_clean" />
+      <field id="haze_clean" grid_ref="src_grid_regular_clean" />
+      <!-- soil -->
+      <field id="inertiedat_clean" grid_ref="src_grid_soil_clean" />
+      <!-- q2 -->
+      <field id="q2_clean" grid_ref="src_grid_regular_p1_clean" />
+      <!-- from topography file -->
+      <field id="tsoil_clean"  grid_ref="src_grid_soil_clean"  />
+    </field_group>
+
+   </field_definition>
+
+   <file_definition type="one_file" par_access="collective"
+                    output_freq="1ts" output_level="10"  enabled=".TRUE.">
+      <!-- input files -->
+      <file_group id="read_files" >
+       <file id="start_archive_nc4" name="start_archive_nc4" mode="read" >
+         <!-- 2D fields -->
+         <field_group freq_offset="1ts"
+                      domain_ref="src_domain_regular"
+                      operation="instant" >
+          <field id="src_ps" name="ps" />
+          <field id="src_q2surf" name="q2surf" />
+          <field id="src_tsurf" name="tsurf" />
+          <field id="src_emis" name="emis" />
+          <field id="src_ZMEA" name="ZMEA" />
+          <field id="src_ZSTD" name="ZSTD" />
+          <field id="src_ZSIG" name="ZSIG" />
+          <field id="src_ZGAM" name="ZGAM" />
+          <field id="src_ZTHE" name="ZTHE" />
+          <field id="src_albedodat" name="albedodat" />
+
+          <!--2D fields associated with tracers-->
+          <field id="src_n2_surf" name="n2_surf" />
+          <field id="src_co_ice_surf" name="co_ice_surf" />
+          <field id="src_co_gas_surf" name="co_gas_surf" />
+          <field id="src_ch4_ice_surf" name="ch4_ice_surf" />
+          <field id="src_ch4_gas_surf" name="ch4_gas_surf" />
+          <field id="src_prec_haze_surf" name="prec_haze_surf" />
+          <field id="src_haze_surf" name="haze_surf" />
+         </field_group>
+         <!-- 3D fields -->
+         <field_group freq_offset="1ts"
+                      grid_ref="src_grid_regular"
+                      operation="instant" >
+          <field id="src_temp" name="temp" />
+          <field id="src_u" name="u" />
+          <field id="src_v" name="v" />
+          <field id="src_q2atm" name="q2atm" />
+        <!-- traceurs -->
+          <field id="src_trac1" name="n2" />
+          <field id="src_trac2" name="co_ice" />
+          <field id="src_trac3" name="co_gas" />
+          <field id="src_trac4" name="ch4_ice" />
+          <field id="src_trac5" name="ch4_gas" />
+          <field id="src_trac6" name="prec_haze" />
+          <field id="src_trac7" name="haze" />
+         </field_group>
+         <!-- soil fields -->
+          <field id="src_tsoil" name="tsoil" freq_offset="1ts"
+                 grid_ref="src_grid_soil"
+                 operation="instant" />
+          <field id="src_inertiedat" name="inertiedat" freq_offset="1ts"
+                 grid_ref="src_grid_soil"
+                 operation="instant" />
+       </file>
+       <file id="surface_nc4" name="surface_nc4" mode="read" >
+         <field id="zMOL" name="zMOL"
+                domain_ref="src_topo_domain_regular"
+                freq_offset="1ts"
+                operation="instant" />
+       </file>
+      </file_group>
+
+      <!-- output files -->
+      <file_group id="write_files" >
+        <file id="start_icosa_prefinalize" name="start_icosa_prefinalize" >
+         <!-- 2D fields -->
+         <field_group domain_ref="dst_domain_unstructured"
+                      operation="once" >
+          <field field_ref="ps_clean" name="ps" />
+          <!-- <field field_ref="phis_clean" name="phis" /> -->
+          <field field_ref="topo" name="phis" />
+         </field_group>
+         <!-- 3D fields -->
+         <field_group grid_ref="dst_grid_unstructured"
+                      operation="once" >
+          <field field_ref="theta_rhodz_clean" name="theta_rhodz" />
+          <field field_ref="u_clean" name="ulon" />
+          <field field_ref="v_clean" name="ulat" />
+          <!-- tracers -->
+          <field field_ref="n2_clean" name="n2" />
+          <field field_ref="co_ice_clean" name="co_ice" />
+          <field field_ref="co_gas_clean" name="co_gas" />
+          <field field_ref="ch4_ice_clean" name="ch4_ice" />
+          <field field_ref="ch4_gas_clean" name="ch4_gas" />
+          <field field_ref="prec_haze_clean" name="prec_haze" />
+          <field field_ref="haze_clean" name="haze" />
+         </field_group>
+        </file>
+        <file id="startfi_prefinalize" name="startfi_prefinalize" >
+         <!-- 2D -->
+         <field_group domain_ref="dst_domain_unstructured"
+                      operation="once" >
+          <field field_ref="topo" name="phisfi" />
+          <field field_ref="tsurf_clean" name="tsurf" />
+          <field field_ref="emis_clean" name="emis" />
+          <field field_ref="ZMEA_clean" name="ZMEA" />
+          <field field_ref="ZSTD_clean" name="ZSTD" />
+          <field field_ref="ZSIG_clean" name="ZSIG" />
+          <field field_ref="ZTHE_clean" name="ZTHE" />
+          <field field_ref="ZGAM_clean" name="ZGAM" />
+          <field field_ref="albedodat_clean" name="albedodat" />
+
+         <!-- 2D fields associated to tracers -->
+          <field field_ref="n2_surf_clean" name="n2" />
+          <field field_ref="co_ice_surf_clean" name="co_ice" />
+          <field field_ref="co_gas_surf_clean" name="co_gas" />
+          <field field_ref="ch4_ice_surf_clean" name="ch4_ice" />
+          <field field_ref="ch4_gas_surf_clean" name="ch4_gas" />
+          <field field_ref="prec_haze_surf_clean" name="prec_haze" />
+          <field field_ref="haze_surf_clean" name="haze" />
+         </field_group>
+         <!-- soil fields -->
+          <field field_ref="tsoil_clean" name="tsoil"
+                 grid_ref="dst_grid_soil_unstructured"
+                 operation="once" />
+          <field field_ref="inertiedat_clean" name="inertiedat"
+                 grid_ref="dst_grid_soil_unstructured"
+                 operation="once" />
+         <!-- q2 field -->
+          <field field_ref="q2_clean" name="q2"
+                 grid_ref="dst_p1_grid_unstructured"
+                 operation="once" />
+         <!-- 3D fields -->
+        </file>
+      </file_group>
+   </file_definition>
+
+   <axis_definition>
+     <axis id="lev" positive="down"
+           standard_name="atmosphere_hybrid_sigma_pressure_coordinate"
+           long_name="hybrid level at midpoints" />
+     <axis id="lev_p1" positive="down" />
+     <axis id="nq" name="nq" />
+     <axis id="soil_layers" name="subsurface_layers" />
+   </axis_definition>
+
+   <domain_definition>
+    <domain_group id="read_domains">
+      <domain id="src_domain_regular" type="rectilinear">
+        <!-- <generate_rectilinear_domain /> -->
+      </domain>
+      <domain id="src_domain_regular_clean" type="rectilinear">
+        <!-- <generate_rectilinear_domain /> -->
+      </domain>
+      <domain id="src_topo_domain_regular" type="rectilinear">
+        <!-- <generate_rectilinear_domain /> -->
+      </domain>
+    </domain_group>
+
+    <domain_group id="domain_dst">
+     <domain id="dst_domain_unstructured" type="unstructured">
+       <interpolate_domain order="1" renormalize="true" />
+     </domain>
+    </domain_group>
+   </domain_definition>
+
+   <grid_definition>
+    <grid_group id="read_grids">
+      <grid id="src_grid_regular">
+        <domain domain_ref="src_domain_regular" />
+        <axis axis_ref="lev" />
+      </grid>
+      <grid id="src_grid_regular_clean">
+        <domain domain_ref="src_domain_regular_clean" />
+        <axis axis_ref="lev" />
+      </grid>
+      <grid id="src_grid_regular_p1_clean">
+        <domain domain_ref="src_domain_regular_clean" />
+        <axis axis_ref="lev_p1" />
+      </grid>
+      <grid id="src_nq_grid_regular_clean">
+        <domain domain_ref="src_domain_regular_clean" />
+        <axis axis_ref="lev" />
+        <axis axis_ref="nq" />
+      </grid>
+      <grid id="src_grid_soil">
+        <domain domain_ref="src_domain_regular" />
+        <axis axis_ref="soil_layers" />
+      </grid>
+      <grid id="src_grid_soil_clean">
+        <domain domain_ref="src_domain_regular_clean" />
+        <axis axis_ref="soil_layers" />
+      </grid>
+    </grid_group>
+
+    <grid_group id="grid_dst">
+      <grid id="dst_grid_unstructured">
+        <domain domain_ref="dst_domain_unstructured" />
+        <axis axis_ref="lev" />
+      </grid>
+      <grid id="dst_p1_grid_unstructured">
+        <domain domain_ref="dst_domain_unstructured" />
+        <axis axis_ref="lev_p1" />
+      </grid>
+      <grid id="dst_nq_grid_unstructured">
+        <domain domain_ref="dst_domain_unstructured" />
+        <axis axis_ref="lev" />
+        <axis axis_ref="nq" />
+      </grid>
+      <grid id="dst_grid_soil_unstructured">
+        <domain domain_ref="dst_domain_unstructured" />
+        <axis axis_ref="soil_layers" />
+      </grid>
+    </grid_group>
+
+   </grid_definition>
+
+  </context>
+
+  <context id="xios">
+      <variable_definition>
+        <variable_group id="buffer">
+            <variable id="optimal_buffer_size" type="string">performance</variable>
+            <variable id="buffer_size_factor" type="double">30.0</variable>
+            <variable id="min_buffer_size" type="double">800000</variable>
+         </variable_group>
+
+        <variable_group id="parameters" >
+          <variable id="using_server" type="bool">false</variable>
+          <variable id="info_level" type="int">100</variable>
+          <variable id="print_file" type="bool">false</variable>
+        </variable_group>
+      </variable_definition>
+  </context>
+</simulation>
+
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/job_start_archive_2icosa
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/job_start_archive_2icosa	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/job_start_archive_2icosa	(revision 3545)
@@ -0,0 +1,19 @@
+#!/bin/bash
+#SBATCH --nodes=1
+#SBATCH --ntasks-per-node=12
+#SBATCH --cpus-per-task=1
+### SBATCH --cpus-per-task=2
+#SBATCH --partition=zen4 # zen4: 64cores/node and 240GB of memory
+##SBATCH --partition=zen16 # zen16: 32 cores/node core and 496GB of memory
+#SBATCH -J start_archive2icosa
+#SBATCH --time=39:59:00
+#SBATCH --output %x.%j.out
+
+arch=ifort_MESOIPSL
+source $HOME/lmdz/LMDZ.COMMON/arch/arch-$arch.env
+
+\rm xios*err
+\rm xios*out
+
+mpirun start_archive2icosa.e > log_start_archive2icosa.out 2>&1
+
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/rearrange_startphy.f90
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/rearrange_startphy.f90	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/rearrange_startphy.f90	(revision 3545)
@@ -0,0 +1,260 @@
+PROGRAM rearrange_startphy
+
+USE netcdf
+
+IMPLICIT NONE
+
+INTEGER :: ncid
+INTEGER :: dimids(9)
+INTEGER :: varid
+INTEGER :: ierr
+INTEGER :: nvar
+INTEGER :: ndim
+CHARACTER(LEN=100) :: varname
+INTEGER :: varname_dimids(9)
+
+INTEGER :: i,j,k,nb_cells,nlev,nsoil,nvertex,nlev_p1
+
+INTEGER :: physical_points, subslope, index_, inter_slope, subsurface_layer, lev_p1, Time, nslope
+
+INTEGER,ALLOCATABLE :: cell_index(:)
+REAL,ALLOCATABLE :: ref_lon(:)
+REAL,ALLOCATABLE :: ref_lat(:)
+REAL,ALLOCATABLE :: lon(:)
+REAL,ALLOCATABLE :: lat(:)
+REAL,ALLOCATABLE :: ref_field(:),field(:)
+REAL,ALLOCATABLE :: ref_field_3D(:,:),field_3D(:,:)
+REAL,ALLOCATABLE :: ref_field_3D_p1(:,:),field_3D_p1(:,:)
+REAL,ALLOCATABLE :: ref_field_soil(:,:),field_soil(:,:)
+REAL,ALLOCATABLE :: ref_field_vertex(:,:),field_vertex(:,:)
+! REAL,ALLOCATABLE :: ref_field_subslope(:,:),field_subslope(:,:)
+! REAL,ALLOCATABLE :: ref_field_soil_subslope(:,:,:),field_soil_subslope(:,:,:)
+REAL :: lati,loni
+REAL :: diff_lat,diff_lon
+CHARACTER(LEN=*),PARAMETER :: ref_file="startphy_icosa_ref.nc"
+CHARACTER(LEN=*),PARAMETER :: file="startfi.nc"
+
+DOUBLE PRECISION,PARAMETER :: pi=acos(-1.d0)
+REAL :: reflatj,reflonj
+
+! load coordinates from files
+  ierr=NF90_OPEN(ref_file, NF90_NOWRITE, ncid)
+  ierr=NF90_INQ_DIMID(ncid,"physical_points",dimids(1))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(1), len=nb_cells)
+  write(*,*) "nb_cells=",nb_cells,"dimids(1)=",dimids(1)
+  allocate(ref_lat(nb_cells),ref_lon(nb_cells))
+
+  ierr=NF90_INQ_VARID(ncid,"latitude",varid)
+  ierr=NF90_GET_VAR(ncid,varid,ref_lat)
+  if (ierr /= nf90_noerr) then
+    write(*,*) "cannot load latitude from ",trim(ref_file)
+  else
+    write(*,*) "ref_lat(1:5)=",ref_lat(1:5)
+  endif
+  ierr=NF90_INQ_VARID(ncid,"longitude",varid)
+  ierr=NF90_GET_VAR(ncid,varid,ref_lon)
+  if (ierr /= nf90_noerr) then
+    write(*,*) "cannot load longitude from ",trim(ref_file)
+  else
+    write(*,*) "ref_lon(1:5)=",ref_lon(1:5)
+  endif
+  ierr=NF90_CLOSE(ncid)
+
+  ierr=NF90_OPEN(file, NF90_WRITE, ncid)
+  allocate(lat(nb_cells),lon(nb_cells))
+  ierr=NF90_INQ_VARID(ncid,"latitude",varid)
+  ierr=NF90_GET_VAR(ncid,varid,lat)
+  if (ierr /= nf90_noerr) then
+    write(*,*) "cannot load lat from ",trim(file)
+  else
+    write(*,*) "lat(1:5)=",lat(1:5)
+  endif
+  ierr=NF90_INQ_VARID(ncid,"longitude",varid)
+  ierr=NF90_GET_VAR(ncid,varid,lon)
+  if (ierr /= nf90_noerr) then
+    write(*,*) "cannot load lat from ",trim(file)
+  else
+    write(*,*) "lon(1:5)=",lon(1:5)
+  endif
+
+  ! find correspondances between lon/ref_lon & lat/ref_lat
+  allocate(cell_index(nb_cells))
+  cell_index(:)=0
+  do i=1,nb_cells !in case lon and lat are expressed in rad in startphy_icosa_ref /180*pi
+    lat(i)=lat(i) /(180.d0/pi) ; lon(i)=lon(i)/(180.d0/pi)
+    do j=1,nb_cells
+     reflatj=ref_lat(j)
+     reflonj=ref_lon(j)
+
+     if (lat(i) ==0.) then
+       diff_lat=abs((lat(i)-ref_lat(j))/1.e-8)
+     else
+       diff_lat=abs((lat(i)-ref_lat(j))/lat(i))
+     endif
+
+     if (lon(i) ==0.) then
+      diff_lon=abs((lon(i)-ref_lon(j))/1.e-8)
+     else
+      diff_lon=abs((lon(i)-ref_lon(j))/lon(i))
+     endif
+
+     if ((diff_lat <= 1.e-5).and.(diff_lon <= 1.e-5)) then
+      cell_index(i)=j
+      write(*,*)"j=",j," lat(i)=",lat(i)," ref_lat(j)=",reflatj
+      write(*,*)"j=",j," lon(i)=",lon(i)," ref_lon(j)=",reflonj
+     endif
+    enddo ! of do j=1,nb_cells
+    write(*,*) ">> i=",i,"cell_index(i)=",cell_index(i)
+    ! sanity check:
+    if (cell_index(i)==0) then
+      write(*,*) "Error, could not find lon-lat match for i=",i , lat(i), lon(i)
+      stop
+    endif
+    ! writing lat and lon in rad rather than deg
+    ierr=NF90_INQ_VARID(ncid,"longitude",varid)
+    ierr=NF90_PUT_VAR(ncid,varid,lon)
+
+    ierr=NF90_INQ_VARID(ncid,"latitude",varid)
+    ierr=NF90_PUT_VAR(ncid,varid,lat)
+  enddo ! of do i=1,nb_cells
+
+!  do i=1,nb_cells
+!    write(*,*) "i=",i," cell_index(i)=",cell_index(i)
+!    write(*,*) "  lat(i)=",lat(i),"ref_lat(cell_index(i))=",ref_lat(cell_index(i))
+!  enddo
+
+  ! load, rearrange and write variables
+  ierr=NF90_INQ_DIMID(ncid,"physical_points",dimids(1))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(1), len=physical_points)
+  ierr=NF90_INQ_DIMID(ncid,"nvertex",dimids(2))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=nvertex)
+!   ierr=NF90_INQ_DIMID(ncid,"subslope",dimids(3))
+!   ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(3), len=subslope)
+  ierr=NF90_INQ_DIMID(ncid,"index",dimids(4))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(4), len=index_)
+!   ierr=NF90_INQ_DIMID(ncid,"inter_slope",dimids(5))
+!   ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(5), len=inter_slope)
+  ierr=NF90_INQ_DIMID(ncid,"subsurface_layers",dimids(6))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(6), len=subsurface_layer)
+  ierr=NF90_INQ_DIMID(ncid,"lev_p1",dimids(7))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(7), len=lev_p1)
+  ierr=NF90_INQ_DIMID(ncid,"Time",dimids(8))
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(8), len=Time)
+!   ierr=NF90_INQ_DIMID(ncid,"nslope",dimids(9))
+!   ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(9), len=nslope)
+  ierr=NF90_INQUIRE(ncid,nVariables=nvar)
+
+
+!  ierr=NF90_INQ_DIMID(ncid,"lev",dimids(2))
+!  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=nlev)
+!  ierr=NF90_INQ_DIMID(ncid,"subsurface_layers",dimids(3))
+!  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(3), len=nsoil)
+!  ierr=NF90_INQ_DIMID(ncid,"nvertex",dimids(4))
+!  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(4), len=nvertex)
+!  ierr=NF90_INQ_DIMID(ncid,"lev_p1",dimids(5))
+!  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=nlev_p1)
+
+  write(*,*) "nvar=",nvar
+  allocate(ref_field(physical_points),field(physical_points))
+  allocate(ref_field_3D_p1(physical_points,lev_p1),field_3D_p1(physical_points,lev_p1))
+!   allocate(ref_field_subslope(physical_points,subslope),field_subslope(physical_points,subslope))
+  allocate(ref_field_soil(physical_points,subsurface_layer),field_soil(physical_points,subsurface_layer))
+  allocate(ref_field_vertex(nvertex,physical_points),field_vertex(nvertex,physical_points))
+! ! !   allocate(ref_field_soil_subslope(physical_points,subsurface_layer,subslope),field_soil_subslope(physical_points,subsurface_layer,subslope))
+  write(*,*) "dimids :", dimids
+
+  ! loop over variables:
+  do k=1,nvar
+    varname_dimids(:)=0
+    ierr=NF90_INQUIRE_VARIABLE(ncid,k,name=varname,ndims=ndim,dimids=varname_dimids)
+      write(*,*) "name: ",trim(varname),";ndim=",ndim,"; dimensions:",varname_dimids
+    if (ierr /= nf90_noerr) then
+      write(*,*) "error for variable k=",k
+      write(*,*) nf90_strerror(ierr)
+    endif
+    ! Processing 2D variables
+    if ((ndim==1).and.(varname_dimids(1)==dimids(1))) then
+      write(*,*) "processing ",trim(varname)
+      ! load field
+      ierr=NF90_INQ_VARID(ncid,varname,varid)
+      ierr=NF90_GET_VAR(ncid,varid,ref_field)
+      ! rearrange field
+      do i=1,nb_cells
+        field(cell_index(i))=ref_field(i)
+      enddo
+      ! write field
+      ierr=NF90_PUT_VAR(ncid,varid,field)
+
+    ! Processing vertex variables : bounds_lon and bounds_lat
+    else if ((ndim==2).and.(varname_dimids(1)==dimids(2))) then
+      write(*,*) "processing ",trim(varname)
+      ! load field_3D
+      ierr=NF90_INQ_VARID(ncid,varname,varid)
+      if (ierr /= nf90_noerr) print*,"error inqvarid ",trim(varname)
+      ierr=NF90_GET_VAR(ncid,varid,ref_field_vertex)
+      if (ierr /= nf90_noerr) print*,"error get_var ",trim(varname)
+      ! rearrange field_3D
+      do i=1,nb_cells
+        field_vertex(:,cell_index(i))=ref_field_vertex(:,i)
+      enddo
+      ! write field_3D
+      ierr=NF90_PUT_VAR(ncid,varid,field_vertex)
+      if (ierr /= nf90_noerr) print*,"error putvar ",trim(varname)
+
+    ! ! Processing 3D variables : subslope
+    ! else if ((ndim==2).and.(varname_dimids(2)==dimids(3))) then
+    !   write(*,*) "processing ",trim(varname)
+    !   ! load field_3D
+    !   ierr=NF90_INQ_VARID(ncid,varname,varid)
+    !   if (ierr /= nf90_noerr) print*,"error inqvarid ",trim(varname)
+    !   ierr=NF90_GET_VAR(ncid,varid,ref_field_subslope)
+    !   if (ierr /= nf90_noerr) print*,"error get_var ",trim(varname)
+    !   ! rearrange field_3D
+    !   do i=1,nb_cells
+    !     field_subslope(cell_index(i),:)=ref_field_subslope(i,:)
+    !   enddo
+    !   ! write field_3D
+    !   ierr=NF90_PUT_VAR(ncid,varid,field_subslope)
+    !   if (ierr /= nf90_noerr) print*,"error putvar ",trim(varname)
+
+    ! Processing 3D variables : altitude
+    else if ((ndim==2).and.(varname_dimids(2)==dimids(7))) then
+      write(*,*) "processing ",trim(varname)
+      ! load field_3D
+      ierr=NF90_INQ_VARID(ncid,varname,varid)
+      if (ierr /= nf90_noerr) print*,"error inqvarid ",trim(varname)
+      ierr=NF90_GET_VAR(ncid,varid,ref_field_3D_p1)
+      if (ierr /= nf90_noerr) print*,"error get_var ",trim(varname)
+      ! rearrange field_3D
+      do i=1,nb_cells
+        field_3D_p1(cell_index(i),:)=ref_field_3D_p1(i,:)
+      enddo
+      ! write field_3D
+      ierr=NF90_PUT_VAR(ncid,varid,field_3D_p1)
+      if (ierr /= nf90_noerr) print*,"error putvar ",trim(varname)
+
+    ! Processing 2D variables : soil
+    else if ((ndim==2).and.(varname_dimids(2)==subsurface_layer)) then
+      write(*,*) "processing ",trim(varname)
+      ! load field_soil
+      ierr=NF90_INQ_VARID(ncid,varname,varid)
+      if (ierr /= nf90_noerr) print*,"error inqvarid ",trim(varname)
+      ierr=NF90_GET_VAR(ncid,varid,ref_field_soil)
+      if (ierr /= nf90_noerr) print*,"error get_var ",trim(varname)
+      ! rearrange field_soil
+      do i=1,nb_cells
+        field_soil(cell_index(i),:)=ref_field_soil(i,:)
+      enddo
+      ! write field_soil
+      ierr=NF90_PUT_VAR(ncid,varid,field_soil)
+      if (ierr /= nf90_noerr) print*,"error putvar ",trim(varname)
+
+    else
+      print *, "Nothing to do with ", trim(varname), " ndim=", ndim, " varname_dimids(:)=", varname_dimids(:)
+
+    endif
+  enddo
+
+     print *, "All is well that ends well"
+
+END PROGRAM rearrange_startphy
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/run_icosa.def.no_startfi
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/run_icosa.def.no_startfi	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/run_icosa.def.no_startfi	(revision 3545)
@@ -0,0 +1,90 @@
+#---------------- Mesh ----------------
+
+# Number of subdivisions on a main triangle : integer (default=40)
+nbp = 40
+
+# Number of vertical layers : integer (default=19)
+llm = 19
+
+# Vertical grid : [std|ncar|ncarl30] (default=std)
+# disvert = std
+disvert = plugin
+hybrid = .false.
+
+# Mesh optimisation : number of iterations : integer (default=0)
+optim_it = 1000
+
+# Sub splitting of main rhombus : integer (default=1)
+nsplit_i = 10
+nsplit_j = 10
+
+#number of openmp task on vertical level
+omp_level_size=1
+
+#---------------- Numerics ----------------
+
+# Advection called every itau_adv time steps : integer (default=2)
+itau_adv = 1
+
+# Time step in s : real (default=480)
+# dt = 720
+# Alternative to specifying "dt", specify number of steps per day : day_step
+day_step = 12000
+
+# Number of tracers : integer (default=1)
+nqtot = 7
+
+#---------------- Time and output ----------------
+
+# Time style : [none|dcmip] (default=dcmip)
+time_style = none
+
+# Run length in s : real (default=??)
+run_length = 1500
+# Alternative to specifying "run_length", specify number of days to run : ndays
+# ndays=1
+
+# Interval in s between two outputs : integer (default=??)
+write_period = 1000
+
+
+
+#---------------- Planet ----------------
+
+INCLUDEDEF=pluto_const.def
+
+#---------------- Physical parameters ----------------
+
+# Initial state :
+#   [jablonowsky06|academic|dcmip[1-4]|heldsz|dcmip2_schaer_noshear] (default=jablonowsky06)
+etat0 = isothermal
+etat0_isothermal_temp=50
+etat0_ps_white_noise=0.01
+etat0_theta_rhodz_white_noise=0.01
+
+# Physics package : [none|held_suarez|dcmip] (default=none)
+# physics = held_suarez
+# physics = none
+physics = phys_external
+
+startphy_file = false
+
+# Dissipation time for grad(div) : real (default=5000)
+tau_graddiv = 18000
+
+# Exponent of grad(div) disspation : integer (default=1)
+nitergdiv = 2
+
+# Dissipation time for curl(curl) : real (default=5000)
+tau_gradrot = 18000
+
+# Exponent of curl(curl) disspation : integer (default=1)
+nitergrot = 2
+
+# Dissipation time for div(grad) : real (default=5000)
+tau_divgrad = 18000
+
+# Exponent of div(grad) disspation : integer (default=1)
+niterdivgrad = 2
+
+INCLUDEDEF=callphys.def
Index: /trunk/LMDZ.PLUTO/util/startarchive2icosa/start_archive2icosa.f90
===================================================================
--- /trunk/LMDZ.PLUTO/util/startarchive2icosa/start_archive2icosa.f90	(revision 3545)
+++ /trunk/LMDZ.PLUTO/util/startarchive2icosa/start_archive2icosa.f90	(revision 3545)
@@ -0,0 +1,558 @@
+PROGRAM start_archive2icosa
+
+  USE xios
+  USE mod_wait
+  USE netcdf
+
+  IMPLICIT NONE
+  INCLUDE "mpif.h"
+  INTEGER :: rank
+  INTEGER :: size
+  INTEGER :: ierr
+
+  CHARACTER(len=*),PARAMETER :: id="client"
+  INTEGER :: comm
+  TYPE(xios_duration) :: dtime
+  CHARACTER(len=15) :: calendar_type
+  TYPE(xios_context) :: ctx_hdl
+
+  INTEGER :: n,l
+  INTEGER :: src_ibegin, src_iend, src_topo_ibegin, src_topo_iend
+  INTEGER :: src_jbegin, src_jend, src_topo_jbegin, src_topo_jend
+  INTEGER :: src_ni, src_ni_glo, src_topo_ni, src_topo_ni_glo
+  INTEGER :: src_nj, src_nj_glo, src_topo_nj, src_topo_nj_glo
+  INTEGER :: src_nlev ! number of vertical layers
+  INTEGER :: src_nq=7 ! number of tracers
+  INTEGER :: src_nt=1 ! number of time steps
+  INTEGER :: src_nsoil=18 ! number of soil layers
+!   INTEGER :: src_nslope=1 ! number of subslope
+  DOUBLE PRECISION,ALLOCATABLE :: lev_values(:) ! vertical axis
+  DOUBLE PRECISION,ALLOCATABLE :: lev_p1_values(:) ! vertical axis
+  DOUBLE PRECISION,ALLOCATABLE :: nq_values(:) ! tracer # axis
+  DOUBLE PRECISION,ALLOCATABLE :: soil_layers_values(:) ! soil axis
+!   DOUBLE PRECISION,ALLOCATABLE :: subslope_values(:) ! subslope axis
+  DOUBLE PRECISION,ALLOCATABLE :: src_lon(:) ! mesh center coordinate
+  DOUBLE PRECISION,ALLOCATABLE :: src_lat(:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_ap(:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_bp(:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_controle(:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_field_2D(:,:)
+!   DOUBLE PRECISION,ALLOCATABLE :: src_field_2D_subslope(:,:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_pk(:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_field_3D(:,:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_pressure(:,:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_theta_rhodz(:,:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_topo_lon(:) ! mesh center coordinate
+  DOUBLE PRECISION,ALLOCATABLE :: src_topo_lat(:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_topo(:,:)
+  DOUBLE PRECISION,ALLOCATABLE :: src_field_3D_soil(:,:,:) ! 3D grid in soil, for tsoil et inertia
+!   DOUBLE PRECISION,ALLOCATABLE :: src_field_3D_soil_subslope(:,:,:,:) ! 3D grid in soil, for tsoil et inertia
+  DOUBLE PRECISION,ALLOCATABLE :: src_soil_layers(:) ! soil_depth
+  DOUBLE PRECISION,ALLOCATABLE :: src_field_3D_p1(:,:,:) !q2 field
+
+  CHARACTER(LEN=*),PARAMETER :: src_file="start_archive_nc4.nc"
+  CHARACTER(LEN=*),PARAMETER :: src_topo_file="surface_nc4.nc"
+  CHARACTER(LEN=*),PARAMETER :: dst_coord_file="start_icosa_ref.nc"
+  CHARACTER(LEN=*),PARAMETER :: src_controle_file="startphy_icosa_ref.nc"
+  CHARACTER(LEN=*),PARAMETER :: output_start_file="start_icosa_prefinalize.nc"
+  CHARACTER(LEN=*),PARAMETER :: output_startfi_file="startfi_prefinalize.nc"
+  DOUBLE PRECISION,ALLOCATABLE :: dst_lon(:),dst_lat(:)
+  DOUBLE PRECISION,ALLOCATABLE :: dst_boundslon(:,:) ! mesh corner coordinates
+  DOUBLE PRECISION,ALLOCATABLE :: dst_boundslat(:,:)
+  INTEGER :: dst_ibegin !, dst_iend
+  INTEGER :: dst_ni, dst_ni_glo
+  INTEGER :: dst_nvertex
+  INTEGER :: ncid
+  INTEGER :: dimids(5)
+  INTEGER :: varid
+
+  INTEGER :: div, remain
+  INTEGER :: ts ! time step #
+  DOUBLE PRECISION,PARAMETER :: pi=acos(-1.d0)
+  DOUBLE PRECISION :: gravity,kappa,preff
+! Tracers
+  CHARACTER(LEN=11)          :: i_trac,format_string
+  INTEGER                    :: i
+
+!!! MPI Initialization
+  CALL MPI_INIT(ierr)
+  CALL init_wait
+
+!!! XIOS Initialization (get the local communicator)
+  CALL xios_initialize(id,return_comm=comm)
+! get local rank of MPI process
+  CALL MPI_COMM_RANK(comm,rank,ierr)
+! get total number of MPI processes
+  CALL MPI_COMM_SIZE(comm,size,ierr)
+
+!!! Open files and load sizes and coordinates
+  ierr=NF90_OPEN(src_topo_file, NF90_NOWRITE, ncid)
+  ierr=NF90_INQ_VARID(ncid,"zMOL",varid)
+  ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids)
+  write(*,*) "rank=",rank,"dimids=",dimids
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(1), len=src_topo_ni_glo)
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=src_topo_nj_glo)
+  write(*,*) "rank=",rank," src_topo_ni_glo=",src_topo_ni_glo ! longitude
+  write(*,*) "rank=",rank," src_topo_nj_glo=",src_topo_nj_glo ! latitude
+
+! assume domain splitup with MPI only along latitudes
+  src_topo_ni=src_topo_ni_glo
+  src_topo_ibegin=0
+  src_topo_iend=src_topo_ibegin+src_ni-1
+  write(*,*) "rank=",rank," src_topo_ni=",src_topo_ni
+
+  src_topo_jbegin=0
+  DO n=0,size-1
+    src_topo_nj=src_topo_nj_glo/size
+    IF (n<MOD(src_topo_nj_glo,size)) src_topo_nj=src_topo_nj+1
+    IF (n==rank) exit
+    src_topo_jbegin=src_topo_jbegin+src_topo_nj
+  ENDDO
+  src_topo_jend=src_topo_jbegin+src_topo_nj-1
+  write(*,*) "rank=",rank," src_topo_nj=",src_topo_nj, &
+             " src_topo_jbegin=",src_topo_jbegin
+
+  ALLOCATE(src_topo_lon(src_topo_ni))
+  ALLOCATE(src_topo_lat(src_topo_nj))
+  ALLOCATE(src_topo(src_topo_ni,src_topo_nj))
+
+! load src_topo_lon and src_topo_lat
+  ierr=NF90_INQ_VARID(ncid,"longitude",varid)
+  ierr=NF90_GET_VAR(ncid,varid, src_topo_lon, &
+                    start=(/src_topo_ibegin+1/),count=(/src_topo_ni/))
+  WRITE(*,*) rank,":src_topo_lon(1:2)=",src_topo_lon(1:2)
+  ierr=NF90_INQ_VARID(ncid,"latitude",varid)
+  ierr=NF90_GET_VAR(ncid,varid, src_topo_lat, &
+                    start=(/src_topo_jbegin+1/),count=(/src_topo_nj/))
+  WRITE(*,*) rank,":src_topo_lat(1:2)=",src_topo_lat(1:2)
+
+! from start_archive.nc file
+  ierr=NF90_OPEN(src_file, NF90_NOWRITE, ncid)
+  ierr=NF90_INQ_VARID(ncid,"temp",varid)
+  ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids)
+  write(*,*) "rank=",rank,"dimids=",dimids
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(1), len=src_ni_glo)
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=src_nj_glo)
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(3), len=src_nlev)
+  write(*,*) "rank=",rank," src_ni_glo=",src_ni_glo ! longitude
+  write(*,*) "rank=",rank," src_nj_glo=",src_nj_glo ! latitude
+  write(*,*) "rank=",rank," src_nlev=",src_nlev ! number of vertical layers
+  write(*,*) "rank=",rank," src_nq=",src_nq ! number of tracers
+! soil_depth with tsoil variable
+  ierr=NF90_INQ_VARID(ncid,"tsoil",varid)
+  ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids)
+  write(*,*) "rank=",rank,"dimids tsoil =",dimids
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(3), len=src_nsoil)
+!  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(4), len=src_nslope)
+  write(*,*) "rank=",rank," src_nsoil=",src_nsoil ! number of vertical layers
+!   write(*,*) "rank=",rank," src_nslope=",src_nslope ! number of subslope
+
+! assume domain splitup with MPI only along latitudes
+  src_ni=src_ni_glo
+  src_ibegin=0
+  src_iend=src_ibegin+src_ni-1
+  write(*,*) "rank=",rank," src_ni=",src_ni
+
+  src_jbegin=0
+  DO n=0,size-1
+    src_nj=src_nj_glo/size
+    IF (n<MOD(src_nj_glo,size)) src_nj=src_nj+1
+    IF (n==rank) exit
+    src_jbegin=src_jbegin+src_nj
+  ENDDO
+  src_jend=src_jbegin+src_nj-1
+  write(*,*) "rank=",rank," src_nj=",src_nj," src_jbegin=",src_jbegin
+
+  ALLOCATE(src_lon(src_ni))
+  ALLOCATE(src_lat(src_nj))
+  ALLOCATE(src_field_2D(src_ni,src_nj))
+!   ALLOCATE(src_field_2D_subslope(src_ni,src_nj,src_nslope))
+  ALLOCATE(src_pk(src_ni,src_nj))
+  ALLOCATE(src_field_3D(src_ni,src_nj,src_nlev))
+  ALLOCATE(src_field_3D_p1(src_ni,src_nj,src_nlev+1))
+  ALLOCATE(src_field_3D_soil(src_ni,src_nj,src_nsoil))
+!   ALLOCATE(src_field_3D_soil_subslope(src_ni,src_nj,src_nsoil,src_nslope))
+!  ALLOCATE(src_field_soil_layers(src_nsoil))
+  ALLOCATE(src_pressure(src_ni,src_nj,src_nlev+1))
+  ALLOCATE(src_theta_rhodz(src_ni,src_nj,src_nlev))
+
+! load src_lon and src_lat
+  ierr=NF90_INQ_VARID(ncid,"rlonv",varid)
+  ierr=NF90_GET_VAR(ncid,varid, src_lon, &
+                    start=(/src_ibegin+1/),count=(/src_ni/))
+! convert rad to deg
+  src_lon(1:src_ni)=src_lon(1:src_ni)*(180.d0/pi)
+  WRITE(*,*) rank,":src_lon=",src_lon
+  ierr=NF90_INQ_VARID(ncid,"rlatu",varid)
+  ierr=NF90_GET_VAR(ncid,varid, src_lat, &
+                    start=(/src_jbegin+1/),count=(/src_nj/))
+! convert rad to deg
+  src_lat(1:src_nj)=src_lat(1:src_nj)*(180.d0/pi)
+  WRITE(*,*) rank,":src_lat=",src_lat
+
+! load ap, bp and controle
+  ALLOCATE(src_ap(src_nlev+1),src_bp(src_nlev+1))
+  ierr=NF90_INQ_VARID(ncid,"ap",varid)
+  ierr=NF90_GET_VAR(ncid,varid,src_ap)
+  WRITE(*,*) rank,":src_ap(1:5)=",src_ap(1:5)
+  ierr=NF90_INQ_VARID(ncid,"bp",varid)
+  ierr=NF90_GET_VAR(ncid,varid,src_bp)
+  WRITE(*,*) rank,":src_bp(1:5)=",src_bp(1:5)
+
+! controle is taken in startphy_icosa_ref as start_archive_nc4 is too old
+  ierr=NF90_OPEN(src_controle_file, NF90_NOWRITE, ncid)
+  ALLOCATE(src_controle(100))
+  ierr=NF90_INQ_VARID(ncid,"controle",varid)
+  ierr=NF90_GET_VAR(ncid,varid,src_controle)
+  ! day_ini set to 0 as startphy_icosa_ref is a restart
+  src_controle(3)=0
+  WRITE(*,*) rank,":src_controle(1:5)=",src_controle(1:5)
+  gravity=src_controle(7)
+  WRITE(*,*) rank,":gravity=",gravity
+  kappa=src_controle(9)
+  WRITE(*,*) rank,":kappa=",kappa
+!  preff=src_controle(18)
+! AD: Warning preff is hardcoded because not in controle of restartfi
+  preff=610.
+  WRITE(*,*) rank,":preff=",preff
+
+! destination coordinates
+  ierr=NF90_OPEN(dst_coord_file, NF90_NOWRITE, ncid)
+  ierr=NF90_INQ_VARID(ncid,"bounds_lon_mesh",varid)
+  ierr=NF90_INQUIRE_VARIABLE(ncid, varid,dimids=dimids)
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(1), len=dst_nvertex)
+  ierr=NF90_INQUIRE_DIMENSION(ncid, dimids(2), len=dst_ni_glo)
+  write(*,*) "rank=",rank," dst_nvertex=",dst_nvertex ! vertex
+  write(*,*) "rank=",rank," dst_ni_glo=",dst_ni_glo ! vertex boundaries
+
+! evenly split into MPI domains
+  div    = dst_ni_glo/size
+  remain = MOD( dst_ni_glo, size )
+  IF (rank < remain) THEN
+    dst_ni=div+1 ;
+    dst_ibegin=rank*(div+1) ;
+  ELSE
+    dst_ni=div ;
+    dst_ibegin= remain * (div+1) + (rank-remain) * div ;
+  ENDIF
+  write(*,*) "rank=",rank," dst_ni=",dst_ni
+
+  ALLOCATE(dst_lon(dst_ni))
+  ALLOCATE(dst_lat(dst_ni))
+  ALLOCATE(dst_boundslon(dst_nvertex,dst_ni))
+  ALLOCATE(dst_boundslat(dst_nvertex,dst_ni))
+
+! load dst_lon, dst_lat, dst_boundslon and dst_boundslat
+  ierr=NF90_INQ_VARID(ncid,"lon_mesh",varid)
+  ierr=NF90_GET_VAR(ncid,varid, dst_lon, &
+                    start=(/dst_ibegin+1/), count=(/dst_ni/))
+  WRITE(*,*) rank,":dst_lon(1:5)=",dst_lon(1:5)
+  ierr=NF90_INQ_VARID(ncid,"lat_mesh",varid)
+  ierr=NF90_GET_VAR(ncid,varid, dst_lat, &
+                    start=(/dst_ibegin+1/), count=(/dst_ni/))
+  WRITE(*,*) rank,":dst_lat(1:5)=",dst_lat(1:5)
+  ierr=NF90_INQ_VARID(ncid,"bounds_lon_mesh",varid)
+  ierr=NF90_GET_VAR(ncid,varid,dst_boundslon, &
+                    start=(/1,dst_ibegin+1/), count=(/dst_nvertex,dst_ni/))
+  WRITE(*,*) rank,":dst_boundslon(:,1:2)=",dst_boundslon(:,1:2)
+  ierr=NF90_INQ_VARID(ncid,"bounds_lat_mesh",varid)
+  ierr=NF90_GET_VAR(ncid,varid, dst_boundslat, &
+                    start=(/1,dst_ibegin+1/), count=(/dst_nvertex,dst_ni/))
+  WRITE(*,*) rank,":dst_boundslat(:,1:2)=",dst_boundslat(:,1:2)
+
+
+! Initialize XIOS context
+  WRITE(*,*) rank,":CALL xios_context_initialize()"
+  CALL xios_context_initialize("test",comm)
+  CALL xios_get_handle("test",ctx_hdl)
+  CALL xios_set_current_context(ctx_hdl)
+
+! Set XIOS calendar and timestep
+  CALL xios_get_calendar_type(calendar_type)
+  WRITE(*,*) rank,":calendar_type = ", calendar_type
+  dtime%second = 3600
+  CALL xios_set_timestep(dtime)
+
+! Set axes
+  ! vertical atm axis
+  ALLOCATE(lev_values(src_nlev))
+  lev_values=(/ (l,l=1,src_nlev) /)
+  CALL xios_set_axis_attr("lev",n_glo=src_nlev,value=lev_values)
+  ! lev+1 for q2
+  ALLOCATE(lev_p1_values(src_nlev+1))
+  lev_p1_values=(/ (l,l=1,src_nlev+1) /)
+  CALL xios_set_axis_attr("lev_p1",n_glo=src_nlev+1,value=lev_p1_values)
+  ! tracers axis
+  ALLOCATE(nq_values(src_nq))
+  nq_values=(/(l,l=1,src_nq)/)
+  CALL xios_set_axis_attr("nq",n_glo=src_nq,value=nq_values)
+  ! soil layers axis
+  ALLOCATE(soil_layers_values(src_nsoil))
+  soil_layers_values=(/ (l,l=1,src_nsoil) /)
+  CALL xios_set_axis_attr("soil_layers",n_glo=src_nsoil,value=soil_layers_values)
+!   ALLOCATE(subslope_values(src_nslope))
+!   subslope_values=(/ (l,l=1,src_nslope) /)
+!   CALL xios_set_axis_attr("subslope",n_glo=src_nslope,value=subslope_values)
+
+! Set domains
+  CALL xios_set_domain_attr("src_domain_regular", &
+                            ni_glo=src_ni_glo, nj_glo=src_nj_glo, &
+                            ibegin=src_ibegin, ni=src_ni, &
+                            jbegin=src_jbegin, nj=src_nj, &
+                            type='rectilinear')
+  CALL xios_set_domain_attr("src_domain_regular", &
+                             data_dim=2, &
+                             data_ibegin=0, data_ni=src_ni, &
+                             data_jbegin=0, data_nj=src_nj)
+  CALL xios_set_domain_attr("src_domain_regular", &
+                            lonvalue_1D=src_lon, &
+                            latvalue_1D=src_lat)
+
+  CALL xios_set_domain_attr("src_topo_domain_regular", &
+                            ni_glo=src_topo_ni_glo, nj_glo=src_topo_nj_glo, &
+                            ibegin=src_topo_ibegin, ni=src_topo_ni, &
+                            jbegin=src_topo_jbegin, nj=src_topo_nj, &
+                            type='rectilinear')
+  CALL xios_set_domain_attr("src_topo_domain_regular", &
+                             data_dim=2, &
+                             data_ibegin=0, data_ni=src_topo_ni, &
+                             data_jbegin=0, data_nj=src_topo_nj)
+  CALL xios_set_domain_attr("src_topo_domain_regular", &
+                            lonvalue_1D=src_topo_lon, &
+                            latvalue_1D=src_topo_lat)
+
+  CALL xios_set_domain_attr("src_domain_regular_clean", &
+                            ni_glo=src_ni_glo-1, nj_glo=src_nj_glo, &
+                            ibegin=src_ibegin, ni=src_ni-1, &
+                            jbegin=src_jbegin, nj=src_nj, &
+                            type='rectilinear')
+  CALL xios_set_domain_attr("src_domain_regular_clean", &
+                             data_dim=2, &
+                             data_ibegin=0, data_ni=src_ni-1, &
+                             data_jbegin=0, data_nj=src_nj)
+  CALL xios_set_domain_attr("src_domain_regular_clean", &
+                            lonvalue_1D=src_lon(1:src_ni-1), &
+                            latvalue_1D=src_lat)
+
+  CALL xios_set_domain_attr("dst_domain_unstructured", &
+                            ni_glo=dst_ni_glo, &
+                            ibegin=dst_ibegin, &
+                            ni=dst_ni, &
+                            type="unstructured")
+  CALL xios_set_domain_attr("dst_domain_unstructured", &
+                            lonvalue_1D=dst_lon, &
+                            latvalue_1D=dst_lat, &
+                            bounds_lon_1D=dst_boundslon, &
+                            bounds_lat_1D=dst_boundslat, &
+                            nvertex=dst_nvertex)
+
+! Finalize XIOS context definition
+  WRITE(*,*) rank,":CALL xios_close_context_definition()"
+  CALL xios_close_context_definition()
+  CALL xios_get_handle("test",ctx_hdl)
+  CALL xios_set_current_context(ctx_hdl)
+
+! Temporal loop
+  DO ts=1,src_nt
+    WRITE(*,*) rank,":ts=",ts
+    ! Update calendar
+    CALL xios_update_calendar(ts)
+
+    ! Topography
+    CALL xios_recv_field("zMOL",src_topo)
+    WRITE(*,*) rank,":topo(1:2,1:3)=",src_topo(1:2,1:3)
+    ! Send surface geopotential
+    CALL xios_send_field("topo",src_topo(:,:)*gravity*1000.)
+
+    ! Surface pressure:
+    !! get data using XIOS:
+    CALL xios_recv_field("src_ps",src_field_2D)
+    WRITE(*,*) rank,":src_ps(1:2,1:3)=",src_field_2D(1:2,1:3)
+    !! write data using XIOS
+    CALL xios_send_field("ps_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! compute inter-layer pressures
+    DO l=1,src_nlev+1
+      src_pressure(:,:,l) = src_ap(l)+src_bp(l)*src_field_2D(:,:)
+    ENDDO
+
+    ! surface temperature:
+    CALL xios_recv_field("src_tsurf",src_field_2D)
+    WRITE(*,*) rank,":src_tsurf(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("tsurf_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! co2 ice coverage:
+!    CALL xios_recv_field("src_co2ice",src_field_2D)
+!    WRITE(*,*) rank,":src_co2ice(1:2,1:3)=",src_field_2D(1:2,1:3)
+!    CALL xios_send_field("co2ice_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! emissivity:
+    CALL xios_recv_field("src_emis",src_field_2D)
+    WRITE(*,*) rank,":src_emis(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("emis_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! q2 : q2surf for first layer of q2, the rest is q2atm
+    CALL xios_recv_field("src_q2surf",src_field_2D)
+    WRITE(*,*) rank,":src_q2(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_recv_field("src_q2atm",src_field_3D)
+    src_field_3D_p1(:,:,1)=src_field_2D(:,:)
+    src_field_3D_p1(:,:,2:src_nlev+1)=src_field_3D(:,:,:)
+
+    CALL xios_send_field("q2_clean",src_field_3D_p1(1:src_ni-1,1:src_nj,1:src_nlev+1))
+
+    ! Temperature:
+    CALL xios_recv_field("src_temp",src_field_3D)
+    ! compute theta_rhodz
+    DO l=1,src_nlev
+      src_pk(:,:)=((.5/preff)*(src_pressure(:,:,l)+src_pressure(:,:,l+1)))**kappa
+      src_theta_rhodz(:,:,l) = src_field_3D(:,:,l) * &
+      ((src_pressure(:,:,l)-src_pressure(:,:,l+1))/gravity)/src_pk(:,:)
+    ENDDO
+    CALL xios_send_field("theta_rhodz_clean", &
+                         src_theta_rhodz(1:src_ni-1,1:src_nj,1:src_nlev))
+
+    ! zonal wind
+    CALL xios_recv_field("src_u",src_field_3D)
+    CALL xios_send_field("u_clean", &
+                          src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+
+    ! meridional wind
+    CALL xios_recv_field("src_v",src_field_3D)
+    CALL xios_send_field("v_clean", &
+                          src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+    ! tracers
+    DO i=1,src_nq
+       if (i < 10) then
+           format_string = "(A8,I1)"
+       else
+           format_string = "(A8,I2)"
+       endif
+       write (i_trac, format_string) "src_trac", i
+       CALL xios_recv_field(i_trac,src_field_3D(:,:,:))
+       if (i==1) THEN
+          CALL xios_send_field("n2_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_n2_surf",src_field_2D)
+          CALL xios_send_field("n2_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       elseif (i==2) THEN
+          CALL xios_send_field("co_ice_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_co_ice_surf",src_field_2D)
+          CALL xios_send_field("co_ice_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       elseif (i==3) THEN
+          CALL xios_send_field("co_gas_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_co_gas_surf",src_field_2D)
+          CALL xios_send_field("co_gas_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       elseif (i==4) THEN
+          CALL xios_send_field("ch4_ice_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_ch4_ice_surf",src_field_2D)
+          CALL xios_send_field("ch4_ice_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       elseif (i==5) THEN
+          CALL xios_send_field("ch4_gas_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_ch4_gas_surf",src_field_2D)
+          CALL xios_send_field("ch4_gas_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       elseif (i==6) THEN
+          CALL xios_send_field("prec_haze_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_prec_haze_surf",src_field_2D)
+          CALL xios_send_field("prec_haze_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       elseif (i==7) THEN
+          CALL xios_send_field("haze_clean", &
+                        src_field_3D(1:src_ni-1,1:src_nj,1:src_nlev))
+          CALL xios_recv_field("src_haze_surf",src_field_2D)
+          CALL xios_send_field("haze_surf_clean", &
+                        src_field_2D(1:src_ni-1,1:src_nj))
+       ENDIF
+    ENDDO
+
+    ! soil temperature
+    CALL xios_recv_field("src_tsoil",src_field_3D_soil)
+    CALL xios_send_field("tsoil_clean", &
+                          src_field_3D_soil(1:src_ni-1,1:src_nj,1:src_nsoil))
+    ! soil thermal intertia
+    CALL xios_recv_field("src_inertiedat",src_field_3D_soil)
+    CALL xios_send_field("inertiedat_clean", &
+                          src_field_3D_soil(1:src_ni-1,1:src_nj,1:src_nsoil))
+    ! ZMEA "zmea Orographie sous-maille"
+    CALL xios_recv_field("src_ZMEA",src_field_2D)
+    WRITE(*,*) rank,":src_ZMEA(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("ZMEA_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! ZSTD "zstd Orographie sous-maille"
+    CALL xios_recv_field("src_ZSTD",src_field_2D)
+    WRITE(*,*) rank,":src_ZSTD(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("ZSTD_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! ZSIG "zsig Orographie sous-maille"
+    CALL xios_recv_field("src_ZSIG",src_field_2D)
+    WRITE(*,*) rank,":src_ZSIG(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("ZSIG_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! ZGAM "zgam Orographie sous-maille"
+    CALL xios_recv_field("src_ZGAM",src_field_2D)
+    WRITE(*,*) rank,":src_ZGAM(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("ZGAM_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! ZTHE "zthe Orographie sous-maille"
+    CALL xios_recv_field("src_ZTHE",src_field_2D)
+    WRITE(*,*) rank,":src_ZTHE(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("ZTHE_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+    ! albedodat "albedo"
+    CALL xios_recv_field("src_albedodat",src_field_2D)
+    WRITE(*,*) rank,":src_albedodat(1:2,1:3)=",src_field_2D(1:2,1:3)
+    CALL xios_send_field("albedodat_clean",src_field_2D(1:src_ni-1,1:src_nj))
+
+  ENDDO ! of DO ts=1,src_nt
+
+!! Finalize
+  write(*,*) rank,":Finalize: call xios_context_finalize"
+  CALL xios_context_finalize()
+
+  write(*,*) rank,":Finalize: call MPI_COMM_FREE"
+  CALL MPI_COMM_FREE(comm, ierr)
+  write(*,*) rank,":Finalize: call xios_finalize"
+  CALL xios_finalize()
+
+  if (rank==0) then
+    ! add a couple of things in the "startphy_icosa.nc" file
+    write(*,*) rank,"Write controle() to startphy_icosa.nc"
+    ierr=NF90_OPEN(output_startfi_file,NF90_WRITE,ncid)
+    ierr=NF90_REDEF(ncid) ! switch to define mode
+    ierr=NF90_DEF_DIM(ncid,"index",100,dimids(1))
+    ierr=NF90_DEF_VAR(ncid,"controle",NF90_DOUBLE,dimids(1),varid)
+    ierr=NF90_ENDDEF(ncid) ! switch out of define mode
+    ierr=NF90_PUT_VAR(ncid,varid,src_controle(1:100))
+    if (ierr.ne.NF90_NOERR) then
+      write(*,*) "NetCDF Error:",NF90_STRERROR(ierr)
+    endif
+    ierr=NF90_CLOSE(ncid)
+    ! add a couple of things in the "start_icosa.nc" file
+    ierr=NF90_OPEN(output_start_file,NF90_WRITE,ncid)
+    ierr=NF90_REDEF(ncid)
+    ierr=NF90_DEF_DIM(ncid,"nvertex_u",2,dimids(1))
+    ierr=NF90_DEF_VAR(ncid,"iteration",NF90_FLOAT,varid)
+    ierr=NF90_ENDDEF(ncid)
+    if (ierr.ne.NF90_NOERR) then
+      write(*,*) "NetCDF Error:",NF90_STRERROR(ierr)
+    endif
+    ierr=NF90_PUT_VAR(ncid,varid,0) ! set "iteration" value to 0
+    ierr=NF90_CLOSE(ncid)
+
+  endif ! of if (rank==0)
+
+  write(*,*) rank,":Finalize: call MPI_FINALIZE"
+  CALL MPI_FINALIZE(ierr)
+
+  write(*,*) rank,":my_remap: all is well that ends well!"
+
+END PROGRAM start_archive2icosa
