ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_err::err_type Interface Reference

This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected behavior in the ParaMonte library.
More...

Public Attributes

logical(LK) iswarned = .false._LK
 The scalar logical of default kind LK that is .true. if a runtime warning occurs.
More...
 
logical(LK) occurred = .false._LK
 The scalar logical of default kind LK that is .true. if a runtime error occurs.
More...
 
integer(IK) stat = -huge(0_IK)
 The scalar integer of default kind IK to contain the error flag or status code returned by the compiler or program upon encountering an error.
More...
 
character(:, SK), allocatable msg
 The allocatable scalar character of default kind SK containing the error message.
More...
 

Detailed Description

This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected behavior in the ParaMonte library.

Always initialize objects of type err_type if you prefer to avoid the manual allocation of the msg component of the object.
The pre-allocated component can be readily passed to various Fortran routines for catching error messages.

Parameters
[in]occurred: The input scalar logical of default kind LK that is used to initialize the corresponding component of the output object.
(optional, default = .false.)
[in]stat: The input scalar integer of default kind IK that contains the error flag or status.
It is used to to initialize the corresponding component of the output object.
(optional, default = -huge(0_IK))
[in]msg: The input allocatable scalar character of default kind SK containing the error message.
It is used to to initialize the corresponding component of the output object.
(optional, default = repeat(" ", 255))
Returns
err : The output scalar object of type err_type.


Possible calling interfaces

use pm_err, only: err_type
type(err_type) :: err
err = err_type()
print *, err%occurred
print *, err%stat
print *, err%msg
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
Definition: pm_err.F90:157
See also
getStr
setNoted
setWarned
setAborted
setAsserted
getLine


Example usage

1program example
2
3 use pm_kind, only: IK, LK
4 use pm_kind, only: SK ! All kinds are supported.
5 use pm_err, only: err_type
6 use pm_io, only: display_type
7 use iso_fortran_env, only: output_unit
8
9 implicit none
10
11 integer :: fileunit
12 type(err_type) :: err
13 type(display_type) :: disp
14 disp = display_type(file = "main.out.F90")
15
16 call disp%show("err = err_type()")
17 err = err_type()
18 call disp%show("err%msg")
19 call disp%show( err%msg , deliml = SK_"""" )
20 call disp%show("err%stat")
21 call disp%show( err%stat )
22 call disp%show("open(newunit = fileunit, file = 'nonesense.io', status = 'old', iostat = err%stat, iomsg = err%msg)")
23 open(newunit = fileunit, file = 'nonesense.io', status = 'old', iostat = err%stat, iomsg = err%msg)
24 call disp%skip()
25 call disp%show("err%stat")
26 call disp%show( err%stat )
27 call disp%skip()
28 call disp%show("trim(err%msg)")
29 call disp%show( trim(err%msg) )
30 call disp%skip()
31
32end program example
Generate and return an object of type stop_type with the user-specified input attributes.
Definition: pm_err.F90:1618
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1err = err_type()
2err%msg
3"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
4err%stat
5-2147483647
6open(newunit = fileunit, file = 'nonesense.io', status = 'old', iostat = err%stat, iomsg = err%msg)
7
8err%stat
9+2
10
11trim(err%msg)
12Cannot open file 'nonesense.io': No such file or directory
13
14


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, 3:43 AM Friday, March 1, 2013, Institute for Fusion Studies, The University of Texas Austin

Definition at line 157 of file pm_err.F90.

Member Data Documentation

◆ iswarned

logical(LK) pm_err::err_type::iswarned = .false._LK

The scalar logical of default kind LK that is .true. if a runtime warning occurs.

Definition at line 158 of file pm_err.F90.

◆ msg

character(:, SK), allocatable pm_err::err_type::msg

The allocatable scalar character of default kind SK containing the error message.

Definition at line 162 of file pm_err.F90.

◆ occurred

logical(LK) pm_err::err_type::occurred = .false._LK

The scalar logical of default kind LK that is .true. if a runtime error occurs.

Definition at line 159 of file pm_err.F90.

◆ stat

integer(IK) pm_err::err_type::stat = -huge(0_IK)

The scalar integer of default kind IK to contain the error flag or status code returned by the compiler or program upon encountering an error.

Definition at line 160 of file pm_err.F90.


The documentation for this interface was generated from the following file: