forked from wannier-developers/wannier90
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.F90
105 lines (88 loc) · 3.86 KB
/
error.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
!-*- 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
!! Module to handle errors
use w90_error_base
use w90_comms
implicit none
public
integer, parameter :: code_ok = 0
integer, parameter :: code_fatal = 1
integer, parameter :: code_alloc = 2
integer, parameter :: code_dealloc = 3
integer, parameter :: code_mpi = 4
integer, parameter :: code_input = 5
integer, parameter :: code_file = 6
integer, parameter :: code_unconv = -1
integer, parameter :: code_warning = -2 ! mostly for failing to plot something
contains
subroutine set_error_fatal(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_fatal)
call comms_sync_error(comm, err, code_fatal)
end subroutine set_error_fatal
subroutine set_error_alloc(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_alloc)
call comms_sync_error(comm, err, code_alloc)
end subroutine set_error_alloc
subroutine set_error_dealloc(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_dealloc)
call comms_sync_error(comm, err, code_dealloc)
end subroutine set_error_dealloc
! note, this is not used in comms routines
! (otherwise circular dependency)
subroutine set_error_mpi(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_mpi)
call comms_sync_error(comm, err, code_mpi)
end subroutine set_error_mpi
subroutine set_error_input(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_input)
call comms_sync_error(comm, err, code_input)
end subroutine set_error_input
subroutine set_error_file(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_file)
call comms_sync_error(comm, err, code_file)
end subroutine set_error_file
subroutine set_error_unconv(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_unconv)
call comms_sync_error(comm, err, code_unconv)
end subroutine set_error_unconv
subroutine set_error_warn(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_warning)
call comms_sync_error(comm, err, code_warning)
end subroutine set_error_warn
end module w90_error