!********************************************************************* ! Filename: simple_pointer.f ! Author: Eddie Baron ! Created at: Mon Jan 21 12:22:33 2008 ! Modified at: Mon Jan 21 12:46:23 2008 ! Modified by: Eddie Baron ! Version: 1.0 ! Description: illustrate a simple pointer array allocation !********************************************************************* program simple_pointer implicit none integer, parameter :: dp=kind(0.d0) type link real (kind=dp) :: x type (link), pointer :: nextlink=>null() end type link type (link), target :: alpha type (link), pointer :: beta,gamma integer :: i ! write(*,*)"give xinit: " read(*,*)alpha%x gamma => alpha do i=1,100 allocate(beta) gamma%nextlink => beta beta%x = gamma%x + 1.d0 nullify(beta%nextlink) gamma => beta end do gamma => alpha do write(*,*)gamma%x if(.not. associated(gamma%nextlink)) exit gamma => gamma%nextlink end do end