Logger Derived Type

type, public :: Logger


Components

Type Visibility Attributes Name Initial
logical, public :: to_terminal = .TRUE.
logical, public :: to_file = .FALSE.
integer, public :: frequency = 10
character(len=100), public :: filename = "log.txt"
integer, public :: file_unit = 99
integer, public :: step = 0
logical, public :: show_iteration = .TRUE.
logical, public :: show_final = .TRUE.

Type-Bound Procedures

procedure, public :: log => log_message

  • private subroutine log_message(this, msg)

    Arguments

    Type IntentOptional Attributes Name
    class(Logger), intent(inout) :: this
    character(len=*), intent(in) :: msg

procedure, public :: init => init_logger

  • private subroutine init_logger(this)

    Arguments

    Type IntentOptional Attributes Name
    class(Logger), intent(inout) :: this

procedure, public :: close => close_logger

  • private subroutine close_logger(this)

    Arguments

    Type IntentOptional Attributes Name
    class(Logger), intent(inout) :: this

Source Code

    TYPE :: Logger
        LOGICAL :: to_terminal = .TRUE.
        LOGICAL :: to_file = .FALSE.
        INTEGER :: frequency = 10
        CHARACTER(LEN=100) :: filename = "log.txt"
        INTEGER :: file_unit = 99
        INTEGER :: step = 0
        LOGICAL :: show_iteration = .TRUE.
        LOGICAL :: show_final = .TRUE.

        CONTAINS
        
        PROCEDURE :: log => log_message
        PROCEDURE :: init => init_logger
        PROCEDURE :: close => close_logger
    END TYPE Logger