Difference between revisions of "Nmlcompare"
Line 4: | Line 4: | ||
<span style="background-color: #ffffff;">The nmlcompare package is available on raijin available under </span><span style="color: #000000;">[https://accessdev.nci.org.au/trac/wiki/Raijin%20Apps | ACCESS apps]</span><span style="background-color: #ffffff;">.</span> | <span style="background-color: #ffffff;">The nmlcompare package is available on raijin available under </span><span style="color: #000000;">[https://accessdev.nci.org.au/trac/wiki/Raijin%20Apps | ACCESS apps]</span><span style="background-color: #ffffff;">.</span> | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ nmlcompare -h | $ nmlcompare -h | ||
usage: nmlcompare [-h] [-s] [-d] [-g GROUPS] first second | usage: nmlcompare [-h] [-s] [-d] [-g GROUPS] first second | ||
Line 29: | Line 29: | ||
For example, given two namelists, short1.nml: | For example, given two namelists, short1.nml: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ cat short1.nml | $ cat short1.nml | ||
&coupler_nml | &coupler_nml | ||
Line 68: | Line 68: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
and short2.nml: | and short2.nml: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ cat short2.nml | $ cat short2.nml | ||
&coupler_nml | &coupler_nml | ||
Line 104: | Line 104: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
A simple comparison, with no options: | A simple comparison, with no options: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ nmlcompare short1.nml short2.nml | $ nmlcompare short1.nml short2.nml | ||
(?)diag_manager_nml | (?)diag_manager_nml | ||
Line 124: | Line 124: | ||
It is possible to only list specified namelist groups using the "-g" option, multiple times if more than one group is required: | It is possible to only list specified namelist groups using the "-g" option, multiple times if more than one group is required: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ nmlcompare short1.nml -g coupler_nml -g flux_exchange_nml short2.nml | $ nmlcompare short1.nml -g coupler_nml -g flux_exchange_nml short2.nml | ||
(?)coupler_nml | (?)coupler_nml | ||
Line 137: | Line 137: | ||
You can also output variables that are the same in both namelists: | You can also output variables that are the same in both namelists: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ nmlcompare short1.nml -s short2.nml | $ nmlcompare short1.nml -s short2.nml | ||
(?)diag_manager_nml | (?)diag_manager_nml | ||
Line 171: | Line 171: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Equally it is possible to only show the variables that are the same in both namelists by "toggling off" the difference flag (-d): | Equally it is possible to only show the variables that are the same in both namelists by "toggling off" the difference flag (-d): | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=text> |
$ nmlcompare short1.nml -s -d short2.nml | $ nmlcompare short1.nml -s -d short2.nml | ||
(?)diag_manager_nml | (?)diag_manager_nml |
Latest revision as of 23:44, 11 December 2019
Introduction
Is a simple python script which utilises | f90nml, Marshall Ward's excellent FORTRAN namelist parser, to do a simple minded comparison of two FORTRAN | namelists.
The nmlcompare package is available on raijin available under | ACCESS apps.
$ nmlcompare -h
usage: nmlcompare [-h] [-s] [-d] [-g GROUPS] first second
Report the difference between two FORTRAN namelist files. (=) Means they are
same, (-) missing in second, (+) missing in first, (?) exists in both, but
with different values
positional arguments:
first namelist file
second namelist file
optional arguments:
-h, --help show this help message and exit
-s, --same Show variables that are the same (default False)
-d, --diff Show variables that are the different (default True,
use -d to toggle off)
-g GROUPS, --groups GROUPS
Specify particular namelist groups
Examples
For example, given two namelists, short1.nml:
$ cat short1.nml
&coupler_nml
months = 6,
days = 0,
current_date = 1,1,1,0,0,0,
calendar = 'noleap',
dt_cpld = 1800,
dt_atmos = 1800,
do_atmos = .false.,
do_land = .false.,
do_ocean = .true.,
atmos_npes = 0,
ocean_npes = 0,
use_lag_fluxes=.true.
check_stocks=0
/
&data_override_nml
/
&diag_integral_nml
file_name = 'diag_integral.out'
time_units = 'days'
output_interval = -1.0
/
&diag_manager_nml
max_output_fields=700
max_input_fields=700
max_axes=300
max_num_axis_sets=40
max_files = 1000
issue_oor_warnings=.false.
/
and short2.nml:
$ cat short2.nml
&coupler_nml
months = 6,
days = 5,
current_date = 1,1,1,0,0,0,
calendar = 'noleap',
dt_cpld = 1800,
dt_atmos = 1800,
do_atmos = .false.,
do_land = .false.,
do_ice = .true.,
atmos_npes = 0,
ocean_npes = 0,
check_stocks=0
/
&data_override_nml
/
&diag_manager_nml
max_output_fields=700
max_input_fields=700
max_axes=100
max_num_axis_sets=40
max_files = 100
issue_oor_warnings=.false.
/
&flux_exchange_nml
do_area_weighted_flux=.true.
/
A simple comparison, with no options:
$ nmlcompare short1.nml short2.nml
(?)diag_manager_nml
(?)max_axes : 300 -> 100
(?)max_files : 1000 -> 100
(?)coupler_nml
(?)days : 0 -> 5
(-)do_ocean : True
(-)use_lag_fluxes : True
(+)do_ice : True
(-)diag_integral_nml
(-)file_name : diag_integral.out
(-)time_units : days
(-)output_interval : -1.0
(+)flux_exchange_nml
(+)do_area_weighted_flux : True
As explained in the usage above, "(?)" indicates the group (or variable) is in both namelists, but are different, "(-)" that it is only in the first namelist and "(+)" only in the second.
It is possible to only list specified namelist groups using the "-g" option, multiple times if more than one group is required:
$ nmlcompare short1.nml -g coupler_nml -g flux_exchange_nml short2.nml
(?)coupler_nml
(?)days : 0 -> 5
(-)do_ocean : True
(-)use_lag_fluxes : True
(+)do_ice : True
(+)flux_exchange_nml
(+)do_area_weighted_flux : True
You can also output variables that are the same in both namelists:
$ nmlcompare short1.nml -s short2.nml
(?)diag_manager_nml
(=)max_num_axis_sets : 40
(?)max_axes : 300 -> 100
(?)max_files : 1000 -> 100
(=)max_output_fields : 700
(=)issue_oor_warnings : False
(=)max_input_fields : 700
(=)data_override_nml
(?)coupler_nml
(=)atmos_npes : 0
(=)check_stocks : 0
(=)months : 6
(?)days : 0 -> 5
(=)do_land : False
(=)current_date : [1, 1, 1, 0, 0, 0]
(=)do_atmos : False
(=)ocean_npes : 0
(=)calendar : noleap
(=)dt_atmos : 1800
(=)dt_cpld : 1800
(-)do_ocean : True
(-)use_lag_fluxes : True
(+)do_ice : True
(-)diag_integral_nml
(-)file_name : diag_integral.out
(-)time_units : days
(-)output_interval : -1.0
(+)flux_exchange_nml
(+)do_area_weighted_flux : True
Equally it is possible to only show the variables that are the same in both namelists by "toggling off" the difference flag (-d):
$ nmlcompare short1.nml -s -d short2.nml
(?)diag_manager_nml
(=)max_num_axis_sets : 40
(=)max_output_fields : 700
(=)issue_oor_warnings : False
(=)max_input_fields : 700
(=)data_override_nml
(?)coupler_nml
(=)atmos_npes : 0
(=)check_stocks : 0
(=)months : 6
(=)do_land : False
(=)current_date : [1, 1, 1, 0, 0, 0]
(=)do_atmos : False
(=)ocean_npes : 0
(=)calendar : noleap
(=)dt_atmos : 1800
(=)dt_cpld : 1800
This program is very simple, and no attempt has been made to test it against complicated namelist constructions. If you find it does not work for your namelists and would like it to, please contact the | author or contact the CMS team