Developments around CHIMERE

How to pass a new parameter from the yaml to CHIMERE

0. From a yaml that works. Add the new parameter in the yaml (with one of its possible values). Example for a switch, here ignore_input_dates, which can be 0 or 1, True or False:

model :
  plugin:
    name    : CHIMERE
    version : std

  direxec: /home/users/ipison/cif/model_sources/chimereGES/
  ignore_input_dates: True
  [...]
  1. Add the new input arguments in __init__.py with all the relevant information:

input_arguments = {
  "direxec": {
      "doc": "Path to CHIMERE sources and/or executables. "
             "For executables, ``fwdchimere.e``, ``tlchimere.e`` and ``achimere.e`` should be in "
             "``${path}/src``, ``${path}/src_tl`` and ``${path}/src_ad`` respective sub-folders.",
      "default": None,
      "accepted": str
  },
  "ignore_input_dates": {
      "doc": "Ignore errors in CHIMERE that checks the consistency of dates "
             "in AEMISSIONS, BEMISSIONS, BOUN_CONCS, etc; "
             "this is useful if you want to use input files from "
             "another period as is",
      "default": False,
      "accepted": bool
  }
  [...]
  1. Pass this argument to CHIMERE via its input file chimere.nml. This file is generated by io/inputs/params.py by function make_nml so that the new information has simply to be added to the list.

def make_nml(self, runsubdir, sdc, mode, ddi):
  # Default values
  nvegtype = getattr(self, "nvegtype", 16)

  # Fills in chimere.nml
  domain = self.domain
  chemistry = self.chemistry
  dirchem = chemistry.dirchem_ref
  schemeid = chemistry.schemeid
  nho = self.nho

  # NML string to write
  with open("{}/chimere.nml".format(runsubdir), "w") as f:
      f.write("&args\n")

  [...]

      f.write("hpulse = {}\n".format(self.hpulse))
      f.write("ignore_chck_dates = {}\n".format(1 if self.ignore_input_dates else 0))
      f.write("/\n")

Important: for easier use in the fortran, True/False are often “converted” into 1/0.

Remark: the name used in CHIMERE is here different from the name in the yaml.

Remark: it is also pssible to access parameters which are defined in a paragraph that is not model e.g. chemistry.

  1. Make use of the new information in CHIMERE’s sources, in model_sources/chimereGES/src*:

  1. Declare it in modules/chimere_common.F90 and, if the information is to be used by the workers as well as by the master, in :model/worker_common.F90 (which is not the case for the example ignore_chck_dates).

  2. Read it in initio/iniread.F90

  3. If declared in model/wotker_common.F90, pass it from the master to the workers through the relevant subroutine in module/master_message_subs.F90 and the matching one in model/worker_message_subs.F90, plus declare the communication in module/master_message_defs.F90.

  4. Make use of the information where it is relevant in CHIMERE’s sources. Compile CHIMERE to check that everything is OK in the fortan sources.

  1. Run a test case with the yaml including this parameter.