loki.build.compiler
Functions
  | 
Clean up compilation files of previous runs.  | 
  | 
|
  | 
Just-in-time compile Fortran source code and load the respective module or class.  | 
  | 
Utility function to determine what compiler to use  | 
Classes
  | 
Base class for specifying different compiler toolchains.  | 
GNU compiler configuration for gcc and gfortran  | 
|
NVHPC compiler configuration for nvc and nvfortran  | 
- 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, f90wrap_kind_map=None, compiler=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
f2pyandf90wrappackages.- Parameters:
 filename (str) – The source file to be compiled.
cwd (str, optional) – Working directory to use for calls to compiler.
f90wrap_kind_map (str, optional) – Path to
f90wrapKIND_MAP file, containing a Python dictionary in f2py_f2cmap format.compiler (
Compiler, optional) – Use the specified compiler to compile the Fortran source code. Defaults to_default_compiler
- class Compiler
 Bases:
objectBase 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
 
- F2PY_FCOMPILER_TYPE = None
 
- compile_args(source, target=None, include_dirs=None, mod_dir=None, mode='f90')
 Generate arguments for the build line.
Parameters:
- sourcestr or pathlib.Path
 Path to the source file to compile
- targetstr or pathlib.Path, optional
 Path to the output binary to generate
- include_dirslist of str or pathlib.Path, optional
 Path of include directories to specify during compile
- mod_dirstr or pathlib.Path, optional
 Path to directory containing Fortran .mod files
- modestr, optional
 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.
- link(objs, target, shared=True, cwd=None)
 Execute a link command for a given source.
- static f90wrap_args(modname, source, kind_map=None)
 Generate arguments for the
f90wraputility invocation line.
- f90wrap(modname, source, cwd=None, kind_map=None)
 Invoke f90wrap command to create wrappers for a given module.
- f2py_args(modname, source, libs=None, lib_dirs=None, incl_dirs=None)
 Generate arguments for the
f2py-f90wraputility 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.
- get_compiler_from_env(env=None)
 Utility function to determine what compiler to use
This takes the following environment variables in the given order into account to determine the most likely compiler family:
F90,FC,CC.Currently,
GNUCompilerandNvidiaCompilerare available.The compiler binary and flags can be further overwritten by setting the corresponding environment variables:
CC,FC,F90,LDfor compiler/linker binary name or pathCFLAGS,FCFLAGS,LDFLAGSfor compiler/linker flags to use
- Parameters:
 env (dict, optional) – Use the specified environment (default:
os.environ)- Returns:
 A compiler object
- Return type:
 
- class GNUCompiler
 Bases:
CompilerGNU compiler configuration for gcc and gfortran
- CC = 'gcc'
 
- CFLAGS = ['-g', '-fPIC']
 
- F90 = 'gfortran'
 
- F90FLAGS = ['-g', '-fPIC']
 
- FC = 'gfortran'
 
- FCFLAGS = ['-g', '-fPIC']
 
- LD = 'gfortran'
 
- LDFLAGS = ['-static']
 
- LD_STATIC = 'ar'
 
- LDFLAGS_STATIC = ['src']
 
- F2PY_FCOMPILER_TYPE = 'gnu95'
 
- CC_PATTERN = re.compile('(^|/|\\\\)gcc\\b')
 
- FC_PATTERN = re.compile('(^|/|\\\\)gfortran\\b')
 
- class NvidiaCompiler
 Bases:
CompilerNVHPC compiler configuration for nvc and nvfortran
- CC = 'nvc'
 
- CFLAGS = ['-g', '-fPIC']
 
- F90 = 'nvfortran'
 
- F90FLAGS = ['-g', '-fPIC']
 
- FC = 'nvfortran'
 
- FCFLAGS = ['-g', '-fPIC']
 
- LD = 'nvfortran'
 
- LDFLAGS = ['-static']
 
- LD_STATIC = 'ar'
 
- LDFLAGS_STATIC = ['src']
 
- F2PY_FCOMPILER_TYPE = 'nv'
 
- CC_PATTERN = re.compile('(^|/|\\\\)nvc\\b')
 
- FC_PATTERN = re.compile('(^|/|\\\\)(pgf9[05]|pgfortran|nvfortran)\\b')