Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array index lost when passing array?

Status
Not open for further replies.

gittenlucky

Programmer
Oct 31, 2009
1
US
I have an array that I create, but when I pass it, it loses the indexing properties. example:


-main program-
real, allocatable, dimension:)) :: peanut
...
Allocate(peanut(5:16))
...
call subroutine butter(peanut)
...
real, intent(in out), dimension:)) :: peanut
...
-end subroutine
-end program

so the array peanut should index from 5:16, but when I try to access it in the subroutine, it indexes from 1:12. The data passes OK, but the index is reset to start at 1. Does anyone know how I can fix this? Thanks!
 
Say peanut contains "ABCDEFGHIJKLMNOP". When you pass 5:16, the callee gets EFGHIJKLMNOP. In the eyes of the callee, this is 1:12. If you want to pass in 5 and 16, they ought to be passed as parameters otherwise it defaults to 1:...

If you want to access ABCD from the callee, you'd have to access -3:0. Not sure how legal that is though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top