New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Developers/NamelistChecker (diff) – NEMO

Changes between Initial Version and Version 1 of Developers/NamelistChecker


Ignore:
Timestamp:
2020-06-05T12:16:17+02:00 (4 years ago)
Author:
acc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Developers/NamelistChecker

    v1 v1  
     1= Namelist Integrity checks = 
     2 
     3Misplaced or mis-spelt variables in configuration namelist files can be a source of frustration when porting configurations used with older releases of NEMO to more modern versions. The code will report these occurrences and stop during start-up; but only one instance is reported each time. Finding them all this way can be a time-consuming business. Part 1 of this page details a simple Python script which can be used to find mis-matches between a configuration namelist and its reference counterpart before attempting to run the model.  
     4 
     5For most users, this should be sufficient but developers of new features have the added uncertainty of not knowing if the reference namelist correctly contains all the namlist options available in the code. Part 2 of this page suggests further tools which can can construct a 'pseudo reference namelist' by parsing the fortran code base. The actual reference namelist and the 'pseudo' version can then be used with the integrity checker from part 1. By using the integrity checker twice, with the roles of the two namelists swapped, it is possible to confirm that: 
     6 
     7 * The actual reference namelist is compatible with the code base 
     8 * The actual reference namelist contains examples of all the namelist variables defined in the code base. 
     9 
     10All the scripts mentioned are attached to this page. 
     11 
     12== Part 1 Integrity checker == 
     13 
     14If we assume the following conventions for NEMO namelists: 
     15 
     16  * namelists are started with ''&name_of_namelist'' appearing as the first non-whitespace on a line (and not followed by anything other than an optional comment) 
     17  * Only one variable is set on each line 
     18  * namelists are closed with / appearing as the first non-whitespace on a line 
     19 
     20then the attached nemo_nml_check.py script will: 
     21 * read supplied namelist files  
     22 * construct lists of namelist blocks and their contents (the latter being a list of lists)  
     23 * compare the contents lists for matching named blocks to confirm membership 
     24 * report any mis-matches together with the line number in the configuration namelist 
     25 
     26By default, the script will compare ''namelist_cfg'' and ''namelist_ref'' from the current directory. Alternative pairs can be named using the ''-c'' and ''-r'' command-line options: 
     27 
     28{{{#!bash 
     29python nemo_nml_check.py --help 
     30usage: nemo_nml_check.py [-h] [--cfg [CFGFILE]]  [--ref [REFFILE]] 
     31 
     32Check for consistency between cfg namelists and ref versions e.g.  
     33python nemo_nml_check.py --cfg <cfg namelist> --ref <ref namelist> 
     34 
     35optional arguments: 
     36  -h, --help            show this help message and exit 
     37  --cfg [CFGFILE], -c [CFGFILE]  configuration namelist 
     38  --ref [REFFILE], -r [REFFILE]  reference namelist 
     39}}} 
     40 
     41A typical example of an error found between the default pairing is: 
     42 
     43{{{#!bash 
     44python nemo_nml_check.py 
     45No match for:  rn_rdt  in  namdom  (at line no.  39 ) 
     46}}} 
     47 
     48and a quick check in the ''namelist_ref'' file will confirm that this is because ''rn_rdt'' has been renamed as ''rn_Dt''. 
     49 
     50== Part 2 Constructing a pseudo-reference namelist ==