コード例 #1
0
ファイル: compilers.py プロジェクト: Katetc/cime
    def __init__(self, machobj, infile=None, compiler=None, mpilib=None, files=None, version=None):
        """
        initialize an object
        """

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
            schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._machobj = machobj
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self.machine  = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler       = compiler

        if mpilib is None:
            if compiler is None:
                mpilib = machobj.get_default_MPIlib()
            else:
                mpilib = machobj.get_default_MPIlib(attributes={'compiler':compiler})
        self.mpilib = mpilib

        self.compiler_nodes = None # Listed from last to first
        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            schema_db = GenericXML(infile=schema)
            compiler_vars = schema_db.get_child("{http://www.w3.org/2001/XMLSchema}group", attributes={"name":"compilerVars"})
            choice  = schema_db.get_child(name="{http://www.w3.org/2001/XMLSchema}choice", root=compiler_vars)
            self.flag_vars = set(schema_db.get(elem, "name") for elem in schema_db.get_children(root=choice, attributes={"type":"flagsVar"}))
コード例 #2
0
ファイル: compilers.py プロジェクト: sarats/ACME
    def __init__(self,
                 machobj,
                 infile=None,
                 compiler=None,
                 mpilib=None,
                 files=None,
                 version=None):
        """
        initialize an object
        """

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
            schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._machobj = machobj
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self.machine = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler = compiler

        if mpilib is None:
            if compiler is None:
                mpilib = machobj.get_default_MPIlib()
            else:
                mpilib = machobj.get_default_MPIlib(
                    attributes={'compiler': compiler})
        self.mpilib = mpilib

        self.compiler_nodes = None  # Listed from last to first
        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"), ".cime",
                              "config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            schema_db = GenericXML(infile=schema)
            compiler_vars = schema_db.get_child(
                "{http://www.w3.org/2001/XMLSchema}group",
                attributes={"name": "compilerVars"})
            choice = schema_db.get_child(
                name="{http://www.w3.org/2001/XMLSchema}choice",
                root=compiler_vars)
            self.flag_vars = set(
                schema_db.get(elem, "name") for elem in schema_db.get_children(
                    root=choice, attributes={"type": "flagsVar"}))
コード例 #3
0
ファイル: compilers.py プロジェクト: sjsprecious/cime
    def __init__(
        self,
        machobj,
        infile=None,
        compiler=None,
        mpilib=None,
        files=None,
        version=None,
        extra_machines_dir=None,
    ):
        """
        initialize an object

        If extra_machines_dir is provided, it should be a string giving a path to an
        additional directory that will be searched for a config_compilers.xml file; if
        found, the contents of this file will be appended to the standard
        config_compilers.xml. An empty string is treated the same as None.
        """

        expect(
            "CIME_NO_CMAKE_MACRO" in os.environ,
            "Should not be using config_compilers.xml without CIME_NO_CMAKE_MACRO",
        )

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
        schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self._machobj = machobj
        self.machine = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler = compiler

        if mpilib is None:
            if compiler is None:
                mpilib = machobj.get_default_MPIlib()
            else:
                mpilib = machobj.get_default_MPIlib(attributes={"compiler": compiler})
        self.mpilib = mpilib

        self.compiler_nodes = None  # Listed from last to first
        # Append the contents of $HOME/.cime/config_compilers.xml if it exists.
        #
        # Also append the contents of a config_compilers.xml file in the directory given by
        # extra_machines_dir, if present.
        #
        # This could cause problems if node matches are repeated when only one is expected.
        infile = os.path.join(os.environ.get("HOME"), ".cime", "config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile, schema=schema)
        if extra_machines_dir:
            infile = os.path.join(extra_machines_dir, "config_compilers.xml")
            if os.path.exists(infile):
                GenericXML.read(self, infile, schema=schema)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            schema_db = GenericXML(infile=schema)
            compiler_vars = schema_db.get_child(
                "{http://www.w3.org/2001/XMLSchema}group",
                attributes={"name": "compilerVars"},
            )
            choice = schema_db.get_child(
                name="{http://www.w3.org/2001/XMLSchema}choice", root=compiler_vars
            )
            self.flag_vars = set(
                schema_db.get(elem, "name")
                for elem in schema_db.get_children(
                    root=choice, attributes={"type": "flagsVar"}
                )
            )