Skip to content

Commit

Permalink
Merge pull request #880 from jedwards4b/buildnml_fix
Browse files Browse the repository at this point in the history
Buildnml fix

If buildnml is in perl a SyntaxError exception will be raised when you try to load it
as a module, trap and use run_cmd instead. On the other hand if a SyntaxError is
raised and the code is python raise that error.

Test suite:
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes [CIME Github issue #]

User interface changes?:

Code review:
  • Loading branch information
jgfouca authored Dec 2, 2016
2 parents fce75f0 + 08cecc5 commit 3c8ceaa
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions utils/python/CIME/preview_namelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ def create_namelists(case):
compname = "drv"
else:
compname = case.get_value("COMP_%s" % model_str.upper())
cmd = os.path.join(config_dir, "buildnml")
try:
mod = imp.load_source("buildnml",
os.path.join(config_dir, "buildnml"))
mod = imp.load_source("buildnml", cmd)
logger.info("Calling %s buildnml"%compname)
mod.buildnml(case, caseroot, compname)

except SyntaxError as detail:
with open(cmd, 'r') as f:
first_line = f.readline()
if 'python' in first_line:
expect(False, detail)
else:
run_cmd_no_fail("%s %s" % (cmd, caseroot), verbose=True)
except AttributeError:
cmd = os.path.join(config_dir, "buildnml")
run_cmd_no_fail("%s %s" % (cmd, caseroot), verbose=True)
except:
raise
Expand Down

0 comments on commit 3c8ceaa

Please sign in to comment.