0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_errormeasures.f90
Go to the documentation of this file.
1!> \file mo_errormeasures.f90
2!> \brief \copybrief mo_errormeasures
3!> \details \copydetails mo_errormeasures
4
5!> \brief Calculation of error measures.
6!> \details This module contains routines for the masked calculation of
7!! error measures like MSE, RMSE, BIAS, SSE, NSE, ...
8!> \note all except variance and standard deviation are population and not sample moments,
9!! i.e. they are normally divided by n and not (n-1)
10!> \authors Mathias Zink
11!> \date Aug 2012
12!> \copyright Copyright 2005-\today, the CHS Developers, Sabine Attinger: All rights reserved.
13!! FORCES is released under the LGPLv3+ license \license_note
15
16 USE mo_kind, ONLY : i4, sp, dp
17
18 IMPLICIT NONE
19
20 PUBLIC :: bias ! bias
21 PUBLIC :: kge ! Kling-Gupta efficiency measure
22 PUBLIC :: kgenocorr ! KGE without correlation
23 PUBLIC :: lnnse ! Logarithmic Nash Sutcliffe efficiency
24 PUBLIC :: mae ! Mean of absolute errors
25 PUBLIC :: mse ! Mean of squared errors
26 PUBLIC :: nse ! Nash Sutcliffe efficiency
27 PUBLIC :: sse ! Sum of squared errors
28 PUBLIC :: sae ! Sum of absolute errors
29 PUBLIC :: rmse ! Root mean squared error
30 PUBLIC :: wnse ! weighted NSE
31
32 ! ------------------------------------------------------------------
33
34 !> \brief Calculates bias.
35
36 !> \details Calculates the bias
37 !!
38 !! \f[BIAS = \bar y - \bar x\f]
39 !!
40 !! Where \f$ \bar y \f$ and \f$ \bar x \f$ are means of the data points.
41 !!
42 !! If an optinal mask is given, the calculations are over those locations that correspond to true values in the mask.
43 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
44 !!
45 !! \b Example
46 !!
47 !! \code{.f90}
48 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
49 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
50 !! m = BIAS(vec1, vec2, mask=(vec >= 0.))
51 !! --> m = 0.0
52 !! \endcode
53 !!
54 !! See also example in test directory.
55
56
57 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
58 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
59 !! If present, only those locations in vec corresponding to the true values in mask are used.
60
61 !> \returns "real(sp/dp) :: BIAS" Bias.
62
63 !> \note
64 !! Input values must be floating points.
65
66 !> \authors Matthias Zink
67 !> \date Sept 2012
68 INTERFACE bias
69 MODULE PROCEDURE bias_sp_1d, bias_dp_1d, bias_sp_2d, bias_dp_2d, bias_sp_3d, bias_dp_3d
70 END INTERFACE bias
71
72 ! ------------------------------------------------------------------
73
74 !> \brief Kling-Gupta-Efficiency measure.
75
76 !> \details
77 !! The Kling-Gupta model efficiency coefficient \f$ KGE \f$ is
78 !! \f[ KGE = 1 - \sqrt{( (1-r)^2 + (1-\alpha)^2 + (1-\beta)^2 )} \f]
79 !! where \n
80 !! \f$ r \f$ = Pearson product-moment correlation coefficient \n
81 !! \f$ \alpha \f$ = ratio of simulated mean to observed mean \n
82 !! \f$ \beta \f$ = ratio of simulated standard deviation to
83 !! observed standard deviation \n
84 !! This three measures are calculated between two arrays (1d, 2d, or 3d).
85 !! Usually, one is an observation and the second is a modelled variable.\n
86 !!
87 !! The higher the KGE the better the observation and simulation are matching.
88 !! The upper limit of KGE is 1.\n
89 !!
90 !! Therefore, if you apply a minimization algorithm to calibrate regarding
91 !! KGE you have to use the objective function
92 !! \f[ obj\_value = 1.0 - KGE \f]
93 !! which has then the optimum at 0.0.
94 !! (Like for the NSE where you always optimize 1-NSE.)\n
95 !!
96 !! \b Example
97 !!
98 !! \code{.f90}
99 !! para = (/ 1., 2, 3., -999., 5., 6. /)
100 !! kge = kge(x,y,mask=mask)
101 !! \endcode
102 !!
103 !! \b Literature
104 !!
105 !> 1. Gupta, Hoshin V., et al.
106 !! _"Decomposition of the mean squared error and NSE performance criteria:
107 !! Implications for improving hydrological modelling"_.
108 !! Journal of Hydrology 377.1 (2009): 80-91.
109 !!
110 !> \param[in] "real(sp/dp) :: x, y" 1D/2D/3D-array with input numbers
111 !> \param[in] "logical, optional :: mask" 1D/2D/3D-array of logical values with size(x/y).
112 !> \retval "real(sp/dp) ::kge" Kling-Gupta-Efficiency (value less equal 1.0)
113
114 !> \note Input values must be floating points. \n
115
116 !> \author Rohini Kumar
117 !> \date August 2014
118
119 !> \author R. Kumar, J. Mai, & O. Rakovec
120 !> \date Sep. 2014
121 !! - remove double packing of input data (bug)
122 !! - KGE instead of 1.0-KGE
123 !! - 1d, 2d, 3d, version in sp and dp
124
125 INTERFACE kge
126 MODULE PROCEDURE kge_dp_1d, kge_dp_2d, kge_dp_3d, kge_sp_1d, kge_sp_2d, kge_sp_3d
127 END INTERFACE kge
128
129 ! ------------------------------------------------------------------
130
131 !> \brief Kling-Gupta-Efficiency measure without correlation
132
133 !> \details The modified Kling-Gupta model efficiency coefficient \f$ KGEnocorr \f$ is
134 !! \f[ KGEnocorr = 1 - \sqrt{( (1-\alpha)^2 + (1-\beta)^2 )} \f]
135 !! where \n
136 !! \f$ \alpha \f$ = ratio of simulated mean to observed mean \n
137 !! \f$ \beta \f$ = ratio of simulated standard deviation to
138 !! observed standard deviation \n
139 !! This two measures are calculated between two arrays (1d, 2d, or 3d).
140 !! Usually, one is an observation and the second is a modelled variable.\n
141 !!
142 !! The higher the KGEnocorr the better the observation and simulation are matching.
143 !! The upper limit of KGEnocorr is 1.\n
144 !!
145 !! Therefore, if you apply a minimization algorithm to calibrate regarding
146 !! KGEnocorr you have to use the objective function
147 !! \f[ obj\_value = 1.0 - KGEnocorr \f]
148 !! which has then the optimum at 0.0.
149 !! (Like for the NSE where you always optimize 1-NSE.)\n
150 !!
151 !! \b Example
152 !!
153 !! \code{.f90}
154 !! para = (/ 1., 2, 3., -999., 5., 6. /)
155 !! kgenocorr = kgenocorr(x,y,mask=mask)
156 !! \endcode
157 !!
158 !! \b Literature
159 !!
160 !! 1. Gupta, Hoshin V., et al.
161 !! _"Decomposition of the mean squared error and NSE performance criteria:
162 !! Implications for improving hydrological modelling"_.
163 !! Journal of Hydrology 377.1 (2009): 80-91.
164 !!
165 !> \param[in] "real(sp/dp) :: x, y" 1D/2D/3D-array with input numbers
166 !> \param[in] "logical, optional :: mask" 1D/2D/3D-array of logical values with size(x/y).
167 !> \retval "real(sp/dp) :: kgenocorr" Kling-Gupta-Efficiency without correlation (value less equal 1.0)
168
169 !> \note Input values must be floating points. \n
170
171 !> \author Rohini Kumar
172 !> \date Aug 2014
173
174 !> \author M. Schroen
175 !> \date Jul 2017
176 !! - add KGEnocorr
177
178 !> \author R. Kumar, J. Mai, & O. Rakovec
179 !> \date Sep 2014
180 !! - remove double packing of input data (bug)
181 !! - KGE instead of 1.0-KGE
182 !! - 1d, 2d, 3d, version in sp and dp
183
184 INTERFACE kgenocorr
185 MODULE PROCEDURE kgenocorr_dp_1d, kgenocorr_dp_2d, kgenocorr_dp_3d, kgenocorr_sp_1d, kgenocorr_sp_2d, kgenocorr_sp_3d
186 END INTERFACE kgenocorr
187
188
189 ! ------------------------------------------------------------------
190
191 !> \brief Logarithmic Nash Sutcliffe Efficiency.
192
193 !> \details Calculates the Logarithmic Nash Sutcliffe Efficiency
194 !!
195 !! \f[LNNSE = \frac{\sum_i(\ln(y_i) - \ln(x_i))^2} {\sum_i (\ln(x_i) - \ln(\bar x))^2 }\f]
196 !!
197 !! where \f$ x\f$ is the observation and \f$ y\f$ is the modelled data.\n
198 !!
199 !! If an optinal mask is given, the calculations are over those locations that correspond to true values in the mask.
200 !! Note that the mask is intent inout, since values which are less or equal zero will be masked additionally.
201 !! \f$ x \f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
202 !!
203 !! \b Example
204 !!
205 !! \code{.f90}
206 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
207 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
208 !! m = LNNSE(vec1, vec2, mask=(vec >= 0.))
209 !! --> m = 1.0
210 !! \endcode
211 !!
212 !! See also example in test directory.
213
214 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
215 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
216 !! If present, only those locations in vec corresponding to the true values in mask are used.
217
218 !> \retval "real(sp/dp) :: LNNSE" LNNSE.
219
220 !> \note
221 !! Input values must be floating points.
222
223 !> \author Juliane Mai
224 !> \date May 2013
225
226 !> \author Rohini Kumar
227 !> \date May 2013
228 !! - mean of logQ
229 INTERFACE lnnse
230 MODULE PROCEDURE lnnse_sp_1d, lnnse_dp_1d, lnnse_dp_2d, lnnse_sp_2d, lnnse_sp_3d, lnnse_dp_3d
231 END INTERFACE lnnse
232
233 ! ------------------------------------------------------------------
234
235 !> \brief Mean absolute error.
236
237 !> \details Calculates the mean absolute error,
238 !!
239 !! \f[ MAE = \sum_i\frac{|y_i - x_i|}{N_\text{mask}} \f]
240 !!
241 !! If an optinal mask is given, the calculations are over those locations that correspond to true values in the mask.
242 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
243 !!
244 !! \b Example
245 !!
246 !! \code{.f90}
247 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
248 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
249 !! m = MAE(vec1, vec2, mask=(vec >= 0.))
250 !! --> m = 0.0
251 !! \endcode
252 !!
253 !! See also example in test directory.
254
255 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
256 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
257 !! If present, only those locations in vec corresponding to the true values in mask are used.
258
259 !> \returns "real(sp/dp) :: MAE" MAE.
260
261 !> \note
262 !! Input values must be floating points.
263
264 !> \authors Matthias Zink
265 !> \date Sept 2012
266
267 ! ------------------------------------------------------------------
268
269 INTERFACE mae
270 MODULE PROCEDURE mae_sp_1d, mae_dp_1d, mae_sp_2d, mae_dp_2d, mae_sp_3d, mae_dp_3d
271 END INTERFACE mae
272
273 ! ------------------------------------------------------------------
274
275 !> \brief Mean squared error.
276
277 !> \details Calculates the mean squared error
278 !!
279 !! \f[ MSE = \sum_i\frac{(y_i - x_i)^2}{N_\text{mask}} \f]
280 !!
281 !! If an optional mask is given, the calculations are over those locations that correspond to true values in the mask.
282 !! x and y can be single or double precision. The result will have the same numerical precision.
283 !!
284 !! \b Example
285 !!
286 !! \code{.f90}
287 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
288 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
289 !! m = MSE(vec1, vec2, mask=(vec >= 0.))
290 !! --> m = 0.0
291 !! \endcode
292 !!
293 !! See also example in test directory.
294
295 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
296 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
297 !! If present, only those locations in vec corresponding to the true values in mask are used.
298 !> \retval "real(sp/dp) :: MSE" MSE.
299
300 !> \note
301 !! Input values must be floating points.
302
303 !> \authors Matthias Zink
304 !> \date Sept 2012
305
306 ! ------------------------------------------------------------------
307
308 INTERFACE mse
309 MODULE PROCEDURE mse_sp_1d, mse_dp_1d, mse_sp_2d, mse_dp_2d, mse_sp_3d, mse_dp_3d
310 END INTERFACE mse
311
312 ! ------------------------------------------------------------------
313
314 !> \brief Nash Sutcliffe Efficiency.
315
316 !> \details Calculates the Nash Sutcliffe Efficiency
317 !!
318 !! \f[NSE = \frac{\sum_i(y_i - x_i)^2} {\sum_i (x_i - \bar x)^2 }\f]
319 !!
320 !! where \f$ x\f$ is the observation and \f$ y\f$ is the modelled data.
321 !!
322 !! If an optinal mask is given, the calculations are over those locations that correspond to true values in the mask.
323 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
324 !!
325 !! \b Example
326 !!
327 !! \code{.f90}
328 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
329 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
330 !! m = NSE(vec1, vec2, mask=(vec >= 0.))
331 !! --> m = 1.0
332 !! \endcode
333 !!
334 !! See also example in test directory.
335 !!
336 !! \b Literature
337 !!
338 !! 1. Nash, J., & Sutcliffe, J. (1970). _River flow forecasting through conceptual models part I: A discussion of
339 !! principles_. Journal of Hydrology, 10(3), 282-290. doi:10.1016/0022-1694(70)90255-6
340 !!
341 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
342 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
343 !! If present, only those locations in vec corresponding to the true values in mask are used.
344 !> \retval "real(sp/dp) :: NSE" NSE.
345
346 !> \note
347 !! Input values must be floating points.
348
349 !> \authors Matthias Zink
350 !> \date Sept 2012
351
352 ! ------------------------------------------------------------------
353
354 INTERFACE nse
355 MODULE PROCEDURE nse_sp_1d, nse_dp_1d, nse_dp_2d, nse_sp_2d, nse_sp_3d, nse_dp_3d
356 END INTERFACE nse
357
358 ! ------------------------------------------------------------------
359
360 !> \brief Sum of absolute errors.
361
362 !> \details Calculates the sum of absolute errors
363 !!
364 !! \f[ SAE = \sum_i|y_i - x_i| \f]
365 !!
366 !! If an optional mask is given, the calculations are over those locations that correspond to true values in the mask.
367 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
368 !!
369 !! \b Example
370 !!
371 !! \code{.f90}
372 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
373 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
374 !! m = NSE(vec1, vec2, mask=(vec >= 0.))
375 !! --> m = 0.0
376 !! \endcode
377 !!
378 !! See also example in test directory.
379
380 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
381 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
382 !! If present, only those locations in vec corresponding to the true values in mask are used.
383
384 !> \returns "real(sp/dp) :: NSE" NSE.
385
386 !> \note
387 !! Input values must be floating points.
388
389 !> \authors Matthias Zink
390 !> \date Sept 2012
391
392 ! ------------------------------------------------------------------
393
394 INTERFACE sae
395 MODULE PROCEDURE sae_sp_1d, sae_dp_1d, sae_sp_2d, sae_dp_2d, sae_sp_3d, sae_dp_3d
396 END INTERFACE sae
397
398 ! ------------------------------------------------------------------
399
400 !> \brief Sum of squared errors
401
402 !> \details Calculates the sum of squared errors
403 !!
404 !! \f[ SSE = \sum_i(y_i - x_i)^2 \f]
405 !!
406 !! If an optional mask is given, the calculations are over those locations that correspond to true values in the mask.
407 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
408 !!
409 !! \b Example
410 !!
411 !! \code{.f90}
412 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
413 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
414 !! m = SSE(vec1, vec2, mask=(vec >= 0.))
415 !! --> m = 0.0
416 !! \endcode
417 !!
418 !! See also example in test directory.
419
420 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
421 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
422 !! If present, only those locations in vec corresponding to the true values in mask are used.
423 !> \retval "real(sp/dp) :: SSE" SSE.
424
425 !> \note
426 !! Input values must be floating points.
427
428 !> \authors Matthias Zink
429 !> \date Sept 2012
430
431 ! ------------------------------------------------------------------
432
433 INTERFACE sse
434 MODULE PROCEDURE sse_sp_1d, sse_dp_1d, sse_sp_2d, sse_dp_2d, sse_sp_3d, sse_dp_3d
435 END INTERFACE sse
436
437 ! ------------------------------------------------------------------
438
439 !> \brief RMS Error.
440
441 !> \details Calculates the root-mean-square error
442 !!
443 !! \f[ RMSE = \sqrt{\frac{\sum_i{(y_i - x_i)^2}} {{N_\text{count}}}} \f]
444 !!
445 !! If an optional mask is given, the calculations are over those locations that correspond to true values in the mask.
446 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
447 !!
448 !! \b Example
449 !!
450 !! \code{.f90}
451 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
452 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
453 !! m = RMSE(vec1, vec2, mask=(vec >= 0.))
454 !! --> m = 0.0
455 !! \endcode
456 !!
457 !! See also example in test directory.
458
459 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
460 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
461 !! If present, only those locations in vec corresponding to the true values in mask are used.
462 !> \retval "real(sp/dp) :: RMSE" RMSE.
463
464 !> \note
465 !! Input values must be floating points.
466
467 !> \authors Matthias Zink
468 !> \date Sept 2012
469
470 ! ------------------------------------------------------------------
471
472 INTERFACE rmse
473 MODULE PROCEDURE rmse_sp_1d, rmse_dp_1d, rmse_sp_2d, rmse_dp_2d, rmse_sp_3d, rmse_dp_3d
474 END INTERFACE rmse
475
476 ! ------------------------------------------------------------------
477
478 !> \brief weighted Nash Sutcliffe Efficiency.
479
480 !> Calculates the weighted Nash Sutcliffe Efficiency
481 !!
482 !! \f[ wNSE = \frac{\sum_i {x_i (y_i - x_i)^2}} {\sum_i{ x_i (x_i - \bar x)^2}} \f]
483 !!
484 !! where \f$ x\f$ is the observation and \f$ y\f$ is the modelled data.
485 !! This objective function is introduced in Hundecha and Bardossy, 2004.
486 !!
487 !! If an optinal mask is given, the calculations are over those locations that correspond to true values in the mask.
488 !! \f$ x\f$ and \f$ y\f$ can be single or double precision. The result will have the same numerical precision.
489 !!
490 !! \b Example
491 !!
492 !! \code{.f90}
493 !! vec1 = (/ 1., 2, 3., -999., 5., 6. /)
494 !! vec2 = (/ 1., 2, 3., -999., 5., 6. /)
495 !! m = wNSE(vec1, vec2, mask=(vec >= 0.))
496 !! --> m = 1.0
497 !! \endcode
498 !!
499 !! See also example in test directory.
500 !!
501 !! \b Literature
502 !!
503 !! 1. Nash, J., & Sutcliffe, J. (1970). _River flow forecasting through conceptual models part I: A discussion of
504 !! principles_. Journal of Hydrology, 10(3), 282-290. doi:10.1016/0022-1694(70)90255-6\n
505 !! 2. Hundecha and Bardossy (2004). _Modeling of the effect of land use changes on the runoff generation of a river
506 !! domain through parameter regionalization of a watershed model_. Journal of Hydrology, 292, 281-295
507 !!
508 !> \param[in] "real(sp/dp), dimension() :: x, y" 1D/2D/3D-array with input numbers.
509 !> \param[in] "logical, optional :: mask" 1D/2D/Array-array of logical values with `size(x/y)`.
510 !! If present, only those locations in vec corresponding to the true values in mask are used.
511 !> \retval "real(sp/dp) :: wNSE" wNSE.
512
513 !> \note
514 !! Input values must be floating points.
515
516 !> \authors Matthias Zink & Bjoern Guse
517 !> \date May 2018
518
519 ! ------------------------------------------------------------------
520
521 INTERFACE wnse
522 MODULE PROCEDURE wnse_sp_1d, wnse_dp_1d, wnse_dp_2d, wnse_sp_2d, wnse_sp_3d, wnse_dp_3d
523 END INTERFACE wnse
524
525 ! ------------------------------------------------------------------
526
527 PRIVATE
528
529 ! ------------------------------------------------------------------
530
531CONTAINS
532
533 ! ------------------------------------------------------------------
534
535 FUNCTION bias_sp_1d(x, y, mask)
536
537 USE mo_moment, ONLY : average
538
539 IMPLICIT NONE
540
541 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
542 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
543 REAL(sp) :: BIAS_sp_1d
544
545 INTEGER(i4) :: n
546 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
547 LOGICAL, DIMENSION(size(x)) :: maske
548
549 if (present(mask)) then
550 shapemask = shape(mask)
551 else
552 shapemask = shape(x)
553 end if
554 !
555 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
556 stop 'BIAS_sp_1d: shapes of inputs(x,y) or mask are not matching'
557 !
558 if (present(mask)) then
559 maske = mask
560 n = count(maske)
561 else
562 maske = .true.
563 n = size(x)
564 end if
565 !
566 if (n .LE. 1_i4) stop 'BIAS_sp_1d: number of arguments must be at least 2'
567 !
568 bias_sp_1d = average(y, mask = maske) - average(x, mask = maske)
569
570 END FUNCTION bias_sp_1d
571
572 FUNCTION bias_dp_1d(x, y, mask)
573
574 USE mo_moment, ONLY : average
575
576 IMPLICIT NONE
577
578 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
579 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
580 REAL(dp) :: BIAS_dp_1d
581
582 INTEGER(i4) :: n
583 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
584 LOGICAL, DIMENSION(size(x)) :: maske
585
586 if (present(mask)) then
587 shapemask = shape(mask)
588 else
589 shapemask = shape(x)
590 end if
591 !
592 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
593 stop 'BIAS_dp_1d: shapes of inputs(x,y) or mask are not matching'
594 !
595 if (present(mask)) then
596 maske = mask
597 n = count(maske)
598 else
599 maske = .true.
600 n = size(x)
601 end if
602 if (n .LE. 1_i4) stop 'BIAS_dp_1d: number of arguments must be at least 2'
603 !
604 bias_dp_1d = average(y, mask = maske) - average(x, mask = maske)
605
606 END FUNCTION bias_dp_1d
607
608 FUNCTION bias_sp_2d(x, y, mask)
609
610 USE mo_moment, ONLY : average
611
612 IMPLICIT NONE
613
614 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
615 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
616 REAL(sp) :: BIAS_sp_2d
617
618 INTEGER(i4) :: n
619
620 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
621 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
622
623 if (present(mask)) then
624 shapemask = shape(mask)
625 else
626 shapemask = shape(x)
627 end if
628 !
629 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
630 stop 'BIAS_sp_2d: shapes of inputs(x,y) or mask are not matching'
631 !
632 if (present(mask)) then
633 maske = mask
634 n = count(maske)
635 else
636 maske = .true.
637 n = size(x, dim = 1) * size(x, dim = 2)
638 end if
639 !
640 if (n .LE. 1_i4) stop 'BIAS_sp_2d: number of arguments must be at least 2'
641 !
642 bias_sp_2d = average(reshape(y, (/size(y, dim = 1) * size(y, dim = 2)/)), &
643 mask = reshape(maske, (/size(y, dim = 1) * size(y, dim = 2)/))) - &
644 average(reshape(x, (/size(x, dim = 1) * size(x, dim = 2)/)), &
645 mask = reshape(maske, (/size(x, dim = 1) * size(x, dim = 2)/)))
646 !
647 END FUNCTION bias_sp_2d
648
649 FUNCTION bias_dp_2d(x, y, mask)
650
651 USE mo_moment, ONLY : average
652
653 IMPLICIT NONE
654
655 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
656 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
657 REAL(dp) :: BIAS_dp_2d
658
659 INTEGER(i4) :: n
660 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
661 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
662
663 if (present(mask)) then
664 shapemask = shape(mask)
665 else
666 shapemask = shape(x)
667 end if
668 !
669 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
670 stop 'BIAS_dp_2d: shapes of inputs(x,y) or mask are not matching'
671 !
672 if (present(mask)) then
673 maske = mask
674 n = count(maske)
675 else
676 maske = .true.
677 n = size(x, dim = 1) * size(x, dim = 2)
678 end if
679 !
680 if (n .LE. 1_i4) stop 'BIAS_dp_2d: number of arguments must be at least 2'
681 !
682 bias_dp_2d = average(reshape(y, (/size(y, dim = 1) * size(y, dim = 2)/)), &
683 mask = reshape(maske, (/size(y, dim = 1) * size(y, dim = 2)/))) - &
684 average(reshape(x, (/size(x, dim = 1) * size(x, dim = 2)/)), &
685 mask = reshape(maske, (/size(x, dim = 1) * size(x, dim = 2)/)))
686 !
687 END FUNCTION bias_dp_2d
688
689 FUNCTION bias_sp_3d(x, y, mask)
690
691 USE mo_moment, ONLY : average
692
693 IMPLICIT NONE
694
695 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
696 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
697 REAL(sp) :: BIAS_sp_3d
698
699 INTEGER(i4) :: n
700 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
701 LOGICAL, DIMENSION(size(x, dim = 1), & size(x, dim = 2), size(x, dim = 3)) :: maske
702
703 if (present(mask)) then
704 shapemask = shape(mask)
705 else
706 shapemask = shape(x)
707 end if
708 !
709 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
710 stop 'BIAS_sp_3d: shapes of inputs(x,y) or mask are not matching'
711 !
712 if (present(mask)) then
713 maske = mask
714 n = count(maske)
715 else
716 maske = .true.
717 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
718 end if
719 !
720 ! not really sopisticated, it has to be checked if the 3 numbers of x and y are matching in arry position
721 if (n .LE. 1_i4) stop 'BIAS_sp_3d: number of arguments must be at least 2'
722 !
723 bias_sp_3d = average(reshape(y, (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
724 mask = reshape(maske, (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/))) - &
725 average(reshape(x, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
726 mask = reshape(maske, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
727 !
728 END FUNCTION bias_sp_3d
729
730 FUNCTION bias_dp_3d(x, y, mask)
731
732 USE mo_moment, ONLY : average
733
734 IMPLICIT NONE
735
736 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
737 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
738 REAL(dp) :: BIAS_dp_3d
739
740 INTEGER(i4) :: n
741 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
742 LOGICAL, DIMENSION(size(x, dim = 1), & size(x, dim = 2), size(x, dim = 3)) :: maske
743
744 if (present(mask)) then
745 shapemask = shape(mask)
746 else
747 shapemask = shape(x)
748 end if
749 !
750 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
751 stop 'BIAS_dp_3d: shapes of inputs(x,y) or mask are not matching'
752 !
753 if (present(mask)) then
754 maske = mask
755 n = count(maske)
756 else
757 maske = .true.
758 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
759 end if
760 !
761 ! not really sopisticated, it has to be checked if the 3 numbers of x and y are matching in arry position
762 if (n .LE. 1_i4) stop 'BIAS_dp_3d: number of arguments must be at least 2'
763 !
764 bias_dp_3d = average(reshape(y, (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
765 mask = reshape(maske, (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/))) - &
766 average(reshape(x, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
767 mask = reshape(maske, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
768 !
769 END FUNCTION bias_dp_3d
770
771 ! ------------------------------------------------------------------
772
773 FUNCTION kge_sp_1d(x, y, mask)
774
775 USE mo_moment, ONLY : average, stddev, correlation
776
777 IMPLICIT NONE
778
779 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
780 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
781 REAL(sp) :: KGE_sp_1d
782
783 ! local variables
784 INTEGER(i4) :: n
785 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
786 LOGICAL, DIMENSION(size(x)) :: maske
787
788 REAL(sp) :: mu_Obs, mu_Sim ! Mean of x and y
789 REAL(sp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
790 REAL(sp) :: pearson_coor ! Pearson Corr. of x and y
791
792 if (present(mask)) then
793 shapemask = shape(mask)
794 else
795 shapemask = shape(x)
796 end if
797 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
798 stop 'KGE_sp_1d: shapes of inputs(x,y) or mask are not matching'
799 !
800 if (present(mask)) then
801 maske = mask
802 n = count(maske)
803 else
804 maske = .true.
805 n = size(x)
806 end if
807 if (n .LE. 1_i4) stop 'KGE_sp_1d: sample size must be at least 2'
808
809 ! Mean
810 mu_obs = average(x, mask = maske)
811 mu_sim = average(y, mask = maske)
812 ! Standard Deviation
813 sigma_obs = stddev(x, mask = maske)
814 sigma_sim = stddev(y, mask = maske)
815 ! Pearson product-moment correlation coefficient is with (N-1) not N
816 pearson_coor = correlation(x, y, mask = maske) * real(n, sp) / real(n - 1, sp)
817 !
818 kge_sp_1d = 1.0 - sqrt(&
819 (1.0_sp - (mu_sim / mu_obs))**2 + &
820 (1.0_sp - (sigma_sim / sigma_obs))**2 + &
821 (1.0_sp - pearson_coor)**2 &
822 )
823
824 END FUNCTION kge_sp_1d
825
826 FUNCTION kge_sp_2d(x, y, mask)
827
828 USE mo_moment, ONLY : average, stddev, correlation
829
830 IMPLICIT NONE
831
832 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
833 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
834 REAL(sp) :: KGE_sp_2d
835
836 ! local variables
837 INTEGER(i4) :: n
838 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
839 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
840 REAL(sp) :: mu_Obs, mu_Sim ! Mean of x and y
841 REAL(sp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
842 REAL(sp) :: pearson_coor ! Pearson Corr. of x and y
843
844 if (present(mask)) then
845 shapemask = shape(mask)
846 else
847 shapemask = shape(x)
848 end if
849 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
850 stop 'KGE_sp_2d: shapes of inputs(x,y) or mask are not matching'
851 !
852 if (present(mask)) then
853 maske = mask
854 n = count(maske)
855 else
856 maske = .true.
857 n = size(x)
858 end if
859 if (n .LE. 1_i4) stop 'KGE_sp_2d: sample size must be at least 2'
860
861 ! Mean
862 mu_obs = average(&
863 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
864 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
865 mu_sim = average(&
866 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
867 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
868 ! Standard Deviation
869 sigma_obs = stddev(&
870 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
871 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
872 sigma_sim = stddev(&
873 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
874 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
875 ! Pearson product-moment correlation coefficient is with (N-1) not N
876 pearson_coor = correlation(&
877 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
878 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
879 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/))) * &
880 real(n, sp) / real(n - 1, sp)
881 !
882 kge_sp_2d = 1.0 - sqrt(&
883 (1.0_sp - (mu_sim / mu_obs))**2 + &
884 (1.0_sp - (sigma_sim / sigma_obs))**2 + &
885 (1.0_sp - pearson_coor)**2 &
886 )
887
888 END FUNCTION kge_sp_2d
889
890 FUNCTION kge_sp_3d(x, y, mask)
891
892 USE mo_moment, ONLY : average, stddev, correlation
893
894 IMPLICIT NONE
895
896 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
897 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
898 REAL(sp) :: KGE_sp_3d
899
900 ! local variables
901 INTEGER(i4) :: n
902 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
903 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: maske
904 REAL(sp) :: mu_Obs, mu_Sim ! Mean of x and y
905 REAL(sp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
906 REAL(sp) :: pearson_coor ! Pearson Corr. of x and y
907
908 if (present(mask)) then
909 shapemask = shape(mask)
910 else
911 shapemask = shape(x)
912 end if
913 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
914 stop 'KGE_sp_3d: shapes of inputs(x,y) or mask are not matching'
915 !
916 if (present(mask)) then
917 maske = mask
918 n = count(maske)
919 else
920 maske = .true.
921 n = size(x)
922 end if
923 if (n .LE. 1_i4) stop 'KGE_sp_3d: sample size must be at least 2'
924
925 ! Mean
926 mu_obs = average(&
927 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
928 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
929 mu_sim = average(&
930 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
931 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
932 ! Standard Deviation
933 sigma_obs = stddev(&
934 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
935 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
936 sigma_sim = stddev(&
937 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
938 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
939 ! Pearson product-moment correlation coefficient is with (N-1) not N
940 pearson_coor = correlation(&
941 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
942 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
943 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/))) * &
944 real(n, sp) / real(n - 1, sp)
945 !
946 kge_sp_3d = 1.0 - sqrt(&
947 (1.0_sp - (mu_sim / mu_obs))**2 + &
948 (1.0_sp - (sigma_sim / sigma_obs))**2 + &
949 (1.0_sp - pearson_coor)**2 &
950 )
951
952 END FUNCTION kge_sp_3d
953
954 FUNCTION kge_dp_1d(x, y, mask)
955
956 USE mo_moment, ONLY : average, stddev, correlation
957
958 IMPLICIT NONE
959
960 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
961 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
962 REAL(dp) :: KGE_dp_1d
963
964 ! local variables
965 INTEGER(i4) :: n
966 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
967 LOGICAL, DIMENSION(size(x)) :: maske
968
969 REAL(dp) :: mu_Obs, mu_Sim ! Mean of x and y
970 REAL(dp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
971 REAL(dp) :: pearson_coor ! Pearson Corr. of x and y
972
973 if (present(mask)) then
974 shapemask = shape(mask)
975 else
976 shapemask = shape(x)
977 end if
978 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
979 stop 'KGE_dp_1d: shapes of inputs(x,y) or mask are not matching'
980 !
981 if (present(mask)) then
982 maske = mask
983 n = count(maske)
984 else
985 maske = .true.
986 n = size(x)
987 end if
988 if (n .LE. 1_i4) stop 'KGE_dp_1d: sample size must be at least 2'
989
990 ! Mean
991 mu_obs = average(x, mask = maske)
992 mu_sim = average(y, mask = maske)
993 ! Standard Deviation
994 sigma_obs = stddev(x, mask = maske)
995 sigma_sim = stddev(y, mask = maske)
996 ! Pearson product-moment correlation coefficient is with (N-1) not N
997 pearson_coor = correlation(x, y, mask = maske) * real(n, dp) / real(n - 1, dp)
998 !
999 kge_dp_1d = 1.0 - sqrt(&
1000 (1.0_dp - (mu_sim / mu_obs))**2 + &
1001 (1.0_dp - (sigma_sim / sigma_obs))**2 + &
1002 (1.0_dp - pearson_coor)**2 &
1003 )
1004
1005 END FUNCTION kge_dp_1d
1006
1007 FUNCTION kge_dp_2d(x, y, mask)
1008
1009 USE mo_moment, ONLY : average, stddev, correlation
1010
1011 IMPLICIT NONE
1012
1013 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
1014 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
1015 REAL(dp) :: KGE_dp_2d
1016
1017 ! local variables
1018 INTEGER(i4) :: n
1019 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1020 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1021 REAL(dp) :: mu_Obs, mu_Sim ! Mean of x and y
1022 REAL(dp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1023 REAL(dp) :: pearson_coor ! Pearson Corr. of x and y
1024
1025 if (present(mask)) then
1026 shapemask = shape(mask)
1027 else
1028 shapemask = shape(x)
1029 end if
1030 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1031 stop 'KGE_dp_2d: shapes of inputs(x,y) or mask are not matching'
1032 !
1033 if (present(mask)) then
1034 maske = mask
1035 n = count(maske)
1036 else
1037 maske = .true.
1038 n = size(x)
1039 end if
1040 if (n .LE. 1_i4) stop 'KGE_dp_2d: sample size must be at least 2'
1041
1042 ! Mean
1043 mu_obs = average(&
1044 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1045 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
1046 mu_sim = average(&
1047 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1048 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
1049 ! Standard Deviation
1050 sigma_obs = stddev(&
1051 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1052 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
1053 sigma_sim = stddev(&
1054 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1055 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
1056 ! Pearson product-moment correlation coefficient is with (N-1) not N
1057 pearson_coor = correlation(&
1058 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1059 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1060 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/))) * &
1061 real(n, dp) / real(n - 1, dp)
1062 !
1063 kge_dp_2d = 1.0 - sqrt(&
1064 (1.0_dp - (mu_sim / mu_obs))**2 + &
1065 (1.0_dp - (sigma_sim / sigma_obs))**2 + &
1066 (1.0_dp - pearson_coor)**2 &
1067 )
1068
1069 END FUNCTION kge_dp_2d
1070
1071 FUNCTION kge_dp_3d(x, y, mask)
1072
1073 USE mo_moment, ONLY : average, stddev, correlation
1074
1075 IMPLICIT NONE
1076
1077 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1078 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
1079 REAL(dp) :: KGE_dp_3d
1080
1081 ! local variables
1082 INTEGER(i4) :: n
1083 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1084 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: maske
1085 REAL(dp) :: mu_Obs, mu_Sim ! Mean of x and y
1086 REAL(dp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1087 REAL(dp) :: pearson_coor ! Pearson Corr. of x and y
1088
1089 if (present(mask)) then
1090 shapemask = shape(mask)
1091 else
1092 shapemask = shape(x)
1093 end if
1094 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1095 stop 'KGE_dp_3d: shapes of inputs(x,y) or mask are not matching'
1096 !
1097 if (present(mask)) then
1098 maske = mask
1099 n = count(maske)
1100 else
1101 maske = .true.
1102 n = size(x)
1103 end if
1104 if (n .LE. 1_i4) stop 'KGE_dp_3d: sample size must be at least 2'
1105
1106 ! Mean
1107 mu_obs = average(&
1108 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1109 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
1110 mu_sim = average(&
1111 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1112 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
1113 ! Standard Deviation
1114 sigma_obs = stddev(&
1115 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1116 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
1117 sigma_sim = stddev(&
1118 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1119 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
1120 ! Pearson product-moment correlation coefficient is with (N-1) not N
1121 pearson_coor = correlation(&
1122 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1123 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1124 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/))) * &
1125 real(n, dp) / real(n - 1, dp)
1126 !
1127 kge_dp_3d = 1.0 - sqrt(&
1128 (1.0_dp - (mu_sim / mu_obs))**2 + &
1129 (1.0_dp - (sigma_sim / sigma_obs))**2 + &
1130 (1.0_dp - pearson_coor)**2 &
1131 )
1132
1133 END FUNCTION kge_dp_3d
1134
1135 ! ------------------------------------------------------------------
1136
1137 FUNCTION kgenocorr_sp_1d(x, y, mask)
1138
1139 USE mo_moment, ONLY : average, stddev
1140
1141 IMPLICIT NONE
1142
1143 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
1144 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
1145 REAL(sp) :: KGEnocorr_sp_1d
1146
1147 ! local variables
1148 INTEGER(i4) :: n
1149 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1150 LOGICAL, DIMENSION(size(x)) :: maske
1151
1152 REAL(sp) :: mu_Obs, mu_Sim ! Mean of x and y
1153 REAL(sp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1154
1155 if (present(mask)) then
1156 shapemask = shape(mask)
1157 else
1158 shapemask = shape(x)
1159 end if
1160 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1161 stop 'KGEnocorr_sp_1d: shapes of inputs(x,y) or mask are not matching'
1162 !
1163 if (present(mask)) then
1164 maske = mask
1165 n = count(maske)
1166 else
1167 maske = .true.
1168 n = size(x)
1169 end if
1170 if (n .LE. 1_i4) stop 'KGEnocorr_sp_1d: sample size must be at least 2'
1171
1172 ! Mean
1173 mu_obs = average(x, mask = maske)
1174 mu_sim = average(y, mask = maske)
1175 ! Standard Deviation
1176 sigma_obs = stddev(x, mask = maske)
1177 sigma_sim = stddev(y, mask = maske)
1178
1179 !
1180 kgenocorr_sp_1d = 1.0 - sqrt(&
1181 (1.0_sp - (mu_sim / mu_obs))**2 + &
1182 (1.0_sp - (sigma_sim / sigma_obs))**2 &
1183 )
1184
1185 END FUNCTION kgenocorr_sp_1d
1186
1187 FUNCTION kgenocorr_sp_2d(x, y, mask)
1188
1189 USE mo_moment, ONLY : average, stddev
1190
1191 IMPLICIT NONE
1192
1193 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
1194 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
1195 REAL(sp) :: KGEnocorr_sp_2d
1196
1197 ! local variables
1198 INTEGER(i4) :: n
1199 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1200 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1201 REAL(sp) :: mu_Obs, mu_Sim ! Mean of x and y
1202 REAL(sp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1203
1204 if (present(mask)) then
1205 shapemask = shape(mask)
1206 else
1207 shapemask = shape(x)
1208 end if
1209 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1210 stop 'KGEnocorr_sp_2d: shapes of inputs(x,y) or mask are not matching'
1211 !
1212 if (present(mask)) then
1213 maske = mask
1214 n = count(maske)
1215 else
1216 maske = .true.
1217 n = size(x)
1218 end if
1219 if (n .LE. 1_i4) stop 'KGEnocorr_sp_2d: sample size must be at least 2'
1220
1221 ! Mean
1222 mu_obs = average(&
1223 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1224 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
1225 mu_sim = average(&
1226 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1227 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
1228 ! Standard Deviation
1229 sigma_obs = stddev(&
1230 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1231 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
1232 sigma_sim = stddev(&
1233 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1234 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
1235 !
1236 kgenocorr_sp_2d = 1.0 - sqrt(&
1237 (1.0_sp - (mu_sim / mu_obs))**2 + &
1238 (1.0_sp - (sigma_sim / sigma_obs))**2 &
1239 )
1240
1241 END FUNCTION kgenocorr_sp_2d
1242
1243 FUNCTION kgenocorr_sp_3d(x, y, mask)
1244
1245 USE mo_moment, ONLY : average, stddev
1246
1247 IMPLICIT NONE
1248
1249 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1250 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
1251 REAL(sp) :: KGEnocorr_sp_3d
1252
1253 ! local variables
1254 INTEGER(i4) :: n
1255 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1256 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: maske
1257 REAL(sp) :: mu_Obs, mu_Sim ! Mean of x and y
1258 REAL(sp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1259
1260 if (present(mask)) then
1261 shapemask = shape(mask)
1262 else
1263 shapemask = shape(x)
1264 end if
1265 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1266 stop 'KGEnocorr_sp_3d: shapes of inputs(x,y) or mask are not matching'
1267 !
1268 if (present(mask)) then
1269 maske = mask
1270 n = count(maske)
1271 else
1272 maske = .true.
1273 n = size(x)
1274 end if
1275 if (n .LE. 1_i4) stop 'KGEnocorr_sp_3d: sample size must be at least 2'
1276
1277 ! Mean
1278 mu_obs = average(&
1279 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1280 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
1281 mu_sim = average(&
1282 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1283 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
1284 ! Standard Deviation
1285 sigma_obs = stddev(&
1286 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1287 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
1288 sigma_sim = stddev(&
1289 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1290 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
1291
1292 !
1293 kgenocorr_sp_3d = 1.0 - sqrt(&
1294 (1.0_sp - (mu_sim / mu_obs))**2 + &
1295 (1.0_sp - (sigma_sim / sigma_obs))**2 &
1296 )
1297
1298 END FUNCTION kgenocorr_sp_3d
1299
1300 FUNCTION kgenocorr_dp_1d(x, y, mask)
1301
1302 USE mo_moment, ONLY : average, stddev
1303
1304 IMPLICIT NONE
1305
1306 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
1307 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
1308 REAL(dp) :: KGEnocorr_dp_1d
1309
1310 ! local variables
1311 INTEGER(i4) :: n
1312 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1313 LOGICAL, DIMENSION(size(x)) :: maske
1314
1315 REAL(dp) :: mu_Obs, mu_Sim ! Mean of x and y
1316 REAL(dp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1317
1318 if (present(mask)) then
1319 shapemask = shape(mask)
1320 else
1321 shapemask = shape(x)
1322 end if
1323 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1324 stop 'KGEnocorr_dp_1d: shapes of inputs(x,y) or mask are not matching'
1325 !
1326 if (present(mask)) then
1327 maske = mask
1328 n = count(maske)
1329 else
1330 maske = .true.
1331 n = size(x)
1332 end if
1333 if (n .LE. 1_i4) stop 'KGEnocorr_dp_1d: sample size must be at least 2'
1334
1335 ! Mean
1336 mu_obs = average(x, mask = maske)
1337 mu_sim = average(y, mask = maske)
1338 ! Standard Deviation
1339 sigma_obs = stddev(x, mask = maske)
1340 sigma_sim = stddev(y, mask = maske)
1341
1342 !
1343 kgenocorr_dp_1d = 1.0 - sqrt(&
1344 (1.0_dp - (mu_sim / mu_obs))**2 + &
1345 (1.0_dp - (sigma_sim / sigma_obs))**2 &
1346 )
1347
1348 END FUNCTION kgenocorr_dp_1d
1349
1350 FUNCTION kgenocorr_dp_2d(x, y, mask)
1351
1352 USE mo_moment, ONLY : average, stddev
1353
1354 IMPLICIT NONE
1355
1356 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
1357 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
1358 REAL(dp) :: KGEnocorr_dp_2d
1359
1360 ! local variables
1361 INTEGER(i4) :: n
1362 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1363 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1364 REAL(dp) :: mu_Obs, mu_Sim ! Mean of x and y
1365 REAL(dp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1366
1367 if (present(mask)) then
1368 shapemask = shape(mask)
1369 else
1370 shapemask = shape(x)
1371 end if
1372 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1373 stop 'KGEnocorr_dp_2d: shapes of inputs(x,y) or mask are not matching'
1374 !
1375 if (present(mask)) then
1376 maske = mask
1377 n = count(maske)
1378 else
1379 maske = .true.
1380 n = size(x)
1381 end if
1382 if (n .LE. 1_i4) stop 'KGEnocorr_dp_2d: sample size must be at least 2'
1383
1384 ! Mean
1385 mu_obs = average(&
1386 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1387 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
1388 mu_sim = average(&
1389 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1390 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
1391 ! Standard Deviation
1392 sigma_obs = stddev(&
1393 reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
1394 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
1395 sigma_sim = stddev(&
1396 reshape(y(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)), &
1397 mask = reshape(maske(:, :), (/size(y, dim = 1) * size(y, dim = 2)/)))
1398 !
1399 kgenocorr_dp_2d = 1.0 - sqrt(&
1400 (1.0_dp - (mu_sim / mu_obs))**2 + &
1401 (1.0_dp - (sigma_sim / sigma_obs))**2 &
1402 )
1403
1404 END FUNCTION kgenocorr_dp_2d
1405
1406 FUNCTION kgenocorr_dp_3d(x, y, mask)
1407
1408 USE mo_moment, ONLY : average, stddev
1409
1410 IMPLICIT NONE
1411
1412 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1413 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
1414 REAL(dp) :: KGEnocorr_dp_3d
1415
1416 ! local variables
1417 INTEGER(i4) :: n
1418 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1419 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: maske
1420 REAL(dp) :: mu_Obs, mu_Sim ! Mean of x and y
1421 REAL(dp) :: sigma_Obs, sigma_Sim ! Standard dev. of x and y
1422
1423 if (present(mask)) then
1424 shapemask = shape(mask)
1425 else
1426 shapemask = shape(x)
1427 end if
1428 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1429 stop 'KGEnocorr_dp_3d: shapes of inputs(x,y) or mask are not matching'
1430 !
1431 if (present(mask)) then
1432 maske = mask
1433 n = count(maske)
1434 else
1435 maske = .true.
1436 n = size(x)
1437 end if
1438 if (n .LE. 1_i4) stop 'KGEnocorr_dp_3d: sample size must be at least 2'
1439
1440 ! Mean
1441 mu_obs = average(&
1442 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1443 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
1444 mu_sim = average(&
1445 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1446 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
1447 ! Standard Deviation
1448 sigma_obs = stddev(&
1449 reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
1450 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
1451 sigma_sim = stddev(&
1452 reshape(y(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)), &
1453 mask = reshape(maske(:, :, :), (/size(y, dim = 1) * size(y, dim = 2) * size(y, dim = 3)/)))
1454
1455 !
1456 kgenocorr_dp_3d = 1.0 - sqrt(&
1457 (1.0_dp - (mu_sim / mu_obs))**2 + &
1458 (1.0_dp - (sigma_sim / sigma_obs))**2 &
1459 )
1460
1461 END FUNCTION kgenocorr_dp_3d
1462
1463
1464 ! ------------------------------------------------------------------
1465
1466 FUNCTION lnnse_sp_1d(x, y, mask)
1467
1468 USE mo_moment, ONLY : average
1469
1470 IMPLICIT NONE
1471
1472 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
1473 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(INOUT) :: mask
1474 REAL(sp) :: LNNSE_sp_1d
1475
1476 INTEGER(i4) :: n
1477 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1478 REAL(sp) :: xmean
1479 REAL(sp), DIMENSION(size(x)) :: logx, logy, v1, v2
1480 LOGICAL, DIMENSION(size(x)) :: maske
1481
1482 if (present(mask)) then
1483 shapemask = shape(mask)
1484 else
1485 shapemask = shape(x)
1486 end if
1487 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1488 stop 'LNNSE_sp_1d: shapes of inputs(x,y) or mask are not matching'
1489 !
1490 if (present(mask)) then
1491 maske = mask
1492 else
1493 maske = .true.
1494 end if
1495
1496 ! mask all negative and zero entries
1497 where (x .lt. tiny(1.0_sp) .or. y .lt. tiny(1.0_sp))
1498 maske = .false.
1499 end where
1500 n = count(maske)
1501 if (n .LE. 1_i4) stop 'LNNSE_sp_1d: number of arguments must be at least 2'
1502
1503 ! logarithms
1504 logx = 0.0_sp
1505 logy = 0.0_sp
1506 where (maske)
1507 logx = log(x)
1508 logy = log(y)
1509 end where
1510
1511 ! mean of x
1512 xmean = average(logx, mask = maske)
1513
1514 ! NSE
1515 v1 = merge(logy - logx, 0.0_sp, maske)
1516 v2 = merge(logx - xmean, 0.0_sp, maske)
1517 lnnse_sp_1d = 1.0_sp - dot_product(v1, v1) / dot_product(v2, v2)
1518
1519 END FUNCTION lnnse_sp_1d
1520
1521 ! ------------------------------------------------------------------
1522
1523 FUNCTION lnnse_dp_1d(x, y, mask)
1524
1525 USE mo_moment, ONLY : average
1526
1527 IMPLICIT NONE
1528
1529 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
1530 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(INOUT) :: mask
1531 REAL(dp) :: LNNSE_dp_1d
1532
1533 INTEGER(i4) :: n
1534 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1535 REAL(dp) :: xmean
1536 REAL(dp), DIMENSION(size(x)) :: logx, logy, v1, v2
1537 LOGICAL, DIMENSION(size(x)) :: maske
1538
1539 if (present(mask)) then
1540 shapemask = shape(mask)
1541 else
1542 shapemask = shape(x)
1543 end if
1544 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1545 stop 'LNNSE_dp_1d: shapes of inputs(x,y) or mask are not matching'
1546 !
1547 if (present(mask)) then
1548 maske = mask
1549 else
1550 maske = .true.
1551 end if
1552
1553 ! mask all negative and zero entries
1554 where (x .lt. tiny(1.0_dp) .or. y .lt. tiny(1.0_dp))
1555 maske = .false.
1556 end where
1557 n = count(maske)
1558 if (n .LE. 1_i4) stop 'LNNSE_dp_1d: number of arguments must be at least 2'
1559
1560 ! logarithms
1561 logx = 0.0_dp
1562 logy = 0.0_dp
1563 where (maske)
1564 logx = log(x)
1565 logy = log(y)
1566 end where
1567
1568 ! mean of x
1569 xmean = average(logx, mask = maske)
1570
1571 ! NSE
1572 v1 = merge(logy - logx, 0.0_dp, maske)
1573 v2 = merge(logx - xmean, 0.0_dp, maske)
1574 lnnse_dp_1d = 1.0_dp - sum(v1 * v1, mask = maske) / sum(v2 * v2, mask = maske)
1575
1576 END FUNCTION lnnse_dp_1d
1577
1578 ! ------------------------------------------------------------------
1579
1580 FUNCTION lnnse_sp_2d(x, y, mask)
1581
1582 USE mo_moment, ONLY : average
1583
1584 IMPLICIT NONE
1585
1586 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
1587 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(INOUT) :: mask
1588 REAL(sp) :: LNNSE_sp_2d
1589
1590 INTEGER(i4) :: n
1591 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1592 REAL(sp) :: xmean
1593 REAL(sp), DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: logx, logy, v1, v2
1594 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1595
1596 if (present(mask)) then
1597 shapemask = shape(mask)
1598 else
1599 shapemask = shape(x)
1600 end if
1601 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1602 stop 'LNNSE_sp_2d: shapes of inputs(x,y) or mask are not matching'
1603 !
1604 if (present(mask)) then
1605 maske = mask
1606 else
1607 maske = .true.
1608 end if
1609
1610 ! mask all negative and zero entries
1611 where (x .lt. tiny(1.0_sp) .or. y .lt. tiny(1.0_sp))
1612 maske = .false.
1613 end where
1614 n = count(maske)
1615 if (n .LE. 1_i4) stop 'LNNSE_sp_2d: number of arguments must be at least 2'
1616
1617 ! logarithms
1618 logx = 0.0_sp
1619 logy = 0.0_sp
1620 where (maske)
1621 logx = log(x)
1622 logy = log(y)
1623 end where
1624
1625 ! mean of x
1626 xmean = average(pack(logx, maske))
1627
1628 ! NSE
1629 v1 = merge(logy - logx, 0.0_sp, maske)
1630 v2 = merge(logx - xmean, 0.0_sp, maske)
1631 lnnse_sp_2d = 1.0_sp - sum(v1 * v1, mask = maske) / sum(v2 * v2, mask = maske)
1632
1633 END FUNCTION lnnse_sp_2d
1634
1635 ! ------------------------------------------------------------------
1636
1637 FUNCTION lnnse_dp_2d(x, y, mask)
1638
1639 USE mo_moment, ONLY : average
1640
1641 IMPLICIT NONE
1642
1643 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
1644 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(INOUT) :: mask
1645 REAL(dp) :: LNNSE_dp_2d
1646
1647 INTEGER(i4) :: n
1648 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1649 REAL(dp) :: xmean
1650 REAL(dp), DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: logx, logy, v1, v2
1651 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1652
1653 if (present(mask)) then
1654 shapemask = shape(mask)
1655 else
1656 shapemask = shape(x)
1657 end if
1658 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1659 stop 'LNNSE_dp_2d: shapes of inputs(x,y) or mask are not matching'
1660 !
1661 if (present(mask)) then
1662 maske = mask
1663 else
1664 maske = .true.
1665 end if
1666
1667 ! mask all negative and zero entries
1668 where (x .lt. tiny(1.0_dp) .or. y .lt. tiny(1.0_dp))
1669 maske = .false.
1670 end where
1671 n = count(maske)
1672 if (n .LE. 1_i4) stop 'LNNSE_dp_2d: number of arguments must be at least 2'
1673
1674 ! logarithms
1675 logx = 0.0_dp
1676 logy = 0.0_dp
1677 where (maske)
1678 logx = log(x)
1679 logy = log(y)
1680 end where
1681
1682 ! mean of x
1683 xmean = average(pack(logx, maske))
1684
1685 ! NSE
1686 v1 = merge(logy - logx, 0.0_dp, maske)
1687 v2 = merge(logx - xmean, 0.0_dp, maske)
1688 lnnse_dp_2d = 1.0_dp - sum(v1 * v1, mask = maske) / sum(v2 * v2, mask = maske)
1689
1690 END FUNCTION lnnse_dp_2d
1691
1692 ! ------------------------------------------------------------------
1693
1694 FUNCTION lnnse_sp_3d(x, y, mask)
1695
1696 USE mo_moment, ONLY : average
1697
1698 IMPLICIT NONE
1699
1700 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1701 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(INOUT) :: mask
1702 REAL(sp) :: LNNSE_sp_3d
1703
1704 INTEGER(i4) :: n
1705 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1706 REAL(sp) :: xmean
1707 REAL(sp), DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: logx, logy, v1, v2
1708 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: maske
1709
1710 if (present(mask)) then
1711 shapemask = shape(mask)
1712 else
1713 shapemask = shape(x)
1714 end if
1715 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1716 stop 'LNNSE_sp_3d: shapes of inputs(x,y) or mask are not matching'
1717 !
1718 if (present(mask)) then
1719 maske = mask
1720 else
1721 maske = .true.
1722 end if
1723
1724 ! mask all negative and zero entries
1725 where (x .lt. tiny(1.0_sp) .or. y .lt. tiny(1.0_sp))
1726 maske = .false.
1727 end where
1728 n = count(maske)
1729 if (n .LE. 1_i4) stop 'LNNSE_sp_3d: number of arguments must be at least 2'
1730
1731 ! logarithms
1732 logx = 0.0_sp
1733 logy = 0.0_sp
1734 where (maske)
1735 logx = log(x)
1736 logy = log(y)
1737 end where
1738
1739 ! mean of x
1740 xmean = average(pack(logx, maske))
1741
1742 ! NSE
1743 v1 = merge(logy - logx, 0.0_sp, maske)
1744 v2 = merge(logx - xmean, 0.0_sp, maske)
1745 lnnse_sp_3d = 1.0_sp - sum(v1 * v1, mask = maske) / sum(v2 * v2, mask = maske)
1746
1747 END FUNCTION lnnse_sp_3d
1748
1749 ! ------------------------------------------------------------------
1750
1751 FUNCTION lnnse_dp_3d(x, y, mask)
1752
1753 USE mo_moment, ONLY : average
1754
1755 IMPLICIT NONE
1756
1757 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1758 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(INOUT) :: mask
1759 REAL(dp) :: LNNSE_dp_3d
1760
1761 INTEGER(i4) :: n
1762 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1763 REAL(dp) :: xmean
1764 REAL(dp), DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: logx, logy, v1, v2
1765 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), size(x, dim = 3)) :: maske
1766
1767 if (present(mask)) then
1768 shapemask = shape(mask)
1769 else
1770 shapemask = shape(x)
1771 end if
1772 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1773 stop 'LNNSE_dp_3d: shapes of inputs(x,y) or mask are not matching'
1774 !
1775 if (present(mask)) then
1776 maske = mask
1777 else
1778 maske = .true.
1779 end if
1780
1781 ! mask all negative and zero entries
1782 where (x .lt. tiny(1.0_dp) .or. y .lt. tiny(1.0_dp))
1783 maske = .false.
1784 end where
1785 n = count(maske)
1786 if (n .LE. 1_i4) stop 'LNNSE_dp_3d: number of arguments must be at least 2'
1787
1788 ! logarithms
1789 logx = 0.0_dp
1790 logy = 0.0_dp
1791 where (maske)
1792 logx = log(x)
1793 logy = log(y)
1794 end where
1795
1796 ! mean of x
1797 xmean = average(pack(logx, maske))
1798
1799 ! NSE
1800 v1 = merge(logy - logx, 0.0_dp, maske)
1801 v2 = merge(logx - xmean, 0.0_dp, maske)
1802 lnnse_dp_3d = 1.0_dp - sum(v1 * v1, mask = maske) / sum(v2 * v2, mask = maske)
1803
1804 END FUNCTION lnnse_dp_3d
1805
1806 ! ------------------------------------------------------------------
1807
1808 FUNCTION mae_sp_1d(x, y, mask)
1809
1810 IMPLICIT NONE
1811
1812 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
1813 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
1814 REAL(sp) :: MAE_sp_1d
1815
1816 INTEGER(i4) :: n
1817 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1818 LOGICAL, DIMENSION(size(x, dim = 1)) :: maske
1819
1820 if (present(mask)) then
1821 shapemask = shape(mask)
1822 else
1823 shapemask = shape(x)
1824 end if
1825 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1826 stop 'MAE_sp_1d: shapes of inputs(x,y) or mask are not matching'
1827 !
1828 if (present(mask)) then
1829 maske = mask
1830 n = count(maske)
1831 else
1832 maske = .true.
1833 n = size(x, dim = 1)
1834 end if
1835 if (n .LE. 1_i4) stop 'MAE_sp_1d: number of arguments must be at least 2'
1836 !
1837 mae_sp_1d = sae_sp_1d(x, y, mask = maske) / real(n, sp)
1838
1839 END FUNCTION mae_sp_1d
1840
1841 FUNCTION mae_dp_1d(x, y, mask)
1842
1843 IMPLICIT NONE
1844
1845 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
1846 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
1847 REAL(dp) :: MAE_dp_1d
1848
1849 INTEGER(i4) :: n
1850 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1851 LOGICAL, DIMENSION(size(x, dim = 1)) :: maske
1852
1853 if (present(mask)) then
1854 shapemask = shape(mask)
1855 else
1856 shapemask = shape(x)
1857 end if
1858 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1859 stop 'MAE_dp_1d: shapes of inputs(x,y) or mask are not matching'
1860 !
1861 if (present(mask)) then
1862 maske = mask
1863 n = count(maske)
1864 else
1865 maske = .true.
1866 n = size(x, dim = 1)
1867 end if
1868 if (n .LE. 1_i4) stop 'MAE_dp_1d: number of arguments must be at least 2'
1869 !
1870 mae_dp_1d = sae_dp_1d(x, y, mask = maske) / real(n, dp)
1871
1872 END FUNCTION mae_dp_1d
1873
1874 FUNCTION mae_sp_2d(x, y, mask)
1875
1876 IMPLICIT NONE
1877
1878 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
1879 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
1880 REAL(sp) :: MAE_sp_2d
1881
1882 INTEGER(i4) :: n
1883 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1884 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1885
1886 if (present(mask)) then
1887 shapemask = shape(mask)
1888 else
1889 shapemask = shape(x)
1890 end if
1891 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1892 stop 'MAE_sp_2d: shapes of inputs(x,y) or mask are not matching'
1893 !
1894 if (present(mask)) then
1895 maske = mask
1896 n = count(maske)
1897 else
1898 maske = .true.
1899 n = size(x, dim = 1) * size(x, dim = 2)
1900 end if
1901 if (n .LE. 1_i4) stop 'MAE_sp_2d: number of arguments must be at least 2'
1902 !
1903 mae_sp_2d = sae_sp_2d(x, y, mask = maske) / real(n, sp)
1904
1905 END FUNCTION mae_sp_2d
1906
1907 FUNCTION mae_dp_2d(x, y, mask)
1908
1909 IMPLICIT NONE
1910
1911 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
1912 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
1913 REAL(dp) :: MAE_dp_2d
1914
1915 INTEGER(i4) :: n
1916 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1917 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
1918
1919 if (present(mask)) then
1920 shapemask = shape(mask)
1921 else
1922 shapemask = shape(x)
1923 end if
1924 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1925 stop 'MAE_dp_2d: shapes of inputs(x,y) or mask are not matching'
1926 !
1927 if (present(mask)) then
1928 maske = mask
1929 n = count(maske)
1930 else
1931 maske = .true.
1932 n = size(x, dim = 1) * size(x, dim = 2)
1933 end if
1934 if (n .LE. 1_i4) stop 'MAE_dp_2d: number of arguments must be at least 2'
1935 !
1936 mae_dp_2d = sae_dp_2d(x, y, mask = maske) / real(n, dp)
1937
1938 END FUNCTION mae_dp_2d
1939
1940 FUNCTION mae_sp_3d(x, y, mask)
1941
1942 IMPLICIT NONE
1943
1944 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1945 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
1946 REAL(sp) :: MAE_sp_3d
1947
1948 INTEGER(i4) :: n
1949 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1950 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
1951
1952 if (present(mask)) then
1953 shapemask = shape(mask)
1954 else
1955 shapemask = shape(x)
1956 end if
1957 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1958 stop 'MAE_sp_3d: shapes of inputs(x,y) or mask are not matching'
1959 !
1960 if (present(mask)) then
1961 maske = mask
1962 n = count(maske)
1963 else
1964 maske = .true.
1965 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
1966 end if
1967 if (n .LE. 1_i4) stop 'MAE_sp_3d: number of arguments must be at least 2'
1968 !
1969 mae_sp_3d = sae_sp_3d(x, y, mask = maske) / real(n, sp)
1970
1971 END FUNCTION mae_sp_3d
1972
1973 FUNCTION mae_dp_3d(x, y, mask)
1974
1975 IMPLICIT NONE
1976
1977 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
1978 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
1979 REAL(dp) :: MAE_dp_3d
1980
1981 INTEGER(i4) :: n
1982 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
1983 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
1984
1985 if (present(mask)) then
1986 shapemask = shape(mask)
1987 else
1988 shapemask = shape(x)
1989 end if
1990 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
1991 stop 'MAE_dp_3d: shapes of inputs(x,y) or mask are not matching'
1992 !
1993 if (present(mask)) then
1994 maske = mask
1995 n = count(maske)
1996 else
1997 maske = .true.
1998 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
1999 end if
2000 if (n .LE. 1_i4) stop 'MAE_dp_3d: number of arguments must be at least 2'
2001 !
2002 mae_dp_3d = sae_dp_3d(x, y, mask = maske) / real(n, dp)
2003
2004 END FUNCTION mae_dp_3d
2005
2006 ! ------------------------------------------------------------------
2007
2008 FUNCTION mse_sp_1d(x, y, mask)
2009
2010 IMPLICIT NONE
2011
2012 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
2013 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2014 REAL(sp) :: MSE_sp_1d
2015
2016 INTEGER(i4) :: n
2017 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2018 LOGICAL, DIMENSION(size(x, dim = 1)) :: maske
2019
2020 if (present(mask)) then
2021 shapemask = shape(mask)
2022 else
2023 shapemask = shape(x)
2024 end if
2025 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2026 stop 'MSE_sp_1d: shapes of inputs(x,y) or mask are not matching'
2027 !
2028 if (present(mask)) then
2029 maske = mask
2030 n = count(maske)
2031 else
2032 maske = .true.
2033 n = size(x, dim = 1)
2034 end if
2035 if (n .LE. 1_i4) stop 'MSE_sp_1d: number of arguments must be at least 2'
2036 !
2037 mse_sp_1d = sse_sp_1d(x, y, mask = maske) / real(n, sp)
2038
2039 END FUNCTION mse_sp_1d
2040
2041 FUNCTION mse_dp_1d(x, y, mask)
2042
2043 IMPLICIT NONE
2044
2045 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
2046 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2047 REAL(dp) :: MSE_dp_1d
2048
2049 INTEGER(i4) :: n
2050 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2051 LOGICAL, DIMENSION(size(x, dim = 1)) :: maske
2052
2053 if (present(mask)) then
2054 shapemask = shape(mask)
2055 else
2056 shapemask = shape(x)
2057 end if
2058 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2059 stop 'MSE_dp_1d: shapes of inputs(x,y) or mask are not matching'
2060 !
2061 if (present(mask)) then
2062 maske = mask
2063 n = count(maske)
2064 else
2065 maske = .true.
2066 n = size(x, dim = 1)
2067 end if
2068 if (n .LE. 1_i4) stop 'MSE_dp_1d: number of arguments must be at least 2'
2069 !
2070 mse_dp_1d = sse_dp_1d(x, y, mask = maske) / real(n, dp)
2071
2072 END FUNCTION mse_dp_1d
2073
2074 FUNCTION mse_sp_2d(x, y, mask)
2075
2076 IMPLICIT NONE
2077
2078 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
2079 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2080 REAL(sp) :: MSE_sp_2d
2081
2082 INTEGER(i4) :: n
2083 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2084 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2085
2086 if (present(mask)) then
2087 shapemask = shape(mask)
2088 else
2089 shapemask = shape(x)
2090 end if
2091 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2092 stop 'MSE_sp_2d: shapes of inputs(x,y) or mask are not matching'
2093 !
2094 if (present(mask)) then
2095 maske = mask
2096 n = count(maske)
2097 else
2098 maske = .true.
2099 n = size(x, dim = 1) * size(x, dim = 2)
2100 end if
2101 if (n .LE. 1_i4) stop 'MSE_sp_2d: number of arguments must be at least 2'
2102 !
2103 mse_sp_2d = sse_sp_2d(x, y, mask = maske) / real(n, sp)
2104
2105 END FUNCTION mse_sp_2d
2106
2107 FUNCTION mse_dp_2d(x, y, mask)
2108
2109 IMPLICIT NONE
2110
2111 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
2112 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2113 REAL(dp) :: MSE_dp_2d
2114
2115 INTEGER(i4) :: n
2116 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2117 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2118
2119 if (present(mask)) then
2120 shapemask = shape(mask)
2121 else
2122 shapemask = shape(x)
2123 end if
2124 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2125 stop 'MSE_dp_2d: shapes of inputs(x,y) or mask are not matching'
2126 !
2127 if (present(mask)) then
2128 maske = mask
2129 n = count(maske)
2130 else
2131 maske = .true.
2132 n = size(x, dim = 1) * size(x, dim = 2)
2133 end if
2134 if (n .LE. 1_i4) stop 'MSE_dp_2d: number of arguments must be at least 2'
2135 !
2136 mse_dp_2d = sse_dp_2d(x, y, mask = maske) / real(n, dp)
2137
2138 END FUNCTION mse_dp_2d
2139
2140 FUNCTION mse_sp_3d(x, y, mask)
2141
2142 IMPLICIT NONE
2143
2144 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2145 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2146 REAL(sp) :: MSE_sp_3d
2147
2148 INTEGER(i4) :: n
2149 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2150 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
2151
2152 if (present(mask)) then
2153 shapemask = shape(mask)
2154 else
2155 shapemask = shape(x)
2156 end if
2157 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2158 stop 'MSE_sp_3d: shapes of inputs(x,y) or mask are not matching'
2159 !
2160 if (present(mask)) then
2161 maske = mask
2162 n = count(maske)
2163 else
2164 maske = .true.
2165 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
2166 end if
2167 if (n .LE. 1_i4) stop 'MSE_sp_3d: number of arguments must be at least 2'
2168 !
2169 mse_sp_3d = sse_sp_3d(x, y, mask = maske) / real(n, sp)
2170
2171 END FUNCTION mse_sp_3d
2172
2173 FUNCTION mse_dp_3d(x, y, mask)
2174
2175 IMPLICIT NONE
2176
2177 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2178 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2179 REAL(dp) :: MSE_dp_3d
2180
2181 INTEGER(i4) :: n
2182 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2183 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
2184
2185 if (present(mask)) then
2186 shapemask = shape(mask)
2187 else
2188 shapemask = shape(x)
2189 end if
2190 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2191 stop 'MSE_dp_3d: shapes of inputs(x,y) or mask are not matching'
2192 !
2193 if (present(mask)) then
2194 maske = mask
2195 n = count(maske)
2196 else
2197 maske = .true.
2198 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
2199 end if
2200 if (n .LE. 1_i4) stop 'MSE_dp_3d: number of arguments must be at least 2'
2201 !
2202 mse_dp_3d = sse_dp_3d(x, y, mask = maske) / real(n, dp)
2203
2204 END FUNCTION mse_dp_3d
2205
2206 ! ------------------------------------------------------------------
2207
2208 FUNCTION nse_sp_1d(x, y, mask)
2209
2210 USE mo_moment, ONLY : average
2211
2212 IMPLICIT NONE
2213
2214 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
2215 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2216 REAL(sp) :: NSE_sp_1d
2217
2218 INTEGER(i4) :: n
2219 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2220 REAL(sp) :: xmean
2221 REAL(sp), DIMENSION(size(x)) :: v1, v2
2222 LOGICAL, DIMENSION(size(x)) :: maske
2223
2224 if (present(mask)) then
2225 shapemask = shape(mask)
2226 else
2227 shapemask = shape(x)
2228 end if
2229 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2230 stop 'NSE_sp_1d: shapes of inputs(x,y) or mask are not matching'
2231 !
2232 if (present(mask)) then
2233 maske = mask
2234 n = count(maske)
2235 else
2236 maske = .true.
2237 n = size(x)
2238 end if
2239 if (n .LE. 1_i4) stop 'NSE_sp_1d: number of arguments must be at least 2'
2240 ! mean of x
2241 xmean = average(x, mask = maske)
2242 !
2243 v1 = merge(y - x, 0.0_sp, maske)
2244 v2 = merge(x - xmean, 0.0_sp, maske)
2245 !
2246 nse_sp_1d = 1.0_sp - dot_product(v1, v1) / dot_product(v2, v2)
2247
2248 END FUNCTION nse_sp_1d
2249
2250 FUNCTION nse_dp_1d(x, y, mask)
2251
2252 USE mo_moment, ONLY : average
2253
2254 IMPLICIT NONE
2255
2256 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
2257 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2258 REAL(dp) :: NSE_dp_1d
2259
2260 INTEGER(i4) :: n
2261 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2262 REAL(dp) :: xmean
2263 REAL(dp), DIMENSION(size(x)) :: v1, v2
2264 LOGICAL, DIMENSION(size(x)) :: maske
2265
2266 if (present(mask)) then
2267 shapemask = shape(mask)
2268 else
2269 shapemask = shape(x)
2270 end if
2271 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2272 stop 'NSE_dp_1d: shapes of inputs(x,y) or mask are not matching'
2273 !
2274 if (present(mask)) then
2275 maske = mask
2276 n = count(maske)
2277 else
2278 maske = .true.
2279 n = size(x)
2280 end if
2281 if (n .LE. 1_i4) stop 'NSE_dp_1d: number of arguments must be at least 2'
2282 ! mean of x
2283 xmean = average(x, mask = maske)
2284 !
2285 v1 = merge(y - x, 0.0_dp, maske)
2286 v2 = merge(x - xmean, 0.0_dp, maske)
2287 !
2288 nse_dp_1d = 1.0_dp - dot_product(v1, v1) / dot_product(v2, v2)
2289
2290 END FUNCTION nse_dp_1d
2291
2292 FUNCTION nse_sp_2d(x, y, mask)
2293
2294 USE mo_moment, ONLY : average
2295
2296 IMPLICIT NONE
2297
2298 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
2299 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2300 REAL(sp) :: NSE_sp_2d
2301
2302 INTEGER(i4) :: n
2303 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2304 REAL(sp) :: xmean
2305 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2306
2307 if (present(mask)) then
2308 shapemask = shape(mask)
2309 else
2310 shapemask = shape(x)
2311 end if
2312 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2313 stop 'NSE_sp_2d: shapes of inputs(x,y) or mask are not matching'
2314 !
2315 if (present(mask)) then
2316 maske = mask
2317 n = count(maske)
2318 else
2319 maske = .true.
2320 n = size(x, dim = 1) * size(x, dim = 2)
2321 end if
2322 !
2323 if (n .LE. 1_i4) stop 'NSE_sp_2d: number of arguments must be at least 2'
2324 ! mean of x
2325 xmean = average(reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
2326 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
2327 !
2328 nse_sp_2d = 1.0_sp - sum((y - x) * (y - x), mask = maske) / sum((x - xmean) * (x - xmean), mask = maske)
2329 !
2330 END FUNCTION nse_sp_2d
2331
2332 FUNCTION nse_dp_2d(x, y, mask)
2333
2334 USE mo_moment, ONLY : average
2335
2336 IMPLICIT NONE
2337
2338 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
2339 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2340 REAL(dp) :: NSE_dp_2d
2341
2342 INTEGER(i4) :: n
2343 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2344 REAL(dp) :: xmean
2345 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2346
2347 if (present(mask)) then
2348 shapemask = shape(mask)
2349 else
2350 shapemask = shape(x)
2351 end if
2352 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2353 stop 'NSE_dp_2d: shapes of inputs(x,y) or mask are not matching'
2354 !
2355 if (present(mask)) then
2356 maske = mask
2357 n = count(maske)
2358 else
2359 maske = .true.
2360 n = size(x, dim = 1) * size(x, dim = 2)
2361 end if
2362 !
2363 if (n .LE. 1_i4) stop 'NSE_dp_2d: number of arguments must be at least 2'
2364 ! mean of x
2365 xmean = average(reshape(x(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)), &
2366 mask = reshape(maske(:, :), (/size(x, dim = 1) * size(x, dim = 2)/)))
2367 !
2368 nse_dp_2d = 1.0_dp - sum((y - x) * (y - x), mask = maske) / sum((x - xmean) * (x - xmean), mask = maske)
2369 !
2370 END FUNCTION nse_dp_2d
2371
2372 FUNCTION nse_sp_3d(x, y, mask)
2373
2374 USE mo_moment, ONLY : average
2375
2376 IMPLICIT NONE
2377
2378 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2379 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2380 REAL(sp) :: NSE_sp_3d
2381
2382 INTEGER(i4) :: n
2383 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2384 REAL(sp) :: xmean
2385 LOGICAL, DIMENSION(size(x, dim = 1), & size(x, dim = 2), size(x, dim = 3)) :: maske
2386
2387 if (present(mask)) then
2388 shapemask = shape(mask)
2389 else
2390 shapemask = shape(x)
2391 end if
2392 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2393 stop 'NSE_sp_3d: shapes of inputs(x,y) or mask are not matching'
2394 !
2395 if (present(mask)) then
2396 maske = mask
2397 n = count(maske)
2398 else
2399 maske = .true.
2400 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
2401 end if
2402 !
2403 if (n .LE. 1_i4) stop 'NSE_sp_3d: number of arguments must be at least 2'
2404 ! mean of x
2405 xmean = average(reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
2406 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
2407 !
2408 nse_sp_3d = 1.0_sp - sum((y - x) * (y - x), mask = maske) / sum((x - xmean) * (x - xmean), mask = maske)
2409 !
2410 END FUNCTION nse_sp_3d
2411
2412 FUNCTION nse_dp_3d(x, y, mask)
2413
2414 USE mo_moment, ONLY : average
2415
2416 IMPLICIT NONE
2417
2418 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2419 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2420 REAL(dp) :: NSE_dp_3d
2421
2422 INTEGER(i4) :: n
2423 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2424 REAL(dp) :: xmean
2425 LOGICAL, DIMENSION(size(x, dim = 1), & size(x, dim = 2), size(x, dim = 3)) :: maske
2426
2427 if (present(mask)) then
2428 shapemask = shape(mask)
2429 else
2430 shapemask = shape(x)
2431 end if
2432 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2433 stop 'NSE_dp_3d: shapes of inputs(x,y) or mask are not matching'
2434 !
2435 if (present(mask)) then
2436 maske = mask
2437 n = count(maske)
2438 else
2439 maske = .true.
2440 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
2441 end if
2442 !
2443 if (n .LE. 1_i4) stop 'NSE_dp_3d: number of arguments must be at least 2'
2444 ! Average of x
2445 xmean = average(reshape(x(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
2446 mask = reshape(maske(:, :, :), (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)))
2447 !
2448 nse_dp_3d = 1.0_dp - sum((y - x) * (y - x), mask = maske) / sum((x - xmean) * (x - xmean), mask = maske)
2449 !
2450 END FUNCTION nse_dp_3d
2451
2452
2453 ! ------------------------------------------------------------------
2454
2455 FUNCTION sae_sp_1d(x, y, mask)
2456
2457 IMPLICIT NONE
2458
2459 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
2460 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2461 REAL(sp) :: SAE_sp_1d
2462
2463 INTEGER(i4) :: n
2464 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2465 LOGICAL, DIMENSION(size(x)) :: maske
2466
2467 if (present(mask)) then
2468 shapemask = shape(mask)
2469 else
2470 shapemask = shape(x)
2471 end if
2472 !
2473 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2474 stop 'SAE_sp_1d: shapes of inputs(x,y) or mask are not matching'
2475 !
2476 if (present(mask)) then
2477 maske = mask
2478 n = count(maske)
2479 else
2480 maske = .true.
2481 n = size(x)
2482 end if
2483 if (n .LE. 1_i4) stop 'SAE_sp_1d: number of arguments must be at least 2'
2484 !
2485 sae_sp_1d = sum(abs(y - x), mask = maske)
2486
2487 END FUNCTION sae_sp_1d
2488
2489 FUNCTION sae_dp_1d(x, y, mask)
2490
2491 IMPLICIT NONE
2492
2493 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
2494 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2495 REAL(dp) :: SAE_dp_1d
2496
2497 INTEGER(i4) :: n
2498 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2499 LOGICAL, DIMENSION(size(x)) :: maske
2500
2501 if (present(mask)) then
2502 shapemask = shape(mask)
2503 else
2504 shapemask = shape(x)
2505 end if
2506 !
2507 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2508 stop 'SAE_dp_1d: shapes of inputs(x,y) or mask are not matching'
2509 !
2510 if (present(mask)) then
2511 maske = mask
2512 n = count(maske)
2513 else
2514 maske = .true.
2515 n = size(x)
2516 end if
2517 if (n .LE. 1_i4) stop 'SAE_dp_1d: number of arguments must be at least 2'
2518 !
2519 sae_dp_1d = sum(abs(y - x), mask = maske)
2520
2521 END FUNCTION sae_dp_1d
2522
2523 FUNCTION sae_sp_2d(x, y, mask)
2524
2525 IMPLICIT NONE
2526
2527 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
2528 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2529 REAL(sp) :: SAE_sp_2d
2530
2531 INTEGER(i4) :: n
2532 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2533 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2534
2535 if (present(mask)) then
2536 shapemask = shape(mask)
2537 else
2538 shapemask = shape(x)
2539 end if
2540 !
2541 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2542 stop 'SAE_sp_2d: shapes of inputs(x,y) or mask are not matching'
2543 !
2544 if (present(mask)) then
2545 maske = mask
2546 n = count(maske)
2547 else
2548 maske = .true.
2549 n = size(x, dim = 1) * size(x, dim = 2)
2550 end if
2551 if (n .LE. 1_i4) stop 'SAE_sp_2d: number of arguments must be at least 2'
2552 !
2553 sae_sp_2d = sae_sp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2)/)), &
2554 reshape(y, (/size(y, dim = 1) * size(y, dim = 2)/)), &
2555 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2)/)))
2556
2557 END FUNCTION sae_sp_2d
2558
2559 FUNCTION sae_dp_2d(x, y, mask)
2560
2561 IMPLICIT NONE
2562
2563 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
2564 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2565 REAL(dp) :: SAE_dp_2d
2566
2567 INTEGER(i4) :: n
2568 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2569 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2570
2571 if (present(mask)) then
2572 shapemask = shape(mask)
2573 else
2574 shapemask = shape(x)
2575 end if
2576 !
2577 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2578 stop 'SAE_dp_2d: shapes of inputs(x,y) or mask are not matching'
2579 !
2580 if (present(mask)) then
2581 maske = mask
2582 n = count(maske)
2583 else
2584 maske = .true.
2585 n = size(x, dim = 1) * size(x, dim = 2)
2586 end if
2587 if (n .LE. 1_i4) stop 'SAE_dp_2d: number of arguments must be at least 2'
2588 !
2589 sae_dp_2d = sae_dp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2)/)), &
2590 reshape(y, (/size(y, dim = 1) * size(y, dim = 2)/)), &
2591 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2)/)))
2592
2593 END FUNCTION sae_dp_2d
2594
2595 FUNCTION sae_sp_3d(x, y, mask)
2596
2597 IMPLICIT NONE
2598
2599 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2600 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2601 REAL(sp) :: SAE_sp_3d
2602
2603 INTEGER(i4) :: n
2604 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2605 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
2606
2607 if (present(mask)) then
2608 shapemask = shape(mask)
2609 else
2610 shapemask = shape(x)
2611 end if
2612 !
2613 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2614 stop 'SAE_sp_3d: shapes of inputs(x,y) or mask are not matching'
2615 !
2616 if (present(mask)) then
2617 maske = mask
2618 n = count(maske)
2619 else
2620 maske = .true.
2621 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
2622 end if
2623 if (n .LE. 1_i4) stop 'SAE_sp_3d: number of arguments must be at least 2'
2624 !
2625 sae_sp_3d = sae_sp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
2626 reshape(y, (/size(y, dim = 1) * size(y, dim = 2) * size(x, dim = 3)/)), &
2627 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2) &
2628 * size(maske, dim = 3)/)))
2629
2630 END FUNCTION sae_sp_3d
2631
2632 FUNCTION sae_dp_3d(x, y, mask)
2633
2634 IMPLICIT NONE
2635
2636 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2637 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2638 REAL(dp) :: SAE_dp_3d
2639
2640 INTEGER(i4) :: n
2641 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2642 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
2643
2644 if (present(mask)) then
2645 shapemask = shape(mask)
2646 else
2647 shapemask = shape(x)
2648 end if
2649 !
2650 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2651 stop 'SAE_dp_3d: shapes of inputs(x,y) or mask are not matching'
2652 !
2653 if (present(mask)) then
2654 maske = mask
2655 n = count(maske)
2656 else
2657 maske = .true.
2658 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
2659 end if
2660 if (n .LE. 1_i4) stop 'SAE_dp_3d: number of arguments must be at least 2'
2661 !
2662 sae_dp_3d = sae_dp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
2663 reshape(y, (/size(y, dim = 1) * size(y, dim = 2) * size(x, dim = 3)/)), &
2664 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2) &
2665 * size(maske, dim = 3)/)))
2666
2667 END FUNCTION sae_dp_3d
2668
2669 ! ------------------------------------------------------------------
2670
2671 FUNCTION sse_sp_1d(x, y, mask)
2672
2673 IMPLICIT NONE
2674
2675 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
2676 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2677 REAL(sp) :: SSE_sp_1d
2678
2679 INTEGER(i4) :: n
2680 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2681 LOGICAL, DIMENSION(size(x)) :: maske
2682
2683 if (present(mask)) then
2684 shapemask = shape(mask)
2685 else
2686 shapemask = shape(x)
2687 end if
2688 !
2689 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2690 stop 'SSE_sp_1d: shapes of inputs(x,y) or mask are not matching'
2691 !
2692 if (present(mask)) then
2693 maske = mask
2694 n = count(maske)
2695 else
2696 maske = .true.
2697 n = size(x)
2698 end if
2699 if (n .LE. 1_i4) stop 'SSE_sp_1d: number of arguments must be at least 2'
2700 !
2701 sse_sp_1d = sum((y - x)**2_i4, mask = maske)
2702
2703 END FUNCTION sse_sp_1d
2704
2705 FUNCTION sse_dp_1d(x, y, mask)
2706
2707 IMPLICIT NONE
2708
2709 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
2710 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2711 REAL(dp) :: SSE_dp_1d
2712
2713 INTEGER(i4) :: n
2714 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2715 LOGICAL, DIMENSION(size(x)) :: maske
2716
2717 if (present(mask)) then
2718 shapemask = shape(mask)
2719 else
2720 shapemask = shape(x)
2721 end if
2722 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2723 stop 'SSE_dp_1d: shapes of inputs(x,y) or mask are not matching'
2724 !
2725 if (present(mask)) then
2726 maske = mask
2727 n = count(maske)
2728 else
2729 maske = .true.
2730 n = size(x)
2731 end if
2732 if (n .LE. 1_i4) stop 'SSE_dp_1d: number of arguments must be at least 2'
2733 !
2734 sse_dp_1d = sum((y - x)**2_i4, mask = maske)
2735
2736 END FUNCTION sse_dp_1d
2737
2738 FUNCTION sse_sp_2d(x, y, mask)
2739
2740 IMPLICIT NONE
2741
2742 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
2743 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2744 REAL(sp) :: SSE_sp_2d
2745
2746 INTEGER(i4) :: n
2747 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2748 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2749
2750 if (present(mask)) then
2751 shapemask = shape(mask)
2752 else
2753 shapemask = shape(x)
2754 end if
2755 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2756 stop 'SSE_sp_2d: shapes of inputs(x,y) or mask are not matching'
2757 !
2758 if (present(mask)) then
2759 maske = mask
2760 n = count(maske)
2761 else
2762 maske = .true.
2763 n = size(x)
2764 end if
2765 if (n .LE. 1_i4) stop 'SSE_sp_2d: number of arguments must be at least 2'
2766 !
2767 sse_sp_2d = sse_sp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2)/)), &
2768 reshape(y, (/size(y, dim = 1) * size(y, dim = 2)/)), &
2769 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2)/)))
2770
2771 END FUNCTION sse_sp_2d
2772
2773 FUNCTION sse_dp_2d(x, y, mask)
2774
2775 IMPLICIT NONE
2776
2777 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
2778 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2779 REAL(dp) :: SSE_dp_2d
2780
2781 INTEGER(i4) :: n
2782 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2783 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2784
2785 if (present(mask)) then
2786 shapemask = shape(mask)
2787 else
2788 shapemask = shape(x)
2789 end if
2790 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2791 stop 'SSE_dp_2d: shapes of inputs(x,y) or mask are not matching'
2792 !
2793 if (present(mask)) then
2794 maske = mask
2795 n = count(maske)
2796 else
2797 maske = .true.
2798 n = size(x)
2799 end if
2800 if (n .LE. 1_i4) stop 'SSE_dp_2d: number of arguments must be at least 2'
2801 !
2802 sse_dp_2d = sse_dp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2)/)), &
2803 reshape(y, (/size(y, dim = 1) * size(y, dim = 2)/)), &
2804 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2)/)))
2805
2806 END FUNCTION sse_dp_2d
2807
2808 FUNCTION sse_sp_3d(x, y, mask)
2809
2810 IMPLICIT NONE
2811
2812 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2813 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2814 REAL(sp) :: SSE_sp_3d
2815
2816 INTEGER(i4) :: n
2817 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2818 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
2819
2820 if (present(mask)) then
2821 shapemask = shape(mask)
2822 else
2823 shapemask = shape(x)
2824 end if
2825 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2826 stop 'SSE_sp_3d: shapes of inputs(x,y) or mask are not matching'
2827 !
2828 if (present(mask)) then
2829 maske = mask
2830 n = count(maske)
2831 else
2832 maske = .true.
2833 n = size(x)
2834 end if
2835 if (n .LE. 1_i4) stop 'SSE_sp_3d: number of arguments must be at least 2'
2836 !
2837 sse_sp_3d = sse_sp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
2838 reshape(y, (/size(y, dim = 1) * size(y, dim = 2) * size(x, dim = 3)/)), &
2839 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2) &
2840 * size(maske, dim = 3)/)))
2841
2842 END FUNCTION sse_sp_3d
2843
2844 FUNCTION sse_dp_3d(x, y, mask)
2845
2846 IMPLICIT NONE
2847
2848 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
2849 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
2850 REAL(dp) :: SSE_dp_3d
2851
2852 INTEGER(i4) :: n
2853 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2854 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
2855
2856 if (present(mask)) then
2857 shapemask = shape(mask)
2858 else
2859 shapemask = shape(x)
2860 end if
2861 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2862 stop 'SSE_dp_3d: shapes of inputs(x,y) or mask are not matching'
2863 !
2864 if (present(mask)) then
2865 maske = mask
2866 n = count(maske)
2867 else
2868 maske = .true.
2869 n = size(x)
2870 end if
2871 if (n .LE. 1_i4) stop 'SSE_dp_3d: number of arguments must be at least 2'
2872 !
2873 sse_dp_3d = sse_dp_1d(reshape(x, (/size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)/)), &
2874 reshape(y, (/size(y, dim = 1) * size(y, dim = 2) * size(x, dim = 3)/)), &
2875 mask = reshape(maske, (/size(maske, dim = 1) * size(maske, dim = 2) &
2876 * size(maske, dim = 3)/)))
2877
2878 END FUNCTION sse_dp_3d
2879
2880 ! ------------------------------------------------------------------
2881
2882 FUNCTION rmse_sp_1d(x, y, mask)
2883
2884 IMPLICIT NONE
2885
2886 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
2887 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2888 REAL(sp) :: RMSE_sp_1d
2889
2890 INTEGER(i4) :: n
2891 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2892 LOGICAL, DIMENSION(size(x, dim = 1)) :: maske
2893
2894 if (present(mask)) then
2895 shapemask = shape(mask)
2896 else
2897 shapemask = shape(x)
2898 end if
2899 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2900 stop 'RMSE_sp_1d: shapes of inputs(x,y) or mask are not matching'
2901 !
2902 if (present(mask)) then
2903 maske = mask
2904 n = count(maske)
2905 else
2906 maske = .true.
2907 n = size(x, dim = 1)
2908 end if
2909 if (n .LE. 1_i4) stop 'RMSE_sp_1d: number of arguments must be at least 2'
2910 !
2911 rmse_sp_1d = sqrt(mse_sp_1d(x, y, mask = maske))
2912
2913 END FUNCTION rmse_sp_1d
2914
2915 FUNCTION rmse_dp_1d(x, y, mask)
2916
2917 IMPLICIT NONE
2918
2919 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
2920 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
2921 REAL(dp) :: RMSE_dp_1d
2922
2923 INTEGER(i4) :: n
2924 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2925 LOGICAL, DIMENSION(size(x, dim = 1)) :: maske
2926
2927 if (present(mask)) then
2928 shapemask = shape(mask)
2929 else
2930 shapemask = shape(x)
2931 end if
2932 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2933 stop 'RMSE_dp_1d: shapes of inputs(x,y) or mask are not matching'
2934 !
2935 if (present(mask)) then
2936 maske = mask
2937 n = count(maske)
2938 else
2939 maske = .true.
2940 n = size(x, dim = 1)
2941 end if
2942 if (n .LE. 1_i4) stop 'RMSE_dp_1d: number of arguments must be at least 2'
2943 !
2944 rmse_dp_1d = sqrt(mse_dp_1d(x, y, mask = maske))
2945
2946 END FUNCTION rmse_dp_1d
2947
2948 FUNCTION rmse_sp_2d(x, y, mask)
2949
2950 IMPLICIT NONE
2951
2952 REAL(sp), DIMENSION(:, :), INTENT(IN) :: x, y
2953 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2954 REAL(sp) :: RMSE_sp_2d
2955
2956 INTEGER(i4) :: n
2957 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2958 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2959
2960 if (present(mask)) then
2961 shapemask = shape(mask)
2962 else
2963 shapemask = shape(x)
2964 end if
2965 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2966 stop 'RMSE_sp_2d: shapes of inputs(x,y) or mask are not matching'
2967 !
2968 if (present(mask)) then
2969 maske = mask
2970 n = count(maske)
2971 else
2972 maske = .true.
2973 n = size(x, dim = 1) * size(x, dim = 2)
2974 end if
2975 if (n .LE. 1_i4) stop 'RMSE_sp_2d: number of arguments must be at least 2'
2976 !
2977 rmse_sp_2d = sqrt(mse_sp_2d(x, y, mask = maske))
2978
2979 END FUNCTION rmse_sp_2d
2980
2981 FUNCTION rmse_dp_2d(x, y, mask)
2982
2983 IMPLICIT NONE
2984
2985 REAL(dp), DIMENSION(:, :), INTENT(IN) :: x, y
2986 LOGICAL, DIMENSION(:, :), OPTIONAL, INTENT(IN) :: mask
2987 REAL(dp) :: RMSE_dp_2d
2988
2989 INTEGER(i4) :: n
2990 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
2991 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2)) :: maske
2992
2993 if (present(mask)) then
2994 shapemask = shape(mask)
2995 else
2996 shapemask = shape(x)
2997 end if
2998 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
2999 stop 'RMSE_dp_2d: shapes of inputs(x,y) or mask are not matching'
3000 !
3001 if (present(mask)) then
3002 maske = mask
3003 n = count(maske)
3004 else
3005 maske = .true.
3006 n = size(x, dim = 1) * size(x, dim = 2)
3007 end if
3008 if (n .LE. 1_i4) stop 'RMSE_dp_2d: number of arguments must be at least 2'
3009 !
3010 rmse_dp_2d = sqrt(mse_dp_2d(x, y, mask = maske))
3011
3012 END FUNCTION rmse_dp_2d
3013
3014 FUNCTION rmse_sp_3d(x, y, mask)
3015
3016 IMPLICIT NONE
3017
3018 REAL(sp), DIMENSION(:, :, :), INTENT(IN) :: x, y
3019 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
3020 REAL(sp) :: RMSE_sp_3d
3021
3022 INTEGER(i4) :: n
3023 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
3024 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
3025
3026 if (present(mask)) then
3027 shapemask = shape(mask)
3028 else
3029 shapemask = shape(x)
3030 end if
3031 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
3032 stop 'RMSE_sp_3d: shapes of inputs(x,y) or mask are not matching'
3033 !
3034 if (present(mask)) then
3035 maske = mask
3036 n = count(maske)
3037 else
3038 maske = .true.
3039 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
3040 end if
3041 if (n .LE. 1_i4) stop 'RMSE_sp_3d: number of arguments must be at least 2'
3042 !
3043 rmse_sp_3d = sqrt(mse_sp_3d(x, y, mask = maske))
3044
3045 END FUNCTION rmse_sp_3d
3046
3047 FUNCTION rmse_dp_3d(x, y, mask)
3048
3049 IMPLICIT NONE
3050
3051 REAL(dp), DIMENSION(:, :, :), INTENT(IN) :: x, y
3052 LOGICAL, DIMENSION(:, :, :), OPTIONAL, INTENT(IN) :: mask
3053 REAL(dp) :: RMSE_dp_3d
3054
3055 INTEGER(i4) :: n
3056 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
3057 LOGICAL, DIMENSION(size(x, dim = 1), size(x, dim = 2), & size(x, dim = 3)) :: maske
3058
3059 if (present(mask)) then
3060 shapemask = shape(mask)
3061 else
3062 shapemask = shape(x)
3063 end if
3064 if ((any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask))) &
3065 stop 'RMSE_dp_3d: shapes of inputs(x,y) or mask are not matching'
3066 !
3067 if (present(mask)) then
3068 maske = mask
3069 n = count(maske)
3070 else
3071 maske = .true.
3072 n = size(x, dim = 1) * size(x, dim = 2) * size(x, dim = 3)
3073 end if
3074 if (n .LE. 1_i4) stop 'RMSE_dp_3d: number of arguments must be at least 2'
3075 !
3076 rmse_dp_3d = sqrt(mse_dp_3d(x, y, mask = maske))
3077
3078 END FUNCTION rmse_dp_3d
3079
3080 ! ------------------------------------------------------------------
3081
3082 FUNCTION wnse_sp_1d(x, y, mask)
3083
3084 USE mo_moment, ONLY: average
3085
3086 IMPLICIT NONE
3087
3088 REAL(sp), DIMENSION(:), INTENT(IN) :: x, y
3089 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
3090 REAL(sp) :: wNSE_sp_1d
3091
3092 INTEGER(i4) :: n
3093 INTEGER(i4), DIMENSION(size(shape(x))) :: shapemask
3094 REAL(sp) :: xmean
3095 REAL(sp), DIMENSION(size(x)) :: v1, v2, ww
3096 LOGICAL, DIMENSION(size(x)) :: maske
3097
3098 if (present(mask)) then
3099 shapemask = shape(mask)
3100 else
3101 shapemask = shape(x)
3102 end if
3103 if ( (any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask)) ) &
3104 stop 'wNSE_sp_1d: shapes of inputs(x,y) or mask are not matching'
3105 !
3106 if (present(mask)) then
3107 maske = mask
3108 n = count(maske)
3109 else
3110 maske = .true.
3111 n = size(x)
3112 end if
3113 if (n .LE. 1_i4) stop 'wNSE_sp_1d: number of arguments must be at least 2'
3114 ! mean of x
3115 xmean = average(x, mask=maske)
3116 !
3117 v1 = merge(y - x , 0.0_sp, maske)
3118 v2 = merge(x - xmean, 0.0_sp, maske)
3119 ww = merge(x , 0.0_sp, maske)
3120 !
3121 wnse_sp_1d = 1.0_sp - dot_product(ww * v1,v1) / dot_product(ww * v2,v2)
3122
3123 END FUNCTION wnse_sp_1d
3124
3125 FUNCTION wnse_dp_1d(x, y, mask)
3126
3127 USE mo_moment, ONLY: average
3128
3129 IMPLICIT NONE
3130
3131 REAL(dp), DIMENSION(:), INTENT(IN) :: x, y
3132 LOGICAL, DIMENSION(:), OPTIONAL, INTENT(IN) :: mask
3133 REAL(dp) :: wNSE_dp_1d
3134
3135 INTEGER(i4) :: n
3136 INTEGER(i4), DIMENSION(size(shape(x)) ) :: shapemask
3137 REAL(dp) :: xmean
3138 REAL(dp), DIMENSION(size(x)) :: v1, v2, ww
3139 LOGICAL, DIMENSION(size(x)) :: maske
3140
3141 if (present(mask)) then
3142 shapemask = shape(mask)
3143 else
3144 shapemask = shape(x)
3145 end if
3146 if ( (any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask)) ) &
3147 stop 'wNSE_dp_1d: shapes of inputs(x,y) or mask are not matching'
3148 !
3149 if (present(mask)) then
3150 maske = mask
3151 n = count(maske)
3152 else
3153 maske = .true.
3154 n = size(x)
3155 end if
3156 if (n .LE. 1_i4) stop 'wNSE_dp_1d: number of arguments must be at least 2'
3157 ! mean of x
3158 xmean = average(x, mask=maske)
3159 !
3160 v1 = merge(y - x , 0.0_dp, maske)
3161 v2 = merge(x - xmean, 0.0_dp, maske)
3162 ww = merge(x , 0.0_dp, maske)
3163 !
3164 wnse_dp_1d = 1.0_dp - dot_product(ww * v1,v1) / dot_product(ww * v2,v2)
3165
3166 END FUNCTION wnse_dp_1d
3167
3168 FUNCTION wnse_sp_2d(x, y, mask)
3169
3170 USE mo_moment, ONLY: average
3171
3172 IMPLICIT NONE
3173
3174 REAL(sp), DIMENSION(:,:), INTENT(IN) :: x, y
3175 LOGICAL, DIMENSION(:,:), OPTIONAL, INTENT(IN) :: mask
3176 REAL(sp) :: wNSE_sp_2d
3177
3178 INTEGER(i4) :: n
3179 INTEGER(i4), DIMENSION(size(shape(x)) ) :: shapemask
3180 REAL(sp) :: xmean
3181 LOGICAL, DIMENSION(size(x, dim=1), size(x, dim=2)):: maske
3182
3183 if (present(mask)) then
3184 shapemask = shape(mask)
3185 else
3186 shapemask = shape(x)
3187 end if
3188 if ( (any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask)) ) &
3189 stop 'wNSE_sp_2d: shapes of inputs(x,y) or mask are not matching'
3190 !
3191 if (present(mask)) then
3192 maske = mask
3193 n = count(maske)
3194 else
3195 maske = .true.
3196 n = size(x, dim=1) * size(x, dim=2)
3197 end if
3198 !
3199 if (n .LE. 1_i4) stop 'wNSE_sp_2d: number of arguments must be at least 2'
3200 ! mean of x
3201 xmean = average(reshape(x(:,:), (/size(x, dim=1)*size(x, dim=2)/)), &
3202 mask=reshape(maske(:,:), (/size(x, dim=1)*size(x, dim=2)/)))
3203 !
3204 wnse_sp_2d = 1.0_sp - sum(x * (y-x)*(y-x), mask=maske) / sum(x * (x-xmean)*(x-xmean), mask=maske)
3205 !
3206 END FUNCTION wnse_sp_2d
3207
3208 FUNCTION wnse_dp_2d(x, y, mask)
3209
3210 USE mo_moment, ONLY: average
3211
3212 IMPLICIT NONE
3213
3214 REAL(dp), DIMENSION(:,:), INTENT(IN) :: x, y
3215 LOGICAL, DIMENSION(:,:), OPTIONAL, INTENT(IN) :: mask
3216 REAL(dp) :: wNSE_dp_2d
3217
3218 INTEGER(i4) :: n
3219 INTEGER(i4), DIMENSION(size(shape(x)) ) :: shapemask
3220 REAL(dp) :: xmean
3221 LOGICAL, DIMENSION(size(x, dim=1), size(x, dim=2)):: maske
3222
3223 if (present(mask)) then
3224 shapemask = shape(mask)
3225 else
3226 shapemask = shape(x)
3227 end if
3228 if ( (any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask)) ) &
3229 stop 'wNSE_dp_2d: shapes of inputs(x,y) or mask are not matching'
3230 !
3231 if (present(mask)) then
3232 maske = mask
3233 n = count(maske)
3234 else
3235 maske = .true.
3236 n = size(x, dim=1) * size(x, dim=2)
3237 end if
3238 !
3239 if (n .LE. 1_i4) stop 'wNSE_dp_2d: number of arguments must be at least 2'
3240 ! mean of x
3241 xmean = average(reshape(x(:,:), (/size(x, dim=1)*size(x, dim=2)/)), &
3242 mask=reshape(maske(:,:), (/size(x, dim=1)*size(x, dim=2)/)))
3243 !
3244 wnse_dp_2d = 1.0_dp - sum(x * (y-x)*(y-x), mask=maske) / sum(x * (x-xmean)*(x-xmean), mask=maske)
3245 !
3246 END FUNCTION wnse_dp_2d
3247
3248 FUNCTION wnse_sp_3d(x, y, mask)
3249
3250 USE mo_moment, ONLY: average
3251
3252 IMPLICIT NONE
3253
3254 REAL(sp), DIMENSION(:,:,:), INTENT(IN) :: x, y
3255 LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(IN) :: mask
3256 REAL(sp) :: wNSE_sp_3d
3257
3258 INTEGER(i4) :: n
3259 INTEGER(i4), DIMENSION(size(shape(x)) ) :: shapemask
3260 REAL(sp) :: xmean
3261 LOGICAL, DIMENSION(size(x, dim=1), & size(x, dim=2), size(x, dim=3)) :: maske
3262
3263 if (present(mask)) then
3264 shapemask = shape(mask)
3265 else
3266 shapemask = shape(x)
3267 end if
3268 if ( (any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask)) ) &
3269 stop 'wNSE_sp_3d: shapes of inputs(x,y) or mask are not matching'
3270 !
3271 if (present(mask)) then
3272 maske = mask
3273 n = count(maske)
3274 else
3275 maske = .true.
3276 n = size(x, dim=1) * size(x, dim=2) * size(x, dim=3)
3277 end if
3278 !
3279 if (n .LE. 1_i4) stop 'wNSE_sp_3d: number of arguments must be at least 2'
3280 ! mean of x
3281 xmean = average(reshape(x(:,:,:), (/size(x, dim=1)*size(x, dim=2)*size(x, dim=3)/)), &
3282 mask=reshape(maske(:,:,:), (/size(x, dim=1)*size(x, dim=2)*size(x, dim=3)/)))
3283 !
3284 wnse_sp_3d = 1.0_sp - sum(x * (y-x)*(y-x), mask=maske) / sum(x * (x-xmean)*(x-xmean), mask=maske)
3285 !
3286 END FUNCTION wnse_sp_3d
3287
3288 FUNCTION wnse_dp_3d(x, y, mask)
3289
3290 USE mo_moment, ONLY: average
3291
3292 IMPLICIT NONE
3293
3294 REAL(dp), DIMENSION(:,:,:), INTENT(IN) :: x, y
3295 LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(IN) :: mask
3296 REAL(dp) :: wNSE_dp_3d
3297
3298 INTEGER(i4) :: n
3299 INTEGER(i4), DIMENSION(size(shape(x)) ) :: shapemask
3300 REAL(dp) :: xmean
3301 LOGICAL, DIMENSION(size(x, dim=1), & size(x, dim=2), size(x, dim=3)) :: maske
3302
3303 if (present(mask)) then
3304 shapemask = shape(mask)
3305 else
3306 shapemask = shape(x)
3307 end if
3308 if ( (any(shape(x) .NE. shape(y))) .OR. (any(shape(x) .NE. shapemask)) ) &
3309 stop 'wNSE_dp_3d: shapes of inputs(x,y) or mask are not matching'
3310 !
3311 if (present(mask)) then
3312 maske = mask
3313 n = count(maske)
3314 else
3315 maske = .true.
3316 n = size(x, dim=1) * size(x, dim=2) * size(x, dim=3)
3317 end if
3318 !
3319 if (n .LE. 1_i4) stop 'wNSE_dp_3d: number of arguments must be at least 2'
3320 ! Average of x
3321 xmean = average(reshape(x(:,:,:), (/size(x, dim=1)*size(x, dim=2)*size(x, dim=3)/)), &
3322 mask=reshape(maske(:,:,:), (/size(x, dim=1)*size(x, dim=2)*size(x, dim=3)/)))
3323 !
3324 wnse_dp_3d = 1.0_dp - sum(x * (y-x)*(y-x), mask=maske) / sum(x * (x-xmean)*(x-xmean), mask=maske)
3325 !
3326 END FUNCTION wnse_dp_3d
3327
3328END MODULE mo_errormeasures
3329
Kling-Gupta-Efficiency measure.
Kling-Gupta-Efficiency measure without correlation.
Logarithmic Nash Sutcliffe Efficiency.
Mean absolute error.
Mean squared error.
Nash Sutcliffe Efficiency.
Sum of absolute errors.
Sum of squared errors.
weighted Nash Sutcliffe Efficiency.
Mean of vector.
Correlation between two vectors.
Standard deviation of a vector.
Calculation of error measures.
Define number representations.
Definition mo_kind.F90:17
integer, parameter sp
Single Precision Real Kind.
Definition mo_kind.F90:44
integer, parameter i4
4 Byte Integer Kind
Definition mo_kind.F90:40
integer, parameter dp
Double Precision Real Kind.
Definition mo_kind.F90:46
Statistical moments.
Definition mo_moment.f90:25