Skip to content

Commit aeb13d7

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

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
@@ -333,14 +333,30 @@ def create_stream_xml(
333333
),
334334
)
335335
if var_key in valid_values:
336+
337+
# # Handle, e.g., 'bilinear' in namelist instead of bilinear (no quotes)
338+
mod_dict_var_key = mod_dict[var_key]
339+
340+
# Check that key is valid
341+
is_valid = mod_dict_var_key in valid_values[var_key]
342+
msg = "{} can only have values of {} for stream {} in file {}, not {}".format(
343+
var_key,
344+
valid_values[var_key],
345+
stream_name,
346+
user_mods_file,
347+
mod_dict[var_key],
348+
)
349+
if not is_valid:
350+
# Check for surrounding quote marks
351+
has_surrounding_quotes = (
352+
(mod_dict_var_key[0] == mod_dict_var_key[-1] == "'") or
353+
(mod_dict_var_key[0] == mod_dict_var_key[-1] == '"')
354+
)
355+
if has_surrounding_quotes and mod_dict_var_key[1:-1] in valid_values[var_key]:
356+
msg += " (try removing surrounding quotes)"
336357
expect(
337-
mod_dict[var_key] in valid_values[var_key],
338-
"{} can only have values of {} for stream {} in file {}".format(
339-
var_key,
340-
valid_values[var_key],
341-
stream_name,
342-
user_mods_file,
343-
),
358+
is_valid,
359+
msg,
344360
)
345361
stream_vars["stream_" + var_key] = mod_dict[var_key]
346362
if var_key == "datafiles":

0 commit comments

Comments
 (0)