Пример #1
0
Файл: dae.py Проект: Katetc/cime
 def __init__(self, case):
 ###########################################################################
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds=False,
                                    run_two_suffix='da',
                                    run_one_description='no data assimilation',
                                    run_two_description='data assimilation')
Пример #2
0
Файл: nck.py Проект: Katetc/cime
 def __init__(self, case):
     self._comp_classes = []
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = True,
                                    run_two_suffix = 'multiinst',
                                    run_one_description = 'one instance',
                                    run_two_description = 'two instances')
Пример #3
0
    def run_phase(self):
        ###########################################################################
        # Clean up any da.log files in case this is a re-run.
        self._activate_case2()
        case_root = self._get_caseroot2()
        rundir2 = self._case.get_value("RUNDIR")
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        for file_ in da_files:
            os.remove(file_)
        # End for

        # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run.
        self._case.set_value("CONTINUE_RUN", False)
        # Start normal run here
        self._activate_case1()
        SystemTestsCompareTwo.run_phase(self)

        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        if da_files is None:
            logger = logging.getLogger(__name__)
            logger.warning("No DA files in %s",
                           os.path.join(case_root, 'da.log.*'))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect(
            (da_files is not None) and (len(da_files) == da_cycles),
            "ERROR: There were %d DA cycles in run but %d DA files were found"
            % (da_cycles, len(da_files) if da_files is not None else 0))
        da_files.sort()
        cycle_num = 0
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            with open(fname) as dfile:
                for line in dfile:
                    expect(line[0:5] != 'ERROR',
                           "ERROR, error line found in %s" % fname)
                    if line[0:8] == 'caseroot':
                        found_caseroot = True
                    elif line[0:5] == 'cycle':
                        found_cycle = True
                        expect(
                            int(line[7:]) == cycle_num,
                            "ERROR: Wrong cycle (%d) found in %s (expected %d)"
                            % (int(line[7:]), fname, cycle_num))
                    else:
                        expect(
                            False,
                            "ERROR: Unrecognized line ('%s') found in %s" %
                            (line, fname))

                # End of for loop
                expect(found_caseroot,
                       "ERROR: No caseroot found in %s" % fname)
                expect(found_cycle, "ERROR: No cycle found in %s" % fname)
            # End of with
            cycle_num = cycle_num + 1
Пример #4
0
 def __init__(self, case):
     self._comp_classes = []
     self._test_instances = 3
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = True,
                                    run_two_suffix = 'single_instance',
                                    run_two_description = 'single instance',
                                    run_one_description = 'multi driver')
    def __init__(self,
                 case1,
                 run_one_suffix = 'base',
                 run_two_suffix = 'test',
                 case2setup_raises_exception = False,
                 run_one_should_pass = True,
                 run_two_should_pass = True):
        """
        Initialize a SystemTestsCompareTwoFake object

        The core test phases prior to RUN_PHASE are set to TEST_PASS_STATUS;
        RUN_PHASE is left unset (as is any later phase)

        Args:
            case1 (CaseFake): existing case
            run_one_suffix (str, optional): Suffix used for first run. Defaults
                to 'base'. Currently MUST be 'base'.
            run_two_suffix (str, optional): Suffix used for the second run. Defaults to 'test'.
            case2setup_raises_exception (bool, optional): If True, then the call
                to _case_two_setup will raise an exception. Default is False.
            run_one_should_pass (bool, optional): Whether the run_indv method should
                pass for the first run. Default is True, meaning it will pass.
            run_two_should_pass (bool, optional): Whether the run_indv method should
                pass for the second run. Default is True, meaning it will pass.
        """

        self._case2setup_raises_exception = case2setup_raises_exception

        # NOTE(wjs, 2016-08-03) Currently, due to limitations in the test
        # infrastructure, run_one_suffix MUST be 'base'. However, I'm keeping it
        # as an explicit argument to the constructor so that it's easy to relax
        # this requirement later: To relax this assumption, remove the following
        # assertion and add run_one_suffix as an argument to
        # SystemTestsCompareTwo.__init__
        assert(run_one_suffix == 'base')

        SystemTestsCompareTwo.__init__(
            self,
            case1,
            separate_builds = False,
            run_two_suffix = run_two_suffix)

        # Need to tell test status that all phases prior to the run phase have
        # passed, since this is checked in the run call (at least for the build
        # phase status)
        with self._test_status:
            for phase in test_status.CORE_PHASES:
                if phase == test_status.RUN_PHASE:
                    break
                self._test_status.set_status(phase, test_status.TEST_PASS_STATUS)

        self.run_pass_casenames = []
        if run_one_should_pass:
            self.run_pass_casenames.append(self._case1.get_value('CASE'))
        if run_two_should_pass:
            self.run_pass_casenames.append(self._case2.get_value('CASE'))

        self.log = []
Пример #6
0
    def __init__(self,
                 case1,
                 run_one_suffix='base',
                 run_two_suffix='test',
                 case2setup_raises_exception=False,
                 run_one_should_pass=True,
                 run_two_should_pass=True):
        """
        Initialize a SystemTestsCompareTwoFake object

        The core test phases prior to RUN_PHASE are set to TEST_PASS_STATUS;
        RUN_PHASE is left unset (as is any later phase)

        Args:
            case1 (CaseFake): existing case
            run_one_suffix (str, optional): Suffix used for first run. Defaults
                to 'base'. Currently MUST be 'base'.
            run_two_suffix (str, optional): Suffix used for the second run. Defaults to 'test'.
            case2setup_raises_exception (bool, optional): If True, then the call
                to _case_two_setup will raise an exception. Default is False.
            run_one_should_pass (bool, optional): Whether the run_indv method should
                pass for the first run. Default is True, meaning it will pass.
            run_two_should_pass (bool, optional): Whether the run_indv method should
                pass for the second run. Default is True, meaning it will pass.
        """

        self._case2setup_raises_exception = case2setup_raises_exception

        # NOTE(wjs, 2016-08-03) Currently, due to limitations in the test
        # infrastructure, run_one_suffix MUST be 'base'. However, I'm keeping it
        # as an explicit argument to the constructor so that it's easy to relax
        # this requirement later: To relax this assumption, remove the following
        # assertion and add run_one_suffix as an argument to
        # SystemTestsCompareTwo.__init__
        assert (run_one_suffix == 'base')

        SystemTestsCompareTwo.__init__(self,
                                       case1,
                                       separate_builds=False,
                                       run_two_suffix=run_two_suffix)

        # Need to tell test status that all phases prior to the run phase have
        # passed, since this is checked in the run call (at least for the build
        # phase status)
        with self._test_status:
            for phase in test_status.CORE_PHASES:
                if phase == test_status.RUN_PHASE:
                    break
                self._test_status.set_status(phase,
                                             test_status.TEST_PASS_STATUS)

        self.run_pass_casenames = []
        if run_one_should_pass:
            self.run_pass_casenames.append(self._case1.get_value('CASE'))
        if run_two_should_pass:
            self.run_pass_casenames.append(self._case2.get_value('CASE'))

        self.log = []
Пример #7
0
    def run_phase(self):  # pylint: disable=arguments-differ
        ###########################################################################
        self._activate_case2()
        should_match = (self._case.get_value("DESP_MODE") == "NOCHANGE")
        SystemTestsCompareTwo.run_phase(self, success_change=not should_match)
        # Look for expected coupler restart files
        logger = logging.getLogger(__name__)
        self._activate_case1()
        rundir1 = self._case.get_value("RUNDIR")
        self._activate_case2()
        rundir2 = self._case.get_value("RUNDIR")
        compare_ok = True
        multi_driver = self._case.get_value("MULTI_DRIVER")
        comps = self._case.get_values("COMP_CLASSES")
        for comp in comps:
            if not self._case.get_value("PAUSE_ACTIVE_{}".format(comp)):
                continue
            if comp == "CPL":
                if multi_driver:
                    ninst = self._case.get_value("NINST_MAX")
                else:
                    ninst = 1
            else:
                ninst = self._case.get_value("NINST_{}".format(comp))

            comp_name = self._case.get_value('COMP_{}'.format(comp))
            for index in range(1, ninst + 1):
                if ninst == 1:
                    rname = '*.{}.r.*'.format(comp_name)
                else:
                    rname = '*.{}_{:04d}.r.*'.format(comp_name, index)

                restart_files_1 = glob.glob(os.path.join(rundir1, rname))
                expect((len(restart_files_1) > 0),
                       "No case1 restart files for {}".format(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 {}".format(
                           comp))
                # Do cprnc of restart files.
                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 = "*.{}".format(".".join(parts[len(parts) - 4:]))
                restart_files_2 = glob.glob(os.path.join(rundir2, glob_str))
                expect((len(restart_files_2) == 1),
                       "Missing case2 restart file, {}", glob_str)
                rfile2 = restart_files_2[0]
                ok = cprnc(comp, rfile1, rfile2, self._case, rundir2)[0]
                logger.warning("CPRNC result for {}: {}".format(
                    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 {}".format(
                "matched" if should_match else "failed to match"))
Пример #8
0
    def __init__(self,
                 case1,
                 run_two_suffix = 'test'):

        SystemTestsCompareTwo.__init__(
            self,
            case1,
            separate_builds = False,
            run_two_suffix = run_two_suffix)
Пример #9
0
 def __init__(self, case):
     """
     initialize an NCR test
     """
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = True,
                                    run_two_suffix = "singleinst",
                                    run_one_description = "two instances, each with the same number of tasks",
                                    run_two_description = "default build")
Пример #10
0
    def run_phase(self): # pylint: disable=arguments-differ
    ###########################################################################
        self._activate_case2()
        should_match = (self._case.get_value("DESP_MODE") == "NOCHANGE")
        SystemTestsCompareTwo.run_phase(self, success_change=not should_match)
        # Look for expected coupler restart files
        logger = logging.getLogger(__name__)
        self._activate_case1()
        rundir1 = self._case.get_value("RUNDIR")
        self._activate_case2()
        rundir2 = self._case.get_value("RUNDIR")
        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(':')

        multi_driver = self._case.get_value("MULTI_DRIVER")

        for comp in pause_comps:
            if comp == "cpl":
                if multi_driver:
                    ninst = self._case.get_value("NINST_MAX")
                else:
                    ninst = 1
            else:
                ninst = self._case.get_value("NINST_{}".format(comp.upper()))

            comp_name = self._case.get_value('COMP_{}'.format(comp.upper()))
            for index in range(1,ninst+1):
                if ninst == 1:
                    rname = '*.{}.r.*'.format(comp_name)
                else:
                    rname = '*.{}_{:04d}.r.*'.format(comp_name, index)

                restart_files_1 = glob.glob(os.path.join(rundir1, rname))
                expect((len(restart_files_1) > 0), "No case1 restart files for {}".format(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 {}".format(comp))
                # Do cprnc of restart files.
                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 = "*.{}".format(".".join(parts[len(parts)-4:]))
                restart_files_2 = glob.glob(os.path.join(rundir2, glob_str))
                expect((len(restart_files_2) == 1),
                       "Missing case2 restart file, {}", glob_str)
                rfile2 = restart_files_2[0]
                ok = cprnc(comp, rfile1, rfile2, self._case, rundir2)[0]
                logger.warning("CPRNC result for {}: {}".format(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 {}".format("matched" if should_match else "failed to match"))
Пример #11
0
 def __init__(self, case):
     """
     initialize a test object
     """
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = False,
                                    run_two_suffix = 'single_thread',
                                    run_one_description = 'default threading',
                                    run_two_description = 'threads set to 1')
Пример #12
0
 def __init__(self, case):
 ###########################################################################
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds=False,
                                    run_two_suffix='pr',
                                    run_one_description='no pause/resume',
                                    run_two_description='pause/resume')
     self._stopopt  = ''
     self._stopn    = 0
Пример #13
0
 def __init__(self, case):
     """
     initialize an object interface to file env_test.xml in the case directory
     """
     SystemTestsCompareTwo.__init__(self,
                                    case,
                                    separate_builds=True,
                                    run_two_suffix="seq",
                                    run_one_description = "base",
                                    run_two_description = "sequence")
Пример #14
0
    def run_phase(self): # pylint: disable=arguments-differ
    ###########################################################################
        # Clean up any da.log files in case this is a re-run.
        self._activate_case2()
        case_root = self._get_caseroot2()
        rundir2 = self._case.get_value("RUNDIR")
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        for file_ in da_files:
            os.remove(file_)
        # End for

        # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run.
        self._case.set_value("CONTINUE_RUN", False)
        # Start normal run here
        self._activate_case1()
        SystemTestsCompareTwo.run_phase(self)

        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        if da_files is None:
            logger = logging.getLogger(__name__)
            path = os.path.join(case_root, 'da.log.*')
            logger.warning("No DA files in {}".format(path))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect((da_files is not None) and (len(da_files) == da_cycles),
               "ERROR: There were {:d} DA cycles in run but {:d} DA files were found".format(da_cycles, len(da_files) if da_files is not None else 0))
        da_files.sort()
        cycle_num = 0
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            with open(fname) as dfile:
                for line in dfile:
                    expect(line[0:5] != 'ERROR', "ERROR, error line found in {}".format(fname))
                    if line[0:8] == 'caseroot':
                        found_caseroot = True
                    elif line[0:5] == 'cycle':
                        found_cycle = True
                        expect(int(line[7:]) == cycle_num,
                               "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})".format(int(line[7:]), fname, cycle_num))
                    else:
                        expect(False, "ERROR: Unrecognized line ('{}') found in {}".format(line, fname))

                # End of for loop
                expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname))
                expect(found_cycle, "ERROR: No cycle found in {}".format(fname))
            # End of with
            cycle_num = cycle_num + 1
Пример #15
0
    def run_phase(self):
        ###########################################################################
        SystemTestsCompareTwo.run_phase(self)
        # Look for expected coupler restart files
        logger = logging.getLogger(__name__)
        self._activate_case1()
        rundir1 = self._case.get_value("RUNDIR")
        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(':')

        for comp in pause_comps:
            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[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))
            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)  # 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"))
Пример #16
0
    def run_phase(self):
    ###########################################################################
        SystemTestsCompareTwo.run_phase(self)
        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        case_root = self._get_caseroot2()
        da_files = glob.glob(os.path.join(case_root, 'da.log.*'))
        if da_files is None:
            logger = logging.getLogger(__name__)
            logger.warning("No DA files in %s", os.path.join(case_root, 'da.log.*'))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect((da_files is not None) and (len(da_files) == da_cycles),
               "ERROR: There were %d DA cycles in run but %d DA files were found"%
               (da_cycles, len(da_files) if da_files is not None else 0))
        da_files.sort()
        cycle_num = 0
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            found_total = False
            with open(fname) as dfile:
                for line in dfile:
                    expect(line[0:5] != 'ERROR', "ERROR, error line found in %s"%fname)
                    if line[0:8] == 'caseroot':
                        found_caseroot = True
                    elif line[0:5] == 'cycle':
                        found_cycle = True
                        expect(int(line[7:]) == cycle_num,
                               "ERROR: Wrong cycle (%d) found in %s (expected %d)"%
                               (int(line[7:]), fname, cycle_num))
                    elif line[0:12] == 'total_cycles':
                        found_total = True
                        expect(int(line[14:]) == da_cycles,
                               "ERROR: Wrong total cycle count (%d) found in %s (expected %d)"%
                               (int(line[14:]), fname, da_cycles))
                    else:
                        expect(False, "ERROR: Unrecognized line ('%s') found in %s"%(line, fname))

                # End of for loop
                expect(found_caseroot, "ERROR: No caseroot found in %s"%fname)
                expect(found_cycle, "ERROR: No cycle found in %s"%fname)
                expect(found_total, "ERROR: No total_cycles found in %s"%fname)
            # End of with
            cycle_num = cycle_num + 1
Пример #17
0
    def run_phase(self):  # pylint: disable=arguments-differ
        ###########################################################################
        # Clean up any da.log files in case this is a re-run.
        self._activate_case2()
        case_root = self._get_caseroot2()
        rundir2 = self._case.get_value("RUNDIR")
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        for file_ in da_files:
            os.remove(file_)
        # End for

        # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run.
        self._case.set_value("CONTINUE_RUN", False)
        # Start normal run here
        self._activate_case1()
        SystemTestsCompareTwo.run_phase(self)

        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        if da_files is None:
            logger = logging.getLogger(__name__)
            path = os.path.join(case_root, 'da.log.*')
            logger.warning("No DA files in {}".format(path))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect((da_files is not None) and (
            len(da_files) == da_cycles
        ), "ERROR: There were {:d} DA cycles in run but {:d} DA files were found"
               .format(da_cycles,
                       len(da_files) if da_files is not None else 0))
        da_files.sort()
        cycle_num = 0
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            with gzip.open(fname, "r") as dfile:
                for bline in dfile:
                    line = bline.decode("utf-8")
                    expect(
                        not 'ERROR' in line,
                        "ERROR, error line {} found in {}".format(line, fname))
                    if 'caseroot' in line[0:8]:
                        found_caseroot = True
                    elif 'cycle' in line[0:5]:
                        found_cycle = True
                        expect(
                            int(line[7:]) == cycle_num,
                            "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})"
                            .format(int(line[7:]), fname, cycle_num))
                    else:
                        expect(
                            False,
                            "ERROR: Unrecognized line ('{}') found in {}".
                            format(line, fname))

                # End of for loop
                expect(found_caseroot,
                       "ERROR: No caseroot found in {}".format(fname))
                expect(found_cycle,
                       "ERROR: No cycle found in {}".format(fname))
            # End of with
            cycle_num = cycle_num + 1
Пример #18
0
 def __init__(self, case):
     """
     initialize a test object
     """
     SystemTestsCompareTwo.__init__(self, case, True)
Пример #19
0
 def __init__(self, case):
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = False,
                                    run_two_suffix = 'interp',
                                    run_one_description = 'use_init_interp set to false',
                                    run_two_description = 'use_init_interp set to true')
Пример #20
0
Файл: dae.py Проект: Katetc/cime
    def run_phase(self): # pylint: disable=arguments-differ
    ###########################################################################
        # Clean up any da.log files in case this is a re-run.
        self._activate_case2()
        case_root = self._get_caseroot2()
        rundir2 = self._case.get_value("RUNDIR")
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        for file_ in da_files:
            os.remove(file_)
        # End for

        # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run.
        self._case.set_value("CONTINUE_RUN", False)
        # Start normal run here
        self._activate_case1()
        SystemTestsCompareTwo.run_phase(self)

        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        if da_files is None:
            logger = logging.getLogger(__name__)
            path = os.path.join(case_root, 'da.log.*')
            logger.warning("No DA files in {}".format(path))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect((da_files is not None) and (len(da_files) == da_cycles),
               "ERROR: There were {:d} DA cycles in run but {:d} DA files were found".format(da_cycles, len(da_files) if da_files is not None else 0))
        da_files.sort()
        cycle_num = 0
        compset = self._case.get_value("COMPSET")
        is_dwav = '_DWAV' in compset
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            found_signal = 0
            if is_dwav and (cycle_num > 0):
                expected_signal = self._case.get_value("NINST_WAV")
            else:
                expected_signal = 0

            with gzip.open(fname, "r") as dfile:
                for bline in dfile:
                    line = bline.decode("utf-8")
                    expect(not 'ERROR' in line, "ERROR, error line {} found in {}".format(line, fname))
                    if 'caseroot' in line[0:8]:
                        found_caseroot = True
                    elif 'cycle' in line[0:5]:
                        found_cycle = True
                        expect(int(line[7:]) == cycle_num,
                               "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})".format(int(line[7:]), fname, cycle_num))
                    elif 'resume signal' in line:
                        found_signal = found_signal + 1
                        expect('Post-DA resume signal found' in line[0:27],
                               "ERROR: bad post-DA message found in {}".format(fname))
                    else:
                        expect(False, "ERROR: Unrecognized line ('{}') found in {}".format(line, fname))

                # End of for loop
                expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname))
                expect(found_cycle, "ERROR: No cycle found in {}".format(fname))
                expect(found_signal == expected_signal,
                       "ERROR: Expected {} post-DA resume signal message(s), {} found in {}".format(expected_signal, found_signal, fname))
            # End of with
            cycle_num = cycle_num + 1
Пример #21
0
Файл: rep.py Проект: Katetc/cime
 def __init__(self, case):
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = False,
                                    run_two_suffix = 'rep2')
Пример #22
0
 def __init__(self, case):
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = True,
                                    run_two_suffix = 'modpes',
                                    run_one_description = 'default pe counts',
                                    run_two_description = 'halved pe counts')
Пример #23
0
 def __init__(self, case):
     SystemTestsCompareTwo.__init__(self, case,
                                    separate_builds = True,
                                    run_two_suffix = 'mpi-serial',
                                    run_one_description = 'default mpi library',
                                    run_two_description = 'mpi-serial')
Пример #24
0
    def run_phase(self): # pylint: disable=arguments-differ
    ###########################################################################
        # Clean up any da.log files in case this is a re-run.
        self._activate_case2()
        case_root = self._get_caseroot2()
        rundir2 = self._case.get_value("RUNDIR")
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        for file_ in da_files:
            os.remove(file_)
        # End for

        # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run.
        with self._case:
            self._case.set_value("CONTINUE_RUN", False)
            # Turn off post DA in case this is a re-run
            for comp in self._case.get_values("COMP_CLASSES"):
                if comp == "ESP":
                    continue
                else:
                    self._case.set_value("DATA_ASSIMILATION_{}".format(comp), False)

        # Start normal run here
        self._activate_case1()
        SystemTestsCompareTwo.run_phase(self)

        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        da_files = glob.glob(os.path.join(rundir2, 'da.log.*'))
        if da_files is None:
            logger = logging.getLogger(__name__)
            path = os.path.join(case_root, 'da.log.*')
            logger.warning("No DA files in {}".format(path))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect((da_files is not None) and (len(da_files) == da_cycles),
               "ERROR: There were {:d} DA cycles in run but {:d} DA files were found".format(da_cycles, len(da_files) if da_files is not None else 0))
        da_files.sort()
        cycle_num = 0
        compset = self._case.get_value("COMPSET")
        # Special case for DWAV so we can make sure other variables are set
        is_dwav = '_DWAV' in compset
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            found_signal = 0
            found_init = 0
            if is_dwav:
                expected_init = self._case.get_value("NINST_WAV")
            else:
                # Expect a signal from every instance of every DA component
                expected_init = 0
                for comp in self._case.get_values("COMP_CLASSES"):
                    if comp == "ESP":
                        continue
                    elif self._case.get_value("DATA_ASSIMILATION_{}".format(comp)):
                        expected_init = expected_init + self._case.get_value("NINST_{}".format(comp))

            # Adjust expected initial run and post-DA numbers
            if cycle_num == 0:
                expected_signal = 0
            else:
                expected_signal = expected_init
                expected_init = 0

            with gzip.open(fname, "r") as dfile:
                for bline in dfile:
                    line = bline.decode("utf-8")
                    expect(not 'ERROR' in line, "ERROR, error line {} found in {}".format(line, fname))
                    if 'caseroot' in line[0:8]:
                        found_caseroot = True
                    elif 'cycle' in line[0:5]:
                        found_cycle = True
                        expect(int(line[7:]) == cycle_num,
                               "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})".format(int(line[7:]), fname, cycle_num))
                    elif 'resume signal' in line:
                        found_signal = found_signal + 1
                        expect('Post-DA resume signal found' in line[0:27],
                               "ERROR: bad post-DA message found in {}".format(fname))
                    elif 'Initial run' in line:
                        found_init = found_init + 1
                        expect('Initial run signal found' in line[0:24],
                               "ERROR: bad Initial run message found in {}".format(fname))
                    else:
                        expect(False, "ERROR: Unrecognized line ('{}') found in {}".format(line, fname))

                # End for
                expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname))
                expect(found_cycle, "ERROR: No cycle found in {}".format(fname))
                expect(found_signal == expected_signal,
                       "ERROR: Expected {} post-DA resume signal message(s), {} found in {}".format(expected_signal, found_signal, fname))
                expect(found_init == expected_init,
                       "ERROR: Expected {} Initial run message(s), {} found in {}".format(expected_init, found_init, fname))
            # End with
            cycle_num = cycle_num + 1
Пример #25
0
    def run_phase(self):  # pylint: disable=arguments-differ
        ###########################################################################
        # Clean up any da.log files in case this is a re-run.
        self._activate_case2()
        case_root = self._get_caseroot2()
        rundir2 = self._case.get_value("RUNDIR")
        da_files = glob.glob(os.path.join(rundir2, "da.log.*"))
        for file_ in da_files:
            os.remove(file_)
        # End for

        # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run.
        with self._case:
            self._case.set_value("CONTINUE_RUN", False)
            # Turn off post DA in case this is a re-run
            for comp in self._case.get_values("COMP_CLASSES"):
                if comp == "ESP":
                    continue
                else:
                    self._case.set_value("DATA_ASSIMILATION_{}".format(comp),
                                         False)

        # Start normal run here
        self._activate_case1()
        SystemTestsCompareTwo.run_phase(self)

        # Do some checks on the data assimilation 'output' from case2
        self._activate_case2()
        da_files = glob.glob(os.path.join(rundir2, "da.log.*"))
        if da_files is None:
            logger = logging.getLogger(__name__)
            path = os.path.join(case_root, "da.log.*")
            logger.warning("No DA files in {}".format(path))

        da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES")
        expect(
            (da_files is not None) and (len(da_files) == da_cycles),
            "ERROR: There were {:d} DA cycles in run but {:d} DA files were found"
            .format(da_cycles,
                    len(da_files) if da_files is not None else 0),
        )
        da_files.sort()
        cycle_num = 0
        compset = self._case.get_value("COMPSET")
        # Special case for DWAV so we can make sure other variables are set
        is_dwav = "_DWAV" in compset
        for fname in da_files:
            found_caseroot = False
            found_cycle = False
            found_signal = 0
            found_init = 0
            if is_dwav:
                expected_init = self._case.get_value("NINST_WAV")
            else:
                # Expect a signal from every instance of every DA component
                expected_init = 0
                for comp in self._case.get_values("COMP_CLASSES"):
                    if comp == "ESP":
                        continue
                    elif self._case.get_value(
                            "DATA_ASSIMILATION_{}".format(comp)):
                        expected_init = expected_init + self._case.get_value(
                            "NINST_{}".format(comp))

            # Adjust expected initial run and post-DA numbers
            if cycle_num == 0:
                expected_signal = 0
            else:
                expected_signal = expected_init
                expected_init = 0

            with gzip.open(fname, "r") as dfile:
                for bline in dfile:
                    line = bline.decode("utf-8")
                    expect(
                        not "ERROR" in line,
                        "ERROR, error line {} found in {}".format(line, fname),
                    )
                    if "caseroot" in line[0:8]:
                        found_caseroot = True
                    elif "cycle" in line[0:5]:
                        found_cycle = True
                        expect(
                            int(line[7:]) == cycle_num,
                            "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})"
                            .format(int(line[7:]), fname, cycle_num),
                        )
                    elif "resume signal" in line:
                        found_signal = found_signal + 1
                        expect(
                            "Post-DA resume signal found" in line[0:27],
                            "ERROR: bad post-DA message found in {}".format(
                                fname),
                        )
                    elif "Initial run" in line:
                        found_init = found_init + 1
                        expect(
                            "Initial run signal found" in line[0:24],
                            "ERROR: bad Initial run message found in {}".
                            format(fname),
                        )
                    else:
                        expect(
                            False,
                            "ERROR: Unrecognized line ('{}') found in {}".
                            format(line, fname),
                        )

                # End for
                expect(found_caseroot,
                       "ERROR: No caseroot found in {}".format(fname))
                expect(found_cycle,
                       "ERROR: No cycle found in {}".format(fname))
                expect(
                    found_signal == expected_signal,
                    "ERROR: Expected {} post-DA resume signal message(s), {} found in {}"
                    .format(expected_signal, found_signal, fname),
                )
                expect(
                    found_init == expected_init,
                    "ERROR: Expected {} Initial run message(s), {} found in {}"
                    .format(expected_init, found_init, fname),
                )
            # End with
            cycle_num = cycle_num + 1