You shouldn't need to make any copies. Is it that you're passing these arrays to the C routines? The C routines have no idea how the arrays are allocated - you'd have to pass the sizes separately. You should be able to just pass the arrays and the bounds in the way C wants them.
If I haven't understood your question correctly, please post some sample code to illustrate the problem and where you think you need to chsange things. I will warn you that a 2-dimension array in C is an array of arrays. More likely that the C routine wants the first element address and the bounds.




Shifting array from (1:size_x,1:size_y) to (0:size_x-1,0:size_y-1)
Hi,
I am writng a CFD code and I'm using the PETSc library. It has some new functions which help to partition my solution automatically. However, since it's written in C, its output array are always given as A(0:size_x-1,0:size_y-1).
However, my fortran array was allocated as A(1:size_x,1:size_y). Since I am implementing the new functions into my existing code, I'm trying to modify as little codes as possible. I have many subroutines which uses A(1:size_x,1:size_y) as the input array.Is there anyway whereby I can change between A(1:size_x,1:size_y) and A(0:size_x-1,0:size_y-1), without the need to copy one over the other and take up more memory?
Thanks!