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 usage is as follows: ``` ❯❯❯ python3 compare_f90nml.py -h usage: compare_f90nml.py [-h] [-r] left_namelist right_namelist Compare two Fortran namelists and display differences (left_namelist - right_namelist) positional arguments: left_namelist Left namelist to compare right_namelist Right namelist to compare options: -h, --help show this help message and exit -r, --reverse reverse diff (right_namelist - left_namelist) (default: False) ``` The comparison is done as follows: - Both namelists are loaded - We loop over the keys of `left_namelist`. We look for the same key in the `right_namelist`. 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 `right_namelist`. - Differences in the values are printed to screen. - The `-r | --reverse` reverses the `namelists`. This allows the user to use `right_namelist` 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 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