Hello
I’m using pgi/12.8 .
Since at least the pgi/12.5 version the reshape function doesn’t work correctly for non contiguous array passed as argument to subroutines .
Here is small example to extract interior points , with value 1, in 1D array from a 2D domain with ‘halo’ points value 0 .
OK Compiled with pgi/11.10 version :
test_halo_reshape_2D_1D
==== I2D=All 2D domaine ====
0 0 0 0
0 > 1 1 > 0
0 > 1 1 > 0
0 0 0 0
=== I1D=Interior Points ===
1 1 1 1
BUG Compiled with pgi/12.5 and over
test_halo_reshape_2D_1D
==== I2D=All 2D domaine ====
0 0 0 0
0 > 1 1 > 0
0 > 1 1 > 0
0 0 0 0
=== I1D=Interior Points ===
1 1 > 0 0
Here is the sample code compiled by
pgf90 -g test_halo_reshape_2D_1D.f90 -o test_halo_reshape_2D_1D
PROGRAM HALO_RESHAPE
IMPLICIT NONE
INTEGER, PARAMETER :: NI=2 , NHALO = 1 , NIEXT = NI + 2 * NHALO
INTEGER, ALLOCATABLE, DIMENSION(:,:) :: I2D
INTEGER, ALLOCATABLE, DIMENSION(:) :: I1D
INTEGER :: I,IIB,IIE
ALLOCATE (I2D(NIEXT,NIEXT))
ALLOCATE (I1D(NI*NI))
IIB=1+NHALO
IIE=NIEXT-NHALO
!
! Field I2D with 1 in interior and 0 in the halo
!
I2D = 0
I2D(IIB:IIE,IIB:IIE) = 1
print*," ==== I2D=All 2D domaine ===="
DO I=1,NIEXT
print*,I2D(:,I)
END DO
!
! get linearized interior points
!
CALL PACK_2D_1D(I2D(IIB:IIE,IIB:IIE),I1D )
print*," === I1D=Interior Points ==="
print*,I1D
CONTAINS
SUBROUTINE PACK_2D_1D(K2D,K1D)
IMPLICIT NONE
INTEGER, DIMENSION(:,:), INTENT(IN) :: K2D
INTEGER, DIMENSION(:), INTENT(OUT):: K1D
K1D=RESHAPE(K2D, (/ SIZE(K2D) /) )
END SUBROUTINE PACK_2D_1D
END PROGRAM HALO_RESHAPE
A+
Juan