Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cime_config/atm_in_paramgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def _get_nml_value_str(var_name, var_type, var_val):
'"apple"'

8. Check that a character variable with a quotation mark
innternal to the string outputs the correct value:
internal to the string outputs the correct value:
>>> _get_nml_value_str("banana", "char*31", ''' "app'le" ''')
'"app\\'le"'

Expand All @@ -731,6 +731,16 @@ def _get_nml_value_str(var_name, var_type, var_val):
...
atm_in_paramgen.AtmInParamGenError: Namelist type 'apple' for entry 'banana' is un-recognized.
Acceptable namelist types are: logical, integer, real, or char*N.

10. Check that a character variable with a trailing comma outputs
the correct value:
>>> _get_nml_value_str("ncdata", "char*250", "'/path/to/file',")
"'/path/to/file'"

11. Check that a character variable with quotes and trailing comma
outputs the correct value:
>>> _get_nml_value_str("ncdata", "char*250", " '/path/to/file', ")
"'/path/to/file'"
"""

#Create set for variable types
Expand Down Expand Up @@ -762,6 +772,10 @@ def _get_nml_value_str(var_name, var_type, var_val):
#Remove extra white space:
var_val_strip = var_val.strip()

#Remove trailing comma if present (valid Fortran namelist separator. F90 10.9.1(4); 10.8(1))
if var_val_strip.endswith(','):
var_val_strip = var_val_strip[:-1].strip()

#Check if string is wrapped in quotes:
quoted_flag = _check_string_quotes(var_name, var_val_strip)

Expand Down