Difference between revisions of "Nmlcompare"
(Imported from Wikispaces) |
|||
Line 194: | Line 194: | ||
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 [http://www.climatescience.org.au/staff/profile/AHeerdegen | author] or [[home | contact the CMS team]] | 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 [http://www.climatescience.org.au/staff/profile/AHeerdegen | author] or [[home | contact the CMS team]] | ||
− | [[Category: | + | [[Category:Fortran]] |
Revision as of 01:00, 21 March 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