ESCOMP / CAM-SIMA

Community Atmosphere Model - System for Integrated Modeling of the Atmosphere
4 stars 12 forks source link

Trailing comma at end of character namelist entry will throw error #294

Open jimmielin opened 2 months ago

jimmielin commented 2 months ago

What is the feature/what would you like to discuss?

Hi all - not sure if this is intended behavior (couldn't find a closed issue discussing it - sorry if there is!) so I'm posting to see if it's an issue that should be fixed.

In user_nl_cam, for character-type namelist entries (e.g., ncdata), if the entry terminates with a comma, this comma is erroneously considered by the atm_in_paramgen as part of the namelist character entry and complains about mis-matched quotes:

atm_in_paramgen.AtmInParamGenError: Namelist entry 'ncdata' is of type character but its input value:
'/example/path/here',
has mis-matched quotes.  Please fix.

the 'offending' user_nl_cam file would be

ncdata = '/example/path/here',
ncdata_check = /example/path/here'

This is because the mis-matched quotes checker only checks the last character of the input string, regardless of whether there's a value separator (i.e., ,) at the end. The Fortran 90 Standard (https://wg5-fortran.org/N001-N1100/N692.pdf) states, in pertinent part:

A value separator for namelist formatting is the same as for list-directed formatting (10.8). 10.9.1 Namelist input Input for a namelist input statement consists of: ... (4) A sequence of zero or more name-value subsequences separated by value separators, and ...

In section 10.8:

A value separator is one of the following: (1) A comma optionally preceded by one or more contiguous blanks and optionally followed by one or more contiguous blanks, ...

This only affects character-type entries because it's the quotes checker blocking this particular format. Other types (e.g., pver = 32,) will work fine.

Is there anyone in particular you want to be part of this conversation?

No response

Will this change (regression test) answers?

No

Will you be implementing this enhancement yourself?

Yes