forked from wannier-developers/wannier90
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_base.F90
62 lines (52 loc) · 2.13 KB
/
error_base.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
!-*- mode: F90 -*-!
!------------------------------------------------------------!
! This file is distributed as part of the Wannier90 code and !
! under the terms of the GNU General Public License. See the !
! file `LICENSE' in the root directory of the Wannier90 !
! distribution, or http://www.gnu.org/copyleft/gpl.txt !
! !
! The webpage of the Wannier90 code is www.wannier.org !
! !
! The Wannier90 code is hosted on GitHub: !
! !
! https://github.com/wannier-developers/wannier90 !
!------------------------------------------------------------!
module w90_error_base
!! Module to handle errors
implicit none
public
!! Codify error state with integer code and human readable string
type w90_error_type
integer :: code
character(len=128) :: message
#ifdef W90DEV
contains
final :: untrapped_error
#endif
end type w90_error_type
integer, parameter :: code_remote = -99 ! special code for error triggered by other mpi rank
integer, parameter :: code_deactivated = -888 ! special code for error triggered by other mpi rank
contains
subroutine untrapped_error(err)
type(w90_error_type), intent(in) :: err
! this routine should never be called, so write to stderr and call "stop" in desparation
if (err%code == code_deactivated) return
write (0, *) "UNTRAPPED ERROR: ", err%code
write (0, *) "UNTRAPPED ERROR: ", err%message
stop
end subroutine untrapped_error
subroutine set_base_error(err, mesg, code)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
integer, intent(in) :: code
allocate (err)
err%message = trim(mesg)
err%code = code
end subroutine set_base_error
! the following is required by subroutines of the comms module
subroutine recv_error(err)
type(w90_error_type), allocatable, intent(out) :: err
allocate (err)
err%code = code_remote
end subroutine recv_error
end module w90_error_base