fab.tools.compiler_wrapper#

This file contains the base class for any compiler-wrapper, including the derived classes for mpif90, mpicc, and CrayFtnWrapper and CrayCcWrapper.

Classes

CompilerWrapper(name, exec_name, compiler[, mpi])

A decorator-based compiler wrapper.

CrayCcWrapper(compiler)

Class for the Cray C compiler wrapper.

CrayFtnWrapper(compiler)

Class for the Cray Fortran compiler wrapper.

Mpicc(compiler)

Class for a simple wrapper for using a compiler driver (like mpicc) It will be using the name "mpicc-COMPILER_NAME" and calls mpicc.

Mpif90(compiler)

Class for a simple wrapper for using a compiler driver (like mpif90) It will be using the name "mpif90-COMPILER_NAME" and calls mpif90.

class fab.tools.compiler_wrapper.CompilerWrapper(name, exec_name, compiler, mpi=False)#

A decorator-based compiler wrapper. It basically uses a different executable name when compiling, but otherwise behaves like the wrapped compiler. An example of a compiler wrapper is mpif90 (which can internally call e.g. gfortran, icc, …)

Parameters:
  • name (str) – name of the wrapper.

  • exec_name (str) – name of the executable to call.

  • compiler (Compiler) – the compiler that is decorated.

  • mpi (bool) – whether MPI is supported by this compiler or not. (default: False)

property compiler: Compiler#
Returns:

the compiler that is wrapped by this CompilerWrapper.

property suite: str#
Returns:

the compiler suite of this tool.

property openmp_flag: str#

Returns the flag to enable OpenMP.

property has_syntax_only: bool#
Returns:

whether this compiler supports a syntax-only feature.

Raises:

RuntimeError – if this function is called for a non-Fortran wrapped compiler.

get_flags(profile=None)#
Return type:

List[str]

Returns:

the ProfileFlags for the given profile, combined from the wrapped compiler and this wrapper.

Parameters:

profile (Optional[str]) – the profile to use. (default: None)

set_module_output_path(path)#

Sets the output path for modules.

Params path:

the path to the output directory.

Raises:

RuntimeError – if this function is called for a non-Fortran wrapped compiler.

get_all_commandline_options(config, input_file, output_file, add_flags=None, syntax_only=False)#

This function returns all command line options for a compiler wrapper. The syntax_only flag is only accepted, if the wrapped compiler is a Fortran compiler. Otherwise, an exception will be raised.

Parameters:
  • input_file (Path) – the name of the input file.

  • output_file (Path) – the name of the output file.

  • config (BuildConfig) – The BuildConfig, from which compiler profile and OpenMP status are taken.

  • add_flags (Optional[List[str]]) – additional flags for the compiler. (default: None)

  • syntax_only (Optional[bool]) – if set, the compiler will only do a syntax check (default: False)

Return type:

List[str]

Returns:

command line flags for compiler wrapper.

Raises:

RuntimeError – if syntax_only is requested for a non-Fortran compiler.

compile_file(input_file, output_file, config, add_flags=None, syntax_only=None)#

Compiles a file using the wrapper compiler.

Parameters:
  • input_file (Path) – the name of the input file.

  • output_file (Path) – the name of the output file.

  • config (BuildConfig) – The BuildConfig, from which compiler profile and OpenMP status are taken.

  • add_flags (Optional[List[str]]) – additional flags for the compiler. (default: None)

  • syntax_only (Optional[bool]) – if set, the compiler will only do a syntax check (default: None)

class fab.tools.compiler_wrapper.Mpif90(compiler)#

Class for a simple wrapper for using a compiler driver (like mpif90) It will be using the name “mpif90-COMPILER_NAME” and calls mpif90. All flags from the original compiler will be used when using the wrapper as compiler.

Parameters:

compiler (Compiler) – the compiler that the mpif90 wrapper will use.

class fab.tools.compiler_wrapper.Mpicc(compiler)#

Class for a simple wrapper for using a compiler driver (like mpicc) It will be using the name “mpicc-COMPILER_NAME” and calls mpicc. All flags from the original compiler will be used when using the wrapper as compiler.

Parameters:

compiler (Compiler) – the compiler that the mpicc wrapper will use.

class fab.tools.compiler_wrapper.CrayFtnWrapper(compiler)#

Class for the Cray Fortran compiler wrapper. We add ‘wrapper’ to the class name to make this class distinct from the Crayftn compiler class.

Parameters:

compiler (Compiler) – the compiler that the ftn wrapper will use.

class fab.tools.compiler_wrapper.CrayCcWrapper(compiler)#

Class for the Cray C compiler wrapper. We add ‘wrapper’ to the class name to make this class distinct from the Craycc compiler class

Parameters:

compiler (Compiler) – the compiler that the mpicc wrapper will use.