Skip to content

Commit 1e403a8

Browse files
committed
Provide hint in error message if namelist variable invalid due to surrounding quote marks.
1 parent e0b7594 commit 1e403a8

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

cime_config/stream_cdeps.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,30 @@ def create_stream_xml(
315315
),
316316
)
317317
if var_key in valid_values:
318+
319+
# # Handle, e.g., 'bilinear' in namelist instead of bilinear (no quotes)
320+
mod_dict_var_key = mod_dict[var_key]
321+
322+
# Check that key is valid
323+
is_valid = mod_dict_var_key in valid_values[var_key]
324+
msg = "{} can only have values of {} for stream {} in file {}, not {}".format(
325+
var_key,
326+
valid_values[var_key],
327+
stream_name,
328+
user_mods_file,
329+
mod_dict[var_key],
330+
)
331+
if not is_valid:
332+
# Check for surrounding quote marks
333+
has_surrounding_quotes = (
334+
(mod_dict_var_key[0] == mod_dict_var_key[-1] == "'") or
335+
(mod_dict_var_key[0] == mod_dict_var_key[-1] == '"')
336+
)
337+
if has_surrounding_quotes and mod_dict_var_key[1:-1] in valid_values[var_key]:
338+
msg += " (try removing surrounding quotes)"
318339
expect(
319-
mod_dict[var_key] in valid_values[var_key],
320-
"{} can only have values of {} for stream {} in file {}".format(
321-
var_key,
322-
valid_values[var_key],
323-
stream_name,
324-
user_mods_file,
325-
),
340+
is_valid,
341+
msg,
326342
)
327343
stream_vars["stream_" + var_key] = mod_dict[var_key]
328344
if var_key == "datafiles":

0 commit comments

Comments
 (0)