-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreation.f90
More file actions
70 lines (50 loc) · 1.82 KB
/
creation.f90
File metadata and controls
70 lines (50 loc) · 1.82 KB
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
!> Error creation
!>
!> A very basic demo to get the idea.
!
! TODO: discuss - we should probably have some convention for module names.
! The hard part is avoiding them becoming too long...
module m_error_v_creation
use m_error_v, only: ErrorV, NO_ERROR_CODE
implicit none
private
public :: create_error, create_errors
contains
function create_error(inv) result(err)
!! Create an error
!!
!> If an odd number is supplied, the error code is [[m_error_v:NO_ERROR_CODE(variable)]].
!> If an even number is supplied, the error code is `1`.
!> If a negative number is supplied, the error code is `2`.
integer, intent(in) :: inv
!! Value to use to create the error
type(ErrorV) :: err
!! Created error
if (inv < 0) then
err = ErrorV(code=2, message="Negative number supplied")
return
end if
if (mod(inv, 2) .eq. 0) then
err = ErrorV(code=1, message="Even number supplied")
else
err = ErrorV(code=NO_ERROR_CODE)
end if
end function create_error
function create_errors(invs, n) result(errs)
!! Create a number of errors
!!
!> If an odd number is supplied, the error code is [[m_error_v:NO_ERROR_CODE(variable)]].
!> If an even number is supplied, the error code is `1`.
!> If a negative number is supplied, the error code is `2`.
integer, dimension(n), intent(in) :: invs
!! Values to use to create the error
integer, intent(in) :: n
!! Number of values to create
type(ErrorV), dimension(n) :: errs
!! Created errors
integer :: i
do i = 1, n
errs(i) = create_error(invs(i))
end do
end function create_errors
end module m_error_v_creation