-
Notifications
You must be signed in to change notification settings - Fork 56
Description
I am using f90nml to pull namelists out of a model log file.
A description and context are available here:
TL;DR the (MOM5) stdout contains the following text:
&OCEAN_SHORTWAVE_GFDL_NML
USE_THIS_MODULE = T,
READ_CHL = T,
CHL_DEFAULT = 8.000000000000000E-002,
ZMAX_PEN = 1000000.00000000 ,
SW_FRAC_TOP = 0.000000000000000E+000,
DEBUG_THIS_MODULE = F,
ENFORCE_SW_FRAC = T,
OVERRIDE_F_VIS = T,
SW_MOREL_FIXED_DEPTHS = F,
OPTICS_FOR_UNIFORM_CHL = F,
OPTICS_MOREL_ANTOINE = F,
OPTICS_MANIZZA = T
/
NOTE from PE 0: ==>Note: USING shortwave_gfdl_mod.
=>Note: Using shortwave penetration with GFDL formulaton & Manizza etal optics.
NOTE from PE 0: ==>Note: Reading in chlorophyll-a from data file for shortwave penetration.
=>Note: computing solar shortwave penetration. Assume stf has sw-radiation field
included. Hence, solar shortwave penetration effects placed in sw_source will
subtract out the effects of shortwave at k=1 to avoid double-counting.
==>Note: Setting optical model coefficients assuming nonuniform chl distribution.
&OCEAN_SPONGES_TRACER_NML
USE_THIS_MODULE = F,
DAMP_COEFF_3D = F
/
The parser interprets the & in the purely descriptive middle paragraph as the start of a namelist and parses the rest of the text like so:
Details
manizza:
':': null
'=':
- '>'
- Note
- ':'
- Setting
- optical
- model
- coefficients
- assuming
- nonuniform
- chl
- distribution.
penetration.:
- '>'
- Note
- ':'
- computing
- solar
- shortwave
- penetration.
- Assume
- stf
- has
- sw-radiation
- field
- included.
- Hence
- solar
- shortwave
- penetration
- effects
- placed
- in
- sw_source
- will
- subtract
- out
- the
- effects
- of
- shortwave
- at
k:
- 1
- to
- avoid
double-counting.: null
I know this is a tough ask, and not exactly a well supported use-case, but I'd really like it if I could ask the parser to be more strict. The paragraph it had interpreted as a namelist group doesn't have a closing \ for example.
Would it be possible, or desirable, to have a --strict mode, or similar, that required what I would describe as "well-formed" namelists, e.g. start of a group is an & which is the first character on a line, preceded only by whitespace? Similar for the end of a namelist group and \.