SABER
tools_repro.F90
Go to the documentation of this file.
1 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
2 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../generics.fypp" 1
3 !----------------------------------------------------------------------
4 ! Header: generics
5 !> Generic ranks, dimensions and types
6 ! Author: Benjamin Menetrier
7 ! Licensing: this code is distributed under the CeCILL-C license
8 ! Copyright 2015-... UCAR, CERFACS, METEO-FRANCE and IRIT
9 !----------------------------------------------------------------------
10 
11 # 57 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../generics.fypp"
12 # 2 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp" 2
13 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../instrumentation.fypp" 1
14 # 1 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../subr_list.fypp" 1
15 !----------------------------------------------------------------------
16 ! Header: subr_list
17 !> Subroutines/functions list
18 ! Author: Benjamin Menetrier
19 ! Licensing: this code is distributed under the CeCILL-C license
20 ! Copyright 2015-... UCAR, CERFACS, METEO-FRANCE and IRIT
21 !----------------------------------------------------------------------
22 
23 # 926 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../subr_list.fypp"
24 # 2 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../instrumentation.fypp" 2
25 !----------------------------------------------------------------------
26 ! Header: instrumentation
27 !> Instrumentation functions
28 ! Author: Benjamin Menetrier
29 ! Licensing: this code is distributed under the CeCILL-C license
30 ! Copyright 2015-... UCAR, CERFACS, METEO-FRANCE and IRIT
31 !----------------------------------------------------------------------
32 
33 # 112 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/../instrumentation.fypp"
34 # 3 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp" 2
35 !----------------------------------------------------------------------
36 ! Module: tools_repro
37 !> Reproducibility functions
38 ! Author: Benjamin Menetrier
39 ! Licensing: this code is distributed under the CeCILL-C license
40 ! Copyright 2015-... UCAR, CERFACS, METEO-FRANCE and IRIT
41 !----------------------------------------------------------------------
43 
44 use tools_const, only: zero,one,pi
46 
47 
48 implicit none
49 
50 logical :: repro = .true. !< Reproducibility flag
51 real(kind_real) :: rth = 1.0e-12 !< Reproducibility threshold
52 
53 interface eq
54 # 23 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
55  module procedure repro_eq_int
56 # 23 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
57  module procedure repro_eq_real
58 # 23 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
59  module procedure repro_eq_logical
60 # 25 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
61 end interface
62 interface inf
63 # 28 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
64  module procedure repro_inf_int
65 # 28 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
66  module procedure repro_inf_real
67 # 30 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
68 end interface
69 interface infeq
70 # 33 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
71  module procedure repro_infeq_int
72 # 33 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
73  module procedure repro_infeq_real
74 # 35 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
75 end interface
76 interface sup
77 # 38 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
78  module procedure repro_sup_int
79 # 38 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
80  module procedure repro_sup_real
81 # 40 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
82 end interface
83 interface supeq
84 # 43 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
85  module procedure repro_supeq_int
86 # 43 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
87  module procedure repro_supeq_real
88 # 45 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
89 end interface
90 interface indist
91  module procedure repro_indist
92 end interface
93 interface small
94  module procedure repro_small
95 end interface
96 
97 private
98 public :: repro,rth
99 public :: eq,inf,infeq,sup,supeq,indist,small
100 
101 contains
102 
103 # 60 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
104 !----------------------------------------------------------------------
105 ! Function: repro_eq_int
106 !> Equal test for int
107 !----------------------------------------------------------------------
108 function repro_eq_int(x,y) result(test)
109 
110 implicit none
111 
112 ! Passed variables
113 integer(kind_int),intent(in) :: x !< First real
114 integer(kind_int),intent(in) :: y !< Second real
115 
116 ! Returned variable
117 logical :: test
118 
119 ! Set name
120 
121 
122 ! Probe in
123 
124 
125  test = (x==y)
126 # 89 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
127 
128 
129 ! Probe out
130 
131 
132 end function repro_eq_int
133 # 60 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
134 !----------------------------------------------------------------------
135 ! Function: repro_eq_real
136 !> Equal test for real
137 !----------------------------------------------------------------------
138 function repro_eq_real(x,y) result(test)
139 
140 implicit none
141 
142 ! Passed variables
143 real(kind_real),intent(in) :: x !< First real
144 real(kind_real),intent(in) :: y !< Second real
145 
146 ! Returned variable
147 logical :: test
148 
149 ! Set name
150 
151 
152 ! Probe in
153 
154 
155 
156 # 83 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
157  if (repro) then
158  test = indist(x,y)
159  else
160  test = .not.(abs(x-y)>zero)
161  end if
162 # 89 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
163 
164 
165 ! Probe out
166 
167 
168 end function repro_eq_real
169 # 60 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
170 !----------------------------------------------------------------------
171 ! Function: repro_eq_logical
172 !> Equal test for logical
173 !----------------------------------------------------------------------
174 function repro_eq_logical(x,y) result(test)
175 
176 implicit none
177 
178 ! Passed variables
179 logical,intent(in) :: x !< First real
180 logical,intent(in) :: y !< Second real
181 
182 ! Returned variable
183 logical :: test
184 
185 ! Set name
186 
187 
188 ! Probe in
189 
190 
191 
192 # 89 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
193  test = (x.eqv.y)
194 
195 ! Probe out
196 
197 
198 end function repro_eq_logical
199 # 96 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
200 
201 # 98 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
202 !----------------------------------------------------------------------
203 ! Function: repro_inf_int
204 !> Inferior test for int
205 !----------------------------------------------------------------------
206 function repro_inf_int(x,y) result(test)
207 
208 implicit none
209 
210 ! Passed variables
211 integer(kind_int),intent(in) :: x !< First real
212 integer(kind_int),intent(in) :: y !< Second real
213 
214 ! Returned variable
215 logical :: test
216 
217 ! Set name
218 
219 
220 ! Probe in
221 
222 
223 test = (x<y)
224 
225 
226 ! Probe out
227 
228 
229 end function repro_inf_int
230 # 98 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
231 !----------------------------------------------------------------------
232 ! Function: repro_inf_real
233 !> Inferior test for real
234 !----------------------------------------------------------------------
235 function repro_inf_real(x,y) result(test)
236 
237 implicit none
238 
239 ! Passed variables
240 real(kind_real),intent(in) :: x !< First real
241 real(kind_real),intent(in) :: y !< Second real
242 
243 ! Returned variable
244 logical :: test
245 
246 ! Set name
247 
248 
249 ! Probe in
250 
251 
252 test = (x<y)
253  if (repro) test = test.and.(.not.indist(x,y))
254 
255 ! Probe out
256 
257 
258 end function repro_inf_real
259 # 127 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
260 
261 # 129 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
262 !----------------------------------------------------------------------
263 ! Function: repro_infeq_int
264 !> Inferior or equal test for int
265 !----------------------------------------------------------------------
266 function repro_infeq_int(x,y) result(test)
267 
268 implicit none
269 
270 ! Passed variables
271 integer(kind_int),intent(in) :: x !< First real
272 integer(kind_int),intent(in) :: y !< Second real
273 
274 ! Returned variable
275 logical :: test
276 
277 ! Set name
278 
279 
280 ! Probe in
281 
282 
283 test = inf(x,y).or.eq(x,y)
284 
285 ! Probe out
286 
287 
288 end function repro_infeq_int
289 # 129 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
290 !----------------------------------------------------------------------
291 ! Function: repro_infeq_real
292 !> Inferior or equal test for real
293 !----------------------------------------------------------------------
294 function repro_infeq_real(x,y) result(test)
295 
296 implicit none
297 
298 ! Passed variables
299 real(kind_real),intent(in) :: x !< First real
300 real(kind_real),intent(in) :: y !< Second real
301 
302 ! Returned variable
303 logical :: test
304 
305 ! Set name
306 
307 
308 ! Probe in
309 
310 
311 test = inf(x,y).or.eq(x,y)
312 
313 ! Probe out
314 
315 
316 end function repro_infeq_real
317 # 157 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
318 
319 # 159 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
320 !----------------------------------------------------------------------
321 ! Function: repro_sup_int
322 !> Superior test for int
323 !----------------------------------------------------------------------
324 function repro_sup_int(x,y) result(test)
325 
326 implicit none
327 
328 ! Passed variables
329 integer(kind_int),intent(in) :: x !< First real
330 integer(kind_int),intent(in) :: y !< Second real
331 
332 ! Returned variable
333 logical :: test
334 
335 ! Set name
336 
337 
338 ! Probe in
339 
340 
341 test = (x>y)
342 
343 
344 ! Probe out
345 
346 
347 end function repro_sup_int
348 # 159 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
349 !----------------------------------------------------------------------
350 ! Function: repro_sup_real
351 !> Superior test for real
352 !----------------------------------------------------------------------
353 function repro_sup_real(x,y) result(test)
354 
355 implicit none
356 
357 ! Passed variables
358 real(kind_real),intent(in) :: x !< First real
359 real(kind_real),intent(in) :: y !< Second real
360 
361 ! Returned variable
362 logical :: test
363 
364 ! Set name
365 
366 
367 ! Probe in
368 
369 
370 test = (x>y)
371  if (repro) test = test.and.(.not.indist(x,y))
372 
373 ! Probe out
374 
375 
376 end function repro_sup_real
377 # 188 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
378 
379 # 190 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
380 !----------------------------------------------------------------------
381 ! Function: repro_supeq_int
382 !> Superior or equal test for int
383 !----------------------------------------------------------------------
384 function repro_supeq_int(x,y) result(test)
385 
386 implicit none
387 
388 ! Passed variables
389 integer(kind_int),intent(in) :: x !< First real
390 integer(kind_int),intent(in) :: y !< Second real
391 
392 ! Returned variable
393 logical :: test
394 
395 ! Set name
396 
397 
398 ! Probe in
399 
400 
401 test = sup(x,y).or.eq(x,y)
402 
403 ! Probe out
404 
405 
406 end function repro_supeq_int
407 # 190 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
408 !----------------------------------------------------------------------
409 ! Function: repro_supeq_real
410 !> Superior or equal test for real
411 !----------------------------------------------------------------------
412 function repro_supeq_real(x,y) result(test)
413 
414 implicit none
415 
416 ! Passed variables
417 real(kind_real),intent(in) :: x !< First real
418 real(kind_real),intent(in) :: y !< Second real
419 
420 ! Returned variable
421 logical :: test
422 
423 ! Set name
424 
425 
426 ! Probe in
427 
428 
429 test = sup(x,y).or.eq(x,y)
430 
431 ! Probe out
432 
433 
434 end function repro_supeq_real
435 # 218 "/Users/miesch/JEDI/code/working_copy/internal/mpas-bundle/saber/src/saber/util/tools_repro.fypp"
436 
437 !----------------------------------------------------------------------
438 ! Function: repro_indist
439 !> Indistiguishability test
440 !----------------------------------------------------------------------
441 function repro_indist(x,y) result(test)
442 
443 implicit none
444 
445 ! Passed variables
446 real(kind_real),intent(in) :: x !< First real
447 real(kind_real),intent(in) :: y !< Second real
448 
449 ! Returned variable
450 logical :: test
451 
452 ! Set name
453 
454 
455 ! Probe in
456 
457 
458 test = .false.
459 if (repro) then
460  if ((abs(x)>zero).or.(abs(y)>zero)) then
461  test = abs(x-y)<rth*(abs(x+y))
462  else
463  test = .true.
464  end if
465 end if
466 
467 ! Probe out
468 
469 
470 end function repro_indist
471 
472 !----------------------------------------------------------------------
473 ! Function: repro_small
474 !> Small value test
475 !----------------------------------------------------------------------
476 function repro_small(x,y) result(test)
477 
478 implicit none
479 
480 ! Passed variables
481 real(kind_real),intent(in) :: x !< First real
482 real(kind_real),intent(in) :: y !< Second real
483 
484 ! Returned variable
485 logical :: test
486 
487 ! Set name
488 
489 
490 ! Probe in
491 
492 
493 test = .false.
494 if (repro) test = abs(x)<rth*abs(y)
495 
496 ! Probe out
497 
498 
499 end function repro_small
500 
501 end module tools_repro
Subroutines/functions list.
Definition: tools_const.F90:31
real(kind_real), parameter, public one
One.
Definition: tools_const.F90:42
real(kind_real), parameter, public pi
Pi.
Definition: tools_const.F90:53
real(kind_real), parameter, public zero
Zero.
Definition: tools_const.F90:37
Kinds definition.
Definition: tools_kinds.F90:9
integer, parameter, public kind_int
Integer kind.
Definition: tools_kinds.F90:17
integer, parameter, public kind_real
Real kind alias for the whole code.
Definition: tools_kinds.F90:31
Generic ranks, dimensions and types.
Definition: tools_repro.F90:42
logical function repro_eq_logical(x, y)
Equal test for logical.
logical function repro_sup_int(x, y)
Superior test for int.
logical function repro_infeq_int(x, y)
Inferior or equal test for int.
logical function repro_indist(x, y)
Indistiguishability test.
real(kind_real), public rth
Reproducibility threshold.
Definition: tools_repro.F90:51
logical function repro_sup_real(x, y)
Superior test for real.
logical, public repro
Reproducibility flag.
Definition: tools_repro.F90:50
logical function repro_supeq_int(x, y)
Superior or equal test for int.
logical function repro_supeq_real(x, y)
Superior or equal test for real.
logical function repro_inf_real(x, y)
Inferior test for real.
logical function repro_infeq_real(x, y)
Inferior or equal test for real.
logical function repro_small(x, y)
Small value test.
logical function repro_inf_int(x, y)
Inferior test for int.
logical function repro_eq_int(x, y)
Equal test for int.
logical function repro_eq_real(x, y)
Equal test for real.