replace reading of fortran namelists with yaml config files in the data coupler
currently the data coupler uses a fortran namelist as input, which is then parsed to be converted to a python dixxt(). It would be much better *and clearer) to define those dictionnaries in yaml files directly.
The reading is done here https://earth.bsc.es/gitlab/es/python-amip-reader/-/blob/data-coupler/sources/data-coupler/DataCoupler.py#L22
and the remapping to a dict() is done here : https://earth.bsc.es/gitlab/es/python-amip-reader/-/blob/data-coupler/sources/data-coupler/DataCouplerUtils.py#L84
The format of the obscure keys for FileInputVars
and OasisOutputVars
is defined here: https://earth.bsc.es/gitlab/es/python-amip-reader/-/blob/data-coupler/tests/run_example.sh#L135 and https://earth.bsc.es/gitlab/es/python-amip-reader/-/blob/data-coupler/tests/run_example.sh#L154
A quick load of the used python3 module shows that the yaml package is available.
EDIT : This feature will also allow to run any box model with a custom yaml file. For now the Co2 and amip data coupler python scripts are there just to specify some different things like the namelist.
NAMELIST_FILE_NAME = 'namelist.co2box'
NAMELIST_SECTION = 'NAMCO2BOX'
LOG_FILE_NAME = 'co2box.log'
CPLNG_COMP_NAME = 'CO2BOX'
this could be replaced by calling DataCoupler.py -f <file.yml>
and <file.yml>
contains these 4 parameters as well as the others currently in the fortran namelist.
Main steps in the refactoring:
-
replace fortran namelist with yaml template namelist -
minor changes to the initial implementation in the comments to commit 3bd4fafa -
refactor OasisOutputVar to contain send_id, receive_id, send_grid_name and receive_grid_name -
replace IFS_toy.py with the generic toy model and yaml file generated by the DataCoupler . in_vars will be populated by the receive_id elements of the OasisOutputVar dict and out_vars={} -
generation of the namcouple file from the OasisOutputVar dict and other variables -
Add co2flux template (amip+co2 fluxes on the nx grid, used for EC-Earth4-CC), used for the CO2_EMODE case -
Add co2box template, used for EC-Earth3 co2box) - @etourign -
implement small issues mentionned in #6 and #7 -
add support for mixed co2box + amip (2 different grids)