I have a Fortran subroutine taking an assumed size array:
subroutine sub(arr)
implicit none
double precision arr(*)
end subroutine
I made a native call from Java using JNA, the Fortran subroutine is compiled as a shared library mylib.so
:
import com.sun.jna.Library;
import com.sun.jna.Native;
public class Wrapper {
public interface MyLib extends Library {
public void sub_(double[] arr);
}
public static void main(String[] args) {
System.setProperty("jna.library.path", ".");
MyLib lib = (MyLib) Native.loadLibrary("mylib.so", MyLib.class);
double[] myarr = new double[10];
lib.sub_(myarr);
}
}
Now, is there a way to get (in the Fortran subroutine) the size of the array I passed into this subroutine without passing the actual size (10 in this case) as an additional argument?
I tried (Fortran) print*, size(arr)
, but that gives a compiler error:
print*,size(arr)
1
Error: The upper bound in the last dimension must appear in the reference to the assumed size array ‘arr’ at (1)