kapahianil
Programmer
Please have a look at piece of code below and try to answer the questions given in comments. Thanks.
Anil
Program TEST
IMPLICIT NONE
INTEGER :: nch, iside, i
! cell pointer type
TYPE :: cell_ptr
TYPE(cell_type), POINTER :: cptr
END TYPE cell_ptr
TYPE :: cell_type
! cell index
INTEGER, DIMENSION(1) :: index
! Pointers to neighbors
TYPE(cell_ptr), DIMENSION(1:27) :: nbrcell !! As cell_ptr type is a
!! pointer does that mean nbrcell is a pointer too.
END TYPE cell_type
TYPE(cell_ptr),DIMENSION), POINTER :: basecell
TYPE(cell_type), TARGET :: cell0
! Initialize cell0
cell0%index(1) = 0
DO iside = 1, 27
cell0%nbrcell(iside)%cptr => cell0
ENDDO
ALLOCATE(basecell(0:10000))
DO i = 0,10000 !! Do I need This
ALLOCATE(basecell(i)%cptr) !! part?Please give your comments as the
END DO !! code works the same with and without this part
basecell(0)%cptr => cell0
DO iside = 1,27
PRINT*,"cell0=",cell0%nbrcell(iside)%cptr%index(1),"iside=",iside
PRINT*,"basecell0=",basecell(0)%cptr%nbrcell(iside)%cptr%index(1),"iside=",iside
END DO
END Program TEST
Anil
Program TEST
IMPLICIT NONE
INTEGER :: nch, iside, i
! cell pointer type
TYPE :: cell_ptr
TYPE(cell_type), POINTER :: cptr
END TYPE cell_ptr
TYPE :: cell_type
! cell index
INTEGER, DIMENSION(1) :: index
! Pointers to neighbors
TYPE(cell_ptr), DIMENSION(1:27) :: nbrcell !! As cell_ptr type is a
!! pointer does that mean nbrcell is a pointer too.
END TYPE cell_type
TYPE(cell_ptr),DIMENSION), POINTER :: basecell
TYPE(cell_type), TARGET :: cell0
! Initialize cell0
cell0%index(1) = 0
DO iside = 1, 27
cell0%nbrcell(iside)%cptr => cell0
ENDDO
ALLOCATE(basecell(0:10000))
DO i = 0,10000 !! Do I need This
ALLOCATE(basecell(i)%cptr) !! part?Please give your comments as the
END DO !! code works the same with and without this part
basecell(0)%cptr => cell0
DO iside = 1,27
PRINT*,"cell0=",cell0%nbrcell(iside)%cptr%index(1),"iside=",iside
PRINT*,"basecell0=",basecell(0)%cptr%nbrcell(iside)%cptr%index(1),"iside=",iside
END DO
END Program TEST