Programming ART: Difference between revisions

From icon-art guide
Jump to navigation Jump to search
(added Sven's Namelist article)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:

= Programming ART =


== Adding a new Namelist Parameter ==
== Adding a new Namelist Parameter ==


Namelist parameters enable the execution of simulations with different settings
''work in Progress ''
without the need to recompile the code. The ICON-ART code has a multitude of
namelists encompasing a plethora of parameters which can be adjusted for each
simulation.

How to add a new namelist parameter is described in the following:

# Find a suitable namelist for your new parameter. When programming ART this will be the "art_nml" most of the time. However, there may be cases where a different namelist is more fitting.
# Look for the desired namelist module in the src/namelist-directory of the ICON code. The module for the ART namelist, for example, is found in src/namelist/mo_ art_nml.f90. This is the module file you need to edit to add your new namelist parameter.
# You need to add your new parameter in 4 places of this module:
#* The first one is the declaration of the corresponding namelist variable. Declare its type (INTEGER, CHARACTER(LEN=xyz), LOGICAL, REAL(wp)) and name (Before the "NAMELIST"-command)
#* Add the variable name to the "NAMELIST"-command
#* The module also has a subroutine for reading the namelist, for example "read_art_namelist( filename )". Inside this routine you set a default value and
#* add the new variable to the corresponding config-structure.
#* (optional) This subroutine is also the place to do some quality control/sanity checks if your namelist parameter requires this (for example: preventing negative values, ensuring limits, etc.).

The Namelist variables are saved inside a config-structure
representing the Namelist. Hence, you also need to add your new namelist parameter
to said config structure. The namelist module gives you the name of the config-
module that is linked with it (in its USE list). For example, the ART Namelist
is saved in the art_config-structure which is defined in the module "mo_art_config".
Look for this module name in the src/configure_model-directory (src/configure_model/
mo_art_config.f90). In this module you will find the DERIVED TYPE that represents
aforementioned config-structure (for "art_config", this is "t_art_config"). Add your
namelist variable to this DERIVED TYPE (take care that it is of the same type as in
the namelist module).

Now you can access your new namelist variable via the corresponding config-structure.


== Adding a new Module ==
== Adding a new Module ==

Latest revision as of 10:04, 16 February 2023


Adding a new Namelist Parameter

Namelist parameters enable the execution of simulations with different settings without the need to recompile the code. The ICON-ART code has a multitude of namelists encompasing a plethora of parameters which can be adjusted for each simulation.

How to add a new namelist parameter is described in the following:

  1. Find a suitable namelist for your new parameter. When programming ART this will be the "art_nml" most of the time. However, there may be cases where a different namelist is more fitting.
  2. Look for the desired namelist module in the src/namelist-directory of the ICON code. The module for the ART namelist, for example, is found in src/namelist/mo_ art_nml.f90. This is the module file you need to edit to add your new namelist parameter.
  3. You need to add your new parameter in 4 places of this module:
    • The first one is the declaration of the corresponding namelist variable. Declare its type (INTEGER, CHARACTER(LEN=xyz), LOGICAL, REAL(wp)) and name (Before the "NAMELIST"-command)
    • Add the variable name to the "NAMELIST"-command
    • The module also has a subroutine for reading the namelist, for example "read_art_namelist( filename )". Inside this routine you set a default value and
    • add the new variable to the corresponding config-structure.
    • (optional) This subroutine is also the place to do some quality control/sanity checks if your namelist parameter requires this (for example: preventing negative values, ensuring limits, etc.).

The Namelist variables are saved inside a config-structure representing the Namelist. Hence, you also need to add your new namelist parameter to said config structure. The namelist module gives you the name of the config- module that is linked with it (in its USE list). For example, the ART Namelist is saved in the art_config-structure which is defined in the module "mo_art_config". Look for this module name in the src/configure_model-directory (src/configure_model/ mo_art_config.f90). In this module you will find the DERIVED TYPE that represents aforementioned config-structure (for "art_config", this is "t_art_config"). Add your namelist variable to this DERIVED TYPE (take care that it is of the same type as in the namelist module).

Now you can access your new namelist variable via the corresponding config-structure.

Adding a new Module

work in Progress

Adding a new Diagnostic

work in Progress