esm-tools / esm_tools

Simple Infrastructure for Earth System Simulations
https://esm-tools.github.io/
GNU General Public License v2.0
25 stars 12 forks source link

add_namelist_changes not working when used in yaml runscript #205

Closed seb-wahl closed 3 years ago

seb-wahl commented 4 years ago

Describe the bug Hi all. Just discovered that if you add a add_namelist_changes in a yaml runscript e.g.

oifs: 
    add_namelist_changes:
                fort.4:
                        NAMCLDP:
                                SCLCT_SWITCH: 1

all other add_namelist_changes that are found in oifs.yaml (there are several in oifs.yaml) are NOT applied e.g.

## Using XIOS?
choose_with_xios:
        1:
                add_include_models:
                        - xios
                add_namelist_changes:
                        fort.4:
                                NAMCT0:
                                        LXIOS: ".true."

i.e. the final oifs namelist fort.4 will NOT have a LXIOS = .true. entry.

To Reproduce cd /to/where/you/store/model/codes esm_master install-oifs-43r3-v1 cd /to/your/esm_tools/runscripts/oifs/ esm_runscripts -e oifstest oifs-43r3-tco95-amip-blogin-initial-daily_SW.yaml

Expected behavior The namelist changes inside the add_namelist_changes should be applied correctly.

System (please complete the following information):

mandresm commented 4 years ago

Hi @seb-wahl, I managed to reproduce the issue in blogin using oifs, but also in ollie using the sample component. However, this is not necessarily a bug, but a particularity of the _changes functionality. I agree that the behavior is somehow weird and we might want to revisit it (and for sure document it), so I will leave this issue open for the other team members to join the discussion and potentially decide on taking further actions (@dbarbi , @pgierz , @nwieters , @denizural ).

How do _changes currently work? 1) Changes inside a _changes variable (without add_) contained in multiple files are combined, they do not overwrite (opposite to normal variables where not having an add_ results in overwritting). For example, in your runscript you could just use:

oifs: 
    namelist_changes:
                fort.4:
                        NAMCLDP:
                                SCLCT_SWITCH: 1

This will be combined with whatever is the final configuration for namelist_changes in oifs.yaml. 2) You only need add_ to the _changes if you want to "modularly" add changes within _choose blocks to the main _changes inside that given file.

Provisional solution and oifs specific details

A provisional solution would be to remove the add_ from your runscript.

Another thing I noticed though is that there is no namelist_changes in oifs.yaml, all are add_namelist_changes. However, adding namelist_changes in oifs.yaml with a dummy variable does not fix the problem.