- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in assumed shape passsing, e.g.:
real A(-10:10)
call x(A)
...
suborutine(Ad)
real Ad(:)
the dummy array Ad will be dimensioned (1:21).
Is there a way to
1. have it dimensioned the same as the actual array A?
OR
2. somehow find out the original bounds (or their offset)?
Thanks,
Tim
real A(-10:10)
call x(A)
...
suborutine(Ad)
real Ad(:)
the dummy array Ad will be dimensioned (1:21).
Is there a way to
1. have it dimensioned the same as the actual array A?
OR
2. somehow find out the original bounds (or their offset)?
Thanks,
Tim
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No and no. You can pass the bounds separately and declare the array as an adjustable array if you like. This is a peculiar aspect of the Fortran language that puzzles many.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following appears to work with ifc 7.1.
I am not sure if it is fully standard.
module themodule
contains
subroutine sub1(A)
real :: A(:)
write (*,*) lbound(A,1), ubound(A,1)
return
end subroutine sub1
subroutine sub2(A)
real,pointer :: A(:)
write (*,*) lbound(A,1), ubound(A,1)
return
end subroutine sub2
subroutine main
real :: A(-10:10)
real,target :: A2(-10:10)
real, pointer :: Ap(:)
call sub1(A)
Ap => A2
call sub2(Ap)
end subroutine main
end module themodule
program testshapepassing
use themodule
call main
end program testshapepassing
[mbk@lyapunov language]% ./a.out
1 21
-10 10
[mbk@lyapunov language]%
I am not sure if it is fully standard.
module themodule
contains
subroutine sub1(A)
real :: A(:)
write (*,*) lbound(A,1), ubound(A,1)
return
end subroutine sub1
subroutine sub2(A)
real,pointer :: A(:)
write (*,*) lbound(A,1), ubound(A,1)
return
end subroutine sub2
subroutine main
real :: A(-10:10)
real,target :: A2(-10:10)
real, pointer :: Ap(:)
call sub1(A)
Ap => A2
call sub2(Ap)
end subroutine main
end module themodule
program testshapepassing
use themodule
call main
end program testshapepassing
[mbk@lyapunov language]% ./a.out
1 21
-10 10
[mbk@lyapunov language]%
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's tres cool!
Alas, I never acquired a general understanding of f90 pointers (unlike the cvf pointers which parallel C pointers which are a rather simple concept).
So far I have seen two unique uses of f90 pointers:
1. Your exmaple, and
2. A way doing what "Equivalence" used to do.
Which begs the question, what other things can one do with this thingie?!
The cvf doc's are sorely lacking in tutorial quality (unlike the old MSPS docs). Can you refer me to a place where the f90 pointers are explained in concrete terms?
Thanks,
Tim
Alas, I never acquired a general understanding of f90 pointers (unlike the cvf pointers which parallel C pointers which are a rather simple concept).
So far I have seen two unique uses of f90 pointers:
1. Your exmaple, and
2. A way doing what "Equivalence" used to do.
Which begs the question, what other things can one do with this thingie?!
The cvf doc's are sorely lacking in tutorial quality (unlike the old MSPS docs). Can you refer me to a place where the f90 pointers are explained in concrete terms?
Thanks,
Tim
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/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