Hi,
I need to reshape a one dimensional array into three three-dimensional arrays and I wonder how to do this correctly. In the code sample below you can see how the big one dimensional array is formed from the three three-dimensional ones. But now I need to do the opposite operation. Would be nice if someone could give me a hint. Thanks in advance
Eide
..... code sample ....
!
! variables
!
real (kind = 4), dimension,:, :: vector_x, vector_y, vector_z
real (kind = 4), dimension) :: vector_full
integer (kind = 4) :: nx,ny,nz
integer (kind = 4) :: ndfx,ndfy,ndfz,ndf_full
!
! init
!
allocate(vector_x(nx-1,ny,nz))
allocate(vector_y(nx,ny-1,nz))
allocate(vector_z(nx,ny,nz-1))
!
! degrees of freedom
!
ndfx = (nx-1) * ny * nz
ndfy = nx * (ny-1) * nz
ndfz = nx * ny * (nz-1)
!
! some computation ...
!
!
! memory for big array
!
ndf_full = ndfx + ndfy + ndfz
allocate(full_vector(ndf_full))
!
! map the three vectors into a single one dimensional array
!
full_vector( 1:ndfx ) = reshape(vector_x,(/ndfx/))
full_vector( ndfx+1:ndfx+ndfy ) = reshape(vector_y,(/ndfy/))
full_vector(ndfy+ndfx+1:ndfx+ndfy+ndfz) = reshape(vector_z,(/ndfz/))
!
! some computation ...
!
!
! map back into the three three-dimensional arrays
!
! ????
I need to reshape a one dimensional array into three three-dimensional arrays and I wonder how to do this correctly. In the code sample below you can see how the big one dimensional array is formed from the three three-dimensional ones. But now I need to do the opposite operation. Would be nice if someone could give me a hint. Thanks in advance
Eide
..... code sample ....
!
! variables
!
real (kind = 4), dimension,:, :: vector_x, vector_y, vector_z
real (kind = 4), dimension) :: vector_full
integer (kind = 4) :: nx,ny,nz
integer (kind = 4) :: ndfx,ndfy,ndfz,ndf_full
!
! init
!
allocate(vector_x(nx-1,ny,nz))
allocate(vector_y(nx,ny-1,nz))
allocate(vector_z(nx,ny,nz-1))
!
! degrees of freedom
!
ndfx = (nx-1) * ny * nz
ndfy = nx * (ny-1) * nz
ndfz = nx * ny * (nz-1)
!
! some computation ...
!
!
! memory for big array
!
ndf_full = ndfx + ndfy + ndfz
allocate(full_vector(ndf_full))
!
! map the three vectors into a single one dimensional array
!
full_vector( 1:ndfx ) = reshape(vector_x,(/ndfx/))
full_vector( ndfx+1:ndfx+ndfy ) = reshape(vector_y,(/ndfy/))
full_vector(ndfy+ndfx+1:ndfx+ndfy+ndfz) = reshape(vector_z,(/ndfz/))
!
! some computation ...
!
!
! map back into the three three-dimensional arrays
!
! ????