Difference between revisions of "LMDZ to DYNAMICO start files"

From Planets
Jump to: navigation, search
m (add categories)
 
(7 intermediate revisions by one other user not shown)
Line 2: Line 2:
 
There is a wiki page specific for Dynamico just in case: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_DYNAMICO_dynamical_core ).
 
There is a wiki page specific for Dynamico just in case: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_DYNAMICO_dynamical_core ).
  
The first step is to compile DYNAMICO using the LMDZ physics. Please refer to [[DYNAMICO with LMDZ physics]] for this step.
+
== Overview ==
 +
The general idea here is to present how to convert some "longitude-latitude grid" initial condition files (obtained using the LMDZ.COMMON dynamical core) into corresponding icosahedral (to use with DYNAMICO) initial condition files. In practice this requires the following main steps:
 +
# Take a lon-lat start.nc and starfi.nc pair of files and generate a start_archive.nc file
 +
# Generate a pair of restart.nc and restartfi.nc files with DYNAMICO at the desired resolution, starting from idealized initial condition (fixed temperature, or temperature profile, and not physics start file)
 +
# Use a dedicated utility to reinterpolate the contents of start_archive.nc onto the restart files from previous step
  
1. Get start.nc and startfi.nc from your simulation via newstart or the PCM.
+
== Compilation ==
  
2. Get an archive file using '''start2archive'''
+
* The first step is to compile DYNAMICO using the LMDZ physics. Please refer to [[DYNAMICO with LMDZ physics]] for this step. This implies the compilation of [[IOIPSL]], [[XIOS]], [[DYNAMICO]] and [[Quick Install and Run|LMDZ package]] (Generic, Mars, Pluto, ...). It will create the executable '''icosa_lmdz.exe''' in your '''[[ICOSA_LMDZ]]/bin''' directory.
* a) Compile '''start_archive.e''' using the following command. Replace dimensions and <your_physics> by your package (mars/pluto/...)
+
 
 +
* Compile '''start_archive.e''' using the following command. Replace architecture, dimensions and <your_physics> by your package (mars/pluto/...)
 
<pre>
 
<pre>
makelmdz_fcm -arch <archive> -d <dimensions (lonxlatxalt)>  -p <your_physics> start2archive  
+
makelmdz_fcm -arch <architecture> -d <dimensions (lonxlatxalt)>  -p <your_physics> start2archive  
 
</pre>
 
</pre>
* b) run it:
+
 
 +
* Compile the files in LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa (where YOUR_PHYSICS is MARS/PLUTO/...) with the '''compile''' script, which will create start_archive2icosa and rearrange_startphy.
 +
 
 +
== Preliminary steps ==
 +
 
 +
To convert your lmdz files to dynamico files, you will need to go through the [[#startarchive2icosa]] script, which requires the following files:
 +
 
 +
* start_archive_nc4.nc
 +
* startphy_icosa_ref.nc
 +
* start_icosa_ref.nc
 +
* surface_nc4.nc
 +
 
 +
To get these files, follow the following procedure:
 +
 
 +
1. Get start.nc and startfi.nc from your simulation via newstart or the PCM and create an archive file using '''start2archive''', and convert it to netcdf4:
 +
 
 
<pre>
 
<pre>
 
start2archive.e
 
start2archive.e
 +
nccopy -k 4 start_archive.nc start_archive_nc4.nc
 +
</pre>
 +
 +
2. Create an initial conditions files for dynamico by running a  dynamico simulation without an initial physics file (startphy_file=false).
 +
*a) In '''run_icosa.def''' change the following variables (adapt to your case) :
 +
<pre>
 +
 +
# short run
 +
run_length=1500
 +
# isothermal could a bad initial state, you can try  etat0=temperature_profile, which reads a 'profile.in' file.
 +
etat=isothermal
 +
etat_isothermal_temp=200
 +
# use LMDZ physics
 +
physics = phys_external
 +
# do not use startfi.nc
 +
startphy_file=false
 
</pre>
 
</pre>
* c) Copy start archive to your new dynamico simulation folder
+
 
 +
*b) run '''icosa_lmdz.exe''' (fingers crossed it run smoothly) and copy its output files.
 +
<pre>
 +
icosa_lmdz.exe
 +
cp restartfi.nc startphy_icosa_ref.nc
 +
cp restart.nc start_icosa_ref.nc
 +
</pre>
 +
 
 +
3) Create a '''surface_nc4.nc''' based on your topography (could be a symbolic link).
 +
 
 +
It may fail if the format is netCDF 3. You can convert the file with '''nc3tonc4''' or '''nccopy -k 4'''.
 +
 
 +
== startarchive2icosa ==
 +
 
 +
This script will convert the LMDZ start files to the DYNAMCIO grid.
 +
 
 +
1) Gather:
 +
* start_archive_nc4.nc
 +
* startphy_icosa_ref.nc
 +
* start_icosa_ref.nc
 +
* surface_nc4.nc
 +
* xml files for DYNAMICO (in deftank/ hopefully)
 +
 
 +
2) Then get executable files (*.e)  from path/to/LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa/*
 
<pre>
 
<pre>
cp start_archive.nc dynamico_runs
+
ln -s path/to/LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa/
 +
cp -r startarchive2icosa/*.e startarchive2icosa/run* startarchive2icosa/*.xml startarchive2icosa/job* startarchive2icosa/*sh .
 +
mv run_icosa.def.no_startfi run.def
 
</pre>
 
</pre>
*d) Convert the start archive to netCDF4
+
 
 +
3) run '''start_archive2icosa''' as a job (requires a lot of memory). Make sure that '''iodef.xml''' is the one from the '''startarchive2icosa''' folder.
 
<pre>
 
<pre>
nccopy -k 4 start_archive.nc start_archive_nc4.nc
+
sbatch job_start_archive_2icosa
 
</pre>
 
</pre>
 +
The script creates '''start_icosa_prefinalize.nc''' and  '''startfi_prefinalize.nc'''.
  
3. Create an initial conditions files for dynamico by running a  dynamico simulation without an initial physics file (startphy_file=false).
+
4) You will need to run a final script:
*a) In run.def change the following variables (adapt to your case) : run_length=1500, etat_isothermal_temp=200, etat=isothermal and startphy_file=false
 
*b) Follow [[DYNAMICO with LMDZ physics]], to compile '''icosa_lmdz.exe'''.
 
*c) run it:
 
 
<pre>
 
<pre>
icosa_lmdz.exe
+
./icosa_finalize.bash
 
</pre>
 
</pre>
*d) copy the files outputed by icosa_lmdz.exe
+
 
 +
There could be an issue with the location of the LMDZ root folder. Please change the icosa_finalize.bash file accordingly or set the '''LMDZ''' variable in your environment.
 +
The script creates a folder '''icosa_starts/''' with the dynamico '''startfi.nc and start.nc'''.
 +
 
 +
5. NOT NEEDED? update the tracer name in startfi for each tracer for example: ncrename -v ccn_number_surf,ccn_number startfi.nc.
 +
 
 +
== Run Dynamico simulation ==
 +
 
 +
Create another folder, with the xml and def files from '''deftank/dynamico'''.
 +
 
 +
In run.def, be sure to have :
 
<pre>
 
<pre>
cp restartfi.nc startphy_icosa_ref.nc
+
etat0=start_file
cp restart.nc start_icosa_ref.nc
+
etat0_start_file_colocated=true
 
</pre>
 
</pre>
 +
Make sure the run.def also lists '''llm''' equal to your start.nc '''lev''' count. If you encounter an error about '''n_glo''' not being equal to your model '''n_glo''', change '''llm''' to match '''lev'''.
  
4. Convert the LMDZ start files to the DYNAMCIO grid.
+
Copy in your folder the '''startfi.nc and start.nc''' from the '''icosa_starts/''' folder generated by [[#start_archive2icosa]] and icosa_finalize.bash scripts.
* a) Create a '''surface_nc4.nc''' based on your topography (could be a symbolic link)
+
 
* b) Compile the files in LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa (where YOUR_PHYSICS is MARS/PLUTO/...) with the '''compile''' script, which will create '''start_archive2icosa''' and '''rearrange_startphy'''. Copy all the files in your simulation folder, but WARNING: there are some xml files that could overwrite your own files (like iodef.xml).
+
<pre>
*  c) run '''start_archive2icosa''' as a job (requires a lot of memory) and make sure that iodef.xml is the one from the '''startarchive2icosa''' folder.
+
mv icosa_starts/start*nc your_dynamico_folder/
*  d) the script creates '''start_icosa_prefinalize.nc''' and '''startfi_prefinalize.nc'''
+
</pre>
*  e) run '''icosa_finalize.bash'''
 
*  f) TODO change the XIOS and the for startfi0.nc  paths in icosa_finalize.bash and run it. It adds and changes variables in the startfiles.
 
* g) The scripts outputs startfi.nc and start_icosa.nc
 
 
 
6. update the tracer name in startfi for each tracer for example: ncrename -v ccn_number_surf,ccn_number startfi.nc
 
  
7. Run Dynamico simulation
 
  a) change the iodef.xml to the one in '''deftank/dynamico'''
 
  b) change in run.def etat0=start_file and add etat0_start_file_colocated=true
 
  
[[Category:DYNAMICO]]
 
 
[[Category:Generic-DYNAMICO]]
 
[[Category:Generic-DYNAMICO]]
 +
[[Category:Mars-DYNAMICO]]
 
[[Category:Pluto-DYNAMICO]]
 
[[Category:Pluto-DYNAMICO]]
[[Category:Mars-DYNAMICO]]
+
[[Category:Venus-DYNAMICO]]

Latest revision as of 14:43, 14 April 2025

This page explains how to convert a start.nc startfi.nc to a Dynamico There is a wiki page specific for Dynamico just in case: https://lmdz-forge.lmd.jussieu.fr/mediawiki/Planets/index.php/The_DYNAMICO_dynamical_core ).

Overview

The general idea here is to present how to convert some "longitude-latitude grid" initial condition files (obtained using the LMDZ.COMMON dynamical core) into corresponding icosahedral (to use with DYNAMICO) initial condition files. In practice this requires the following main steps:

  1. Take a lon-lat start.nc and starfi.nc pair of files and generate a start_archive.nc file
  2. Generate a pair of restart.nc and restartfi.nc files with DYNAMICO at the desired resolution, starting from idealized initial condition (fixed temperature, or temperature profile, and not physics start file)
  3. Use a dedicated utility to reinterpolate the contents of start_archive.nc onto the restart files from previous step

Compilation

  • Compile start_archive.e using the following command. Replace architecture, dimensions and <your_physics> by your package (mars/pluto/...)
makelmdz_fcm -arch <architecture> -d <dimensions (lonxlatxalt)>  -p <your_physics> start2archive 
  • Compile the files in LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa (where YOUR_PHYSICS is MARS/PLUTO/...) with the compile script, which will create start_archive2icosa and rearrange_startphy.

Preliminary steps

To convert your lmdz files to dynamico files, you will need to go through the #startarchive2icosa script, which requires the following files:

  • start_archive_nc4.nc
  • startphy_icosa_ref.nc
  • start_icosa_ref.nc
  • surface_nc4.nc

To get these files, follow the following procedure:

1. Get start.nc and startfi.nc from your simulation via newstart or the PCM and create an archive file using start2archive, and convert it to netcdf4:

start2archive.e
nccopy -k 4 start_archive.nc start_archive_nc4.nc

2. Create an initial conditions files for dynamico by running a dynamico simulation without an initial physics file (startphy_file=false).

  • a) In run_icosa.def change the following variables (adapt to your case) :

# short run
run_length=1500
# isothermal could a bad initial state, you can try  etat0=temperature_profile, which reads a 'profile.in' file.
etat=isothermal
etat_isothermal_temp=200
# use LMDZ physics
physics = phys_external
# do not use startfi.nc
startphy_file=false
  • b) run icosa_lmdz.exe (fingers crossed it run smoothly) and copy its output files.
icosa_lmdz.exe 
cp restartfi.nc startphy_icosa_ref.nc
cp restart.nc start_icosa_ref.nc

3) Create a surface_nc4.nc based on your topography (could be a symbolic link).

It may fail if the format is netCDF 3. You can convert the file with nc3tonc4 or nccopy -k 4.

startarchive2icosa

This script will convert the LMDZ start files to the DYNAMCIO grid.

1) Gather:

  • start_archive_nc4.nc
  • startphy_icosa_ref.nc
  • start_icosa_ref.nc
  • surface_nc4.nc
  • xml files for DYNAMICO (in deftank/ hopefully)

2) Then get executable files (*.e) from path/to/LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa/*

ln -s path/to/LMDZ.<YOUR_PHYSICS>/util/startarchive2icosa/
cp -r startarchive2icosa/*.e startarchive2icosa/run* startarchive2icosa/*.xml startarchive2icosa/job* startarchive2icosa/*sh .
mv run_icosa.def.no_startfi run.def

3) run start_archive2icosa as a job (requires a lot of memory). Make sure that iodef.xml is the one from the startarchive2icosa folder.

sbatch job_start_archive_2icosa

The script creates start_icosa_prefinalize.nc and startfi_prefinalize.nc.

4) You will need to run a final script:

./icosa_finalize.bash

There could be an issue with the location of the LMDZ root folder. Please change the icosa_finalize.bash file accordingly or set the LMDZ variable in your environment. The script creates a folder icosa_starts/ with the dynamico startfi.nc and start.nc.

5. NOT NEEDED? update the tracer name in startfi for each tracer for example: ncrename -v ccn_number_surf,ccn_number startfi.nc.

Run Dynamico simulation

Create another folder, with the xml and def files from deftank/dynamico.

In run.def, be sure to have :

etat0=start_file 
etat0_start_file_colocated=true

Make sure the run.def also lists llm equal to your start.nc lev count. If you encounter an error about n_glo not being equal to your model n_glo, change llm to match lev.

Copy in your folder the startfi.nc and start.nc from the icosa_starts/ folder generated by #start_archive2icosa and icosa_finalize.bash scripts.

mv icosa_starts/start*nc your_dynamico_folder/