Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility to compare Fortran namelists (#1234)
Often times it is necessary to compare Fortran namelists between a UFS-weather-model regression test and a global-workflow experiment, or in other example applications. This PR adds a simple utility that loads two namelists and spits out the differences between them. The differences are calculated as a departure from the first namelist. This utility leverages `f90nml` (approved for use on WCOSS2) The comparison is done as follows: - Both namelists are loaded - We loop over the keys of namelist 1. We look for the same key in namelist 2. If the key is found, the values are compared. If the key is not found, a note is made that the key is undefined in namelist 2. - Differences in the values are printed to screen. ``` ❯❯❯ python3 compare_f90nml.py -h usage: compare_f90nml.py [-h] -n namelist1 namelist2 [-r] Compare two Fortran namelists and display differences options: -h, --help show this help message and exit -n namelist1 namelist2, --namelists namelist1 namelist2 name of two namelists to compare (namelist1 - namelist2) (default: None) -r, --reverse reverse diff (namelist2 - namelist1) (default: False) ``` The `-r | --reverse` reverses the `namelists`. This allows the user to use `namelist 2` as the reference. If differences are found, they are shown as follows (examples of `input.nml` from the `control_p8` and `cpld_control_p8` regression tests of the ufs-weather-model) ``` ❯❯❯ python3 compare_f90nml.py -n control_p8.nml cpld_control_p8.nml comparing: control_p8.nml | cpld_control_p8.nml ----------------------------------------------- atmos_model_nml: ccpp_suite : FV3_GFS_v17_p8 | FV3_GFS_v17_coupled_p8 fms_nml: domains_stack_size : 3000000 | 8000000 fv_core_nml: dnats : 0 | 2 gfs_physics_nml: min_seaice : 0.15 | 1e-06 use_cice_alb : False | True nstf_name : [2, 1, 0, 0, 0] | [2, 0, 0, 0, 0] cplchm : False | True cplflx : False | True cplice : False | True cplwav : False | True cplwav2atm : False | True ```
- Loading branch information