2 ! PR fortran/109186 - Verify that NEAREST produces same results at
3 ! compile-time and run-time for corner cases
4 ! Reported by John Harper
8 integer, parameter :: sp
= selected_real_kind (6)
9 integer, parameter :: dp
= selected_real_kind (13)
10 real(sp
), parameter :: x1
= huge (1._sp
), t1
= tiny (1._sp
)
11 real(dp
), parameter :: x2
= huge (1._dp
), t2
= tiny (1._dp
)
12 real(sp
), volatile :: y1
, z1
13 real(dp
), volatile :: y2
, z2
15 z1
= nearest (y1
, -1._sp
)
16 if (nearest (x1
, -1._sp
) /= z1
) stop 1
18 z2
= nearest (y2
, -1._dp
)
19 if (nearest (x2
, -1._dp
) /= z2
) stop 2
21 z1
= nearest (y1
, 1._sp
)
22 if (nearest (t1
, 1._sp
) /= z1
) stop 3
24 z2
= nearest (y2
, 1._dp
)
25 if (nearest (t2
, 1._dp
) /= z2
) stop 4