Repository: ESMCI/cime

Issue:
PROJECT not resolving on blues during create_newcase
Using the latest master (212b185f239) I'm getting the following error on Blues:

blogin1[45]: ./create_newcase --case tryX --compset X --res f19_g16 --project ACME 
Compset longname is 2000_XATM_XLND_XICE_XOCN_XROF_XGLC_XWAV 
Compset specification file is /lcrc/group/earthscience/jacob/cimeESMCI2/scripts/Tools/../../driver_cpl/cime_config/config_compsets.xml
Pes     specification file is /lcrc/group/earthscience/jacob/cimeESMCI2/scripts/Tools/../../cime_config/acme/allactive/config_pesall.xml
Not able to fully resolve item '/lcrc/project/$PROJECT/jacob/acme_scratch/tryX/bld'
Not able to fully resolve item '/lcrc/project/$PROJECT/jacob/acme_scratch/tryX/run'

$PROJECT DOES get set in env_batch.xml



Discussion:
On further investigation, the "bld" and "run" directories are quietly (no message to stdout) created by case.setup. Should create_newcase or case.setup make those?

@jedwards4b  said "case.setup".  Then what is create_newcase trying to do with those paths?

create_newcase is looking to see if they exist and warning the user if they do.   I'm looking into why this doesn't resolve now.

I think that cime is working fine on blues with the exception of printing this warning in create_newcase.  


Resolving patch:
diff --git a/utils/python/CIME/case.py b/utils/python/CIME/case.py
--- a/utils/python/CIME/case.py
+++ b/utils/python/CIME/case.py
@@ -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
 
@@ -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")
@@ -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)
@@ -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)


Test patch: