Пример #1
0
 def __init__(self, case_root=None, infile="env_mach_pes.xml", components=None):
     """
     initialize an object interface to file env_mach_pes.xml in the case directory
     """
     self._components = components
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_mach_pes.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #2
0
 def __init__(self, case_root=None, infile="env_mach_pes.xml", components=None):
     """
     initialize an object interface to file env_mach_pes.xml in the case directory
     """
     self._components = components
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_mach_pes.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #3
0
 def __init__(
     self, case_root=None, infile="env_test.xml", components=None, read_only=False
 ):
     """
     initialize an object interface to file env_test.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile, read_only=read_only)
Пример #4
0
    def get_value(self,
                  item,
                  attribute=None,
                  resolved=True,
                  subgroup="case.run"):
        """
        Must default subgroup to something in order to provide single return value
        """

        value = None
        if subgroup is None:
            nodes = self.get_nodes(item, attribute)
            if len(nodes) == 1:
                node = nodes[0]
                value = node.text
                if resolved:
                    value = self.get_resolved_value(value)
            elif not nodes:
                value = EnvBase.get_value(self, item, attribute, resolved)
        else:
            value = EnvBase.get_value(self,
                                      item,
                                      attribute=attribute,
                                      resolved=resolved,
                                      subgroup=subgroup)

        return value
Пример #5
0
 def __init__(self, case_root=None, infile="env_archive.xml"):
     """
     initialize an object interface to file env_archive.xml in the case directory
     """
     schema = os.path.join(get_cime_root(), "config", "xml_schemas",
                           "env_archive.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #6
0
    def get_value(self,
                  item,
                  attribute=None,
                  resolved=True,
                  subgroup="case.run"):
        """
        Must default subgroup to something in order to provide single return value
        """

        value = None
        if subgroup is None:
            node = self.get_optional_child(item, attribute)
            if node is not None:
                value = self.text(node)
                if resolved:
                    value = self.get_resolved_value(value)
            else:
                value = EnvBase.get_value(self, item, attribute, resolved)
        else:
            value = EnvBase.get_value(self,
                                      item,
                                      attribute=attribute,
                                      resolved=resolved,
                                      subgroup=subgroup)

        return value
Пример #7
0
 def __init__(self, case_root=None, infile="env_batch.xml"):
     """
     initialize an object interface to file env_batch.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile)
     self.prereq_jobid = None
     self.batchtype = None
Пример #8
0
 def __init__(self, caseroot, infile="env_mach_specific.xml"):
     """
     initialize an object interface to file env_mach_specific.xml in the case directory
     """
     fullpath = infile if os.path.isabs(infile) else os.path.join(
         caseroot, infile)
     EnvBase.__init__(self, caseroot, fullpath)
Пример #9
0
    def __init__(self,
                 caseroot=None,
                 infile="env_mach_specific.xml",
                 components=None,
                 unit_testing=False,
                 read_only=False,
                 standalone_configure=False,
                 comp_interface=None):
        """
        initialize an object interface to file env_mach_specific.xml in the case directory

        Notes on some arguments:
        standalone_configure: logical - whether this is being called from the standalone
            configure utility, outside of a case
        """
        schema = os.path.join(get_cime_root(), "config", "xml_schemas",
                              "env_mach_specific.xsd")
        EnvBase.__init__(self,
                         caseroot,
                         infile,
                         schema=schema,
                         read_only=read_only)
        self._allowed_mpi_attributes = ("compiler", "mpilib", "threaded",
                                        "unit_testing", "queue",
                                        "comp_interface")
        self._comp_interface = comp_interface
        self._unit_testing = unit_testing
        self._standalone_configure = standalone_configure
Пример #10
0
 def __init__(self, case_root=None, infile="env_batch.xml"):
     """
     initialize an object interface to file env_batch.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile)
     self.prereq_jobid = None
     self.batchtype = None
Пример #11
0
 def __init__(self, case_root=None, infile="env_mach_pes.xml", components=None):
     """
     initialize an object interface to file env_mach_pes.xml in the case directory
     """
     self._components = components
     self._component_value_list = ["NTASKS", "NTHRDS", "NINST",
                                   "ROOTPE", "PSTRID", "NINST_LAYOUT"]
     EnvBase.__init__(self, case_root, infile)
Пример #12
0
 def get_nodes(self, nodename, attributes=None, root=None, xpath=None):
     if nodename in ("JOB_WALLCLOCK_TIME", "PROJECT", "CHARGE_ACCOUNT",
                     "PROJECT_REQUIRED", "JOB_QUEUE", "BATCH_COMMAND_FLAGS"):
         nodes = EnvBase.get_nodes(self, "entry", attributes={"id":nodename},
                                     root=root, xpath=xpath)
     else:
         nodes =  EnvBase.get_nodes(self, nodename, attributes, root, xpath)
     return nodes
Пример #13
0
 def get_nodes(self, nodename, attributes=None, root=None, xpath=None):
     if nodename in ("JOB_WALLCLOCK_TIME", "PROJECT", "PROJECT_REQUIRED",
                     "JOB_QUEUE", "BATCH_COMMAND_FLAGS"):
         nodes = EnvBase.get_nodes(self, "entry", attributes={"id":nodename},
                                     root=root, xpath=xpath)
     else:
         nodes =  EnvBase.get_nodes(self, nodename, attributes, root, xpath)
     return nodes
Пример #14
0
 def __init__(self, caseroot, infile="env_mach_specific.xml"):
     """
     initialize an object interface to file env_mach_specific.xml in the case directory
     """
     fullpath = infile if os.path.isabs(infile) else os.path.join(caseroot, infile)
     EnvBase.__init__(self, caseroot, fullpath)
     self._cshscript = []
     self._shscript = []
Пример #15
0
 def __init__(self,
              case_root=None,
              infile="env_build.xml",
              components=None):
     """
     initialize an object interface to file env_build.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile)
Пример #16
0
    def __init__(self, case_root=None, infile="env_run.xml", components=None, read_only=False):
        """
        initialize an object interface to file env_run.xml in the case directory
        """
        self._components = components
        schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_entry_id.xsd")

        EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)
Пример #17
0
 def __init__(
     self, case_root=None, infile="env_case.xml", components=None, read_only=False
 ):
     """
     initialize an object interface to file env_case.xml in the case directory
     """
     schema = os.path.join(utils.get_schema_path(), "env_entry_id.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)
Пример #18
0
    def get_children(self, name=None, attributes=None, root=None):
        if name in ("JOB_WALLCLOCK_TIME", "PROJECT", "CHARGE_ACCOUNT",
                        "PROJECT_REQUIRED", "JOB_QUEUE", "BATCH_COMMAND_FLAGS"):
            nodes = EnvBase.get_children(self, "entry", attributes={"id":name}, root=root)
        else:
            nodes = EnvBase.scan_children(self, name, attributes=attributes, root=root)

        return nodes
Пример #19
0
    def get_children(self, name=None, attributes=None, root=None):
        if name in ("JOB_WALLCLOCK_TIME", "PROJECT", "CHARGE_ACCOUNT",
                        "PROJECT_REQUIRED", "JOB_QUEUE", "BATCH_COMMAND_FLAGS"):
            nodes = EnvBase.get_children(self, "entry", attributes={"id":name}, root=root)
        else:
            nodes = EnvBase.scan_children(self, name, attributes=attributes, root=root)

        return nodes
Пример #20
0
 def __init__(self, case_root=None, infile="env_batch.xml"):
     """
     initialize an object interface to file env_batch.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile)
     self.prereq_jobid = None
     self.batchtype = None
     # This arbitrary setting should always be overwritten
     self._default_walltime = "00:20:00"
Пример #21
0
    def __init__(self, case_root=None, infile="env_run.xml", components=None, read_only=False):
        """
        initialize an object interface to file env_run.xml in the case directory
        """
        self._components = components
        self._pio_async_interface = False
        schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_entry_id.xsd")

        EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only)
Пример #22
0
 def __init__(self, case_root=None, infile="env_batch.xml"):
     """
     initialize an object interface to file env_batch.xml in the case directory
     """
     self._batchtype = None
     # This arbitrary setting should always be overwritten
     self._default_walltime = "00:20:00"
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_batch.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #23
0
 def __init__(self, caseroot=None, infile="env_mach_specific.xml",
              components=None, unit_testing=False):
     """
     initialize an object interface to file env_mach_specific.xml in the case directory
     """
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_mach_specific.xsd")
     EnvBase.__init__(self, caseroot, infile, schema=schema)
     self._allowed_mpi_attributes = ("compiler", "mpilib", "threaded", "unit_testing")
     self._unit_testing = unit_testing
Пример #24
0
 def __init__(self, caseroot=None, infile="env_mach_specific.xml",
              components=None, unit_testing=False, read_only=False):
     """
     initialize an object interface to file env_mach_specific.xml in the case directory
     """
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_mach_specific.xsd")
     EnvBase.__init__(self, caseroot, infile, schema=schema, read_only=read_only)
     self._allowed_mpi_attributes = ("compiler", "mpilib", "threaded", "unit_testing", "queue")
     self._unit_testing = unit_testing
Пример #25
0
 def __init__(self, case_root=None, infile="env_batch.xml"):
     """
     initialize an object interface to file env_batch.xml in the case directory
     """
     self._batchtype = None
     # This arbitrary setting should always be overwritten
     self._default_walltime = "00:20:00"
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_batch.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #26
0
 def __init__(self, case_root=None, infile="env_batch.xml"):
     """
     initialize an object interface to file env_batch.xml in the case directory
     """
     self.prereq_jobid = None
     self.batchtype = None
     # This arbitrary setting should always be overwritten
     self._default_walltime = "00:20:00"
     EnvBase.__init__(self, case_root, infile)
Пример #27
0
 def __init__(self, case_root=None, infile="env_run.xml", components=None):
     """
     initialize an object interface to file env_run.xml in the case directory
     """
     self._components = components
     self._component_value_list = [
         "PIO_TYPENAME", "PIO_STRIDE", "PIO_REARRANGER", "PIO_NUMTASKS",
         "PIO_ROOT"
     ]
     EnvBase.__init__(self, case_root, infile)
Пример #28
0
 def __init__(self,
              caseroot=None,
              infile="env_mach_specific.xml",
              components=None,
              unit_testing=False):
     """
     initialize an object interface to file env_mach_specific.xml in the case directory
     """
     fullpath = infile if os.path.isabs(infile) else os.path.join(
         caseroot, infile)
     EnvBase.__init__(self, caseroot, fullpath)
     self._unit_testing = unit_testing
Пример #29
0
    def __init__(self, case_root=None, infile="env_run.xml", components=None):
        """
        initialize an object interface to file env_run.xml in the case directory
        """
        self._components = components
        self._component_value_list = [
            "PIO_TYPENAME", "PIO_STRIDE", "PIO_REARRANGER", "PIO_NUMTASKS",
            "PIO_ROOT", "PIO_NETCDF_FORMAT"
        ]
        schema = os.path.join(get_cime_root(), "config", "xml_schemas",
                              "env_entry_id.xsd")

        EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #30
0
 def __init__(self,
              case_root=None,
              infile="env_mach_pes.xml",
              components=None):
     """
     initialize an object interface to file env_mach_pes.xml in the case directory
     """
     self._components = components
     self._component_value_list = [
         "NTASKS", "NTHRDS", "NINST", "ROOTPE", "PSTRID", "NINST_LAYOUT"
     ]
     schema = os.path.join(get_cime_root(), "config", "xml_schemas",
                           "env_mach_pes.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)
Пример #31
0
    def set_value(self, vid, value, subgroup=None, ignore_type=False):
        """
        Set the value of an entry-id field to value
        Returns the value or None if not found
        subgroup is ignored in the general routine and applied in specific methods
        """
        if vid == "MULTI_DRIVER" and value:
            ninst_max = self.get_value("NINST_MAX")
            for comp in self._components:
                if comp == "CPL":
                    continue
                ninst = self.get_value("NINST_{}".format(comp))
                expect(
                    ninst == ninst_max,
                    "All components must have the same NINST value in multi_driver mode.  NINST_{}={} shoud be {}"
                    .format(comp, ninst, ninst_max),
                )
        if "NTASKS" in vid or "NTHRDS" in vid:
            expect(value != 0, "Cannot set NTASKS or NTHRDS to 0")

        return EnvBase.set_value(self,
                                 vid,
                                 value,
                                 subgroup=subgroup,
                                 ignore_type=ignore_type)
Пример #32
0
    def get_value(
        self,
        vid,
        attribute=None,
        resolved=True,
        subgroup=None,
        max_mpitasks_per_node=None,
    ):  # pylint: disable=arguments-differ
        # Special variable NINST_MAX is used to determine the number of
        # drivers in multi-driver mode.
        if vid == "NINST_MAX":
            # in the nuopc driver there is only a single NINST value
            value = 1
            for comp in self._components:
                if comp != "CPL":
                    value = max(value, self.get_value("NINST_{}".format(comp)))
            return value

        value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)

        if "NTASKS" in vid or "ROOTPE" in vid:
            if max_mpitasks_per_node is None:
                max_mpitasks_per_node = self.get_value("MAX_MPITASKS_PER_NODE")
            if value is not None and value < 0:
                value = -1 * value * max_mpitasks_per_node
        # in the nuopc driver there is only one NINST value
        # so that NINST_{comp} = NINST
        if "NINST_" in vid and value is None:
            value = self.get_value("NINST")
        return value
Пример #33
0
    def get_value(self, item, attribute=None, resolved=True, subgroup="case.run"):
        """
        Must default subgroup to something in order to provide single return value
        """
        value = None
        if subgroup is None:
            node = self.get_optional_node(item, attribute)
            if node is not None:
                value = node.text
                if resolved:
                    value = self.get_resolved_value(value)
            else:
                value = EnvBase.get_value(self,item,attribute,resolved)
        else:
            job_node = self.get_optional_node("job", {"name":subgroup})
            if job_node is not None:
                node = self.get_optional_node("entry", {"id":item}, root=job_node)
                if node is not None:
                    value = node.get("value")
                    if resolved:
                        value = self.get_resolved_value(value)

                    # Return value as right type if we were able to fully resolve
                    # otherwise, we have to leave as string.
                    if "$" not in value:
                        type_str = self._get_type_info(node)
                        value = convert_to_type(value, type_str, item)
        return value
Пример #34
0
    def get_value(self,
                  item,
                  attribute=None,
                  resolved=True,
                  subgroup="case.run"):
        """
        Must default subgroup to something in order to provide single return value
        """
        value = None
        if subgroup is None:
            node = self.get_optional_node(item, attribute)
            if node is not None:
                value = node.text
                if resolved:
                    value = self.get_resolved_value(value)
            else:
                value = EnvBase.get_value(self, item, attribute, resolved)
        else:
            job_node = self.get_optional_node("job", {"name": subgroup})
            if job_node is not None:
                node = self.get_optional_node("entry", {"id": item},
                                              root=job_node)
                if node is not None:
                    value = node.get("value")
                    if resolved:
                        value = self.get_resolved_value(value)

                    # Return value as right type if we were able to fully resolve
                    # otherwise, we have to leave as string.
                    if "$" not in value:
                        type_str = self._get_type_info(node)
                        value = convert_to_type(value, type_str, item)
        return value
Пример #35
0
 def get_value(self, vid, attribute=None, resolved=True, subgroup=None):
     value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)
     if value is None:
         tnode = self.get_optional_child("test")
         if tnode is not None:
             value = self.get_element_text(vid, root=tnode)
     return value
Пример #36
0
 def get_value(self, vid, attribute=None, resolved=True, subgroup=None):
     value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)
     if value is None:
         tnode = self.get_optional_child("test")
         if tnode is not None:
             value = self.get_element_text(vid, root=tnode)
     return value
Пример #37
0
    def create_job_groups(self, batch_jobs):
        # Subtle: in order to support dynamic batch jobs, we need to remove the
        # job_submission group and replace with job-based groups

        orig_group = self.get_child(
            "group", {"id": "job_submission"},
            err_msg="Looks like job groups have already been created")
        orig_group_children = EnvBase.get_children(self,
                                                   root=orig_group,
                                                   no_validate=True)

        childnodes = []
        for child in reversed(orig_group_children):
            childnodes.append(self.copy(child))

        self.remove_child(orig_group)

        for name, jdict in batch_jobs:
            new_job_group = self.make_child("group", {"id": name})
            for field in jdict.keys():
                val = jdict[field]
                node = self.make_child("entry", {
                    "id": field,
                    "value": val
                },
                                       root=new_job_group)
                self.make_child("type", root=node, text="char")

            for child in childnodes:
                self.add_child(child, root=new_job_group)
Пример #38
0
    def get_value(self, item, attribute=None, resolved=True, subgroup="case.run"):
        """
        Must default subgroup to something in order to provide single return value
        """

        value = None
        if subgroup is None:
            node = self.get_optional_child(item, attribute)
            if node is not None:
                value = self.text(node)
                if resolved:
                    value = self.get_resolved_value(value)
            else:
                value = EnvBase.get_value(self,item,attribute,resolved)
        else:
            value = EnvBase.get_value(self, item, attribute=attribute, resolved=resolved, subgroup=subgroup)

        return value
Пример #39
0
 def get_value(self, vid, attribute={}, resolved=True, subgroup=None):
     value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)
     if "NTASKS" in vid and value < 0:
         value = -1*value*self.get_value("PES_PER_NODE")
     if "NTHRDS" in vid and value < 0:
         value = -1*value*self.get_value("PES_PER_NODE")
     if "ROOTPE" in vid and value < 0:
         value = -1*value*self.get_value("PES_PER_NODE")
     return value
Пример #40
0
    def get_value(self, vid, attribute=None, resolved=True, subgroup=None, pes_per_node=None): # pylint: disable=arguments-differ
        value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)

        if "NTASKS" in vid or "ROOTPE" in vid:
            if pes_per_node is None:
                pes_per_node = self.get_value("PES_PER_NODE")
            if value is not None and value < 0:
                value = -1*value*pes_per_node

        return value
Пример #41
0
 def set_value(self, vid, value, subgroup=None, ignore_type=False):
     """
     check if vid is in test section of file
     """
     newval = EnvBase.set_value(self, vid, value, subgroup, ignore_type)
     if newval is None:
         tnode = self.get_optional_child("test")
         if tnode is not None:
             newval = self.set_element_text(vid, value, root=tnode)
     return newval
Пример #42
0
    def get_value(self, vid, attribute=None, resolved=True, subgroup=None, pes_per_node=None): # pylint: disable=arguments-differ
        value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)
        if "NTASKS" in vid or "ROOTPE" in vid and pes_per_node is None:
            pes_per_node = self.get_value("PES_PER_NODE")

            if "NTASKS" in vid and value < 0:
                value = -1*value*pes_per_node
            if "ROOTPE" in vid and value < 0:
                value = -1*value*pes_per_node
        return value
Пример #43
0
 def set_value(self, vid, value, subgroup=None, ignore_type=False):
     """
     check if vid is in test section of file
     """
     newval = EnvBase.set_value(self, vid, value, subgroup, ignore_type)
     if newval is None:
         tnode = self.get_optional_child("test")
         if tnode is not None:
             newval = self.set_element_text(vid, value, root=tnode)
     return newval
Пример #44
0
    def get_value(self, item, attribute=None, resolved=True, subgroup="case.run"):
        """
        Must default subgroup to something in order to provide single return value
        """

        value = None
        if subgroup is None:
            nodes = self.get_nodes(item, attribute)
            if len(nodes) == 1:
                node = nodes[0]
                value = node.text
                if resolved:
                    value = self.get_resolved_value(value)
            elif not nodes:
                value = EnvBase.get_value(self,item,attribute,resolved)
        else:
            value = EnvBase.get_value(self, item, attribute=attribute, resolved=resolved, subgroup=subgroup)

        return value
Пример #45
0
    def __init__(
        self,
        case_root=None,
        infile="env_mach_pes.xml",
        components=None,
        read_only=False,
        comp_interface="mct",
    ):
        """
        initialize an object interface to file env_mach_pes.xml in the case directory
        """
        self._components = components
        self._comp_interface = comp_interface

        schema = os.path.join(utils.get_schema_path(), "env_mach_pes.xsd")
        EnvBase.__init__(self,
                         case_root,
                         infile,
                         schema=schema,
                         read_only=read_only)
Пример #46
0
 def cleanupnode(self, node):
     if node.get("id") == "batch_system":
         fnode = node.find(".//file")
         node.remove(fnode)
         gnode = node.find(".//group")
         node.remove(gnode)
         vnode = node.find(".//values")
         if vnode is not None:
             node.remove(vnode)
     else:
         node = EnvBase.cleanupnode(self, node)
     return node
Пример #47
0
    def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False):
        if vid is None:
            vid = node.get("id")

        if "NTASKS" in vid and value < 0:
            value = -1*value*self.get_value("PES_PER_NODE")
        if "NTHRDS" in vid and value < 0:
            value = -1*value*self.get_value("PES_PER_NODE")
        if "ROOTPE" in vid and value < 0:
            value = -1*value*self.get_value("PES_PER_NODE")
        val = EnvBase._set_value(self, node, value, vid, subgroup, ignore_type)
        return val
Пример #48
0
 def cleanupnode(self, node):
     if self.get(node, "id") == "batch_system":
         fnode = self.get_child(name="file", root=node)
         self.remove_child(fnode, root=node)
         gnode = self.get_child(name="group", root=node)
         self.remove_child(gnode, root=node)
         vnode = self.get_optional_child(name="values", root=node)
         if vnode is not None:
             self.remove_child(vnode, root=node)
     else:
         node = EnvBase.cleanupnode(self, node)
     return node
Пример #49
0
 def cleanupnode(self, node):
     if node.get("id") == "batch_system":
         fnode = node.find(".//file")
         node.remove(fnode)
         gnode = node.find(".//group")
         node.remove(gnode)
         vnode = node.find(".//values")
         if vnode is not None:
             node.remove(vnode)
     else:
         node = EnvBase.cleanupnode(self, node)
     return node
Пример #50
0
    def _set_value(self, node, value, vid=None, subgroup=None, ignore_type=False, pes_per_node=None): # pylint: disable=arguments-differ
        if vid is None:
            vid = node.get("id")

        if "NTASKS" in vid or "ROOTPE" in vid and pes_per_node is None:
            pes_per_node = self.get_value("PES_PER_NODE")

        if "NTASKS" in vid and value < 0:
            value = -1*value*pes_per_node
        if "ROOTPE" in vid and value < 0:
            value = -1*value*pes_per_node
        val = EnvBase._set_value(self, node, value, vid, subgroup, ignore_type)
        return val
Пример #51
0
    def set_value(self, vid, value, subgroup=None, ignore_type=False):
        """
        Set the value of an entry-id field to value
        Returns the value or None if not found
        subgroup is ignored in the general routine and applied in specific methods
        """
        if vid == "MULTI_DRIVER" and value:
            ninst_max = self.get_value("NINST_MAX")
            for comp in self._components:
                if comp == "CPL":
                    continue
                ninst = self.get_value("NINST_{}".format(comp))
                expect(ninst == ninst_max,
                       "All components must have the same NINST value in multi_driver mode.  NINST_{}={} shoud be {}".format(comp,ninst,ninst_max))

        return EnvBase.set_value(self, vid, value, subgroup=subgroup, ignore_type=ignore_type)
Пример #52
0
    def get_value(self, vid, attribute=None, resolved=True, subgroup=None, MAX_MPITASKS_PER_NODE=None): # pylint: disable=arguments-differ
        # Special variable NINST_MAX is used to determine the number of
        # drivers in multi-driver mode.
        if vid == "NINST_MAX":
            value = 1
            for comp in self._components:
                if comp != "CPL":
                    value = max(value, self.get_value("NINST_{}".format(comp)))
            return value

        value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)

        if "NTASKS" in vid or "ROOTPE" in vid:
            if MAX_MPITASKS_PER_NODE is None:
                MAX_MPITASKS_PER_NODE = self.get_value("MAX_MPITASKS_PER_NODE")
            if value is not None and value < 0:
                value = -1*value*MAX_MPITASKS_PER_NODE

        return value
Пример #53
0
    def get_value(self, vid, attribute=None, resolved=True, subgroup=None, max_mpitasks_per_node=None): # pylint: disable=arguments-differ
        # Special variable NINST_MAX is used to determine the number of
        # drivers in multi-driver mode.
        if vid == "NINST_MAX":
            # in the nuopc driver there is only a single NINST value
            value = 1
            for comp in self._components:
                if comp != "CPL":
                    value = max(value, self.get_value("NINST_{}".format(comp)))
            return value

        value = EnvBase.get_value(self, vid, attribute, resolved, subgroup)

        if "NTASKS" in vid or "ROOTPE" in vid:
            if max_mpitasks_per_node is None:
                max_mpitasks_per_node = self.get_value("MAX_MPITASKS_PER_NODE")
            if value is not None and value < 0:
                value = -1*value*max_mpitasks_per_node
        # in the nuopc driver there is only one NINST value
        # so that NINST_{comp} = NINST
        if "NINST_" in vid and value is None:
            value = self.get_value("NINST")
        return value
Пример #54
0
    def create_job_groups(self, batch_jobs):
        # Subtle: in order to support dynamic batch jobs, we need to remove the
        # job_submission group and replace with job-based groups

        orig_group = self.get_child("group", {"id":"job_submission"},
                                    err_msg="Looks like job groups have already been created")
        orig_group_children = EnvBase.get_children(self, root=orig_group)

        childnodes = []
        for child in reversed(orig_group_children):
            childnodes.append(child)

        self.remove_child(orig_group)

        for name, jdict in batch_jobs:
            new_job_group = self.make_child("group", {"id":name})
            for field in jdict.keys():
                val = jdict[field]
                node = self.make_child("entry", {"id":field,"value":val}, root=new_job_group)
                self.make_child("type", root=node, text="char")

            for child in childnodes:
                self.add_child(self.copy(child), root=new_job_group)
Пример #55
0
 def __init__(self, case_root=None, infile="env_build.xml"):
     """
     initialize an object interface to file env_build.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile)
Пример #56
0
 def __init__(self, case_root=None, infile="env_test.xml", components=None, read_only=False):
     """
     initialize an object interface to file env_test.xml in the case directory
     """
     EnvBase.__init__(self, case_root, infile, read_only=read_only)
Пример #57
0
 def __init__(self, case_root=None, infile="env_archive.xml"):
     """
     initialize an object interface to file env_archive.xml in the case directory
     """
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_archive.xsd")
     EnvBase.__init__(self, case_root, infile, schema=schema)