| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/90608 |
| 4 |
! Check the correct behaviour of the inline MAXLOC implementation, |
| 5 |
! when ARRAY is filled with NANs. |
| 6 |
|
| 7 |
program p |
| 8 |
implicit none |
| 9 |
call check_without_mask |
| 10 |
call check_with_mask |
| 11 |
contains |
| 12 |
subroutine check_without_mask() |
| 13 |
use, intrinsic :: ieee_arithmetic |
| 14 |
real, allocatable :: a(:,:,:) |
| 15 |
real :: nan |
| 16 |
integer, allocatable :: m(:) |
| 17 |
if (.not. ieee_support_nan(nan)) return |
| 18 |
nan = ieee_value(nan, ieee_quiet_nan) |
| 19 |
allocate(a(3,3,3), source = nan) |
| 20 |
m = maxloc(a) |
| 21 |
if (size(m, dim=1) /= 3) stop 32 |
| 22 |
if (any(m /= (/ 1, 1, 1 /))) stop 35 |
| 23 |
end subroutine |
| 24 |
subroutine check_with_mask() |
| 25 |
use, intrinsic :: ieee_arithmetic |
| 26 |
real, allocatable :: a(:,:,:) |
| 27 |
logical, allocatable :: m(:,:,:) |
| 28 |
real :: nan |
| 29 |
integer, allocatable :: r(:) |
| 30 |
if (.not. ieee_support_nan(nan)) return |
| 31 |
nan = ieee_value(nan, ieee_quiet_nan) |
| 32 |
allocate(a(3,3,3), source = nan) |
| 33 |
allocate(m(3,3,3)) |
| 34 |
m(:,:,:) = reshape((/ .false., .false., .true. , .true. , .false., & |
| 35 |
.true. , .false., .false., .false., .true. , & |
| 36 |
.true. , .false., .true. , .true. , .true. , & |
| 37 |
.false., .false., .true. , .true. , .false., & |
| 38 |
.false., .true. , .false., .false., .true. , & |
| 39 |
.true. , .true. /), shape(m)) |
| 40 |
r = maxloc(a, mask = m) |
| 41 |
if (size(r, dim = 1) /= 3) stop 62 |
| 42 |
if (any(r /= (/ 3, 1, 1 /))) stop 65 |
| 43 |
end subroutine |
| 44 |
end program p |