On Wed, 10 Sep 2008 16:53:12 -0500, Lynn McGuire wrote:
We do this all the time in fortran. My intent here is to know the size
of the array being passed to the function from the caller. Otherwise,
my function does not have a clue as to the first limit of the array.
Thanks,
Lynn
Hmm, the below Fortran code is out of scope of this group but that is
completely for example purposes, but I could not understand what you
meant above, as far as I know, in C/C++ there is no direct way to get the
array size from within the function that is why you need to specify the
size as an argument. But in fortran you can get that from inside the
function, as below... Did I correctly understand you?
program array_pass
real, dimension(4,5) :: yourArray
call printDims(yourArray)
contains
subroutine printDims(array)
! deferred shape
real, dimension(:,:) :: array
write(*,*) size(array,1), size(array,2)
end subroutine printDims
end program array_pass
12:44 AM utabak@dutw689 ~ $ ifort arr.f90
12:44 AM utabak@dutw689 ~ $ ./a.out
4 5