Example #1
0
File: seq.py Project: Katetc/cime
    def _case_two_setup(self):
        comp_classes = self._case.get_values("COMP_CLASSES")
        any_changes = False
        for comp in comp_classes:
            any_changes |= self._case.get_value("ROOTPE_{}".format(comp)) != 0
        if any_changes:
            for comp in comp_classes:
                self._case.set_value("ROOTPE_{}".format(comp), 0)
        else:
            totalpes = self._case.get_value("TOTALPES")
            newntasks = max(1, totalpes/len(comp_classes))
            rootpe = newntasks

            for comp in comp_classes:
                # here we set the cpl to have the first 2 tasks
                # and each component to have a different ROOTPE
                if comp == "CPL":
                    self._case.set_value("NTASKS_CPL", newntasks)
                else:
                    self._case.set_value("NTASKS_{}".format(comp), newntasks)
                    self._case.set_value("ROOTPE_{}".format(comp), rootpe)
                    rootpe += newntasks

        self._case.flush()
        case_setup(self._case, test_mode=True, reset=True)
Example #2
0
File: seq.py Project: lxu16/ACME
    def _case_two_setup(self):
        comp_classes = self._case.get_values("COMP_CLASSES")
        any_changes = False
        for comp in comp_classes:
            any_changes |= self._case.get_value("ROOTPE_{}".format(comp)) != 0
        if any_changes:
            for comp in comp_classes:
                self._case.set_value("ROOTPE_{}".format(comp), 0)
        else:
            totalpes = self._case.get_value("TOTALPES")
            newntasks = max(1, totalpes / len(comp_classes))
            rootpe = newntasks

            for comp in comp_classes:
                # here we set the cpl to have the first 2 tasks
                # and each component to have a different ROOTPE
                if comp == "CPL":
                    self._case.set_value("NTASKS_CPL", newntasks)
                else:
                    self._case.set_value("NTASKS_{}".format(comp), newntasks)
                    self._case.set_value("ROOTPE_{}".format(comp), rootpe)
                    rootpe += newntasks

        self._case.flush()
        case_setup(self._case, test_mode=True, reset=True)
Example #3
0
    def build(self, sharedlib_only=False, model_only=False):
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        # first set all component mpi tasks to 1
        for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
            self._case.set_value("NTASKS_%s"%comp, 1)

        build1 = os.path.join("LockedFiles","env_build.PEA1.xml")
        if ( os.path.isfile(build1) ):
            shutil.copy(build1,"env_build.xml")

        mpilib = self._case.get_value("MPILIB")
        for mpilib in [mpilib, "mpi-serial"]:
            logging.warn("Starting bld for %s"%mpilib)
            self._case.set_value("MPILIB",mpilib)
            self._case.flush()
            case_setup(self._case, reset=True)
            self.clean_build()
            SystemTestsCommon.build(self, sharedlib_only=sharedlib_only, model_only=model_only)
            if (not sharedlib_only):
                shutil.move("%s/%s.exe"%(exeroot,cime_model),
                            "%s/%s.exe.PEA_%s"%(exeroot,cime_model,mpilib))
            shutil.copy("env_build.xml",os.path.join("LockedFiles",
                                                     "env_build_PEA_%s.xml"%mpilib))
Example #4
0
File: pet.py Project: Katetc/cime
    def _case_two_setup(self):
        #Do a run with all threads set to 1
        for comp in self._case.get_values("COMP_CLASSES"):
            self._case.set_value("NTHRDS_{}".format(comp), 1)

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #5
0
    def __init__(self, case, expected=None):
        """
        initialize a CIME system test object, if the file LockedFiles/env_run.orig.xml
        does not exist copy the current env_run.xml file.  If it does exist restore values
        changed in a previous run of the test.
        """
        self._case = case
        caseroot = case.get_value("CASEROOT")
        self._caseroot = caseroot
        self._orig_caseroot = caseroot
        self._runstatus = None
        # Needed for sh scripts
        os.environ["CASEROOT"] = caseroot

        if os.path.isfile(os.path.join(caseroot, "LockedFiles", "env_run.orig.xml")):
            self.compare_env_run(expected=expected)
        elif os.path.isfile(os.path.join(caseroot, "env_run.xml")):
            lockedfiles = os.path.join(caseroot, "LockedFiles")
            try:
                os.stat(lockedfiles)
            except:
                os.mkdir(lockedfiles)
            shutil.copy(os.path.join(caseroot,"env_run.xml"),
                        os.path.join(lockedfiles, "env_run.orig.xml"))

        if self._case.get_value("IS_FIRST_RUN"):
            self._case.set_initial_test_values()

        case_setup(self._case, reset=True, test_mode=True)
        self._case.set_value("TEST",True)
Example #6
0
    def _case_two_setup(self):
        for comp in self._comp_classes:
            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)

        case_setup(self._case, test_mode=True, reset=True)
Example #7
0
    def _case_two_setup(self):
        #Do a run with all threads set to 1
        for comp in self._case.get_values("COMP_CLASSES"):
            self._case.set_value("NTHRDS_{}".format(comp), 1)

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #8
0
File: nck.py Project: gold2718/cime
    def _case_two_setup(self):
        for comp in self._comp_classes:
            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)

        case_setup(self._case, test_mode=True, reset=True)
Example #9
0
    def build(self, sharedlib_only=False, model_only=False):
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        # first make sure that all components have threaded settings
        for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
            if self._case.get_value("NTHRDS_%s"%comp) <= 1:
                self._case.set_value("NTHRDS_%s"%comp, 2)

        machpes1 = os.path.join("LockedFiles","env_mach_pes.PET1.xml")
        if ( os.path.isfile(machpes1) ):
            shutil.copy(machpes1,"env_mach_pes.xml")
        else:
            logging.warn("Copying env_mach_pes.xml to %s"%(machpes1))
            shutil.copy("env_mach_pes.xml", machpes1)

        build1 = os.path.join("LockedFiles","env_build.PET1.xml")
        if ( os.path.isfile(build1) ):
            shutil.copy(build1,"env_build.xml")

        self._case.flush()
        case_setup(self._case, reset=True)
        self.clean_build()
        SystemTestsCommon.build(self, sharedlib_only=sharedlib_only, model_only=model_only)
        shutil.copy("env_build.xml",os.path.join("LockedFiles","env_build_PET1.xml"))
Example #10
0
File: pet.py Project: gold2718/cime
    def _case_one_setup(self):
        # first make sure that all components have threaded settings
        for comp in self._COMPONENT_LIST:
            if self._case.get_value("NTHRDS_%s"%comp) <= 1:
                self._case.set_value("NTHRDS_%s"%comp, 2)

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #11
0
    def _case_one_setup(self):
        # first make sure that all components have threaded settings
        for comp in self._case.get_values("COMP_CLASSES"):
            if self._case.get_value("NTHRDS_{}".format(comp)) <= 1:
                self._case.set_value("NTHRDS_{}".format(comp), 2)

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #12
0
File: pet.py Project: apcraig/cime
    def _case_one_setup(self):
        # first make sure that all components have threaded settings
        for comp in self._case.get_values("COMP_CLASSES"):
            if self._case.get_value("NTHRDS_{}".format(comp)) <= 1:
                self._case.set_value("NTHRDS_{}".format(comp), 2)

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #13
0
    def _init_case_setup(self):
        """
        Do initial case setup needed in __init__
        """
        if self._case.get_value("IS_FIRST_RUN"):
            self._case.set_initial_test_values()

        case_setup(self._case, reset=True, test_mode=True)
        self._case.set_value("TEST",True)
        self._case.flush()
Example #14
0
    def _case_two_setup(self):
        for comp in self._comp_classes:
            if (comp == "ESP"):
                self._case.set_value("NINST_{}".format(comp), 1)
            else:
                self._case.set_value("NINST_{}".format(comp), 2)

            ntasks = self._case.get_value("NTASKS_{}".format(comp))
            self._case.set_value("NTASKS_{}".format(comp), ntasks*2)

        case_setup(self._case, test_mode=True, reset=True)
Example #15
0
File: seq.py Project: gold2718/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.
        """
        # Build the default configuration
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        if sharedlib_only:
            return

        # Build the model with all components with different rootpes
        exeroot = self._case.get_value("EXEROOT")
        cime_model = self._case.get_value("MODEL")
        shutil.move("%s/%s.exe" % (exeroot, cime_model),
                    "%s/%s.exe.SEQ1" % (exeroot, cime_model))
        any_changes = False
        machpes1 = os.path.join("LockedFiles", "env_mach_pes.SEQ1.xml")
        if (os.path.isfile(machpes1)):
            shutil.copy(machpes1, "env_mach_pes.xml")
        else:
            logging.info("Copying env_mach_pes.xml to %s" % (machpes1))
            shutil.copy("env_mach_pes.xml", machpes1)

        comp_classes = self._case.get_values("COMP_CLASSES")
        for comp in comp_classes:
            if comp != "DRV":
                any_changes |= self._case.get_value("ROOTPE_%s" % comp) != 0
        if any_changes:
            for comp in comp_classes:
                if comp != "DRV":
                    self._case.set_value("ROOTPE_%s" % comp, 0)
        else:
            rootpe = 2
            for comp in comp_classes:
                # here we set the cpl to have the first 2 tasks
                # and each component to have a different ROOTPE
                if comp == "DRV":
                    self._case.set_value("NTASKS_CPL", 2)
                else:
                    ntasks = self._case.get_value("NTASKS_%s" % comp)
                    if ntasks > 1:
                        self._case.set_value("NTASKS_%s" % comp,
                                             max(1, ntasks - rootpe))
                        self._case.set_value("ROOTPE_%s" % comp, rootpe)
                        rootpe += 1
        self._case.flush()
        case_setup(self._case, test_mode=True, reset=True)
        self.clean_build()
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        shutil.move("%s/%s.exe" % (exeroot, cime_model),
                    "%s/%s.exe.SEQ2" % (exeroot, cime_model))
        machpes2 = os.path.join("LockedFiles", "env_mach_pes.SEQ2.xml")
        logging.info("Copying env_mach_pes.xml to %s" % (machpes2))
        shutil.copy("env_mach_pes.xml", machpes2)
Example #16
0
    def run_phase(self):
        # Move to config_tests.xml once that's ready.
        self._case.set_value("CONTINUE_RUN", False)
        self._case.set_value("REST_OPTION", "never")
        self._case.set_value("HIST_OPTION", "$STOP_OPTION")
        self._case.set_value("HIST_N", "$STOP_N")
        self._case.flush()

        stop_n = self._case.get_value("STOP_N")
        stop_option = self._case.get_value("STOP_OPTION")
        exeroot = self._case.get_value("EXEROOT")
        cime_model = self._case.get_value("MODEL")

        #
        # do an initial run test with default layout
        #
        logger.info("doing a {:d} {} initial test with default layout".format(
            stop_n, stop_option))

        shutil.copy("{}/{}.exe.SEQ1".format(exeroot, cime_model),
                    "{}/{}.exe".format(exeroot, cime_model))
        restore("env_mach_pes.SEQ1.xml", newname="env_mach_pes.xml")

        # update the pelayout settings for this run
        self._case.read_xml()

        case_setup(self._case, test_mode=True, reset=True)
        self._case.set_value(
            "BUILD_COMPLETE",
            True)  # rootpe changes should not require a rebuild

        self.run_indv()

        restore("env_mach_pes.SEQ2.xml", newname="env_mach_pes.xml")

        os.remove("{}/{}.exe".format(exeroot, cime_model))
        shutil.copy("{}/{}.exe.SEQ1".format(exeroot, cime_model),
                    "{}/{}.exe".format(exeroot, cime_model))

        logger.info(
            "doing a second {:d} {} test with rootpes set to zero".format(
                stop_n, stop_option))
        # update the pelayout settings for this run
        self._case.read_xml()

        case_setup(self._case, test_mode=True, reset=True)
        self._case.set_value(
            "BUILD_COMPLETE",
            True)  # rootpe changes should not require a rebuild

        self.run_indv(suffix="seq")
        self._component_compare_test("base", "seq")
Example #17
0
File: seq.py Project: ekluzek/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.
        """
        # Build the default configuration
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        if sharedlib_only:
            return

        # Build the model with all components with different rootpes
        exeroot = self._case.get_value("EXEROOT")
        cime_model = self._case.get_value("MODEL")
        shutil.move("%s/%s.exe"%(exeroot,cime_model),
                    "%s/%s.exe.SEQ1"%(exeroot,cime_model))
        any_changes = False
        machpes1 = os.path.join("LockedFiles","env_mach_pes.SEQ1.xml")
        if ( os.path.isfile(machpes1) ):
            shutil.copy(machpes1,"env_mach_pes.xml")
        else:
            logging.info("Copying env_mach_pes.xml to %s"%(machpes1))
            shutil.copy("env_mach_pes.xml", machpes1)

        comp_classes = self._case.get_value("COMP_CLASSES").split(',')
        for comp in comp_classes:
            if comp != "DRV":
                any_changes |= self._case.get_value("ROOTPE_%s" % comp) != 0
        if any_changes:
            for comp in comp_classes:
                if comp != "DRV":
                    self._case.set_value("ROOTPE_%s"%comp, 0)
        else:
            rootpe = 2
            for comp in comp_classes:
                # here we set the cpl to have the first 2 tasks
                # and each component to have a different ROOTPE
                if comp == "DRV":
                    self._case.set_value("NTASKS_CPL", 2)
                else:
                    ntasks = self._case.get_value("NTASKS_%s"%comp)
                    if ntasks > 1:
                        self._case.set_value("NTASKS_%s"%comp, max(1,ntasks-rootpe))
                        self._case.set_value("ROOTPE_%s"%comp, rootpe)
                        rootpe += 1
        self._case.flush()
        case_setup(self._case, test_mode=True, reset=True)
        self.clean_build()
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        shutil.move("%s/%s.exe"%(exeroot,cime_model),
                    "%s/%s.exe.SEQ2"%(exeroot,cime_model))
        machpes2 = os.path.join("LockedFiles","env_mach_pes.SEQ2.xml")
        logging.info("Copying env_mach_pes.xml to %s"%(machpes2))
        shutil.copy("env_mach_pes.xml", machpes2)
Example #18
0
File: pea.py Project: lxu16/origin
    def _case_two_setup(self):
        mach_name = self._case.get_value("MACH")
        mach_obj = Machines(machine=mach_name)
        if mach_obj.is_valid_MPIlib("mpi-serial"):
            self._case.set_value("MPILIB", "mpi-serial")
        else:
            logger.warning(
                "mpi-serial is not supported on machine '%s', so we have to fall back to default MPI and therefore very little is being tested"
                % mach_name)

        if os.path.isfile("Macros"):
            os.remove("Macros")
        case_setup(self._case, reset=True, test_mode=True)
Example #19
0
File: pea.py Project: Katetc/cime
    def _case_two_setup(self):
        mach_name = self._case.get_value("MACH")
        mach_obj = Machines(machine=mach_name)
        if mach_obj.is_valid_MPIlib("mpi-serial"):
            self._case.set_value("MPILIB","mpi-serial")
        else:
            logger.warning("mpi-serial is not supported on machine '{}', "
                           "so we have to fall back to default MPI and "
                           "therefore very little is being tested".format(mach_name))

        if os.path.isfile("Macros"):
            os.remove("Macros")
        case_setup(self._case, reset=True, test_mode=True)
Example #20
0
    def _resetup_case(self, phase, reset=False):
        """
        Re-setup this case. This is necessary if user is re-running an already-run
        phase.
        """
        # We never want to re-setup if we're doing the resubmitted run
        phase_status = self._test_status.get_status(phase)
        if reset or (self._case.get_value("IS_FIRST_RUN") and phase_status != TEST_PEND_STATUS):

            logging.warning("Resetting case due to detected re-run of phase {}".format(phase))
            self._case.set_initial_test_values()

            case_setup(self._case, reset=True, test_mode=True)
Example #21
0
    def run_phase(self):
        # run will have values 1,2
        for run in range(1,3):

            expect(is_locked("env_mach_pes.ERP%d.xml" % run),
                   "ERROR: LockedFiles/env_mach_pes.ERP%d.xml does not exist, run case.build" % run )

            # Use the second env_mach_pes.xml and env_build.xml files
            restore("env_mach_pes.ERP%d.xml" % run, newname="env_mach_pes.xml")
            restore("env_build.ERP%d.xml" % run, newname="env_build.xml")

            # update the case to use the new values
            self._case.read_xml()

            # Use the second executable that was created
            exeroot = self._case.get_value("EXEROOT")
            cime_model = CIME.utils.get_model()
            exefile  = os.path.join(exeroot,"%s.exe"%(cime_model))
            exefile2 = os.path.join(exeroot,"%s.ERP%d.exe"%(cime_model,run))
            if (os.path.isfile(exefile)):
                os.remove(exefile)
            shutil.copy(exefile2, exefile)

            case_setup(self._case, test_mode=True, reset=True)
            stop_n      = self._case.get_value("STOP_N")
            stop_option = self._case.get_value("STOP_OPTION")

            if run == 1:
                expect(stop_n > 2, "ERROR: stop_n value %d too short"%stop_n)
                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)
                suffix = "base"
            else:
                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))
                self._case.set_value("STOP_N", stop_new)
                self._case.set_value("CONTINUE_RUN", True)
                self._case.set_value("REST_OPTION","never")
                suffix = "rest"

            self.run_indv(suffix=suffix)
            self._case.flush()

        self._component_compare_test("base", "rest")
Example #22
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.
        """
        # Build the default configuration
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        if sharedlib_only:
            return

        # Build the model with all components with different rootpes
        exeroot = self._case.get_value("EXEROOT")
        cime_model = self._case.get_value("MODEL")
        shutil.move("{}/{}.exe".format(exeroot, cime_model),
                    "{}/{}.exe.SEQ1".format(exeroot, cime_model))
        any_changes = False
        machpes1 = "env_mach_pes.SEQ1.xml"
        if is_locked(machpes1):
            restore(machpes1, newname="env_mach_pes.xml")
        else:
            lock_file("env_mach_pes.xml", newname=machpes1)

        comp_classes = self._case.get_values("COMP_CLASSES")
        for comp in comp_classes:
            any_changes |= self._case.get_value("ROOTPE_{}".format(comp)) != 0
        if any_changes:
            for comp in comp_classes:
                self._case.set_value("ROOTPE_{}".format(comp), 0)
        else:
            totalpes = self._case.get_value("TOTALPES")
            newntasks = max(1, totalpes / len(comp_classes))
            rootpe = newntasks

            for comp in comp_classes:
                # here we set the cpl to have the first 2 tasks
                # and each component to have a different ROOTPE
                if comp == "CPL":
                    self._case.set_value("NTASKS_CPL", newntasks)
                else:
                    self._case.set_value("NTASKS_{}".format(comp), newntasks)
                    self._case.set_value("ROOTPE_{}".format(comp), rootpe)
                    rootpe += newntasks

        self._case.flush()
        case_setup(self._case, test_mode=True, reset=True)
        self.clean_build()
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        shutil.move("{}/{}.exe".format(exeroot, cime_model),
                    "{}/{}.exe.SEQ2".format(exeroot, cime_model))
        lock_file("env_mach_pes.xml", newname="env_mach_pes.SEQ2.xml")
Example #23
0
File: erp.py Project: ekluzek/cime
    def run_phase(self):
        # run will have values 1,2
        for run in range(1,3):

            expect(os.path.isfile(os.path.join("LockedFiles","env_mach_pes.ERP%d.xml"%run)),
                   "ERROR: LockedFiles/env_mach_pes.ERP%d.xml does not exist, run case.build"%run )

            # Use the second env_mach_pes.xml and env_build.xml files
            shutil.copy(os.path.join("LockedFiles","env_mach_pes.ERP%d.xml"%run), "env_mach_pes.xml")
            shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles","env_mach_pes.xml"))
            shutil.copy(os.path.join("LockedFiles","env_build.ERP%d.xml")%run, "env_build.xml")
            shutil.copy("env_build.xml", os.path.join("LockedFiles","env_build.xml"))

            # update the case to use the new values
            self._case.read_xml()

            # Use the second executable that was created
            exeroot = self._case.get_value("EXEROOT")
            cime_model = CIME.utils.get_model()
            exefile  = os.path.join(exeroot,"%s.exe"%(cime_model))
            exefile2 = os.path.join(exeroot,"%s.ERP%d.exe"%(cime_model,run))
            if (os.path.isfile(exefile)):
                os.remove(exefile)
            shutil.copy(exefile2, exefile)

            case_setup(self._case, test_mode=True, reset=True)
            stop_n      = self._case.get_value("STOP_N")
            stop_option = self._case.get_value("STOP_OPTION")

            if run == 1:
                expect(stop_n > 2, "ERROR: stop_n value %d too short"%stop_n)
                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)
                suffix = "base"
            else:
                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))
                self._case.set_value("STOP_N", stop_new)
                self._case.set_value("CONTINUE_RUN", True)
                self._case.set_value("REST_OPTION","never")
                suffix = "rest"
            self.run_indv(suffix=suffix)

        self._component_compare_test("base", "rest")
Example #24
0
File: seq.py Project: apcraig/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.
        """
        # Build the default configuration
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        if sharedlib_only:
            return

        # Build the model with all components with different rootpes
        exeroot = self._case.get_value("EXEROOT")
        cime_model = self._case.get_value("MODEL")
        shutil.move("{}/{}.exe".format(exeroot,cime_model),
                    "{}/{}.exe.SEQ1".format(exeroot,cime_model))
        any_changes = False
        machpes1 = "env_mach_pes.SEQ1.xml"
        if is_locked(machpes1):
            restore(machpes1, newname="env_mach_pes.xml")
        else:
            lock_file("env_mach_pes.xml", newname=machpes1)

        comp_classes = self._case.get_values("COMP_CLASSES")
        for comp in comp_classes:
            any_changes |= self._case.get_value("ROOTPE_{}".format(comp)) != 0
        if any_changes:
            for comp in comp_classes:
                self._case.set_value("ROOTPE_{}".format(comp), 0)
        else:
            totalpes = self._case.get_value("TOTALPES")
            newntasks = max(1, totalpes/len(comp_classes))
            rootpe = newntasks

            for comp in comp_classes:
                # here we set the cpl to have the first 2 tasks
                # and each component to have a different ROOTPE
                if comp == "CPL":
                    self._case.set_value("NTASKS_CPL", newntasks)
                else:
                    self._case.set_value("NTASKS_{}".format(comp), newntasks)
                    self._case.set_value("ROOTPE_{}".format(comp), rootpe)
                    rootpe += newntasks

        self._case.flush()
        case_setup(self._case, test_mode=True, reset=True)
        self.clean_build()
        self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
        shutil.move("{}/{}.exe".format(exeroot,cime_model),
                    "{}/{}.exe.SEQ2".format(exeroot,cime_model))
        lock_file("env_mach_pes.xml", newname="env_mach_pes.SEQ2.xml")
Example #25
0
    def build(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.  Case one uses defaults, case2 uses half the number of threads
        and tasks.   This test will fail for components (pop) that do not reproduce exactly
        with different numbers of mpi tasks.
        """
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()
        machpes1 = os.path.join("LockedFiles","env_mach_pes.ERP1.xml")
        if ( os.path.isfile(machpes1) ):
            shutil.copy(machpes1,"env_mach_pes.xml")
        else:
            logging.warn("Copying env_mach_pes.xml to %s"%(machpes1))
            shutil.copy("env_mach_pes.xml", machpes1)

        for bld in range(1,3):
            logging.warn("Starting bld %s"%bld)
            if(bld == 2):
                # halve the number of tasks and threads
                for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
                    ntasks    = self._case.get_value("NTASKS_%s"%comp)
                    nthreads  = self._case.get_value("NTHRDS_%s"%comp)
                    rootpe    = self._case.get_value("ROOTPE_%s"%comp)
                    if ( nthreads > 1 ):
                        self._case.set_value("BUILD_THREADED", True)
                    if ( ntasks > 1 ):
                        self._case.set_value("NTASKS_%s"%comp, ntasks/2)
                        self._case.set_value("ROOTPE_%s"%comp, rootpe/2)
                    if ( nthreads > 1 ):
                        self._case.set_value("NTHRDS_%s"%comp, nthreads/2)
            self._case.set_value("SMP_BUILD","0")
            self._case.flush()
            case_setup(self._case, test_mode=True, reset=True)
            self.clean_build()
            SystemTestsCommon.build(self, sharedlib_only=sharedlib_only, model_only=model_only)
            if (not sharedlib_only):
                shutil.move("%s/%s.exe"%(exeroot,cime_model),
                            "%s/%s.exe.ERP%s"%(exeroot,cime_model,bld))
            shutil.copy("env_build.xml",os.path.join("LockedFiles","env_build_ERP%s.xml"%bld))

        #
        # Because mira/cetus interprets its run script differently than
        # other systems we need to copy the original env_mach_pes.xml
        # back
        #
        shutil.copy(machpes1,"env_mach_pes.xml")
        shutil.copy("env_mach_pes.xml",
                    os.path.join("LockedFiles","env_mach_pes.xml"))
Example #26
0
File: pet.py Project: gold2718/cime
    def _case_two_setup(self):
        #Do a run with all threads set to 1
        for comp in self._COMPONENT_LIST:
            self._case.set_value("NTHRDS_%s"%comp, 1)

        # The need for this is subtle. On batch systems, the entire PET test runs
        # under a single submission and that submission is configured based on
        # the case settings for case 1, IE 2 threads for all components. This causes
        # the procs-per-node to be half of what it would be for single thread. On some
        # machines, if the mpiexec tries to exceed the procs-per-node that were given
        # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of
        # it original value prevents this.
        self._case.set_value("MAX_TASKS_PER_NODE", self._case.get_value("MAX_TASKS_PER_NODE") / 2)

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #27
0
File: pet.py Project: apcraig/cime
    def _case_two_setup(self):
        #Do a run with all threads set to 1
        for comp in self._case.get_values("COMP_CLASSES"):
            self._case.set_value("NTHRDS_{}".format(comp), 1)

        # The need for this is subtle. On batch systems, the entire PET test runs
        # under a single submission and that submission is configured based on
        # the case settings for case 1, IE 2 threads for all components. This causes
        # the procs-per-node to be half of what it would be for single thread. On some
        # machines, if the mpiexec tries to exceed the procs-per-node that were given
        # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of
        # it original value prevents this.
        self._case.set_value("MAX_TASKS_PER_NODE", int(self._case.get_value("MAX_TASKS_PER_NODE") / 2))

        # Need to redo case_setup because we may have changed the number of threads
        case_setup(self._case, reset=True)
Example #28
0
    def _case_one_setup(self):
        # Set the number of instances, the ROOTPEs, and the number of tasks
        # This case should have twice the number of instances and half the number of tasks
        # All tasks should be running concurrently
        # Note that this case must be the multiinstance one
        # to correctly set the required number of nodes and avoid crashing
        ntasks_sum = 0

        for comp in self._comp_classes():
            self._case.set_value("NINST_{}".format(comp), str(2))
            self._case.set_value("ROOTPE_{}".format(comp), ntasks_sum)
            ntasks = self._case.get_value("NTASKS_{}".format(comp)) * 2
            ntasks_sum += ntasks
            self._case.set_value("NTASKS_{}".format(comp), ntasks)
        # test_mode must be False here so the case.test file is updated
        # This ensures that the correct number of nodes are used in case it's larger than in case 2
        case_setup(self._case, test_mode=False, reset=True)
Example #29
0
File: erp.py Project: Katetc/cime
    def _case_two_setup(self):
        # halve the number of tasks and threads
        for comp in self._case.get_values("COMP_CLASSES"):
            ntasks    = self._case1.get_value("NTASKS_{}".format(comp))
            nthreads  = self._case1.get_value("NTHRDS_{}".format(comp))
            rootpe    = self._case1.get_value("ROOTPE_{}".format(comp))
            if ( nthreads > 1 ):
                self._case.set_value("NTHRDS_{}".format(comp), int(nthreads/2))
            if ( ntasks > 1 ):
                self._case.set_value("NTASKS_{}".format(comp), int(ntasks/2))
                self._case.set_value("ROOTPE_{}".format(comp), int(rootpe/2))

        RestartTest._case_two_setup(self)
        # Note, some components, like CESM-CICE, have
        # decomposition information in env_build.xml that
        # needs to be regenerated for the above new tasks and thread counts
        case_setup(self._case, test_mode=True, reset=True)
Example #30
0
    def build(self):
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        machpes1 = os.path.join("LockedFiles","env_mach_pes.NCR1.xml")
        if ( os.path.isfile(machpes1) ):
            shutil.copy(machpes1,"env_mach_pes.xml")

        for bld in range(1,3):
            """
            Build two exectuables for this test, the first is a default build
            the second halves the number of tasks and runs two instances
            for each component
            """
            logging.warn("Starting bld %s"%bld)
            machpes = os.path.join("LockedFiles","env_mach_pes.NCR%s.xml"%bld)
            ntasks_sum = 0
            for comp in ['ATM','OCN','WAV','GLC','ICE','ROF','LND']:
                self._case.set_value("NINST_%s"%comp,str(bld))
                ntasks      = self._case.get_value("NTASKS_%s"%comp)
                if(bld == 1):
                    self._case.set_value("ROOTPE_%s"%comp, 0)
                    if ( ntasks > 1 ):
                        self._case.set_value("NTASKS_%s"%comp, ntasks/2)
                else:
                    self._case.set_value("ROOTPE_%s"%comp, ntasks_sum)
                    ntasks_sum += ntasks*2
                    self._case.set_value("NTASKS_%s"%comp, ntasks*2)
            self._case.flush()

            case_setup(self._case, test_mode=True, reset=True)
            self.clean_build()
            SystemTestsCommon.build(self)
            shutil.move("%s/%s.exe"%(exeroot,cime_model),
                        "%s/%s.exe.NCR%s"%(exeroot,cime_model,bld))
            shutil.copy("env_build.xml",os.path.join("LockedFiles","env_build.NCR%s.xml"%bld))
            shutil.copy("env_mach_pes.xml", machpes)
#
# Because mira/cetus interprets its run script differently than
# other systems we need to copy the original env_mach_pes.xml
# back
#

        shutil.copy(machpes1,"env_mach_pes.xml")
        shutil.copy("env_mach_pes.xml",
                    os.path.join("LockedFiles","env_mach_pes.xml"))
Example #31
0
    def _case_two_setup(self):
        # halve the number of tasks and threads
        for comp in self._case.get_values("COMP_CLASSES"):
            ntasks    = self._case1.get_value("NTASKS_{}".format(comp))
            nthreads  = self._case1.get_value("NTHRDS_{}".format(comp))
            rootpe    = self._case1.get_value("ROOTPE_{}".format(comp))
            if ( nthreads > 1 ):
                self._case.set_value("NTHRDS_{}".format(comp), nthreads/2)
            if ( ntasks > 1 ):
                self._case.set_value("NTASKS_{}".format(comp), ntasks/2)
                self._case.set_value("ROOTPE_{}".format(comp), rootpe/2)

        RestartTest._case_two_setup(self)
        # Note, some components, like CESM-CICE, have
        # decomposition information in env_build.xml that
        # needs to be regenerated for the above new tasks and thread counts
        case_setup(self._case, test_mode=True, reset=True)
Example #32
0
File: seq.py Project: apcraig/cime
    def run_phase(self):
        # Move to config_tests.xml once that's ready.
        self._case.set_value("CONTINUE_RUN", False)
        self._case.set_value("REST_OPTION", "never")
        self._case.set_value("HIST_OPTION", "$STOP_OPTION")
        self._case.set_value("HIST_N", "$STOP_N")
        self._case.flush()

        stop_n      = self._case.get_value("STOP_N")
        stop_option = self._case.get_value("STOP_OPTION")
        exeroot     = self._case.get_value("EXEROOT")
        cime_model  = self._case.get_value("MODEL")

        #
        # do an initial run test with default layout
        #
        logger.info("doing a {:d} {} initial test with default layout".format(stop_n, stop_option))

        shutil.copy("{}/{}.exe.SEQ1".format(exeroot,cime_model),
                    "{}/{}.exe".format(exeroot,cime_model))
        restore("env_mach_pes.SEQ1.xml", newname="env_mach_pes.xml")

        # update the pelayout settings for this run
        self._case.read_xml()

        case_setup(self._case, test_mode=True, reset=True)
        self._case.set_value("BUILD_COMPLETE", True) # rootpe changes should not require a rebuild

        self.run_indv()

        restore("env_mach_pes.SEQ2.xml", newname="env_mach_pes.xml")

        os.remove("{}/{}.exe".format(exeroot,cime_model))
        shutil.copy("{}/{}.exe.SEQ1".format(exeroot,cime_model),
                    "{}/{}.exe".format(exeroot,cime_model))

        logger.info("doing a second {:d} {} test with rootpes set to zero".format(stop_n, stop_option))
        # update the pelayout settings for this run
        self._case.read_xml()

        case_setup(self._case, test_mode=True, reset=True)
        self._case.set_value("BUILD_COMPLETE", True) # rootpe changes should not require a rebuild

        self.run_indv(suffix="seq")
        self._component_compare_test("base", "seq")
Example #33
0
File: ncr.py Project: gold2718/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        machpes1 = os.path.join("LockedFiles", "env_mach_pes.NCR1.xml")
        if (os.path.isfile(machpes1)):
            shutil.copy(machpes1, "env_mach_pes.xml")

        # Build two exectuables for this test, the first is a default build, the
        # second halves the number of tasks and runs two instances for each component
        # Lay all of the components out concurrently
        for bld in range(1, 3):
            logging.warn("Starting bld %s" % bld)
            machpes = os.path.join("LockedFiles",
                                   "env_mach_pes.NCR%s.xml" % bld)
            ntasks_sum = 0
            for comp in ['ATM', 'OCN', 'WAV', 'GLC', 'ICE', 'ROF', 'LND']:
                self._case.set_value("NINST_%s" % comp, str(bld))
                ntasks = self._case.get_value("NTASKS_%s" % comp)
                if (bld == 1):
                    self._case.set_value("ROOTPE_%s" % comp, 0)
                    if (ntasks > 1):
                        self._case.set_value("NTASKS_%s" % comp, ntasks / 2)
                else:
                    self._case.set_value("ROOTPE_%s" % comp, ntasks_sum)
                    ntasks_sum += ntasks * 2
                    self._case.set_value("NTASKS_%s" % comp, ntasks * 2)
            self._case.flush()

            case_setup(self._case, test_mode=True, reset=True)
            self.clean_build()
            self.build_indv(sharedlib_only, model_only)
            shutil.move("%s/%s.exe" % (exeroot, cime_model),
                        "%s/%s.exe.NCR%s" % (exeroot, cime_model, bld))
            shutil.copy(
                "env_build.xml",
                os.path.join("LockedFiles", "env_build.NCR%s.xml" % bld))
            shutil.copy("env_mach_pes.xml", machpes)

        # Because mira/cetus interprets its run script differently than
        # other systems we need to copy the original env_mach_pes.xml back
        shutil.copy(machpes1, "env_mach_pes.xml")
        shutil.copy("env_mach_pes.xml",
                    os.path.join("LockedFiles", "env_mach_pes.xml"))
Example #34
0
    def build(self, sharedlib_only=False, model_only=False):
        """
        build two cases, the first is default the second has halve the tasks per component
        """
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        machpes1 = os.path.join("LockedFiles","env_mach_pes.PEM1.xml")
        if ( os.path.isfile(machpes1) ):
            shutil.copy(machpes1,"env_mach_pes.xml")

        for bld in range(1,3):
            logging.warn("Starting bld %s"%bld)
            self._case.flush()
            case_setup(self._case, reset=True)
            self.clean_build()
            SystemTestsCommon.build(self, sharedlib_only=sharedlib_only, model_only=model_only)
            machpes = os.path.join("LockedFiles","env_mach_pes.PEM%s.xml"%bld)

            if (not sharedlib_only):
                shutil.move("%s/%s.exe"%(exeroot,cime_model),
                            "%s/%s.exe.PEM%s"%(exeroot,cime_model,bld))

            shutil.copy("env_build.xml",os.path.join("LockedFiles","env_build_PEM%s.xml"%bld))
            shutil.copy("env_mach_pes.xml", machpes)

            if bld == 1:
                for comp in ["CPL", "ATM", "LND", "ICE", "OCN", "ROF", "GLC", "WAV"]:
                    ntasks = self._case.get_value("NTASKS_%s"%comp)
                    rootpe = self._case.get_value("ROOTPE_%s"%comp)
                    if ntasks > 1:
                        self._case.set_value("NTASKS_%s"%comp, ntasks/2)
                        self._case.set_value("ROOTPE_%s"%comp, rootpe/2)

        #
        # Because mira/cetus interprets its run script differently than
        # other systems we need to copy the original env_mach_pes.xml
        # back
        #
        shutil.copy(machpes1,"env_mach_pes.xml")
        shutil.copy("env_mach_pes.xml",
                    os.path.join("LockedFiles","env_mach_pes.xml"))
Example #35
0
File: pem.py Project: ekluzek/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.  Case one uses defaults, case2 uses half the number of threads
        and tasks. This test will fail for components (e.g. pop) that do not reproduce exactly
        with different numbers of mpi tasks.
        """
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        machpes1 = os.path.join("LockedFiles", "env_mach_pes.PEM1.xml")
        if os.path.isfile(machpes1):
            shutil.copy(machpes1, "env_mach_pes.xml")
        else:
            logging.warn("Copying env_mach_pes.xml to %s" % (machpes1))
            shutil.copy("env_mach_pes.xml", machpes1)

        self._case.set_value("SMP_BUILD", "0")
        for bld in range(1, 3):
            logging.warn("Starting bld %s" % bld)

            if bld == 2:
                # halve the number of tasks
                for comp in ["ATM", "CPL", "OCN", "WAV", "GLC", "ICE", "ROF", "LND"]:
                    ntasks = self._case.get_value("NTASKS_%s" % comp)
                    if ntasks > 1:
                        self._case.set_value("NTASKS_%s" % comp, ntasks / 2)

            self._case.flush()
            case_setup(self._case, test_mode=True, reset=True)
            self.clean_build()
            self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
            if not sharedlib_only:
                shutil.move("%s/%s.exe" % (exeroot, cime_model), "%s/%s.exe.PEM%s" % (exeroot, cime_model, bld))

            shutil.copy("env_mach_pes.xml", "env_mach_pes.xml.%s" % bld)
        #
        # Because mira/cetus interprets its run script differently than
        # other systems we need to copy the original env_mach_pes.xml# back
        #
        shutil.copy(machpes1, "env_mach_pes.xml")
        shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles", "env_mach_pes.xml"))
Example #36
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        machpes1 = "env_mach_pes.NCR1.xml"
        if is_locked(machpes1):
            restore(machpes1, newname="env_mach_pes.xml")

        # Build two exectuables for this test, the first is a default build, the
        # second halves the number of tasks and runs two instances for each component
        # Lay all of the components out concurrently
        for bld in range(1, 3):
            logging.warn("Starting bld {}".format(bld))
            machpes = "env_mach_pes.NCR{}.xml".format(bld)
            ntasks_sum = 0
            for comp in ['ATM', 'OCN', 'WAV', 'GLC', 'ICE', 'ROF', 'LND']:
                self._case.set_value("NINST_{}".format(comp), str(bld))
                ntasks = self._case.get_value("NTASKS_{}".format(comp))
                if (bld == 1):
                    self._case.set_value("ROOTPE_{}".format(comp), 0)
                    if (ntasks > 1):
                        self._case.set_value("NTASKS_{}".format(comp),
                                             ntasks / 2)
                else:
                    self._case.set_value("ROOTPE_{}".format(comp), ntasks_sum)
                    ntasks_sum += ntasks * 2
                    self._case.set_value("NTASKS_{}".format(comp), ntasks * 2)
            self._case.flush()

            case_setup(self._case, test_mode=True, reset=True)
            self.clean_build()
            self.build_indv(sharedlib_only, model_only)
            shutil.move("{}/{}.exe".format(exeroot, cime_model),
                        "{}/{}.exe.NCR{}".format(exeroot, cime_model, bld))
            lock_file("env_build.xml",
                      newname="env_build.NCR{}.xml".format(bld))
            lock_file("env_mach_pes.xml", newname=machpes)

        # Because mira/cetus interprets its run script differently than
        # other systems we need to copy the original env_mach_pes.xml back
        restore(machpes1, newname="env_mach_pes.xml")
Example #37
0
File: pem.py Project: gold2718/cime
 def _case_two_setup(self):
     for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
         ntasks = self._case.get_value("NTASKS_%s"%comp)
         if ( ntasks > 1 ):
             self._case.set_value("NTASKS_%s"%comp, int(ntasks/2))
     case_setup(self._case, clean=False, test_mode=False, reset=True)
Example #38
0
File: erp.py Project: ekluzek/cime
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.  Case one uses defaults, case2 uses half the number of threads
        and tasks. This test will fail for components (e.g. pop) that do not reproduce exactly
        with different numbers of mpi tasks.
        """
        if sharedlib_only:
            self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
            return

        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        # Make backup copies of the ORIGINAL env_mach_pes.xml and
        # env_build.xml in LockedFiles if they are not there. If there
        # are already copies there then simply copy them back to
        # have the starting env_mach_pes.xml and env_build.xml
        machpes1 = os.path.join("LockedFiles","env_mach_pes.ERP1.xml")
        envbuild1 = os.path.join("LockedFiles","env_build.ERP1.xml")
        if ( os.path.isfile(machpes1) ):
            shutil.copy(machpes1,"env_mach_pes.xml")
        else:
            shutil.copy("env_mach_pes.xml","env_mach_pes.ERP1.xml")

        if ( os.path.isfile(envbuild1) ):
            shutil.copy(envbuild1,"env_build.xml")

        # Build two executables, one using the original tasks and threads (ERP1) and
        # one using the modified tasks and threads (ERP2)
        # The reason we currently need two executables that CESM-CICE has a compile time decomposition
        # For cases where ERP works, changing this decomposition will not effect answers, but it will
        # effect the executable that is used
        self._case.set_value("SMP_BUILD","0")
        for bld in range(1,3):
            logging.warn("Starting bld %s"%bld)

            if (bld == 2):
                # halve the number of tasks and threads
                for comp in ['ATM','CPL','OCN','WAV','GLC','ICE','ROF','LND']:
                    ntasks    = self._case.get_value("NTASKS_%s"%comp)
                    nthreads  = self._case.get_value("NTHRDS_%s"%comp)
                    rootpe    = self._case.get_value("ROOTPE_%s"%comp)
                    if ( nthreads > 1 ):
                        self._case.set_value("BUILD_THREADED", True)
                        self._case.set_value("NTHRDS_%s"%comp, nthreads/2)
                    if ( ntasks > 1 ):
                        self._case.set_value("NTASKS_%s"%comp, ntasks/2)
                        self._case.set_value("ROOTPE_%s"%comp, rootpe/2)

            # Note, some components, like CESM-CICE, have
            # decomposition information in env_build.xml
            # case_setup(self._case, test_mode=True, reset=True)that
            # needs to be regenerated for the above new tasks and thread counts
            case_setup(self._case, test_mode=True, reset=True)

            # Now rebuild the system, given updated information in env_build.xml

            self.build_indv(sharedlib_only=sharedlib_only, model_only=model_only)
            shutil.move("%s/%s.exe"%(exeroot,cime_model),
                        "%s/%s.ERP%s.exe"%(exeroot,cime_model,bld))

            # Make copies of the new env_mach_pes.xml and the new
            # env_build.xml to be used in the run phase
            shutil.copy("env_mach_pes.xml", os.path.join("LockedFiles","env_mach_pes.ERP%s.xml"%bld ))
            shutil.copy("env_build.xml", os.path.join("LockedFiles","env_build.ERP%s.xml"%bld ))
Example #39
0
File: dae.py Project: Katetc/cime
 def _case_one_setup(self):
 ###########################################################################
     case_setup(self._case, test_mode=True, reset=True)
Example #40
0
File: case.py Project: ekluzek/cime
    def create_clone(self, newcase, keepexe=False, mach_dir=None, project=None):

        newcaseroot = os.path.abspath(newcase)
        expect(not os.path.isdir(newcaseroot),
               "New caseroot directory %s already exists" % newcaseroot)
        newcasename = os.path.basename(newcaseroot)
        newcase_cimeroot = os.path.abspath(get_cime_root())

        # create clone from self to case
        clone_cimeroot = self.get_value("CIMEROOT")
        if newcase_cimeroot != clone_cimeroot:
            logger.warning(" case  CIMEROOT is %s " %newcase_cimeroot)
            logger.warning(" clone CIMEROOT is %s " %clone_cimeroot)
            logger.warning(" It is NOT recommended to clone cases from different versions of CIME.")


        # *** create case object as deepcopy of clone object ***
        srcroot = os.path.join(newcase_cimeroot,"..")
        newcase = self.copy(newcasename, newcaseroot, newsrcroot=srcroot)
        newcase.set_value("CIMEROOT", newcase_cimeroot)

        # determine if will use clone executable or not
        if keepexe:
            orig_exeroot = self.get_value("EXEROOT")
            newcase.set_value("EXEROOT", orig_exeroot)
            newcase.set_value("BUILD_COMPLETE","TRUE")
        else:
            newcase.set_value("BUILD_COMPLETE","FALSE")

        # set machdir
        if mach_dir is not None:
            newcase.set_value("MACHDIR", mach_dir)

        # Set project id
        # Note: we do not just copy this from the clone because it seems likely that
        # users will want to change this sometimes, especially when cloning another
        # user's case. However, note that, if a project is not given, the fallback will
        # be to copy it from the clone, just like other xml variables are copied.
        if project is None:
            project = self.get_value("PROJECT", subgroup="case.run")
        if project is not None:
            newcase.set_value("PROJECT", project)

        # create caseroot
        newcase.create_caseroot(clone=True)
        newcase.flush(flushall=True)

        # copy user_nl_files
        cloneroot = self._caseroot
        files = glob.glob(cloneroot + '/user_nl_*')
        for item in files:
            shutil.copy(item, newcaseroot)

        # copy SourceMod and Buildconf files
        for casesub in ("SourceMods", "Buildconf"):
            shutil.copytree(os.path.join(cloneroot, casesub), os.path.join(newcaseroot, casesub))

        # copy env_case.xml to LockedFiles
        shutil.copy(os.path.join(newcaseroot,"env_case.xml"), os.path.join(newcaseroot,"LockedFiles"))

        # Update README.case
        fclone   = open(cloneroot + "/README.case", "r")
        fnewcase = open(newcaseroot  + "/README.case", "a")
        fnewcase.write("\n    *** original clone README follows ****")
        fnewcase.write("\n " +  fclone.read())

        clonename = self.get_value("CASE")
        logger.info(" Successfully created new case %s from clone case %s " %(newcasename, clonename))

        case_setup(newcase, clean=False, test_mode=False)

        return newcase
Example #41
0
File: pre.py Project: lxu16/origin
 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")
Example #42
0
File: pre.py Project: apcraig/cime
 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")
Example #43
0
def create_case_clone(case, newcase, keepexe=False, mach_dir=None, project=None,
                      cime_output_root=None, exeroot=None, rundir=None,
                      user_mods_dir=None):
    """
    Create a case clone

    If exeroot or rundir are provided (not None), sets these directories
    to the given paths; if not provided, uses default values for these
    directories. It is an error to provide exeroot if keepexe is True.
    """
    if cime_output_root is None:
        cime_output_root = case.get_value("CIME_OUTPUT_ROOT")

    newcaseroot = os.path.abspath(newcase)
    expect(not os.path.isdir(newcaseroot),
           "New caseroot directory {} already exists".format(newcaseroot))
    newcasename = os.path.basename(newcaseroot)
    newcase_cimeroot = os.path.abspath(get_cime_root())

    # create clone from case to case
    clone_cimeroot = case.get_value("CIMEROOT")
    if newcase_cimeroot != clone_cimeroot:
        logger.warning(" case  CIMEROOT is {} ".format(newcase_cimeroot))
        logger.warning(" clone CIMEROOT is {} ".format(clone_cimeroot))
        logger.warning(" It is NOT recommended to clone cases from different versions of CIME.")

    # *** create case object as deepcopy of clone object ***
    srcroot = os.path.join(newcase_cimeroot,"..")
    newcase = case.copy(newcasename, newcaseroot, newsrcroot=srcroot)
    newcase.set_value("CIMEROOT", newcase_cimeroot)

    # if we are cloning to a different user modify the output directory
    olduser = case.get_value("USER")
    newuser = os.environ.get("USER")
    if olduser != newuser:
        cime_output_root = cime_output_root.replace(olduser, newuser)
        newcase.set_value("USER", newuser)
    newcase.set_value("CIME_OUTPUT_ROOT", cime_output_root)

    # try to make the new output directory and raise an exception
    # on any error other than directory already exists.
    if os.path.isdir(cime_output_root):
        expect(os.access(cime_output_root, os.W_OK), "Directory {} is not writable "
               "by this user.  Use the --cime-output-root flag to provide a writable "
               "scratch directory".format(cime_output_root))
    else:
        try:
            os.makedirs(cime_output_root)
        except:
            if not os.path.isdir(cime_output_root):
                raise

    # determine if will use clone executable or not
    if keepexe:
        orig_exeroot = case.get_value("EXEROOT")
        newcase.set_value("EXEROOT", orig_exeroot)
        newcase.set_value("BUILD_COMPLETE","TRUE")
        orig_bld_complete = case.get_value("BUILD_COMPLETE")
        if not orig_bld_complete:
            logger.warning("\nWARNING: Creating a clone with --keepexe before building the original case may cause PIO_TYPENAME to be invalid in the clone")
            logger.warning("Avoid this message by building case one before you clone.\n")
    else:
        newcase.set_value("BUILD_COMPLETE","FALSE")

    # set machdir
    if mach_dir is not None:
        newcase.set_value("MACHDIR", mach_dir)

    # set exeroot and rundir if requested
    if exeroot is not None:
        expect(not keepexe, "create_case_clone: if keepexe is True, "
               "then exeroot cannot be set")
        newcase.set_value("EXEROOT", exeroot)
    if rundir is not None:
        newcase.set_value("RUNDIR", rundir)

    # Set project id
    # Note: we do not just copy this from the clone because it seems likely that
    # users will want to change this sometimes, especially when cloning another
    # user's case. However, note that, if a project is not given, the fallback will
    # be to copy it from the clone, just like other xml variables are copied.
    if project is None:
        project = case.get_value("PROJECT", subgroup="case.run")
    if project is not None:
        newcase.set_value("PROJECT", project)

    # create caseroot
    newcase.create_caseroot(clone=True)
    newcase.flush(flushall=True)

    # copy user_ files
    cloneroot = case.get_case_root()
    files = glob.glob(cloneroot + '/user_*')

    for item in files:
        shutil.copy(item, newcaseroot)

    # copy SourceMod and Buildconf files
    # if symlinks exist, copy rather than follow links
    for casesub in ("SourceMods", "Buildconf"):
        shutil.copytree(os.path.join(cloneroot, casesub),
                        os.path.join(newcaseroot, casesub),
                        symlinks=True)

    # lock env_case.xml in new case
    lock_file("env_case.xml", newcaseroot)

    # apply user_mods if appropriate
    newcase_root = newcase.get_value("CASEROOT")
    if user_mods_dir is not None:
        if keepexe:
            # If keepexe CANNOT change any env_build.xml variables - so make a temporary copy of
            # env_build.xml and verify that it has not been modified
            shutil.copy(os.path.join(newcaseroot, "env_build.xml"),
                        os.path.join(newcaseroot, "LockedFiles", "env_build.xml"))

        # Now apply contents of user_mods directory
        apply_user_mods(newcase_root, user_mods_dir, keepexe=keepexe)

        # Determine if env_build.xml has changed
        if keepexe:
            success, comment = compare_files(os.path.join(newcaseroot, "env_build.xml"),
                                             os.path.join(newcaseroot, "LockedFiles", "env_build.xml"))
            if not success:
                logger.warning(comment)
                shutil.rmtree(newcase_root)
                expect(False, "env_build.xml cannot be changed via usermods if keepexe is an option: \n "
                           "Failed to clone case, removed {}\n".format(newcase_root))

    # if keep executable, then remove the new case SourceMods directory and link SourceMods to
    # the clone directory
    if keepexe:
        shutil.rmtree(os.path.join(newcase_root, "SourceMods"))
        os.symlink(os.path.join(cloneroot, "SourceMods"),
                   os.path.join(newcase_root, "SourceMods"))

    # Update README.case
    fclone   = open(cloneroot + "/README.case", "r")
    fnewcase = open(newcaseroot  + "/README.case", "a")
    fnewcase.write("\n    *** original clone README follows ****")
    fnewcase.write("\n " +  fclone.read())

    clonename = case.get_value("CASE")
    logger.info(" Successfully created new case {} from clone case {} ".format(newcasename, clonename))

    case_setup(newcase)

    return newcase
Example #44
0
 def _case_two_setup(self):
     self._case.set_value("NINST", 1)
     case_setup(self._case, test_mode=True, reset=True)
Example #45
0
 def _case_two_setup(self):
     for comp in self._case.get_values("COMP_CLASSES"):
         ntasks = self._case.get_value("NTASKS_{}".format(comp))
         if ( ntasks > 1 ):
             self._case.set_value("NTASKS_{}".format(comp), int(ntasks/2))
     case_setup(self._case, reset=True)
Example #46
0
    def create_clone(self,
                     newcase,
                     keepexe=False,
                     mach_dir=None,
                     project=None):

        newcaseroot = os.path.abspath(newcase)
        expect(not os.path.isdir(newcaseroot),
               "New caseroot directory %s already exists" % newcaseroot)
        newcasename = os.path.basename(newcaseroot)
        newcase_cimeroot = os.path.abspath(get_cime_root())

        # create clone from self to case
        clone_cimeroot = self.get_value("CIMEROOT")
        if newcase_cimeroot != clone_cimeroot:
            logger.warning(" case  CIMEROOT is %s " % newcase_cimeroot)
            logger.warning(" clone CIMEROOT is %s " % clone_cimeroot)
            logger.warning(
                " It is NOT recommended to clone cases from different versions of CIME."
            )

        # *** create case object as deepcopy of clone object ***
        srcroot = os.path.join(newcase_cimeroot, "..")
        newcase = self.copy(newcasename, newcaseroot, newsrcroot=srcroot)
        newcase.set_value("CIMEROOT", newcase_cimeroot)

        # determine if will use clone executable or not
        if keepexe:
            orig_exeroot = self.get_value("EXEROOT")
            newcase.set_value("EXEROOT", orig_exeroot)
            newcase.set_value("BUILD_COMPLETE", "TRUE")
        else:
            newcase.set_value("BUILD_COMPLETE", "FALSE")

        # set machdir
        if mach_dir is not None:
            newcase.set_value("MACHDIR", mach_dir)

        # Set project id
        # Note: we do not just copy this from the clone because it seems likely that
        # users will want to change this sometimes, especially when cloning another
        # user's case. However, note that, if a project is not given, the fallback will
        # be to copy it from the clone, just like other xml variables are copied.
        if project is None:
            project = self.get_value("PROJECT", subgroup="case.run")
        if project is not None:
            newcase.set_value("PROJECT", project)

        # create caseroot
        newcase.create_caseroot(clone=True)
        newcase.flush(flushall=True)

        # copy user_nl_files
        cloneroot = self._caseroot
        files = glob.glob(cloneroot + '/user_nl_*')
        for item in files:
            shutil.copy(item, newcaseroot)

        # copy SourceMod and Buildconf files
        for casesub in ("SourceMods", "Buildconf"):
            shutil.copytree(os.path.join(cloneroot, casesub),
                            os.path.join(newcaseroot, casesub))

        # copy env_case.xml to LockedFiles
        shutil.copy(os.path.join(newcaseroot, "env_case.xml"),
                    os.path.join(newcaseroot, "LockedFiles"))

        # Update README.case
        fclone = open(cloneroot + "/README.case", "r")
        fnewcase = open(newcaseroot + "/README.case", "a")
        fnewcase.write("\n    *** original clone README follows ****")
        fnewcase.write("\n " + fclone.read())

        clonename = self.get_value("CASE")
        logger.info(" Successfully created new case %s from clone case %s " %
                    (newcasename, clonename))

        case_setup(newcase, clean=False, test_mode=False)

        return newcase
Example #47
0
    def _case_one_setup(self):
        for comp in self._comp_classes:
            self._case.set_value("NINST_{}".format(comp), 1)

        case_setup(self._case, test_mode=True, reset=True)
Example #48
0
 def _case_two_setup(self):
     for comp in self._comp_classes():
         self._case.set_value("NINST_{}".format(comp), str(1))
         self._case.set_value("ROOTPE_{}".format(comp), 0)
     case_setup(self._case, test_mode=True, reset=True)
Example #49
0
 def _case_one_setup(self):
     # The multicoupler case will increase the number of tasks by the
     # number of requested couplers.
     self._case.set_value("MULTI_DRIVER", True)
     self._case.set_value("NINST", self._test_instances)
     case_setup(self._case, test_mode=False, reset=True)
Example #50
0
                os.path.join(newcaseroot, "env_build.xml"),
                os.path.join(newcaseroot, "LockedFiles", "env_build.xml"))
            if not success:
                logger.warning(comment)
                shutil.rmtree(newcase_root)
                expect(
                    False,
                    "env_build.xml cannot be changed via usermods if keepexe is an option: \n "
                    "Failed to clone case, removed {}\n".format(newcase_root))

    # if keep executable, then remove the new case SourceMods directory and link SourceMods to
    # the clone directory
    if keepexe:
        shutil.rmtree(os.path.join(newcase_root, "SourceMods"))
        os.symlink(os.path.join(cloneroot, "SourceMods"),
                   os.path.join(newcase_root, "SourceMods"))

    # Update README.case
    fclone = open(cloneroot + "/README.case", "r")
    fnewcase = open(newcaseroot + "/README.case", "a")
    fnewcase.write("\n    *** original clone README follows ****")
    fnewcase.write("\n " + fclone.read())

    clonename = case.get_value("CASE")
    logger.info(" Successfully created new case {} from clone case {} ".format(
        newcasename, clonename))

    case_setup(newcase)

    return newcase
Example #51
0
 def _case_one_setup(self):
     ###########################################################################
     case_setup(self._case, test_mode=True, reset=True)
Example #52
0
File: mcc.py Project: Katetc/cime
 def _case_two_setup(self):
     self._case.set_value("NINST", 1)
     case_setup(self._case, test_mode=True, reset=True)
Example #53
0
 def _case_two_setup(self):
     self._case.set_value("MPILIB", "mpi-serial")
     if os.path.isfile("Macros"):
         os.remove("Macros")
     case_setup(self._case, reset=True, test_mode=True)
Example #54
0
    def build_phase(self, sharedlib_only=False, model_only=False):
        """
        Build two cases.  Case one uses defaults, case2 uses half the number of threads
        and tasks. This test will fail for components (e.g. pop) that do not reproduce exactly
        with different numbers of mpi tasks.
        """
        if sharedlib_only:
            return self.build_indv(sharedlib_only=sharedlib_only,
                                   model_only=model_only)

        exeroot = self._case.get_value("EXEROOT")
        cime_model = CIME.utils.get_model()

        # Make backup copies of the ORIGINAL env_mach_pes.xml and
        # env_build.xml in LockedFiles if they are not there. If there
        # are already copies there then simply copy them back to
        # have the starting env_mach_pes.xml and env_build.xml
        machpes1 = os.path.join("LockedFiles", "env_mach_pes.ERP1.xml")
        envbuild1 = os.path.join("LockedFiles", "env_build.ERP1.xml")
        if (os.path.isfile(machpes1)):
            shutil.copy(machpes1, "env_mach_pes.xml")
        else:
            shutil.copy("env_mach_pes.xml", "env_mach_pes.ERP1.xml")

        if (os.path.isfile(envbuild1)):
            shutil.copy(envbuild1, "env_build.xml")

        # Build two executables, one using the original tasks and threads (ERP1) and
        # one using the modified tasks and threads (ERP2)
        # The reason we currently need two executables that CESM-CICE has a compile time decomposition
        # For cases where ERP works, changing this decomposition will not affect answers, but it will
        # affect the executable that is used
        self._case.set_value("SMP_BUILD", "0")
        for bld in range(1, 3):
            logging.warn("Starting bld %s" % bld)

            if (bld == 2):
                # halve the number of tasks and threads
                for comp in self._case.get_values("COMP_CLASSES"):
                    if comp == "DRV":
                        comp = "CPL"
                    ntasks = self._case.get_value("NTASKS_%s" % comp)
                    nthreads = self._case.get_value("NTHRDS_%s" % comp)
                    rootpe = self._case.get_value("ROOTPE_%s" % comp)
                    if (nthreads > 1):
                        self._case.set_value("BUILD_THREADED", True)
                        self._case.set_value("NTHRDS_%s" % comp, nthreads / 2)
                    if (ntasks > 1):
                        self._case.set_value("NTASKS_%s" % comp, ntasks / 2)
                        self._case.set_value("ROOTPE_%s" % comp, rootpe / 2)

                # Note, some components, like CESM-CICE, have
                # decomposition information in env_build.xml
                # case_setup(self._case, test_mode=True, reset=True)that
                # needs to be regenerated for the above new tasks and thread counts
                case_setup(self._case, test_mode=True, reset=True)

            # Now rebuild the system, given updated information in env_build.xml

            self.build_indv(sharedlib_only=sharedlib_only,
                            model_only=model_only)
            shutil.move("%s/%s.exe" % (exeroot, cime_model),
                        "%s/%s.ERP%s.exe" % (exeroot, cime_model, bld))

            # Make copies of the new env_mach_pes.xml and the new
            # env_build.xml to be used in the run phase
            shutil.copy(
                "env_mach_pes.xml",
                os.path.join("LockedFiles", "env_mach_pes.ERP%s.xml" % bld))
            shutil.copy(
                "env_build.xml",
                os.path.join("LockedFiles", "env_build.ERP%s.xml" % bld))