-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite ERS test using new infrastructure
Also, minor fix to ERS test: use explicit integer division (//) so that it will work with python3 Test suite: None Test baseline: N/A Test namelist changes: N/A Test status: N/A Fixes: None User interface changes?: No Code review: None
- Loading branch information
Showing
1 changed file
with
44 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
""" | ||
CIME restart test This class inherits from SystemTestsCommon | ||
CIME restart test | ||
""" | ||
from CIME.XML.standard_module_setup import * | ||
from CIME.SystemTests.system_tests_common import SystemTestsCommon | ||
from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
class ERS(SystemTestsCommon): | ||
class ERS(SystemTestsCompareTwo): | ||
|
||
def __init__(self, case): | ||
""" | ||
initialize an object interface to the ERS system test | ||
""" | ||
SystemTestsCommon.__init__(self, case) | ||
SystemTestsCompareTwo.__init__(self, case, | ||
two_builds_for_sharedlib = False, | ||
two_builds_for_model = False, | ||
run_one_suffix = 'base', | ||
run_two_suffix = 'rest', | ||
run_one_description = 'initial run', | ||
run_two_description = 'restart test') | ||
|
||
def _ers_first_phase(self): | ||
stop_n = self._case.get_value("STOP_N") | ||
stop_option = self._case.get_value("STOP_OPTION") | ||
expect(stop_n > 0, "Bad STOP_N: %d" % stop_n) | ||
self._stop_option = self._case.get_value("STOP_OPTION") | ||
self._stop_n = self._case.get_value("STOP_N") | ||
|
||
# Move to config_tests.xml once that's ready | ||
rest_n = stop_n/2 + 1 | ||
self._case.set_value("REST_N", rest_n) | ||
self._case.set_value("REST_OPTION", stop_option) | ||
self._case.set_value("HIST_N", stop_n) | ||
self._case.set_value("HIST_OPTION", stop_option) | ||
self._case.set_value("CONTINUE_RUN", False) | ||
self._case.flush() | ||
# Need stop_n > 2 in order to have at least one time unit both before | ||
# and after restart | ||
expect(self._stop_n > 2, "ERROR: stop_n value %d too short"%self._stop_n) | ||
|
||
self._rest_n = self._get_rest_n() | ||
|
||
def _get_rest_n(self): | ||
""" | ||
Return an int giving rest_n for this test. | ||
Assumes that self._stop_n is already set. | ||
""" | ||
|
||
rest_n = self._stop_n // 2 + 1 | ||
expect(rest_n > 0, "ERROR: stop_n value %d generates rest_n too short: %d" | ||
%(self._stop_n, rest_n)) | ||
return rest_n | ||
|
||
expect(stop_n > 2, "ERROR: stop_n value %d too short"%stop_n) | ||
def _run_common_setup(self): | ||
self._case.set_value("HIST_OPTION", self._stop_option) | ||
self._case.set_value("HIST_N", self._stop_n) | ||
|
||
def _run_one_setup(self): | ||
# We shouldn't need to set STOP_N here, but we make this explicit for | ||
# symmetry with _run_two_setup | ||
self._case.set_value("STOP_N", self._stop_n) | ||
self._case.set_value("CONTINUE_RUN", False) | ||
self._case.set_value("REST_OPTION", self._stop_option) | ||
self._case.set_value("REST_N", self._rest_n) | ||
logger.info("doing an %s %s initial test with restart file at %s %s" | ||
%(str(stop_n), stop_option, str(rest_n), stop_option)) | ||
return SystemTestsCommon.run(self) | ||
|
||
def _ers_second_phase(self): | ||
stop_n = self._case.get_value("STOP_N") | ||
stop_option = self._case.get_value("STOP_OPTION") | ||
|
||
rest_n = stop_n/2 + 1 | ||
stop_new = stop_n - rest_n | ||
expect(stop_new > 0, "ERROR: stop_n value %d too short %d %d"%(stop_new,stop_n,rest_n)) | ||
def _run_two_setup(self): | ||
stop_new = self._stop_n - self._rest_n | ||
expect(stop_new > 0, "ERROR: stop_n value %d too short %d %d" | ||
%(stop_new, self._stop_n, self._rest_n)) | ||
|
||
self._case.set_value("STOP_N", stop_new) | ||
self._case.set_value("CONTINUE_RUN", True) | ||
self._case.set_value("REST_OPTION","never") | ||
self._case.flush() | ||
logger.info("doing an %s %s restart test" | ||
%(str(stop_n), stop_option)) | ||
success = SystemTestsCommon._run(self, "rest") | ||
|
||
# Compare restart file | ||
if success: | ||
return self._component_compare_test("base", "rest") | ||
else: | ||
return False | ||
|
||
def run(self): | ||
success = self._ers_first_phase() | ||
|
||
if success: | ||
return self._ers_second_phase() | ||
else: | ||
return False | ||
|
||
def report(self): | ||
SystemTestsCommon.report(self) |