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 Version 1 and Version 2 of Developers/NamelistChecker


Ignore:
Timestamp:
2020-06-05T13:32:41+02:00 (4 years ago)
Author:
acc
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Developers/NamelistChecker

    v1 v2  
    1818  * namelists are closed with / appearing as the first non-whitespace on a line 
    1919 
    20 then the attached nemo_nml_check.py script will: 
     20then the attached [[attachment:nemo_nml_check.py]] script will: 
    2121 * read supplied namelist files  
    2222 * construct lists of namelist blocks and their contents (the latter being a list of lists)  
     
    2626By 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: 
    2727 
    28 {{{#!bash 
     28{{{ 
    2929python nemo_nml_check.py --help 
    3030usage: nemo_nml_check.py [-h] [--cfg [CFGFILE]]  [--ref [REFFILE]] 
     
    4141A typical example of an error found between the default pairing is: 
    4242 
    43 {{{#!bash 
     43{{{ 
    4444python nemo_nml_check.py 
    4545No match for:  rn_rdt  in  namdom  (at line no.  39 ) 
     
    4949 
    5050== Part 2 Constructing a pseudo-reference namelist == 
     51 
     52Parsing 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 
     58With 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{{{ 
     61perl 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 
     85Combined with a few lines of bash, this can be used to construct a pseudo-namelist_ref: 
     86 
     87{{{#!bash 
     88for f in `find ./OCE -name '*.[Fh]90'` 
     89do 
     90  echo "! "$f >> pseudo_nml_ref 
     91  perl nemolist_nmls.pl $f >> pseudo_nml_ref 
     92done 
     93}}} 
     94 
     95''(this does assume scanning OCE is sufficient; how about OFF, SAS etc.?)'' 
     96 
     97 
     98