12 use,
intrinsic :: iso_fortran_env, only : int8, int16, int32, int64, real32, real64
20 integer(int32) :: n_errors=0_int32
21 integer(int32) :: n_tests=0_int32
22 real(real32) :: tolerance32=2._real32*epsilon(1._real32)
23 real(real64) :: tolerance64=2._real64*epsilon(1._real64)
111 subroutine init(this, tolerance32, tolerance64)
112 class(
tester_t),
intent(out) :: this
113 real(real32),
intent(in),
optional :: tolerance32
114 real(real64),
intent(in),
optional :: tolerance64
119 if (present(tolerance64))
then
120 this% tolerance64 = tolerance64
122 this% tolerance64 = 2._real64*epsilon(1._real64)
125 if (present(tolerance32))
then
126 this% tolerance32 = tolerance32
128 this% tolerance32 = 2._real32*epsilon(1._real32)
136 logical,
intent(in),
optional :: errorstop
138 logical :: do_errorstop
139 if (present(errorstop))
then
140 do_errorstop = errorstop
142 do_errorstop = .true.
145 write(*,*)
'fortran_tester:', this% n_errors,
' error(s) for', this% n_tests,
'test(s)'
147 if (this% n_errors == 0)
then
148 write(*,*)
'fortran_tester: all tests succeeded'
150 write(*,*)
'fortran_tester: tests failed'
151 if (do_errorstop)
then
160 class(
tester_t),
intent(inout) :: this
161 integer(int8),
intent(in) :: i1
162 integer(int8),
intent(in) :: i2
164 this% n_tests = this% n_tests + 1
166 this% n_errors = this% n_errors + 1
173 class(
tester_t),
intent(inout) :: this
174 integer(int16),
intent(in) :: i1
175 integer(int16),
intent(in) :: i2
177 this% n_tests = this% n_tests + 1
179 this% n_errors = this% n_errors + 1
186 class(
tester_t),
intent(inout) :: this
187 integer(int32),
intent(in) :: i1
188 integer(int32),
intent(in) :: i2
190 this% n_tests = this% n_tests + 1
192 this% n_errors = this% n_errors + 1
199 class(
tester_t),
intent(inout) :: this
200 integer(int64),
intent(in) :: i1
201 integer(int64),
intent(in) :: i2
203 this% n_tests = this% n_tests + 1
205 this% n_errors = this% n_errors + 1
212 class(
tester_t),
intent(inout) :: this
213 real(real32),
intent(in) :: r1
214 real(real32),
intent(in) :: r2
216 this% n_tests = this% n_tests + 1
218 this% n_errors = this% n_errors + 1
225 class(
tester_t),
intent(inout) :: this
226 real(real64),
intent(in) :: r1
227 real(real64),
intent(in) :: r2
229 this% n_tests = this% n_tests + 1
231 this% n_errors = this% n_errors + 1
238 class(
tester_t),
intent(inout) :: this
239 complex(real32),
intent(in) :: c1
240 complex(real32),
intent(in) :: c2
242 this% n_tests = this% n_tests + 1
244 this% n_errors = this% n_errors + 1
251 class(
tester_t),
intent(inout) :: this
252 complex(real64),
intent(in) :: c1
253 complex(real64),
intent(in) :: c2
255 this% n_tests = this% n_tests + 1
257 this% n_errors = this% n_errors + 1
264 class(
tester_t),
intent(inout) :: this
265 logical,
intent(in) :: l1
266 logical,
intent(in) :: l2
268 this% n_tests = this% n_tests + 1
269 if (l1 .neqv. l2)
then
270 this% n_errors = this% n_errors + 1
277 class(
tester_t),
intent(inout) :: this
278 integer(int8),
dimension(:),
intent(in) :: i1
279 integer(int8),
dimension(:),
intent(in) :: i2
281 this% n_tests = this% n_tests + 1
283 if (
size(i1) .ne.
size(i2) )
then
284 this% n_errors = this% n_errors + 1
286 if ( maxval(abs(i1-i2)) > 0 )
then
287 this% n_errors = this% n_errors + 1
295 class(
tester_t),
intent(inout) :: this
296 integer(int16),
dimension(:),
intent(in) :: i1
297 integer(int16),
dimension(:),
intent(in) :: i2
299 this% n_tests = this% n_tests + 1
301 if (
size(i1) .ne.
size(i2) )
then
302 this% n_errors = this% n_errors + 1
304 if ( maxval(abs(i1-i2)) > 0 )
then
305 this% n_errors = this% n_errors + 1
313 class(
tester_t),
intent(inout) :: this
314 integer(int32),
dimension(:),
intent(in) :: i1
315 integer(int32),
dimension(:),
intent(in) :: i2
317 this% n_tests = this% n_tests + 1
319 if (
size(i1) .ne.
size(i2) )
then
320 this% n_errors = this% n_errors + 1
322 if ( maxval(abs(i1-i2)) > 0 )
then
323 this% n_errors = this% n_errors + 1
331 class(
tester_t),
intent(inout) :: this
332 integer(int64),
dimension(:),
intent(in) :: i1
333 integer(int64),
dimension(:),
intent(in) :: i2
335 this% n_tests = this% n_tests + 1
337 if (
size(i1) .ne.
size(i2) )
then
338 this% n_errors = this% n_errors + 1
340 if ( maxval(abs(i1-i2)) > 0 )
then
341 this% n_errors = this% n_errors + 1
349 class(
tester_t),
intent(inout) :: this
350 real(real32),
dimension(:),
intent(in) :: r1
351 real(real32),
dimension(:),
intent(in) :: r2
353 this% n_tests = this% n_tests + 1
355 if (
size(r1) .ne.
size(r2) )
then
356 this% n_errors = this% n_errors + 1
358 if ( maxval(abs(r1-r2)) > 0 )
then
359 this% n_errors = this% n_errors + 1
367 class(
tester_t),
intent(inout) :: this
368 real(real64),
dimension(:),
intent(in) :: r1
369 real(real64),
dimension(:),
intent(in) :: r2
371 this% n_tests = this% n_tests + 1
373 if (
size(r1) .ne.
size(r2) )
then
374 this% n_errors = this% n_errors + 1
376 if ( maxval(abs(r1-r2)) > 0 )
then
377 this% n_errors = this% n_errors + 1
385 class(
tester_t),
intent(inout) :: this
386 complex(real32),
dimension(:),
intent(in) :: c1
387 complex(real32),
dimension(:),
intent(in) :: c2
389 this% n_tests = this% n_tests + 1
391 if (
size(c1) .ne.
size(c2) )
then
392 this% n_errors = this% n_errors + 1
394 if ( maxval(abs(c1-c2)) > 0 )
then
395 this% n_errors = this% n_errors + 1
403 class(
tester_t),
intent(inout) :: this
404 complex(real64),
dimension(:),
intent(in) :: c1
405 complex(real64),
dimension(:),
intent(in) :: c2
407 this% n_tests = this% n_tests + 1
409 if (
size(c1) .ne.
size(c2) )
then
410 this% n_errors = this% n_errors + 1
412 if ( maxval(abs(c1-c2)) > 0 )
then
413 this% n_errors = this% n_errors + 1
421 class(
tester_t),
intent(inout) :: this
422 logical,
intent(in),
dimension(:) :: l1
423 logical,
intent(in),
dimension(:) :: l2
427 this% n_tests = this% n_tests + 1
429 if (
size(l1) .ne.
size(l2) )
then
430 this% n_errors = this% n_errors + 1
433 if (l1(k) .neqv. l2(k))
then
434 this% n_errors = this% n_errors + 1
444 class(
tester_t),
intent(inout) :: this
445 integer(int8),
intent(in) :: i
447 this% n_tests = this% n_tests + 1
449 this% n_errors = this% n_errors + 1
456 class(
tester_t),
intent(inout) :: this
457 integer(int16),
intent(in) :: i
459 this% n_tests = this% n_tests + 1
461 this% n_errors = this% n_errors + 1
468 class(
tester_t),
intent(inout) :: this
469 integer(int32),
intent(in) :: i
471 this% n_tests = this% n_tests + 1
473 this% n_errors = this% n_errors + 1
480 class(
tester_t),
intent(inout) :: this
481 integer(int64),
intent(in) :: i
483 this% n_tests = this% n_tests + 1
485 this% n_errors = this% n_errors + 1
492 class(
tester_t),
intent(inout) :: this
493 real(real32),
intent(in) :: r
495 this% n_tests = this% n_tests + 1
497 this% n_errors = this% n_errors + 1
504 class(
tester_t),
intent(inout) :: this
505 real(real64),
intent(in) :: r
507 this% n_tests = this% n_tests + 1
509 this% n_errors = this% n_errors + 1
516 class(
tester_t),
intent(inout) :: this
517 integer(int8),
dimension(:),
intent(in) :: i
519 this% n_tests = this% n_tests + 1
521 if ( minval(i) < 0 )
then
522 this% n_errors = this% n_errors + 1
529 class(
tester_t),
intent(inout) :: this
530 integer(int16),
dimension(:),
intent(in) :: i
532 this% n_tests = this% n_tests + 1
534 if ( minval(i) < 0 )
then
535 this% n_errors = this% n_errors + 1
542 class(
tester_t),
intent(inout) :: this
543 integer(int32),
dimension(:),
intent(in) :: i
545 this% n_tests = this% n_tests + 1
547 if ( minval(i) < 0 )
then
548 this% n_errors = this% n_errors + 1
555 class(
tester_t),
intent(inout) :: this
556 integer(int64),
dimension(:),
intent(in) :: i
558 this% n_tests = this% n_tests + 1
560 if ( minval(i) < 0 )
then
561 this% n_errors = this% n_errors + 1
568 class(
tester_t),
intent(inout) :: this
569 real(real32),
dimension(:),
intent(in) :: r
571 this% n_tests = this% n_tests + 1
573 if ( minval(r) < 0 )
then
574 this% n_errors = this% n_errors + 1
581 class(
tester_t),
intent(inout) :: this
582 real(real64),
dimension(:),
intent(in) :: r
584 this% n_tests = this% n_tests + 1
586 if ( minval(r) < 0 )
then
587 this% n_errors = this% n_errors + 1
594 class(
tester_t),
intent(inout) :: this
595 real(real32),
intent(in) :: r1
596 real(real32),
intent(in) :: r2
598 this% n_tests = this% n_tests + 1
600 if ( abs(r1-r2) > this% tolerance32 )
then
601 this% n_errors = this% n_errors + 1
608 class(
tester_t),
intent(inout) :: this
609 real(real64),
intent(in) :: r1
610 real(real64),
intent(in) :: r2
612 this% n_tests = this% n_tests + 1
614 if ( abs(r1-r2) > this% tolerance64 )
then
615 this% n_errors = this% n_errors + 1
622 class(
tester_t),
intent(inout) :: this
623 real(real32),
intent(in),
dimension(:) :: r1
624 real(real32),
intent(in),
dimension(:) :: r2
626 this% n_tests = this% n_tests + 1
628 if (
size(r1) .ne.
size(r2) )
then
629 this% n_errors = this% n_errors + 1
631 if ( maxval(abs(r1-r2)) > this% tolerance32 )
then
632 this% n_errors = this% n_errors + 1
640 class(
tester_t),
intent(inout) :: this
641 real(real64),
intent(in),
dimension(:) :: r1
642 real(real64),
intent(in),
dimension(:) :: r2
644 this% n_tests = this% n_tests + 1
646 if (
size(r1) .ne.
size(r2) )
then
647 this% n_errors = this% n_errors + 1
649 if ( maxval(abs(r1-r2)) > this% tolerance64 )
then
650 this% n_errors = this% n_errors + 1
658 class(
tester_t),
intent(inout) :: this
659 complex(real32),
intent(in) :: c1
660 complex(real32),
intent(in) :: c2
662 this% n_tests = this% n_tests + 1
664 if ( abs(c1-c2) > this% tolerance32 )
then
665 this% n_errors = this% n_errors + 1
672 class(
tester_t),
intent(inout) :: this
673 complex(real64),
intent(in) :: r1
674 complex(real64),
intent(in) :: c2
676 this% n_tests = this% n_tests + 1
678 if ( abs(r1-c2) > this% tolerance64 )
then
679 this% n_errors = this% n_errors + 1
686 class(
tester_t),
intent(inout) :: this
687 complex(real32),
intent(in),
dimension(:) :: c1
688 complex(real32),
intent(in),
dimension(:) :: c2
690 this% n_tests = this% n_tests + 1
692 if (
size(c1) .ne.
size(c2) )
then
693 this% n_errors = this% n_errors + 1
695 if ( maxval(abs(c1-c2)) > this% tolerance32 )
then
696 this% n_errors = this% n_errors + 1
704 class(
tester_t),
intent(inout) :: this
705 complex(real64),
intent(in),
dimension(:) :: c1
706 complex(real64),
intent(in),
dimension(:) :: c2
708 this% n_tests = this% n_tests + 1
710 if (
size(c1) .ne.
size(c2) )
then
711 this% n_errors = this% n_errors + 1
713 if ( maxval(abs(c1-c2)) > this% tolerance64 )
then
714 this% n_errors = this% n_errors + 1
procedure, private assert_close_c64
Check if two complex numbers (64 bits) are close with respect a tolerance.
procedure, private assert_equal_l_1
Check if two logical arrays (rank 1) are equal.
procedure, private assert_close_r32
Check if two reals (32 bits) are close with respect a tolerance.
procedure, private assert_positive_r64
Check if a real (64 bits) is positive.
procedure, private assert_equal_l
Check if two logicals are equal.
procedure, private assert_positive_i32_1
Check if a integer (32 bits) array (rank 1) is positive.
procedure, private assert_positive_i16_1
Check if a integer (16 bits) array (rank 1) is positive.
procedure, private assert_positive_i8_1
Check if a integer (8 bits) array (rank 1) is positive.
procedure, private assert_close_c32_1
Check if two complex (32 bits) arrays (rank 1) are close with respect a tolerance.
procedure, private assert_positive_r32
Check if a real (32 bits) is positive.
procedure, private assert_equal_i64_1
Check if two integer (64 bits) arrays (rank 1) are equal.
procedure, private assert_positive_i16
Check if a integer (16 bits) is positive.
procedure, private assert_positive_i64_1
Check if a integer (64 bits) array (rank 1) is positive.
procedure, private assert_equal_i16
Check if two integers (16 bits) are equal.
procedure, private assert_equal_i32_1
Check if two integer (32 bits) arrays (rank 1) are equal.
procedure, private assert_equal_i16_1
Check if two integer (16 bits) arrays (rank 1) are equal.
procedure, private assert_equal_i8_1
Check if two integer (8 bits) arrays (rank 1) are equal.
procedure, private assert_equal_c64_1
Check if two complex (64 bits) arrays (rank 1) are equal.
procedure, private assert_equal_i32
Check if two integers (32 bits) are equal.
procedure, private assert_equal_c32_1
Check if two complex (32 bits) arrays (rank 1) are equal.
generic, public assert_positive=>assert_positive_i8,assert_positive_i16,assert_positive_i32,assert_positive_i64,assert_positive_r32,assert_positive_r64,assert_positive_i8_1,assert_positive_i16_1,assert_positive_i32_1,assert_positive_i64_1,assert_positive_r32_1,assert_positive_r64_1
Check if a number (integer or real) is positive.
procedure, private assert_close_c32
Check if two complex numbers (32 bits) are close with respect a tolerance.
procedure, private assert_equal_c64
Check if two complex numbers (64 bits) are equal.
procedure, private assert_equal_i64
Check if two integers (64 bits) are equal.
procedure, private assert_equal_r32
Check if two reals (32 bits) are equal.
procedure, private assert_close_r64
Check if two reals (64 bits) are close with respect a tolerance.
procedure, private assert_equal_c32
Check if two complex numbers (32 bits) are equal.
procedure, private assert_equal_i8
Check if two integers (8 bits) are equal.
procedure, private assert_positive_r32_1
Check if a real (32 bits) array (rank 1) is positive.
procedure, private assert_equal_r64
Check if two reals (64 bits) are equal.
procedure print
Print tests results.
generic, public assert_equal=>assert_equal_i8,assert_equal_i16,assert_equal_i32,assert_equal_i64,assert_equal_r32,assert_equal_r64,assert_equal_c32,assert_equal_c64,assert_equal_l,assert_equal_i8_1,assert_equal_i16_1,assert_equal_i32_1,assert_equal_i64_1,assert_equal_r32_1,assert_equal_r64_1,assert_equal_c32_1,assert_equal_c64_1,assert_equal_l_1
Check if two values (integer, real, complex or logical) are equal.
procedure, private assert_positive_i8
Check if a integer (8 bits) is positive.
procedure, private assert_positive_i32
Check if a integer (32 bits) is positive.
procedure, private assert_positive_i64
Check if a integer (64 bits) is positive.
procedure, private assert_equal_r64_1
Check if two real (64 bits) arrays (rank 1) are equal.
procedure, private assert_close_c64_1
Check if two complex (64 bits) arrays (rank 1) are close with respect a tolerance.
generic, public assert_close=>assert_close_r32,assert_close_r64,assert_close_c32,assert_close_c64,assert_close_r32_1,assert_close_r64_1,assert_close_c32_1,assert_close_c64_1
Check if two values (real or complex) are close with respect a tolerance.
procedure, private assert_close_r64_1
Check if two real (64 bits) arrays (rank 1) are close with respect a tolerance.
procedure init
Initialize the tester.
procedure, private assert_positive_r64_1
Check if a real (64 bits) array (rank 1) is positive.
procedure, private assert_close_r32_1
Check if two real (32 bits) arrays (rank 1) are close with respect a tolerance.
Routines to test Fortran programs.
procedure, private assert_equal_r32_1
Check if two real (32 bits) arrays (rank 1) are equal.