FV3 Bundle
tools_repro.F90
Go to the documentation of this file.
1 !----------------------------------------------------------------------
2 ! Module: tools_repro
3 ! Purpose: reproducibility functions
4 ! Author: Benjamin Menetrier
5 ! Licensing: this code is distributed under the CeCILL-C license
6 ! Copyright © 2015-... UCAR, CERFACS, METEO-FRANCE and IRIT
7 !----------------------------------------------------------------------
8 module tools_repro
9 
10 use tools_const, only: pi
11 use tools_kinds, only: kind_real
12 
13 implicit none
14 
15 real(kind_real),parameter :: rth = 1.0e-12 ! Reproducibility threshold
16 
17 private
18 public :: rth
19 public :: eq,inf,infeq,sup,supeq,indist
20 
21 contains
22 
23 !----------------------------------------------------------------------
24 ! Function: eq
25 ! Purpose: equal test for reals
26 !----------------------------------------------------------------------
27 function eq(x,y)
28 
29 implicit none
30 
31 ! Passed variables
32 real(kind_real),intent(in) :: x ! First real
33 real(kind_real),intent(in) :: y ! Second real
34 
35 ! Returned variable
36 logical :: eq
37 
38 eq = abs(x-y)<rth
39 
40 end function eq
41 
42 !----------------------------------------------------------------------
43 ! Function: inf
44 ! Purpose: inferior test for reals
45 !----------------------------------------------------------------------
46 function inf(x,y)
47 
48 implicit none
49 
50 ! Passed variables
51 real(kind_real),intent(in) :: x ! First real
52 real(kind_real),intent(in) :: y ! Second real
53 
54 ! Returned variable
55 logical :: inf
56 
57 inf = (abs(x-y)>rth*abs(x+y)).and.(x<y)
58 
59 end function inf
60 
61 !----------------------------------------------------------------------
62 ! Function: infeq
63 ! Purpose: inferior or equal test for reals
64 !----------------------------------------------------------------------
65 function infeq(x,y)
66 
67 implicit none
68 
69 ! Passed variables
70 real(kind_real),intent(in) :: x ! First real
71 real(kind_real),intent(in) :: y ! Second real
72 
73 ! Returned variable
74 logical :: infeq
75 
76 infeq = inf(x,y).or.eq(x,y)
77 
78 end function infeq
79 
80 !----------------------------------------------------------------------
81 ! Function: sup
82 ! Purpose: superior test for reals
83 !----------------------------------------------------------------------
84 function sup(x,y)
85 
86 implicit none
87 
88 ! Passed variables
89 real(kind_real),intent(in) :: x ! First real
90 real(kind_real),intent(in) :: y ! Second real
91 
92 ! Returned variable
93 logical :: sup
94 
95 sup = (abs(x-y)>rth*abs(x+y)).and.(x>y)
96 
97 end function sup
98 
99 !----------------------------------------------------------------------
100 ! Function: supeq
101 ! Purpose: superior or equal test for reals
102 !----------------------------------------------------------------------
103 function supeq(x,y)
105 implicit none
106 
107 ! Passed variables
108 real(kind_real),intent(in) :: x ! First real
109 real(kind_real),intent(in) :: y ! Second real
110 
111 ! Returned variable
112 logical :: supeq
113 
114 supeq = sup(x,y).or.eq(x,y)
115 
116 end function supeq
117 
118 !----------------------------------------------------------------------
119 ! Function: indist
120 ! Purpose: indistiguishability test
121 !----------------------------------------------------------------------
122 function indist(x,y)
124 implicit none
125 
126 ! Passed variables
127 real(kind_real),intent(in) :: x ! First real
128 real(kind_real),intent(in) :: y ! Second real
129 
130 ! Returned variable
131 logical :: indist
132 
133 indist = abs(x)<rth*abs(y)
134 
135 end function indist
136 
137 end module tools_repro
logical function, public sup(x, y)
Definition: tools_repro.F90:85
real(kind_real), parameter, public rth
Definition: tools_repro.F90:15
logical function, public supeq(x, y)
logical function, public infeq(x, y)
Definition: tools_repro.F90:66
integer, parameter, public kind_real
logical function, public inf(x, y)
Definition: tools_repro.F90:47
logical function, public eq(x, y)
Definition: tools_repro.F90:28
real(fp), parameter, public pi
logical function, public indist(x, y)