Hi Discourse,
I’m using W10, cygwin 3.3.3, and GCC 11.2.0 .
Is the allocate statement (commented out below) standard conforming?
Thank you
subroutine pointer_05()
implicit none (type, external)
integer, target :: A_trgt
integer, pointer :: A_ptr => null()
integer :: ierr
write(*,'(/,1x,60a)') 'pointer_05 '
write(*,*) '1 A_ptr =', A_ptr
write(*,*) '1 A_trgt =', A_trgt
allocate (A_ptr, stat=ierr )
write(*,*) ' ierr =', ierr
write(*,*) '2 A_ptr =', A_ptr
write(*,*) '2 A_trgt =', A_trgt
deallocate(A_ptr)
write(*,*) '3 A_ptr =', A_ptr
write(*,*) '3 A_trgt =', A_trgt
A_ptr => A_trgt
write(*,*) '4 A_ptr =', A_ptr
write(*,*) '4 A_trgt =', A_trgt
allocate (A_ptr, stat=A_trgt )
write(*,*) '5 A_ptr =', A_ptr
write(*,*) '5 A_trgt =', A_trgt
A_ptr => null()
write(*,*) '6 A_ptr =', A_ptr
write(*,*) '6 A_trgt =', A_trgt
A_ptr => ff()
write(*,*) '7 A_ptr =', A_ptr
write(*,*) '7 A_trgt =', A_trgt
! allocate (A_ptr, stat=ff() ) ! <-- standard conforming?
write(*,*) '8 A_ptr =', A_ptr
write(*,*) '8 A_trgt =', A_trgt
contains
function ff()
implicit none
integer, pointer :: ff
ff => A_trgt
end function ff
end subroutine pointer_05