1 ! Program to test MOD and MODULO intrinsics
2 subroutine integertest (ops
, res
)
4 integer, dimension(2) :: ops
5 integer, dimension(2) :: res
7 if ((mod(ops(1), ops(2)) .ne
. res(1)) .or
. &
8 (modulo(ops(1), ops(2)) .ne
. res(2))) call abort
11 subroutine real4test (ops
, res
)
13 real(kind
=4), dimension(2) :: ops
14 real(kind
=4), dimension(2) :: res
16 if (diff(mod(ops(1), ops(2)), res(1)) .or
. &
17 diff(modulo(ops(1), ops(2)), res(2))) call abort
23 diff
= (abs (a
- b
) .gt
. abs(a
* 1e-6))
27 subroutine real8test (ops
, res
)
29 real(kind
=8), dimension(2) :: ops
30 real(kind
=8), dimension(2) :: res
32 if (diff(mod(ops(1), ops(2)), res(1)) .or
. &
33 diff(modulo(ops(1), ops(2)), res(2))) call abort
39 diff
= (abs(a
- b
) .gt
. abs(a
* 1e-6))
43 program mod_modulotest
46 call integertest ((/8, 5/), (/3, 3/))
47 call integertest ((/-8, 5/), (/-3, 2/))
48 call integertest ((/8, -5/), (/3, -2/))
49 call integertest ((/-8, -5/), (/-3, -3/))
50 call integertest ((/ 2, -1/), (/0, 0/))
52 call real4test ((/3.0, 2.5/), (/0.5, 0.5/))
53 call real4test ((/-3.0, 2.5/), (/-0.5, 2.0/))
54 call real4test ((/3.0, -2.5/), (/0.5, -2.0/))
55 call real4test ((/-3.0, -2.5/), (/-0.5, -0.5/))
56 call real4test ((/ 2.0, -1.0/), (/ 0.0, 0.0 /))
58 call real8test ((/3.0_8
, 2.5_8
/), (/0.5_8
, 0.5_8
/))
59 call real8test ((/-3.0_8
, 2.5_8
/), (/-0.5_8
, 2.0_8
/))
60 call real8test ((/3.0_8
, -2.5_8
/), (/0.5_8
, -2.0_8
/))
61 call real8test ((/-3.0_8
, -2.5_8
/), (/-0.5_8
, -0.5_8
/))
62 call real8test ((/ 2.0_8
, -1.0_8
/), (/ 0.0_8
, 0.0_8
/))
65 call real4test ((/2e34
, 1.0/), (/0.0, 0.0/))
66 call real4test ((/2e34
, 1.5e34
/), (/0.5e34
, 0.5e34
/))