fab.tools.tool_repository#
This file contains the ToolRepository class.
Classes
This class implements the tool repository. |
- class fab.tools.tool_repository.ToolRepository#
This class implements the tool repository. It stores a list of tools for various categories. For each compiler, it will automatically create a tool called “linker-{compiler-name}” which can be used for linking with the specified compiler.
Singleton access. Changes the value of _singleton so that the constructor can verify that it is indeed called from here.
- add_tool(tool)#
Creates an instance of the specified class and adds it to the tool repository. If the tool is a compiler, it automatically adds the compiler as a linker as well (named “linker-{tool.name}”).
- Parameters:
tool (
Tool
) – the tool to add.
- get_tool(category, name)#
This functions returns a tool with a given name. The name can either be a Fab compiler name (including wrapper naming), e.g. mpif90-gfortran, or linker-mpif90-ifort, or just the name of the executable (mpif90). If a Fab name is specified, the corresponding tool will be returned, even if it should not be available (allowing default site scripts to setup any compiler, even if they are not available everywhere). If an exec name is specified, the tool must be available. This is required to make sure the user gets the right tool: by specifying just mpif90, it is not clear if the user wants mpif90-ifort, mpif90-gfortran, … . But only one of these tools will actually be available (the wrapper checks the version number to detect the compiler-vendor).
The name can also be specified using an absolute path, in which case only the stem will be used to look up the name, but the returned tool will be updated to use the full path to the tool. This allows the usage of e.g. compilers that are not in $PATH of the user.
- Return type:
- Returns:
the tool with a given name in the specified category.
- Parameters:
- Raises:
- set_default_compiler_suite(suite)#
Sets the default for linker and compilers to be of the given compiler suite.
- Parameters:
suite (
str
) – the name of the compiler suite to make the default.
- get_default(category, mpi=None, openmp=None)#
Returns the default tool for a given category that is available. For most tools that will be the first entry in the list of tools. The exception are compilers and linker: in this case it must be specified if MPI support is required or not. And the default return will be the first tool that either supports MPI or not.
- Parameters:
- Raises:
KeyError – if the category does not exist.
RuntimeError – if no tool in the requested category is available on the system.
RuntimeError – if no compiler/linker is found with the requested level of MPI support (yes or no).