Skip to content

Commit

Permalink
Merge branch 'fix_issue_417' (PR #419)
Browse files Browse the repository at this point in the history
Look in env_batch for variables not otherwise resolved in
case.get_resolved_value

Also restore dialogue in create_newcase asking what to do if EXEROOT and RUNDIR already
exist.

Test suite: scripts_regression_tests
Test status: bit for bit

Fixes #417

Code review: rljacob
  • Loading branch information
rljacob committed Aug 19, 2016
2 parents da2da68 + 311ce87 commit a5e7531
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions utils/python/CIME/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,24 @@ def get_resolved_value(self, item, recurse=0):
recurse_limit = 10
if (num_unresolved > 0 and recurse < recurse_limit ):
for env_file in self._env_entryid_files:
result = env_file.get_resolved_value(item)
item = result
item = env_file.get_resolved_value(item)
if ("$" not in item):
return item
else:
self.get_resolved_value(item,recurse=recurse+1)
item = self.get_resolved_value(item,recurse=recurse+1)

if(recurse >= recurse_limit):
logging.warning("Not able to fully resolve item '%s'" % item)
#try env_batch first
env_batch = self.get_env("batch")
item = env_batch.get_resolved_value(item)
logger.debug("item is %s, checking env_batch"%item)
if item is not None:
if ("$" not in item):
return item
else:
item = self.get_resolved_value(item,recurse=recurse+1)
else:
logging.warning("Not able to fully resolve item '%s'" % item)

return item

Expand Down Expand Up @@ -514,18 +523,6 @@ def configure(self, compset_name, grid_name, machine_name=None,
machdir = machobj.get_machines_dir()
self.set_value("MACHDIR", machdir)

# Overwriting an existing exeroot or rundir can cause problems
exeroot = self.get_value("EXEROOT")
rundir = self.get_value("RUNDIR")
for wdir in (exeroot, rundir):
if os.path.exists(wdir):
expect(not test, "Directory %s already exists, aborting test"% wdir)
response = raw_input("\nDirectory %s already exists, (r)eplace, (a)bort, or (u)se existing?"% wdir)
if response.startswith("r"):
shutil.rmtree(wdir)
else:
expect(response.startswith("u"), "Aborting by user request")

# the following go into the env_mach_specific file
items = ("module_system", "environment_variables", "mpirun")
env_mach_specific_obj = self.get_env("mach_specific")
Expand Down Expand Up @@ -624,10 +621,6 @@ def configure(self, compset_name, grid_name, machine_name=None,
logger.info(" Grid is: %s " %self._gridname )
logger.info(" Components in compset are: %s " %self._components)

# miscellaneous settings
if self.get_value("RUN_TYPE") == 'hybrid':
self.set_value("GET_REFCASE", True)

# Set project id
if project is None:
project = get_project(machobj)
Expand All @@ -636,6 +629,23 @@ def configure(self, compset_name, grid_name, machine_name=None,
elif machobj.get_value("PROJECT_REQUIRED"):
expect(project is not None, "PROJECT_REQUIRED is true but no project found")

# Overwriting an existing exeroot or rundir can cause problems
exeroot = self.get_value("EXEROOT")
rundir = self.get_value("RUNDIR")
for wdir in (exeroot, rundir):
logging.debug("wdir is %s"%wdir)
if os.path.exists(wdir):
expect(not test, "Directory %s already exists, aborting test"% wdir)
response = raw_input("\nDirectory %s already exists, (r)eplace, (a)bort, or (u)se existing?"% wdir)
if response.startswith("r"):
shutil.rmtree(wdir)
else:
expect(response.startswith("u"), "Aborting by user request")

# miscellaneous settings
if self.get_value("RUN_TYPE") == 'hybrid':
self.set_value("GET_REFCASE", True)

def get_compset_var_settings(self):
compset_obj = Compsets(infile=self.get_value("COMPSETS_SPEC_FILE"))
matches = compset_obj.get_compset_var_settings(self._compsetname, self._gridname)
Expand Down

0 comments on commit a5e7531

Please sign in to comment.