- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm a bit confused by the results of the little program below. I create a (pointer) alias for some array and nullify it later. However, the size of the alias remains the same after nullifying it and is not equal to 0. Is this normal? I also tried gfortran and that gives similar results, although the initial size of the pointer is then equal to 1 (even more strange).
Regards, Peter
Code:
program size_p
implicit none
double precision,target::r(10)
double precision,pointer::pr(:)=>null()
integer::i
write(*,*)'Size pr before assigning:',size(pr)
!do something stupid with the array
do i=1,size
r(i)=i
end do
pr=>r
write(*,*)'Size pr after assigning :',size(pr)
nullify(pr)
write(*,*)'Size pr after nullifying:',size(pr)
end program
I'm a bit confused by the results of the little program below. I create a (pointer) alias for some array and nullify it later. However, the size of the alias remains the same after nullifying it and is not equal to 0. Is this normal? I also tried gfortran and that gives similar results, although the initial size of the pointer is then equal to 1 (even more strange).
Regards, Peter
Code:
program size_p
implicit none
double precision,target::r(10)
double precision,pointer::pr(:)=>null()
integer::i
write(*,*)'Size pr before assigning:',size(pr)
!do something stupid with the array
do i=1,size
r(i)=i
end do
pr=>r
write(*,*)'Size pr after assigning :',size(pr)
nullify(pr)
write(*,*)'Size pr after nullifying:',size(pr)
end program
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The program is not legal Fortran. You are not allowed to ask the size of an unallocated array.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page