Operating System - HP-UX
1824169 Members
3356 Online
109668 Solutions
New Discussion

f90 bug: calling sub with pointer array

 
Dong Zheng
Occasional Contributor

f90 bug: calling sub with pointer array

I'm using f90 (v2.4 20000107) on HP-UX 10.20. I think there is a bug when passing a pointer array to a subroutine. See the attached example.

With an array with pointer,
real(8), pointer :: hugearray(:)
When it is passed to a subroutine, I think passing by reference should be used. The dummy array in the sub will be associated with the same memory allocated for hugearray.

However, when "call sub(hugearray,...)" is used, f90 seems to use passing by "copy-in/copy-out" for the array. It creates another copy of the array, passing the address of the new array to the sub, and copy the results back to the original array on return. The result is correct but it uses twice as much as memory.

When "call sub(%ref(hugearray))" is used, another copy of the array is also created. However, the changes made in sub are not copy back in the calling routine.

Only when "call sub(hugearray(1))" is used, the dummy argumenet is associated with the memory allocated for hugearray. However, using an element of an array for a dummy argument array is NOT standard comforming.

Does anyone else has the some kind of problem? Is there a patch or work around for the problem?

Thanks.

Dong Zheng