fab.steps.compile_fortran module#

Fortran file compilation.

class fab.steps.compile_fortran.MpCommonArgs(config, flags, mod_hashes, syntax_only)#

Bases: object

Arguments to be passed into the multiprocessing function, alongside the filenames.

config: BuildConfig#
flags: FlagsConfig#
mod_hashes: Dict[str, int]#
syntax_only: bool#
fab.steps.compile_fortran.compile_fortran(config, common_flags=None, path_flags=None, source=None)#

Compiles all Fortran files in all build trees, creating/extending a set of compiled files for each build target.

Files are compiled in multiple passes, with each pass enabling further files to be compiled in the next pass.

Uses multiprocessing, unless disabled in the config.

Parameters:
fab.steps.compile_fortran.handle_compiler_args(config, common_flags=None, path_flags=None)#
fab.steps.compile_fortran.compile_pass(config, compiled, uncompiled, mp_common_args, mod_hashes)#
fab.steps.compile_fortran.get_compile_next(compiled, uncompiled)#
Return type:

Set[AnalysedFortran]

fab.steps.compile_fortran.store_artefacts(compiled_files, build_lists, artefact_store)#

Create our artefact collection; object files for each compiled file, per root symbol.

fab.steps.compile_fortran.process_file(arg)#

Prepare to compile a fortran file, and compile it if anything has changed since it was last compiled.

Object files are created directly as artefacts in the prebuild folder. Mod files are created in the module folder and copied as artefacts into the prebuild folder. If nothing has changed, prebuilt mod files are copied from the prebuild folder into the module folder. :rtype: Union[Tuple[CompiledFile, List[Path]], Tuple[Exception, None]]

Note

Prebuild filenames include a “combo-hash” of everything that, if changed, must trigger a recompile. For mod and object files, this includes a checksum of: source code, compiler. For object files, this also includes a checksum of: compiler flags, modules on which we depend.

Before compiling a file, we calculate the combo hashes and see if the output files already exists.

Returns a compilation result, regardless of whether it was compiled or prebuilt.

fab.steps.compile_fortran.compile_file(analysed_file, flags, output_fpath, mp_common_args)#

Call the compiler.

The current working folder for the command is set to the folder where the source file lives when compile_file is called. This is done to stop the compiler inserting folder information into the mod files, which would cause them to have different checksums depending on where they live.

fab.steps.compile_fortran.get_mod_hashes(analysed_files, config)#

Get the hash of every module file defined in the list of analysed files.

Return type:

Dict[str, int]