Skip to content

Commit

Permalink
Merge pull request #4558 from ESMCI/jgfouca/fix_env_mach_spec_del_env
Browse files Browse the repository at this point in the history
Fix .env_mach_specific.sh when unsetting env

When an env var value is None, this tells CIME to unset the environment. This use case was not being handled in the creation of .env_mach_specific.sh.

Test suite: by-hand
Test baseline:
Test namelist changes:
Test status: [bit for bit, roundoff, climate changing]

Fixes [CIME Github issue #]

User interface changes?:

Update gh-pages html (Y/N)?:
  • Loading branch information
jgfouca authored Jan 4, 2024
2 parents 14fd58b + 3a4dcdc commit 9dd4fe5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions CIME/XML/env_mach_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,25 @@ def make_env_mach_specific_file(self, shell, case, output_dir=""):
if env_value.startswith("sh"):
lines.append("{}".format(env_name))
else:
lines.append("export {}={}".format(env_name, env_value))
if env_value is None:
lines.append("unset {}".format(env_name))
else:
lines.append("export {}={}".format(env_name, env_value))

elif shell == "csh":
if env_name == "source":
if env_value.startswith("csh"):
lines.append("{}".format(env_name))
else:
lines.append("setenv {} {}".format(env_name, env_value))
if env_value is None:
lines.append("unsetenv {}".format(env_name))
else:
lines.append("setenv {} {}".format(env_name, env_value))
else:
expect(False, "Unknown shell type: '{}'".format(shell))

with open(os.path.join(output_dir, filename), "w") as fd:
fd.write("\n".join(lines))
fd.write("\n".join(lines) + "\n")

# Private API

Expand Down

0 comments on commit 9dd4fe5

Please sign in to comment.