Repository: ESMCI/cime

Issue:
Error trying to create a case with --user-compset
When I try to create a case with `--user-compset` from cime master, I get the following traceback:

```
Traceback (most recent call last):
  File "./create_newcase", line 204, in <module>
    _main_func(__doc__)
  File "./create_newcase", line 187, in _main_func
    run_unsupported=run_unsupported, answer=answer)
  File "/glade/p/work/sacks/cime/scripts/Tools/../../scripts/lib/CIME/case.py", line 745, in configure
    if grid_name in science_support:
TypeError: argument of type 'bool' is not iterable
```

Here is the complete command and output:

```
[yslogin4:/glade/p/work/sacks/cime/scripts]$ ./create_newcase -case test_a_user --user-compset -compset 1850_DATM%NYF_SLND_DICE%SSMI_DOCN%DOM_DROF%NYF_SGLC_SWAV -res f45_g37_rx1 --pesfile ../src/drivers
/mct/cime_config/config_pes.xml
Could not find a compset match for either alias or longname in 1850_DATM%NYF_SLND_DICE%SSMI_DOCN%DOM_DROF%NYF_SGLC_SWAV
Pes setting: grid          is a%4x5_l%null_oi%gx3v7_r%rx1_g%null_w%null_m%gx3v7
Pes setting: compset       is 1850_DATM%NYF_SLND_DICE%SSMI_DOCN%DOM_DROF%NYF_SGLC_SWAV
Pes setting: tasks       is {'NTASKS_ATM': -1, 'NTASKS_ICE': -1, 'NTASKS_CPL': -1, 'NTASKS_LND': -1, 'NTASKS_WAV': -1, 'NTASKS_ROF': -1, 'NTASKS_OCN': -1, 'NTASKS_GLC': -1, 'NTASKS_ESP': -1}
Pes other settings: {'comment': 'none'}
 Compset is: 1850_DATM%NYF_SLND_DICE%SSMI_DOCN%DOM_DROF%NYF_SGLC_SWAV
 Grid is: a%4x5_l%null_oi%gx3v7_r%rx1_g%null_w%null_m%gx3v7
 Components in compset are: ['datm', 'slnd', 'dice', 'docn', 'drof', 'sglc', 'swav', 'sesp', 'cpl', 'dart']
Traceback (most recent call last):
  File "./create_newcase", line 204, in <module>
    _main_func(__doc__)
  File "./create_newcase", line 187, in _main_func
    run_unsupported=run_unsupported, answer=answer)
  File "/glade/p/work/sacks/cime/scripts/Tools/../../scripts/lib/CIME/case.py", line 745, in configure
    if grid_name in science_support:
TypeError: argument of type 'bool' is not iterable
```



Discussion:

Resolving patch:
diff --git a/scripts/lib/CIME/XML/compsets.py b/scripts/lib/CIME/XML/compsets.py
--- a/scripts/lib/CIME/XML/compsets.py
+++ b/scripts/lib/CIME/XML/compsets.py
@@ -38,7 +38,7 @@ def get_compset_match(self, name):
 
                 logger.debug("Found node match with alias: %s and lname: %s" % (alias, lname))
                 return (lname, alias, science_support)
-        return (None, None, False)
+        return (None, None, [False])
 
     def get_compset_var_settings(self, compset, grid):
         '''
@@ -85,4 +85,3 @@ def print_values(self):
         for v in compsets_text.iteritems():
             label, definition = v
             logger.info("   %20s : %s" %(label, definition))
-
diff --git a/scripts/lib/CIME/case.py b/scripts/lib/CIME/case.py
--- a/scripts/lib/CIME/case.py
+++ b/scripts/lib/CIME/case.py
@@ -403,7 +403,7 @@ def _set_compset_and_pesfile(self, compset_name, files, user_compset=False, pesf
         either a longname or an alias.  This will also set the
         compsets and pes specfication files.
         """
-        science_support = {}
+        science_support = []
         compset_alias = None
         components = files.get_components("COMPSETS_SPEC_FILE")
         logger.debug(" Possible components for COMPSETS_SPEC_FILE are %s" % components)
diff --git a/scripts/lib/CIME/utils.py b/scripts/lib/CIME/utils.py
--- a/scripts/lib/CIME/utils.py
+++ b/scripts/lib/CIME/utils.py
@@ -26,7 +26,6 @@ def expect(condition, error_msg, exc_type=SystemExit, error_prefix="ERROR:"):
         if logger.isEnabledFor(logging.DEBUG):
             import pdb
             pdb.set_trace()
-        logger.error("%s %s", error_prefix,error_msg, exc_info=True)
         raise exc_type("%s %s"%(error_prefix,error_msg))
 
 def id_generator(size=6, chars=string.ascii_lowercase + string.digits):


Test patch:
diff --git a/scripts/tests/scripts_regression_tests.py b/scripts/tests/scripts_regression_tests.py
--- a/scripts/tests/scripts_regression_tests.py
+++ b/scripts/tests/scripts_regression_tests.py
@@ -248,13 +248,32 @@ def test_a_createnewcase(self):
             shutil.rmtree(testdir)
 
         cls._testdirs.append(testdir)
-
         run_cmd_assert_result(self, "%s/create_newcase --case %s --compset X --res f19_g16 --output-root %s" % (SCRIPT_DIR, testdir, cls._testroot), from_dir=SCRIPT_DIR)
         run_cmd_assert_result(self, "./case.setup", from_dir=testdir)
         run_cmd_assert_result(self, "./case.build", from_dir=testdir)
 
         cls._do_teardown.append(testdir)
 
+    def test_f_createnewcase_with_user_compset(self):
+        cls = self.__class__
+
+        testdir = os.path.join(cls._testroot, 'testcreatenewcase_with_user_compset')
+        if os.path.exists(testdir):
+            shutil.rmtree(testdir)
+
+        cls._testdirs.append(testdir)
+
+        pesfile = os.path.join("..","src","drivers","mct","cime_config","config_pes.xml")
+        args =  "--case %s --compset 2000_SATM_XLND_SICE_SOCN_XROF_XGLC_SWAV --user-compset --pesfile %s --res f19_g16 --output-root %s" % (testdir, pesfile, cls._testroot)
+        if CIME.utils.get_model() == "cesm":
+            args += " --run-unsupported"
+
+        run_cmd_assert_result(self, "%s/create_newcase %s"%(SCRIPT_DIR, args), from_dir=SCRIPT_DIR)
+        run_cmd_assert_result(self, "./case.setup", from_dir=testdir)
+        run_cmd_assert_result(self, "./case.build", from_dir=testdir)
+
+        cls._do_teardown.append(testdir)
+
     def test_b_user_mods(self):
         cls = self.__class__