Skip to content

Commit

Permalink
Merge pull request #1350 from gold2718/pausePOP
Browse files Browse the repository at this point in the history
Fixes for PRE test
  • Loading branch information
jedwards4b authored Apr 17, 2017
2 parents 9f9da67 + 1d39746 commit 9903472
Show file tree
Hide file tree
Showing 19 changed files with 799 additions and 586 deletions.
2 changes: 2 additions & 0 deletions config/config_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ LAR long term archive test
DAE data assimilation test: non answer changing
PRE pause-resume test: by default a BFB test of pause-resume cycling
======================================================================
Other component-specific tests
======================================================================
Expand Down
6 changes: 5 additions & 1 deletion scripts/lib/CIME/SystemTests/nck.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def _case_one_setup(self):

def _case_two_setup(self):
for comp in self._comp_classes:
self._case.set_value("NINST_%s"%comp, 2)
if (comp == "ESP"):
self._case.set_value("NINST_%s"%comp, 1)
else:
self._case.set_value("NINST_%s"%comp, 2)

ntasks = self._case.get_value("NTASKS_%s"%comp)
self._case.set_value("NTASKS_%s"%comp, ntasks*2)

Expand Down
71 changes: 40 additions & 31 deletions scripts/lib/CIME/SystemTests/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Implementation of the CIME pause/resume test: Tests having driver
'pause' (write cpl restart file) and 'resume' (read cpl restart file)
without changing restart file. Compare to non-pause/resume run.
Test can also be run with other component combinations.
"""

Expand All @@ -19,8 +20,9 @@ class PRE(SystemTestsCompareTwo):
###############################################################################
"""
Implementation of the CIME pause/resume test: Tests having driver
'pause' (write cpl restart file) and 'resume' (read cpl restart file)
without changing restart file. Compare to non-pause/resume run.
'pause' (write cpl and/or other restart file(s)) and 'resume'
(read cpl and/or other restart file(s)) without changing restart
file. Compare to non-pause/resume run.
"""

###########################################################################
Expand All @@ -31,26 +33,35 @@ def __init__(self, case):
run_two_suffix='pr',
run_one_description='no pause/resume',
run_two_description='pause/resume')
self._stopopt = ''
self._stopn = 0

###########################################################################
def _case_one_setup(self):
###########################################################################
case_setup(self._case, test_mode=True, reset=True)
self._stopopt = self._case.get_value("STOP_OPTION")
self._stopn = self._case.get_value("STOP_N")

###########################################################################
def _case_two_setup(self):
###########################################################################
# Set up a pause/resume run
stopopt = self._case.get_value("STOP_OPTION")
stopn = self._case.get_value("STOP_N")
expect((stopn % 5) == 0, "ERROR: PRE test requires that STOP_N be divisible by five")
pausen = stopn / 5
expect(pausen > 0, "ERROR: pause_n (%d) must be > 0, stop_n is %d"%(pausen, stopn))
self._case.set_value("PAUSE_OPTION", stopopt)
self._case.set_value("STOP_OPTION", self._stopopt)
self._case.set_value("STOP_N", self._stopn)
self._case.set_value("ESP_RUN_ON_PAUSE", "TRUE")
if self._stopn > 3:
pausen = 2
else:
pausen = 1
# End if

self._case.set_value("PAUSE_OPTION", self._stopopt)
self._case.set_value("PAUSE_N", pausen)
comps = [ x.lower() for x in self._case.get_values("COMP_CLASSES") ]
pcl = self._case.get_value("PAUSE_COMPONENT_LIST")
expect(pcl == "cpl",
"ERROR: PRE test expected PAUSE_COMPONENT_LIST = 'cpl', found '%s'"%pcl)
expect(pcl == "all" or set(pcl.split(':')).issubset(comps),
"PRE ERROR: Invalid PAUSE_COMPONENT_LIST, '%s'"%pcl)

self._case.flush()

Expand All @@ -65,37 +76,35 @@ def run_phase(self):
self._activate_case2()
rundir2 = self._case.get_value("RUNDIR")
should_match = (self._case.get_value("DESP_MODE") == "NOCHANGE")
compare_ok = True
pause_comps = self._case.get_value("PAUSE_COMPONENT_LIST")
expect((pause_comps != 'none'), "Pause/Resume (PRE) test has no pause components")
if pause_comps == 'all':
pause_comps = self._case.get_values("COMP_CLASSES")
else:
pause_comps = pause_comps.split(':')
# End if

for comp in pause_comps:
restart_files_1 = glob.glob(os.path.join(rundir1, '*.%s.r.*'%comp))
if len(restart_files_1) != 1:
logger.error("Wrong number of case1 %s restart files, %d", comp, len(restart_files_1))
# End if
restart_files_2 = glob.glob(os.path.join(rundir2, '*.%s.r.*'%comp))
if len(restart_files_2) != 5:
logger.error("Wrong number of case2 %s restart files, %d", comp, len(restart_files_2))
# End if
comp_name = self._case.get_value('COMP_%s'%comp.upper())
rname = '*.%s.r.*'%comp_name
restart_files_1 = glob.glob(os.path.join(rundir1, rname))
expect((len(restart_files_1) > 0), "No case1 restart files for %s"%comp)
restart_files_2 = glob.glob(os.path.join(rundir2, rname))
expect((len(restart_files_2) > len(restart_files_1)),
"No pause (restart) files found in case2 for %s"%comp)
# Do cprnc of restart files.
rfile1 = restart_files_1[0]
rfile1 = restart_files_1[len(restart_files_1) - 1]
# rfile2 has to match rfile1 (same time string)
parts = os.path.basename(rfile1).split(".")
glob_str = "*.%s"%".".join(parts[len(parts)-4:])
restart_files_2 = glob.glob(os.path.join(rundir2, glob_str))
if len(restart_files_2) < 1:
logger.error("Missing case2 restart file, %s", glob_str)
# End if
if len(restart_files_2) > 1:
logger.error("Multiple case2 restart files, %s", glob_str)
# End if
expect((len(restart_files_2) == 1),
"Missing case2 restart file, %s", glob_str)
rfile2 = restart_files_2[0]
ok, out = cprnc(comp, rfile1, rfile2, self._case, rundir2)
logger.warning("CPRNC result: %s, file = %s"%(ok, out))
expect((should_match == ok),
"%s restart files%s match"%(comp, " do not" if should_match else ""))
# End for
ok, out = cprnc(comp, rfile1, rfile2, self._case, rundir2) # pylint: disable=unused-variable
logger.warning("CPRNC result for %s: %s"%(os.path.basename(rfile1), "PASS" if (ok == should_match) else "FAIL"))
compare_ok = compare_ok and (should_match == ok)

expect(compare_ok,
"Not all restart files %s"%("matched" if should_match else "failed to match"))

7 changes: 6 additions & 1 deletion scripts/lib/CIME/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,12 @@ def configure(self, compset_name, grid_name, machine_name=None,
if compclass == "CPL":
continue
key = "NINST_%s"%compclass
mach_pes_obj.set_value(key, ninst)
# ESP models are currently limited to 1 instance
if compclass == "ESP":
mach_pes_obj.set_value(key, 1)
else:
mach_pes_obj.set_value(key, ninst)

key = "NTASKS_%s"%compclass
if key not in pes_ntasks.keys():
mach_pes_obj.set_value(key,1)
Expand Down
3 changes: 3 additions & 0 deletions scripts/lib/CIME/case_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _case_setup_impl(case, caseroot, clean=False, test_mode=False, reset=False,
continue
ninst = case.get_value("NINST_%s" % comp)
ntasks = case.get_value("NTASKS_%s" % comp)
# ESP models are currently limited to 1 instance
expect((comp != "ESP") or (ninst == 1),
"ESP components may only have one instance")
if ninst > ntasks:
if ntasks == 1:
case.set_value("NTASKS_%s" % comp, ninst)
Expand Down
19 changes: 19 additions & 0 deletions scripts/lib/CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,25 @@ def convert_to_babylonian_time(seconds):

return "%02d:%02d:%02d" % (hours, minutes, seconds)

def get_time_in_seconds(timeval, unit):
"""
Convert a time from 'unit' to seconds
"""
if 'nyear' in unit:
dmult = 365 * 24 * 3600
elif 'nmonth' in unit:
dmult = 30 * 24 * 3600
elif 'nday' in unit:
dmult = 24 * 3600
elif 'nhour' in unit:
dmult = 3600
elif 'nminute' in unit:
dmult = 60
else:
dmult = 1

return dmult * timeval

def compute_total_time(job_cost_map, proc_pool):
"""
Given a map: jobname -> (procs, est-time), return a total time
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/update_acme_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"ERP.f45_g37_rx1.A",
"SMS_D_Ln9.f19_g16_rx1.A",
"DAE.f19_f19.A",
"SMS.T42_T42.S")
# "PRE.f19_f19.ADESP")
"SMS.T42_T42.S",
"PRE.f45_g37_rx1.ADESP")
),

#
Expand Down
Loading

0 comments on commit 9903472

Please sign in to comment.