stdlib_error:local:
:depth: 2
Catching and handling errors.
check - Checks the value of a logical conditionExperimental
Checks the value of a logical condition.
call {f:subr}check (condition, msg, code, warn)
condition: Shall be a scalar of type logical.
msg (optional): Shall be a character expression containing the message to be printed to stderr. The default msg is ‘Check failed.’.
code (optional): Shall be a scalar of type integer. The default code is 1.
warn (optional): Shall be a scalar of type logical. The default warn is .true..
If condition is .false., and:
no other arguments are provided, this subroutine stops the program with the default message and exit code 1;
msg is provided, this subroutine stops the program and it prints the value of msg;
code is provided, this subroutine stops the program with the given exit code;
warn is provided and warn is .true., this subroutine doesn’t stop the program and prints the message.
```{literalinclude} ../../example/error/example_check1.f90 :language: fortran
```{literalinclude} ../../example/error/example_check2.f90
:language: fortran
```{literalinclude} ../../example/error/example_check3.f90 :language: fortran
```{literalinclude} ../../example/error/example_check4.f90
:language: fortran
error_stop - aborts the programExperimental
Aborts the program with a message and a nonzero exit code.
call {f:subr}error_stop (msg, code)
msg: Shall be a character expression containing the message to be printed to stderr.
code (optional): Shall be a scalar of type integer to be returned as exit code.
Aborts the program with printing the message msg to stderr and a nonzero exit code. The nonzero exit code is equal to code if provided, and 1 otherwise.
Without error code:
```{literalinclude} ../../example/error/example_error_stop1.f90 :language: fortran
With error code:
```{literalinclude} ../../example/error/example_error_stop2.f90
:language: fortran