Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

copy of component structure results in stack overflow

$
0
0

hi,

i have an allocatable, rank=1 structure containing an allocatable component which is a real*8, rank=3 array, defined as follows:

db=kind(1.0d0)
type griddata
    real(kind=db), dimension(:,:,:), allocatable :: u
end type
type(griddata), allocatable, dimension(:) :: gd

i allocate two griddata structures:

ngrids=2
allocate(gd(ngrids))

then if i try to copy the components from grid 1 to grid 2, and all of the following versions of the copy result in a stack overflow:

kgf=1
kg=2
! version 1 :
gd(kgf)%u = gd(kg)%u
! version 2 :
gd(kgf)%u(1:nx(kgf),1:ny(kgf),1:nz(kgf)) = gd(kg)%u(1:nx(kgf),1:ny(kgf),1:nz(kgf))
! version 3 :
gd(kgf)%u(:,:,:) = gd(kg)%u(:,:,:) 

they work only if I hardcode the grid number:  gd(2)%u = gd(1)%u

instead, looping over the three dimensions of the component and performing the copy of the element works just fine:

kgf=1
kg=2
do i
do j
do k
  gd(kgf)%u(i,j,k) = gd(kg)%u(i,j,k)
enddo
enddo
enddo

what is happening?


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>