# tem_abortCriteria_module Module

This module provides the definition of various abort criteria upon which a simulation should be stopped. Note that solvers may extend this table and have their own set of addititonal abort parameters to be set in this table.

There are two primary options that may be set:

• stop_file this denotes a file that will be checked for existence in the current working directory. If it exists the simulation will be stopped (if restarts are active, a restart will be written). If the file is empty the file will be deleted upon completion of the application. Otherwise, if the file is not empty it will be kept around.
• steady_state this is a boolean to indicate whether the simulation is to halt when a steady state is reached. If this is true a convergence table, where the condition for a steady state may be defined, is read. See tem_convergence_module for details.

If the abort criteria table is not provided, the defaults for both settings will be used, which is equivalent to the following definition:

  abort_criteria = {stop_file = '', steady_state = false}


That is, no stop files to look for, and no check whether a steady state is reached.

A more complete example with a check for steady state and a convergence table (more details in tem_convergence_module could look like this:

  abort_criteria = {
stop_file = 'stop',
convergence = {
variable = {'pressure', 'velocity'},
shape = {kind = 'all'},
time_control = {
min = {iter = 0},
max = {iter = tmax},
interval = {iter = 10}
},
reduction = { 'average', 'average' },
norm = 'average',
nvals = 100,
absolute = true,
condition = {
{ threshold = 1.e-15, operator = '<=' },
{ threshold = 1.e-12, operator = '<=' }
}
}
}


This results in the application to look for a file named stop in the working directory and will abort the run if it is found to exist. The application will check for a steady state, where a steady state is assumed when the average of pressure and velocity across the complete domain does not deviate by more of 1.e-15 for pressure and not more than 1.e-12 for the velocity.

## Abstract Interfaces

• ### private subroutine load_aborts(me, conf, abort_table)

#### Arguments

Type IntentOptional AttributesName
class(tem_solverAborts_type), intent(inout) :: me

The solver specific type to hold additional abort parameters.

type(flu_state), intent(in) :: conf

Handle to Lua configuration file to load parameters from.

integer, intent(in) :: abort_table

Handle to the abort criteria table to read from.

## Derived Types

### type, public, abstract :: tem_solverAborts_type

Abstract type to describe solver specific abort criteria.

### type, public :: tem_abortCriteria_type

Definition of the various abort criteria.

#### Components

TypeVisibility AttributesNameInitial
character(len=labelLen), public :: stop_file

A file which should cause the simulation to stop. Default: ''.

Should the simulation be checked for a steady state convergence and stop if it is detected? Default: .false.

type(tem_convergence_type), public, allocatable:: convergence(:)

Convergence conditions for steady state check. Filled only when steady_state is True

## Functions

### public function tem_abortCriteria_new(stop_file, steady_state) result(ac)

Define new abortCriteria.

#### Arguments

Type IntentOptional AttributesName
character(len=*), intent(in), optional :: stop_file

Name of the stop file to react on. Default=''.

Any non-empty string activates this criterion.

Flag to indicate if the simulation should stop upon reaching a steady state. What a steady state exactly is has to be defined in the solver. Default: .false.

#### Return Value type(tem_abortCriteria_type)

A new variable of abortCriteria filled with the values provided as arguments.

### public function tem_stop_file_exists(abortCriteria, rank) result(sf_exists)

Check if the stop file exists.

#### Arguments

Type IntentOptional AttributesName
type(tem_abortCriteria_type), intent(in) :: abortCriteria

Abort criteria settings to use in this check for a stop file.

integer, intent(in) :: rank

Rank of the probing process, only rank==0 actually checks for the file.

#### Return Value logical

Result that indicates, if the stop files exists.

## Subroutines

### public subroutine tem_abortCriteria_load(me, conf, parent, key, solverAborts)

Load the abortCriteria from a given configuration.

#### Arguments

Type IntentOptional AttributesName
type(tem_abortCriteria_type), intent(out) :: me

Abort criteria to load from the Lua table.

type(flu_state) :: conf

Handle for the Lua script.

integer, intent(in), optional :: parent

character(len=*), intent(in), optional :: key

Name of the time control table. Default: 'time_control'

class(tem_solverAborts_type), intent(inout), optional :: solverAborts

Solver specific abort criteria to load.

### public subroutine tem_abortCriteria_out(me, conf, key)

Saves the abortCriteria to a given configuration.

#### Arguments

Type IntentOptional AttributesName
type(tem_abortCriteria_type), intent(in) :: me

The abortCriteria to write out as a Lua table.

type(aot_out_type), intent(inout) :: conf

Handle for the Lua script to write to.

character(len=*), optional :: key

A name for the table to write the abortCriteria to. Default: 'abort_criteria'.

### public subroutine tem_abortCriteria_dump(me, outUnit)

Dump abort criteria information to the specified outUnit.

#### Arguments

Type IntentOptional AttributesName
type(tem_abortCriteria_type), intent(in) :: me

Abort criteria settings to write on outUnit.

integer, intent(in) :: outUnit

File unit to write the settings to.