I am using a API in Fortran which provides a routine for writing data. Let's say its name is api_write_data. This routine expects an array as argument which can be of dimension 1, 2 or 3.
I want to write a subroutine which works as wrapper for this API routine. But therefore it is necessary for me to write a routine which can handle 1D, 2D or 3D arrays and can pass them correctly to the API routine. How can I do that? Can I do that at all?
My approach was something like this, but it does not work:
subroutine write_data(array)
implicit none
integer, dimension(:,:,:), intent(in):: array
call api_write_data(array)
end subroutine write_data
However when I call this routine with for example an 1D array, I get the known error:
Error: Rank mismatch in argument 'array' at (1) (rank-3 and rank-1)
Is there any way to do that kind of thing in Fortran? For me it is necessary to pass the Array as a 1D, 2D or 3D array to the write_data routine. However, I could pass the array as 1D array to api_write_data.
Do you have any idea how I could do that?