5 ! Check that the bounds/shape/strides are correctly set
6 ! for (re)alloc on assignment, if the LHS is either not
7 ! allocated or has the wrong shape. This test is for
8 ! code which is only invoked for libgfortran intrinsic
11 ! Based on the example of PR 52117 by Steven Hirshman
18 INTEGER, PARAMETER :: n1
=2, n2
=2, n3
=2
19 INTEGER :: m1
, m2
, m3
, lc
20 REAL, ALLOCATABLE
:: A(:,:), B(:,:,:)
23 ALLOCATE (A(n1
,n2
*n3
))
24 ! << B is not allocated
38 B
= RESHAPE(A
, [n1
,n2
,n3
])
40 if (any (shape (B
) /= [n1
,n2
,n3
])) STOP 1
41 if (any (ubound (B
) /= [n1
,n2
,n3
])) STOP 2
42 if (any (lbound (B
) /= [1,1,1])) STOP 3
49 ! PRINT *,'A(',m1,',',lc,') = ',A(m1,lc),' B = ',B(m1,m2,m3)
50 if (A(m1
,lc
) /= B(m1
,m2
,m3
)) STOP 4
55 end subroutine unalloc
57 subroutine wrong_shape ()
58 INTEGER, PARAMETER :: n1
=2, n2
=2, n3
=2
59 INTEGER :: m1
, m2
, m3
, lc
60 REAL, ALLOCATABLE
:: A(:,:), B(:,:,:)
63 ALLOCATE (A(n1
,n2
*n3
))
64 ALLOCATE (B(1,1,1)) ! << shape differs from RHS
78 B
= RESHAPE(A
, [n1
,n2
,n3
])
80 if (any (shape (B
) /= [n1
,n2
,n3
])) STOP 5
81 if (any (ubound (B
) /= [n1
,n2
,n3
])) STOP 6
82 if (any (lbound (B
) /= [1,1,1])) STOP 7
89 ! PRINT *,'A(',m1,',',lc,') = ',A(m1,lc),' B = ',B(m1,m2,m3)
90 if (A(m1
,lc
) /= B(m1
,m2
,m3
)) STOP 8
95 end subroutine wrong_shape