Changes between Version 1 and Version 2 of Developers/NamelistChecker
- Timestamp:
- 2020-06-05T13:32:41+02:00 (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Developers/NamelistChecker
v1 v2 18 18 * namelists are closed with / appearing as the first non-whitespace on a line 19 19 20 then the attached nemo_nml_check.pyscript will:20 then the attached [[attachment:nemo_nml_check.py]] script will: 21 21 * read supplied namelist files 22 22 * construct lists of namelist blocks and their contents (the latter being a list of lists) … … 26 26 By 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 27 28 {{{ #!bash28 {{{ 29 29 python nemo_nml_check.py --help 30 30 usage: nemo_nml_check.py [-h] [--cfg [CFGFILE]] [--ref [REFFILE]] … … 41 41 A typical example of an error found between the default pairing is: 42 42 43 {{{ #!bash43 {{{ 44 44 python nemo_nml_check.py 45 45 No match for: rn_rdt in namdom (at line no. 39 ) … … 49 49 50 50 == Part 2 Constructing a pseudo-reference namelist == 51 52 Parsing the source code to extract information to build a pseudo reference namelist is simpler if we assume adherence to some coding conventions: 53 54 * The namelist opening declaration: ''namelist / name_of_namelist /'' occurs on one line 55 * The ''name_of_namelist'' string contains only alphanumeric characters and underscores 56 * subsequent continuation lines have a leading ampersand and a trailing ampersand is placed on the preceding line (comments are allowed after the trailing ampersand) 57 58 With these (seemingly safe) assumptions the attached Perl script: nemo_list_nmls.pl can be used to extract namelist templates from the source. For example: 59 60 {{{ 61 perl nemo_list_nmls.pl OCE/nemogcm.F90 62 &namctl 63 ln_ctl = 64 sn_cfctl = 65 nn_print = 66 nn_ictls = 67 nn_ictle = 68 nn_isplt = 69 nn_jsplt = 70 nn_jctls = 71 nn_jctle = 72 ln_timing = 73 ln_diacfl = 74 / 75 &namcfg 76 ln_read_cfg = 77 cn_domcfg = 78 ln_closea = 79 ln_write_cfg = 80 cn_domcfg_out = 81 ln_use_jattr = 82 / 83 }}} 84 85 Combined with a few lines of bash, this can be used to construct a pseudo-namelist_ref: 86 87 {{{#!bash 88 for f in `find ./OCE -name '*.[Fh]90'` 89 do 90 echo "! "$f >> pseudo_nml_ref 91 perl nemolist_nmls.pl $f >> pseudo_nml_ref 92 done 93 }}} 94 95 ''(this does assume scanning OCE is sufficient; how about OFF, SAS etc.?)'' 96 97 98