Report Typos and Errors    
Semi-Lagrangian Library
Modular library for kinetic and gyrokinetic simulations of plasmas in fusion energy devices.
sll_m_errors.F90
Go to the documentation of this file.
2 
3 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4  use iso_fortran_env, only: &
5  error_unit
6 
7  implicit none
8 
9  public :: &
12 
13  private
14 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 
16  ! Instead of using the non-standard subroutine abort() provided by the compiler,
17  ! use abort() from the C standard library "stdlib.h"
18  interface
19  subroutine c_abort() bind(C, name="abort")
20  end subroutine
21  end interface
22 
23 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 contains
25 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 
27  !----------------------------------------------------------------------------
32  !----------------------------------------------------------------------------
33  subroutine sll_s_warning_handler(file_name, line_num, caller, message)
34  character(len=*), intent(in) :: file_name
35  integer, intent(in) :: line_num
36  character(len=*), intent(in) :: caller
37  character(len=*), intent(in) :: message
38 
39  call errout(error_unit, 'W', file_name, line_num, caller, message)
40 
41  end subroutine sll_s_warning_handler
42 
43  !----------------------------------------------------------------------------
48  !----------------------------------------------------------------------------
49  subroutine sll_s_error_handler(file_name, line_num, caller, message)
50  character(len=*), intent(in) :: file_name
51  integer, intent(in) :: line_num
52  character(len=*), intent(in) :: caller
53  character(len=*), intent(in) :: message
54 
55  call errout(error_unit, 'F', file_name, line_num, caller, message)
56  call c_abort()
57 
58  end subroutine sll_s_error_handler
59 
60  !----------------------------------------------------------------------------
65  !----------------------------------------------------------------------------
66  subroutine errout(out_unit, severity, file_name, line_num, caller, message)
67 
68  integer, intent(in) :: out_unit
69  character(len=1), intent(in) :: severity
70  character(len=*), intent(in) :: file_name
71  integer, intent(in) :: line_num
72  character(len=*), intent(in) :: caller
73  character(len=*), intent(in) :: message
74 
75  character(len=64) :: line_num_str
76 
77  write (out_unit, *)
78  select case (severity) ! *** Severity ***
79  case ('W')!
80  write (out_unit, "(/10x,a)") '*** WARNING ***'
81  case ('F')
82  write (out_unit, "(/10x,a)") '*** FATAL ERROR ***'
83  case default
84  write (out_unit, "(/10x,a)") '*** FATAL ERROR ***'
85  write (out_unit, "(/10x,a)") &
86  'Error handler (ERROUT) called with unknown severity level: ', severity
87  end select
88 
89  write (line_num_str, *) line_num
90  line_num_str = adjustl(line_num_str)
91 
92  write (out_unit, "(/10x,a)") &
93  'Generated by program or subroutine: '//trim(caller)
94  write (out_unit, "(/10x,a)") &
95  'In '//trim(file_name)//':'//trim(line_num_str)
96  write (out_unit, "(/10x,a)") trim(message)
97  write (out_unit, *)
98 
99  end subroutine errout
100  !----------------------------------------------------------------------------
101 
102 end module sll_m_errors
subroutine errout(out_unit, severity, file_name, line_num, caller, message)
Write error/warning message to a given unit.
subroutine, public sll_s_error_handler(file_name, line_num, caller, message)
Print error message to standard-error, stop execution and dump backtrace information.
subroutine, public sll_s_warning_handler(file_name, line_num, caller, message)
Print warning message to standard-error and continue execution.
    Report Typos and Errors