loki.build.compiler

Functions

clean(filename[, pattern])

Clean up compilation files of previous runs.

compile(filename[, include_dirs, compiler, cwd])

compile_and_load(filename[, cwd, ...])

Just-in-time compile Fortran source code and load the respective module or class.

Classes

Compiler()

Base class for specifying different compiler toolchains.

EscapeGNUCompiler()

GNUCompiler()

clean(filename, pattern=None)

Clean up compilation files of previous runs.

Parameters:
  • filename – Filename that triggered the original compilation.

  • suffixes – Optional list of filetype suffixes to delete.

compile(filename, include_dirs=None, compiler=None, cwd=None)
compile_and_load(filename, cwd=None, use_f90wrap=True, f90wrap_kind_map=None)

Just-in-time compile Fortran source code and load the respective module or class.

Both paths, classic subroutine-only and modern module-based are supported via the f2py and f90wrap packages.

Parameters:
  • filename (str) – The source file to be compiled.

  • cwd (str, optional) – Working directory to use for calls to compiler.

  • use_f90wrap (bool, optional) – Flag to trigger the f90wrap compiler required if the source code includes module or derived types.

  • f90wrap_kind_map (str, optional) – Path to f90wrap KIND_MAP file, containing a Python dictionary in f2py_f2cmap format.

class Compiler

Bases: object

Base class for specifying different compiler toolchains.

CC = None
CFLAGS = None
F90 = None
F90FLAGS = None
FC = None
FCFLAGS = None
LD = None
LDFLAGS = None
LD_STATIC = None
LDFLAGS_STATIC = None
compile_args(source, target=None, include_dirs=None, mod_dir=None, mode='F90')

Generate arguments for the build line.

Parameters:

mode – One of 'f90' (free form), 'f' (fixed form) or 'c'.

compile(source, target=None, include_dirs=None, use_c=False, cwd=None)

Execute a build command for a given source.

linker_args(objs, target, shared=True)

Generate arguments for the linker line.

Execute a link command for a given source.

static f90wrap_args(modname, source, kind_map=None)

Generate arguments for the f90wrap utility invocation line.

f90wrap(modname, source, cwd=None, kind_map=None)

Invoke f90wrap command to create wrappers for a given module.

static f2py_args(modname, source, libs=None, lib_dirs=None, incl_dirs=None)

Generate arguments for the f2py-f90wrap utility invocation line.

f2py(modname, source, libs=None, lib_dirs=None, incl_dirs=None, cwd=None)

Invoke f90wrap command to create wrappers for a given module.

class GNUCompiler

Bases: Compiler

CC = 'gcc'
CFLAGS = ['-g', '-fPIC']
F90 = 'gfortran'
F90FLAGS = ['-g', '-fPIC']
LD = 'gfortran'
LDFLAGS = []
class EscapeGNUCompiler

Bases: GNUCompiler

F90FLAGS = ['-O3', '-g', '-fPIC', '-ffpe-trap=invalid,zero,overflow', '-fstack-arrays', '-fconvert=big-endian', '-fbacktrace', '-fno-second-underscore', '-ffree-form', '-ffast-math', '-fno-unsafe-math-optimizations']