Skip to content

Commit

Permalink
Merge branch 'jgfouca/cime/create_namelists_fix' into master (PR #1406)
Browse files Browse the repository at this point in the history
preview_namelists.create_namelists wasn't re-creating dirs

... and therefore did not handle the case where the user
called case.build --clean-all. For most components, it didn't
matter, but it did for CAM.

Fixes #1390

[BFB]

* jgfouca/cime/create_namelists_fix:
  preview_namelists.create_namelists was re-creating dirs
  • Loading branch information
jgfouca committed Apr 13, 2017
2 parents 9127fc5 + e8422ea commit a536e76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 1 addition & 9 deletions utils/python/CIME/case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,7 @@ def _case_setup_impl(case, caseroot, clean=False, test_mode=False, reset=False):

logger.info("If an old case build already exists, might want to run \'case.build --clean\' before building")

# Create test script if appropriate
# Short term fix to be removed when csh tests are removed
if os.path.exists("env_test.xml"):
if not os.path.exists("case.test"):
logger.info("Starting testcase.setup")
run_cmd_no_fail("./testcase.setup -caseroot %s" % caseroot)
logger.info("Finished testcase.setup")

# Some tests need namelists created here (ERP) - so do this if are in test mode
# Some tests need namelists created here (ERP) - so do this if we are in test mode
if test_mode or get_model() == "acme":
logger.info("Generating component namelists as part of setup")
create_namelists(case)
Expand Down
9 changes: 6 additions & 3 deletions utils/python/CIME/preview_namelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def create_dirs(case):
rundir = case.get_value("RUNDIR")
caseroot = case.get_value("CASEROOT")


docdir = os.path.join(caseroot, "CaseDocs")
dirs_to_make = []
models = case.get_values("COMP_CLASSES")
Expand Down Expand Up @@ -47,6 +46,11 @@ def create_namelists(case):
"""
case.flush()

# Needed in case user did case.build --clean-all
exeroot = case.get_value("EXEROOT")
if not os.path.exists(exeroot):
create_dirs(case)

casebuild = case.get_value("CASEBUILD")
caseroot = case.get_value("CASEROOT")
rundir = case.get_value("RUNDIR")
Expand Down Expand Up @@ -100,8 +104,8 @@ def create_namelists(case):
logger.info(output)
# refresh case xml object from file
case.read_xml()
logger.info("Finished creating component namelists")

logger.info("Finished creating component namelists")

# Save namelists to docdir
if (not os.path.isdir(docdir)):
Expand All @@ -112,7 +116,6 @@ def create_namelists(case):
except (OSError, IOError) as e:
expect(False, "Failed to write %s/README: %s" % (docdir, e))


for cpglob in ["*_in_[0-9]*", "*modelio*", "*_in",
"*streams*txt*", "*stxt", "*maps.rc", "*cism.config*"]:
for file_to_copy in glob.glob(os.path.join(rundir, cpglob)):
Expand Down

0 comments on commit a536e76

Please sign in to comment.