exit_codes Module

Provides the exit_code type used to represent an exit reason. Also provides a number of specific exit_code instances for regular expected exit reasons.


Contents


Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: exit_string_len = 100

Length of the exit message string

type(exit_code), public, parameter :: EXIT_NOT_REQUESTED = exit_code()

Type for exiting without specifying a reason, note this uses the default code and message

type(exit_code), public, parameter :: EXIT_NSTEP = exit_code(code=1, message="nstep timesteps completed.")

Type for exiting after completing the specified number of timesteps.

type(exit_code), public, parameter :: EXIT_LINEAR_CONVERGENCE = exit_code(code=2, message="Linear simulation is converged.")

Type for exiting after a linear simulation has converged.

type(exit_code), public, parameter :: EXIT_NONLINEAR_CONVERGENCE = exit_code(code=3, message="Nonlinear simulation is converged.")

Type for exiting after a nonlinear simulation has converged.

type(exit_code), public, parameter :: EXIT_MAX_SIM_TIME = exit_code(code=4, message="Requested maximum simulation time (knobs::max_sim_time) reached.")

Type for exiting after reaching the specified simulation time

type(exit_code), public, parameter :: EXIT_OUT_OF_TIME = exit_code(code=-1, message="GS2 internal time limit exceeded.")

Type for exiting on running out of CPU time.

type(exit_code), public, parameter :: EXIT_STOP_FILE = exit_code(code=-2, message="Stop file detected.")

Type for exiting on detecting a stop file.

type(exit_code), public, parameter :: EXIT_SMALL_TIMESTEP = exit_code(code=-3, message="Timestep is too small.")

Type for exiting after detecting that the timestep is too small.

type(exit_code), public, parameter :: EXIT_RAPID_TIMESTEP_CHANGE = exit_code(code=-4, message="Timestep is changing too rapidly.")

Type for exiting after detecting that the timestep is changing too rapidly.


Derived Types

type, public ::  exit_code

Type providing an exit code and message text for exit reasons

Components

Type Visibility Attributes Name Initial
integer, private :: code = 0

A numeric exit code used to identify the exit reason.

character(len=exit_string_len), private :: message = "No exit reason specified. Code termination may be unexpected."

A user friendly message explaining the exit reason.

Type-Bound Procedures

procedure , public , :: create_message Function

Construct the output message describing the exit reason and return as a string

procedure , public , :: write_exit_file Subroutine

Ask for the exit reason output message and write to the exit_reason_unit

procedure , public , :: is_identical Function

Ask if this instance is identical to another passed exit_code

procedure , private :: code_matches_integer Function

Ask if this instance's code matches the passed value. This can either be another exit_code instance or an integer.

procedure , private :: code_matches_instance Function
generic, public , :: code_matches => code_matches_integer, code_matches_instance

Functions

private function create_message(self)

Make a string containing the error code and exit reason. This is kept minimal to make it easier for tests to parse.

Arguments

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

Return Value character(len=exit_string_len)

private function is_identical(self, other)

Determines if a passed exit_code instance is identical to this instance.

Read more…

Arguments

Type IntentOptional Attributes Name
class(exit_code), intent(in) :: self
type(exit_code), intent(in) :: other

Return Value logical

private function code_matches_integer(self, code)

Determines if a passed exit_code instance has the same code as the passed integer.

Arguments

Type IntentOptional Attributes Name
class(exit_code), intent(in) :: self
integer, intent(in) :: code

Return Value logical

private function code_matches_instance(self, other)

Determines if a passed exit_code instance has the same code as this instance.

Arguments

Type IntentOptional Attributes Name
class(exit_code), intent(in) :: self
type(exit_code), intent(in) :: other

Return Value logical


Subroutines

private subroutine write_exit_file(self)

Write exit file containing exit code and message

Arguments

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