- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have acquired the big fortran code and I am trying to refer to the array and output the array values. I can't output the results properly.
For example an array of two dimensions array1(:,:) is referred by a pointer as follows:
intereger(pntrsize) , pointer: dps
Now, I want to print out the values of array1(2,3) but I don't know how to print that value using pointers. Can anyone give any suggestions on using pointers properly in fortran ? Everytime I try to tweak things, I always get zero values.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why do you wish to use pointers? Could you accomplish your task without them? You can output array values by using the array name, suitably subscripted, in a WRITE statement. Why is doing this not adequate?
program xuseptr implicit none integer :: x(2,3),i,j do i=1,2; do j=1,3; x(i,j)=i+j end do; end do call parray(x) contains subroutine parray(x) implicit none integer, dimension(:,:),target :: x integer, pointer, dimension(:,:) :: p p=>x write(*,10)(p(i,1),i=1,ubound(x,1)) 10 format(2x,2I8) end subroutine end program
![](/skins/images/71A9511A625CE5D5D45FB59952A4AA71/responsive_peak/images/icon_anonymous_message.png)
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