Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

negative index passing

rahzan
Novice
996 Views
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
0 Kudos
3 Replies
Steven_L_Intel1
Employee
996 Views
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
0 Kudos
mbkennel
Beginner
996 Views
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]%

0 Kudos
rahzan
Novice
996 Views
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
0 Kudos
Reply