-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtrace.f90
More file actions
46 lines (40 loc) · 1.3 KB
/
Copy pathtrace.f90
File metadata and controls
46 lines (40 loc) · 1.3 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
program trace
use ErrorInstanceModule
use ErrorCriteriaModule
use ResultModule
implicit none
type(ErrorCriteria) :: EH
type(Result0D) :: a1, a2
call EH%init()
a1 = areaFromRadius(-1.0)
a2 = areaFromDiameter(-2.0)
call EH%trigger(errors=[.error. a1, .error. a2])
contains
function radius(diameter)
real :: diameter
type(Result0D) :: radius
radius = Result( &
data = diameter/2, &
error = EH%positive(diameter) & ! Make sure diameter is positive
)
call radius%addToTrace('Radius from diameter')
end function
function areaFromDiameter(diameter) result(area)
real :: diameter
type(Result0D) :: area
area = Result( &
data = 3.142*.real.radius(diameter)**2, &
error = .error.radius(diameter) & ! Pass the error from the radius() function
)
call area%addToTrace('Area from diameter')
end function
function areaFromRadius(radius) result(area)
real :: radius
type(Result0D) :: area
area = Result( &
data = 3.142*radius**2, &
error = EH%positive(radius) & ! Make sure the radius is positive
)
call area%addToTrace('Area from radius')
end function
end program