f2k  Reference documentation for version 0.0
error_handler.f90
Go to the documentation of this file.
1 !----------------------------------------------------------------------------------------
2 !
3 ! This file is part of f2k.
4 !
5 ! Copyright (C) 2016-2017 by the f2k authors
6 !
7 ! The f2k code is free software;
8 ! You can use it, redistribute it, and/or modify it under the terms
9 ! of the GNU General Public License as published by the Free Software Foundation;
10 ! either version 3 of the License, or (at your option) any later version.
11 ! The full text of the license can be found in the file LICENSE at
12 ! the top level of the f2k distribution.
13 !
14 !----------------------------------------------------------------------------------------
15 
18 
19 !----------------------------------------------------------------------------------------
21 
24 
26 
27  implicit none
28 
29  private
30 
31  !----------------------------------------------------------------------------------------
32  ! Internal definitions:
33 
34  interface
35  subroutine abort() bind(C, name="abort")
36  end subroutine
37  end interface
38 
39  !----------------------------------------------------------------------------------------
40  ! public definitions:
41  public :: raise_error
42 
43  !----------------------------------------------------------------------------------------
44 
45 contains
46 
47  ! ---------------------------------------------------------------------------------------------
55  subroutine raise_error( error_message )
56 
57  implicit none
58 
59  character ( len = * ), intent(in), optional :: error_message
60 
61  ! if there is a message present print it:
62  if ( present( error_message ) ) then
63  write(*,*) error_message
64  end if
65  ! call abort function that prints traceback infos when compiled in debug mode:
66  call abort()
67 
68  end subroutine raise_error
69 
70  ! ---------------------------------------------------------------------------------------------
71 
72 end module f2k_error_handler
This module contains a error handler.
subroutine, public raise_error(error_message)
Subroutine that raises errors.