diff --git a/scripts/lib/CIME/case.py b/scripts/lib/CIME/case.py index f1226ad8abc..0f688baacba 100644 --- a/scripts/lib/CIME/case.py +++ b/scripts/lib/CIME/case.py @@ -1472,10 +1472,11 @@ def create(self, casename, srcroot, compset_name, grid_name, user_mods_dir=None, # Lock env_case.xml lock_file("env_case.xml", self._caseroot) except: - if os.path.exists(self._caseroot) and not logger.isEnabledFor(logging.DEBUG) and not test: - logger.warn("Failed to setup case, removing {}\nUse --debug to force me to keep caseroot".format(self._caseroot)) - shutil.rmtree(self._caseroot) - else: - logger.warn("Leaving broken case dir {}".format(self._caseroot)) + if os.path.exists(self._caseroot): + if not logger.isEnabledFor(logging.DEBUG) and not test: + logger.warn("Failed to setup case, removing {}\nUse --debug to force me to keep caseroot".format(self._caseroot)) + shutil.rmtree(self._caseroot) + else: + logger.warn("Leaving broken case dir {}".format(self._caseroot)) raise