abstract_config_type Derived Type

type, public, abstract :: abstract_config_type

Define abstract type to represent the config type, allows common code to be moved here


Contents

Source Code


Components

TypeVisibility AttributesNameInitial
logical, private :: initialised =.false.

Have we initialised the instance?

logical, public :: exist =.false.

Does the related namelist exist in the target input file?

logical, private :: requires_index =.false.

Is this a numbered namelist with an index

integer, public :: index =0

Used to hold the specific index of numbered namelists

character(len=CONFIG_MAX_NAME_LEN), private :: name =default_name

The name of the namelist that we represent.

logical, public :: skip_read =.false.

Do we want to skip the read step in init?

logical, public :: skip_broadcast =.false.

Do we want to skip the broadcast step in init?


Type-Bound Procedures

procedure, public :: is_initialised => is_initialised_generic

procedure, public :: init => init_generic

  • private subroutine init_generic(self, name, requires_index, index)

    Fully initialise the config object

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(inout) :: self
    character(len=*), intent(in), optional :: name
    logical, intent(in), optional :: requires_index
    integer, intent(in), optional :: index

procedure, public :: setup => setup_generic

  • private subroutine setup_generic(self, name, requires_index, index)

    Do some standard setup/checking

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(inout) :: self
    character(len=*), intent(in), optional :: name
    logical, intent(in), optional :: requires_index
    integer, intent(in), optional :: index

procedure, public :: write_namelist_header

  • private subroutine write_namelist_header(self, unit)

    Write the namelist header for this instance

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    integer, intent(in) :: unit

procedure, public :: get_name => get_name_generic

  • private function get_name_generic(self)

    Returns the namelist name. Not very useful at the moment but may want to do more interesting things in the future

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self

    Return Value character(len=CONFIG_MAX_NAME_LEN)

procedure, public :: get_requires_index => get_requires_index_generic

  • private function get_requires_index_generic(self)

    Returns the requires_index value. Allows access whilst keeping the variable private

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self

    Return Value logical

procedure, public, nopass :: write_namelist_footer

  • private subroutine write_namelist_footer(unit)

    Write the namelist footer

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: unit

procedure, private, nopass :: write_key_val_string

  • private subroutine write_key_val_string(key, val, unit)

    Writes a {key,val} pair where the value is of type character

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    character(len=*), intent(in) :: val
    integer, intent(in) :: unit

procedure, private, nopass :: write_key_val_real

  • private subroutine write_key_val_real(key, val, unit)

    Writes a {key,val} pair where the value is of type real

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    real, intent(in) :: val
    integer, intent(in) :: unit

procedure, private :: write_key_val_real_array

  • private subroutine write_key_val_real_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type real array

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    real, intent(in), dimension(:):: val
    integer, intent(in) :: unit

procedure, private, nopass :: write_key_val_complex

  • private subroutine write_key_val_complex(key, val, unit)

    Writes a {key,val} pair where the value is of type complex

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    complex, intent(in) :: val
    integer, intent(in) :: unit

procedure, private :: write_key_val_complex_array

  • private subroutine write_key_val_complex_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type complex array

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    complex, intent(in), dimension(:):: val
    integer, intent(in) :: unit

procedure, private, nopass :: write_key_val_integer

  • private subroutine write_key_val_integer(key, val, unit)

    Writes a {key,val} pair where the value is of type integer

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    integer, intent(in) :: val
    integer, intent(in) :: unit

procedure, private :: write_key_val_integer_array

  • private subroutine write_key_val_integer_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type integer array

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    integer, intent(in), dimension(:):: val
    integer, intent(in) :: unit

procedure, private, nopass :: write_key_val_logical

  • private subroutine write_key_val_logical(key, val, unit)

    Writes a {key,val} pair where the value is of type logical

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    logical, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_string(key, val, unit)

    Writes a {key,val} pair where the value is of type character

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    character(len=*), intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_real(key, val, unit)

    Writes a {key,val} pair where the value is of type real

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    real, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_complex(key, val, unit)

    Writes a {key,val} pair where the value is of type complex

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    complex, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_integer(key, val, unit)

    Writes a {key,val} pair where the value is of type integer

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    integer, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_logical(key, val, unit)

    Writes a {key,val} pair where the value is of type logical

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: key
    logical, intent(in) :: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_real_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type real array

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    real, intent(in), dimension(:):: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_complex_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type complex array

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    complex, intent(in), dimension(:):: val
    integer, intent(in) :: unit
  • private subroutine write_key_val_integer_array(self, key, val, unit)

    Writes a {key,val} pair where the value is of type integer array

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    character(len=*), intent(in) :: key
    integer, intent(in), dimension(:):: val
    integer, intent(in) :: unit

procedure(read_interface), public, deferred :: read

  • subroutine read_interface(self) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(inout) :: self

procedure(write_interface), public, deferred :: write

  • subroutine write_interface(self, unit) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(in) :: self
    integer, intent(in), optional :: unit

procedure(reset_interface), public, deferred :: reset

  • subroutine reset_interface(self) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(inout) :: self

procedure(broadcast_interface), public, deferred :: broadcast

  • subroutine broadcast_interface(self) Prototype

    Arguments

    Type IntentOptional AttributesName
    class(abstract_config_type), intent(inout) :: self

procedure(get_default_name_interface), public, deferred, nopass :: get_default_name

  • function get_default_name_interface() result(default_name) Prototype

    Arguments

    None

    Return Value character(len=CONFIG_MAX_NAME_LEN)

procedure(get_default_requires_index_interface), public, deferred, nopass :: get_default_requires_index

  • function get_default_requires_index_interface() result(default_requires_index) Prototype

    Arguments

    None

    Return Value logical

Source Code

  type, abstract :: abstract_config_type
     logical, private :: initialised = .false. !< Have we initialised the instance?
     logical :: exist = .false. !< Does the related namelist exist in the target input file?
     logical, private :: requires_index = .false. !< Is this a numbered namelist with an index
     integer :: index = 0 !< Used to hold the specific index of numbered namelists
     character(len = CONFIG_MAX_NAME_LEN), private :: name = default_name !< The name of the namelist that we represent.
     logical :: skip_read = .false. !< Do we want to skip the read step in init?
     logical :: skip_broadcast = .false. !< Do we want to skip the broadcast step in init?
   contains
     procedure :: is_initialised => is_initialised_generic
     procedure :: init => init_generic
     procedure :: setup => setup_generic
     procedure :: write_namelist_header
     procedure :: get_name => get_name_generic
     procedure :: get_requires_index => get_requires_index_generic
     procedure, nopass :: write_namelist_footer
     procedure, private, nopass :: write_key_val_string
     procedure, private, nopass :: write_key_val_real
     procedure, private :: write_key_val_real_array     
     procedure, private, nopass :: write_key_val_complex
     procedure, private :: write_key_val_complex_array     
     procedure, private, nopass :: write_key_val_integer
     procedure, private :: write_key_val_integer_array
     procedure, private, nopass :: write_key_val_logical
     generic :: write_key_val => write_key_val_string, write_key_val_real, write_key_val_complex, write_key_val_integer, write_key_val_logical, write_key_val_real_array, write_key_val_complex_array, write_key_val_integer_array
     procedure(read_interface), deferred :: read
     procedure(write_interface), deferred :: write
     procedure(reset_interface), deferred :: reset
     procedure(broadcast_interface), deferred :: broadcast
     procedure(get_default_name_interface), deferred, nopass :: get_default_name
     procedure(get_default_requires_index_interface), deferred, nopass :: get_default_requires_index    
  end type abstract_config_type