Skip to content

Commit

Permalink
Merge branch 'fv3namelist' into nuopc-cmeps
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdunlapiv committed May 17, 2019
2 parents 1ca2910 + 9102e24 commit 7dd2ade
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions scripts/lib/CIME/namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,32 +1178,34 @@ def _write(self, out_file, groups, format_, sorted_groups):
for group_name in group_names:
if format_ == 'nml':
out_file.write("&{}\n".format(group_name))
group = self._groups[group_name]
for name in sorted(group.keys()):
values = group[name]

# @ is used in a namelist to put the same namelist variable in multiple groups
# in the write phase, all characters in the namelist variable name after
# the @ and including the @ should be removed
if "@" in name:
name = re.sub('@.+$', "", name)

# To prettify things for long lists of values, build strings
# line-by-line.
if values[0] == "True" or values[0] == "False":
values[0] = values[0].replace("True",".true.").replace("False",".false.")
lines = [" {}{} {}".format(name, equals, values[0])]
for value in values[1:]:
if value == "True" or value == "False":
value = value.replace("True",".true.").replace("False",".false.")
if len(lines[-1]) + len(value) <= 77:
lines[-1] += ", " + value
else:
lines[-1] += ",\n"
lines.append(" " + value)
lines[-1] += "\n"
for line in lines:
out_file.write(line)
# allow empty group
if group_name in self._groups:
group = self._groups[group_name]
for name in sorted(group.keys()):
values = group[name]

# @ is used in a namelist to put the same namelist variable in multiple groups
# in the write phase, all characters in the namelist variable name after
# the @ and including the @ should be removed
if "@" in name:
name = re.sub('@.+$', "", name)

# To prettify things for long lists of values, build strings
# line-by-line.
if values[0] == "True" or values[0] == "False":
values[0] = values[0].replace("True",".true.").replace("False",".false.")
lines = [" {}{} {}".format(name, equals, values[0])]
for value in values[1:]:
if value == "True" or value == "False":
value = value.replace("True",".true.").replace("False",".false.")
if len(lines[-1]) + len(value) <= 77:
lines[-1] += ", " + value
else:
lines[-1] += ",\n"
lines.append(" " + value)
lines[-1] += "\n"
for line in lines:
out_file.write(line)
if format_ == 'nml':
out_file.write("/\n")
if format_ == 'nmlcontents':
Expand All @@ -1220,7 +1222,7 @@ def _write_nuopc(self, out_file, groups, sorted_groups, skip_comps):
group_names = groups

for group_name in group_names:
if "_attributes" not in group_name and "nuopc_" not in group_name:
if "_attributes" not in group_name and "nuopc_" not in group_name and "_no_group" not in group_name:
continue
if "_attributes" in group_name:
out_file.write("{}::\n".format(group_name))
Expand Down

0 comments on commit 7dd2ade

Please sign in to comment.