compiler_t Derived Type

type, public, extends(serializable_t) :: compiler_t

Definition of compiler object


Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: cc

Path to the C compiler

character(len=:), public, allocatable :: cxx

Path to the C++ compiler

logical, public :: echo = .true.

Print all commands

character(len=:), public, allocatable :: fc

Path to the Fortran compiler

integer(kind=compiler_enum), public :: id = id_unknown

Identifier of the compiler

logical, public :: verbose = .true.

Verbose output of command


Type-Bound Procedures

procedure, public :: check_fortran_source_runs

Fortran feature support

  • public function check_fortran_source_runs(self, input) result(success)

    Run a single-source Fortran program using the current compiler Compile a Fortran object Create temporary source file Write contents Compile and link program Run and retrieve exit code

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    character(len=*), intent(in) :: input

    Program Source

    Return Value logical

procedure, public :: compile_c

Compile a C object

  • public subroutine compile_c(self, input, output, args, log_file, stat)

    Compile a C object

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    character(len=*), intent(in) :: input

    Source file input

    character(len=*), intent(in) :: output

    Output file of object

    character(len=*), intent(in) :: args

    Arguments for compiler

    character(len=*), intent(in) :: log_file

    Compiler output log file

    integer, intent(out) :: stat

    Status flag

procedure, public :: compile_cpp

Compile a CPP object

  • public subroutine compile_cpp(self, input, output, args, log_file, stat)

    Compile a CPP object

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    character(len=*), intent(in) :: input

    Source file input

    character(len=*), intent(in) :: output

    Output file of object

    character(len=*), intent(in) :: args

    Arguments for compiler

    character(len=*), intent(in) :: log_file

    Compiler output log file

    integer, intent(out) :: stat

    Status flag

procedure, public :: compile_fortran

Compile a Fortran object

  • public subroutine compile_fortran(self, input, output, args, log_file, stat)

    Compile a Fortran object

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    character(len=*), intent(in) :: input

    Source file input

    character(len=*), intent(in) :: output

    Output file of object

    character(len=*), intent(in) :: args

    Arguments for compiler

    character(len=*), intent(in) :: log_file

    Compiler output log file

    integer, intent(out) :: stat

    Status flag

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit

  • private subroutine srcfile_dump_to_toml(self, table, error)

    Dump dependency to toml table

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine dump_to_file(self, file, error, json)

    Write serializable object to file

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    character(len=*), intent(in) :: file

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

  • private subroutine dump_to_unit(self, unit, error, json)

    Write serializable object to a formatted Fortran unit

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    integer, intent(in) :: unit

    Formatted unit

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format requested?

procedure, public :: dump_to_toml => compiler_dump

  • public subroutine compiler_dump(self, table, error)

    Dump dependency to toml table

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

procedure, public :: enumerate_libraries

Enumerate libraries, based on compiler and platform

  • public function enumerate_libraries(self, prefix, libs) result(r)

    Enumerate libraries, based on compiler and platform

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self
    character(len=*), intent(in) :: prefix
    type(string_t), intent(in) :: libs(:)

    Return Value character(len=:), allocatable

procedure, public :: get_default_flags

Get default compiler flags

  • public function get_default_flags(self, release) result(flags)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self
    logical, intent(in) :: release

    Return Value character(len=:), allocatable

procedure, public :: get_feature_flag

Get feature flag

  • public function get_feature_flag(self, feature) result(flags)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self
    character(len=*), intent(in) :: feature

    Return Value character(len=:), allocatable

procedure, public :: get_include_flag

Get flag for include directories

  • public function get_include_flag(self, path) result(flags)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self
    character(len=*), intent(in) :: path

    Return Value character(len=:), allocatable

procedure, public :: get_main_flags

Get flags for the main linking command

  • public subroutine get_main_flags(self, language, flags)

    Get special flags for the main linker

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self
    character(len=*), intent(in) :: language
    character(len=:), intent(out), allocatable :: flags

procedure, public :: get_module_flag

Get flag for module output directories

  • public function get_module_flag(self, path) result(flags)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self
    character(len=*), intent(in) :: path

    Return Value character(len=:), allocatable

procedure, public :: is_gnu

Check whether this is a GNU compiler

  • public pure function is_gnu(self)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Return Value logical

procedure, public :: is_intel

Check whether this is an Intel compiler

  • public pure function is_intel(self)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Return Value logical

procedure, public :: is_unknown

Check whether compiler is recognized

  • public pure function is_unknown(self)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Return Value logical

procedure, public :: link

Link executable

  • public subroutine link(self, output, args, log_file, stat)

    Link an executable

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    character(len=*), intent(in) :: output

    Output file of object

    character(len=*), intent(in) :: args

    Arguments for compiler

    character(len=*), intent(in) :: log_file

    Compiler output log file

    integer, intent(out) :: stat

    Status flag

generic, public :: load => load_from_toml, load_from_file, load_from_unit

  • private subroutine srcfile_load_from_toml(self, table, error)

    Read dependency from toml table (no checks made at this stage)

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine load_from_file(self, file, error, json)

    Read dependency tree from file

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    character(len=*), intent(in) :: file

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

  • private subroutine load_from_unit(self, unit, error, json)

    Read dependency tree from file init JSON interpreter Read object from TOML table

    use default TOML parser

    Read object from TOML table

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    integer, intent(in) :: unit

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

procedure, public :: load_from_toml => compiler_load

  • public subroutine compiler_load(self, table, error)

    Read dependency from toml table (no checks made at this stage)

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

procedure, public :: name => compiler_name

Return compiler name

  • public pure function compiler_name(self) result(name)

    Return a compiler name string

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    Return Value character(len=:), allocatable

    Representation as string

generic, public :: operator(==) => serializable_is_same

  • private function srcfile_is_same(this, that)

    Check that two source files are equal All checks passed!

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(in) :: this
    class(serializable_t), intent(in) :: that

    Return Value logical

procedure, public :: serializable_is_same => compiler_is_same

Serialization interface

  • public function compiler_is_same(this, that)

    Check that two compiler_t objects are equal All checks passed!

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: this
    class(serializable_t), intent(in) :: that

    Return Value logical

procedure, public, non_overridable :: test_serialization

Test load/write roundtrip

  • private subroutine test_serialization(self, message, error)

    Test serialization of a serializable object Dump to scratch file Load from scratch file Check same

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self
    character(len=*), intent(in) :: message
    type(error_t), intent(out), allocatable :: error

procedure, public :: with_qp

  • public function with_qp(self)

    Check if the current compiler supports 128-bit real precision

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    Return Value logical

procedure, public :: with_xdp

  • public function with_xdp(self)

    Check if the current compiler supports 80-bit “extended” real precision

    Arguments

    Type IntentOptional Attributes Name
    class(compiler_t), intent(in) :: self

    Instance of the compiler object

    Return Value logical

Source Code

type, extends(serializable_t) :: compiler_t
    !> Identifier of the compiler
    integer(compiler_enum) :: id = id_unknown
    !> Path to the Fortran compiler
    character(len=:), allocatable :: fc
    !> Path to the C compiler
    character(len=:), allocatable :: cc
    !> Path to the C++ compiler
    character(len=:), allocatable :: cxx
    !> Print all commands
    logical :: echo = .true.
    !> Verbose output of command
    logical :: verbose = .true.
contains
    !> Get default compiler flags
    procedure :: get_default_flags
    !> Get flag for module output directories
    procedure :: get_module_flag
    !> Get flag for include directories
    procedure :: get_include_flag
    !> Get feature flag
    procedure :: get_feature_flag
    !> Get flags for the main linking command
    procedure :: get_main_flags
    !> Compile a Fortran object
    procedure :: compile_fortran
    !> Compile a C object
    procedure :: compile_c
    !> Compile a CPP object
    procedure :: compile_cpp
    !> Link executable
    procedure :: link
    !> Check whether compiler is recognized
    procedure :: is_unknown
    !> Check whether this is an Intel compiler
    procedure :: is_intel
    !> Check whether this is a GNU compiler
    procedure :: is_gnu
    !> Enumerate libraries, based on compiler and platform
    procedure :: enumerate_libraries

    !> Serialization interface
    procedure :: serializable_is_same => compiler_is_same
    procedure :: dump_to_toml => compiler_dump
    procedure :: load_from_toml => compiler_load
    !> Fortran feature support
    procedure :: check_fortran_source_runs
    procedure :: with_xdp
    procedure :: with_qp
    !> Return compiler name
    procedure :: name => compiler_name

end type compiler_t