6 module function assert_r32(x, y, tol) result(rst)
8 real(real32),
intent(in) :: x, y
9 real(real32),
intent(in),
optional :: tol
16 if (
present(tol))
then
25 module function assert_r32_array(x, y, tol, flag) result(rst)
27 real(real32),
intent(in) :: x(:), y(:)
28 real(real32),
intent(in),
optional :: tol
29 integer(int32),
intent(out),
optional :: flag
34 integer(int32) :: i, n
38 if (
present(flag)) flag = 0
42 if (
size(y) /= n)
then
44 if (
present(flag)) flag = -1
49 if (
present(tol))
then
55 if (abs(x(i) - y(i)) > t)
then
57 if (
present(flag)) flag = i
64 module function assert_r32_matrix(x, y, tol, flag, row, col) result(rst)
66 real(real32),
intent(in) :: x(:,:), y(:,:)
67 real(real32),
intent(in),
optional :: tol
68 integer(int32),
intent(out),
optional :: flag, row, col
73 integer(int32) :: i, j, m, n
77 if (
present(flag)) flag = 0
78 if (
present(row)) row = 0
79 if (
present(col)) col = 0
84 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
86 if (
present(flag)) flag = -1
91 if (
present(tol))
then
98 if (abs(x(i,j) - y(i,j)) > t)
then
100 if (
present(flag)) flag = m * (j - 1) + i
101 if (
present(row)) row = i
102 if (
present(col)) col = j
112 module function assert_r64(x, y, tol) result(rst)
114 real(real64),
intent(in) :: x, y
115 real(real64),
intent(in),
optional :: tol
122 if (
present(tol))
then
131 module function assert_r64_array(x, y, tol, flag) result(rst)
133 real(real64),
intent(in) :: x(:), y(:)
134 real(real64),
intent(in),
optional :: tol
135 integer(int32),
intent(out),
optional :: flag
140 integer(int32) :: i, n
144 if (
present(flag)) flag = 0
148 if (
size(y) /= n)
then
150 if (
present(flag)) flag = -1
155 if (
present(tol))
then
161 if (abs(x(i) - y(i)) > t)
then
163 if (
present(flag)) flag = i
170 module function assert_r64_matrix(x, y, tol, flag, row, col) result(rst)
172 real(real64),
intent(in) :: x(:,:), y(:,:)
173 real(real64),
intent(in),
optional :: tol
174 integer(int32),
intent(out),
optional :: flag, row, col
179 integer(int32) :: i, j, m, n
183 if (
present(flag)) flag = 0
184 if (
present(row)) row = 0
185 if (
present(col)) col = 0
190 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
192 if (
present(flag)) flag = -1
197 if (
present(tol))
then
204 if (abs(x(i,j) - y(i,j)) > t)
then
206 if (
present(flag)) flag = m * (j - 1) + i
207 if (
present(row)) row = i
208 if (
present(col)) col = j
218 module function assert_c32(x, y, tol) result(rst)
220 complex(real32),
intent(in) :: x, y
221 real(real32),
intent(in),
optional :: tol
226 complex(real32) :: delta
229 if (
present(tol))
then
235 rst = abs(real(delta)) < t .and. abs(aimag(delta)) < t
239 module function assert_c32_array(x, y, tol, flag) result(rst)
241 complex(real32),
intent(in) :: x(:), y(:)
242 real(real32),
intent(in),
optional :: tol
243 integer(int32),
intent(out),
optional :: flag
248 complex(real32) :: delta
249 integer(int32) :: i, n
253 if (
present(flag)) flag = 0
257 if (
size(y) /= n)
then
259 if (
present(flag)) flag = -1
264 if (
present(tol))
then
271 if (abs(real(delta)) > t .or. abs(aimag(delta)) > t)
then
273 if (
present(flag)) flag = i
280 module function assert_c32_matrix(x, y, tol, flag, row, col) result(rst)
282 complex(real32),
intent(in) :: x(:,:), y(:,:)
283 real(real32),
intent(in),
optional :: tol
284 integer(int32),
intent(out),
optional :: flag, row, col
289 complex(real32) :: delta
290 integer(int32) :: i, j, m, n
294 if (
present(flag)) flag = 0
295 if (
present(row)) row = 0
296 if (
present(col)) col = 0
301 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
303 if (
present(flag)) flag = -1
308 if (
present(tol))
then
315 delta = x(i,j) - y(i,j)
316 if (abs(real(delta)) > t .or. abs(aimag(delta)) > t)
then
318 if (
present(flag)) flag = m * (j - 1) + i
319 if (
present(row)) row = i
320 if (
present(col)) col = j
330 module function assert_c64(x, y, tol) result(rst)
332 complex(real64),
intent(in) :: x, y
333 real(real64),
intent(in),
optional :: tol
338 complex(real64) :: delta
341 if (
present(tol))
then
347 rst = abs(real(delta)) < t .and. abs(aimag(delta)) < t
351 module function assert_c64_array(x, y, tol, flag) result(rst)
353 complex(real64),
intent(in) :: x(:), y(:)
354 real(real64),
intent(in),
optional :: tol
355 integer(int32),
intent(out),
optional :: flag
360 complex(real64) :: delta
361 integer(int32) :: i, n
365 if (
present(flag)) flag = 0
369 if (
size(y) /= n)
then
371 if (
present(flag)) flag = -1
376 if (
present(tol))
then
383 if (abs(real(delta)) > t .or. abs(aimag(delta)) > t)
then
385 if (
present(flag)) flag = i
392 module function assert_c64_matrix(x, y, tol, flag, row, col) result(rst)
394 complex(real64),
intent(in) :: x(:,:), y(:,:)
395 real(real64),
intent(in),
optional :: tol
396 integer(int32),
intent(out),
optional :: flag, row, col
401 complex(real64) :: delta
402 integer(int32) :: i, j, m, n
406 if (
present(flag)) flag = 0
407 if (
present(row)) row = 0
408 if (
present(col)) col = 0
413 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
415 if (
present(flag)) flag = -1
420 if (
present(tol))
then
427 delta = x(i,j) - y(i,j)
428 if (abs(real(delta)) > t .or. abs(aimag(delta)) > t)
then
430 if (
present(flag)) flag = m * (j - 1) + i
431 if (
present(row)) row = i
432 if (
present(col)) col = j
442 module function assert_i16(x, y) result(rst)
444 integer(int16),
intent(in) :: x, y
452 module function assert_i16_array(x, y, flag) result(rst)
454 integer(int16),
intent(in) :: x(:), y(:)
455 integer(int32),
intent(out),
optional :: flag
459 integer(int32) :: i, n
463 if (
present(flag)) flag = 0
465 if (
size(y) /= n)
then
467 if (
present(flag)) flag = -1
472 if (x(i) /= y(i))
then
474 if (
present(flag)) flag = i
481 module function assert_i16_matrix(x, y, flag, row, col) result(rst)
483 integer(int16),
intent(in) :: x(:,:), y(:,:)
484 integer(int32),
intent(out),
optional :: flag, row, col
488 integer(int32) :: i, j, m, n
492 if (
present(flag)) flag = 0
493 if (
present(row)) row = 0
494 if (
present(col)) col = 0
497 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
499 if (
present(flag)) flag = -1
505 if (x(i,j) /= y(i,j))
then
507 if (
present(flag)) flag = m * (j - 1) + i
508 if (
present(row)) row = i
509 if (
present(col)) col = j
519 module function assert_i32(x, y) result(rst)
521 integer(int32),
intent(in) :: x, y
529 module function assert_i32_array(x, y, flag) result(rst)
531 integer(int32),
intent(in) :: x(:), y(:)
532 integer(int32),
intent(out),
optional :: flag
536 integer(int32) :: i, n
540 if (
present(flag)) flag = 0
542 if (
size(y) /= n)
then
544 if (
present(flag)) flag = -1
549 if (x(i) /= y(i))
then
551 if (
present(flag)) flag = i
558 module function assert_i32_matrix(x, y, flag, row, col) result(rst)
560 integer(int32),
intent(in) :: x(:,:), y(:,:)
561 integer(int32),
intent(out),
optional :: flag, row, col
565 integer(int32) :: i, j, m, n
569 if (
present(flag)) flag = 0
570 if (
present(row)) row = 0
571 if (
present(col)) col = 0
574 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
576 if (
present(flag)) flag = -1
582 if (x(i,j) /= y(i,j))
then
584 if (
present(flag)) flag = m * (j - 1) + i
585 if (
present(row)) row = i
586 if (
present(col)) col = j
596 module function assert_i64(x, y) result(rst)
598 integer(int64),
intent(in) :: x, y
606 module function assert_i64_array(x, y, flag) result(rst)
608 integer(int64),
intent(in) :: x(:), y(:)
609 integer(int32),
intent(out),
optional :: flag
613 integer(int32) :: i, n
617 if (
present(flag)) flag = 0
619 if (
size(y) /= n)
then
621 if (
present(flag)) flag = -1
626 if (x(i) /= y(i))
then
628 if (
present(flag)) flag = i
635 module function assert_i64_matrix(x, y, flag, row, col) result(rst)
637 integer(int64),
intent(in) :: x(:,:), y(:,:)
638 integer(int32),
intent(out),
optional :: flag, row, col
642 integer(int32) :: i, j, m, n
646 if (
present(flag)) flag = 0
647 if (
present(row)) row = 0
648 if (
present(col)) col = 0
651 if (
size(y, 1) /= m .or.
size(y, 2) /= n)
then
653 if (
present(flag)) flag = -1
659 if (x(i,j) /= y(i,j))
then
661 if (
present(flag)) flag = m * (j - 1) + i
662 if (
present(row)) row = i
663 if (
present(col)) col = j
A collection of routines to assist in testing.