I'm new to this forum and was not sure where to post this question. I've got some questions regarding setting up a JNI to access a Fortran dll.
I've built a Fortran dll from f77 from UNIX for the PC using the Intel compiler. Now I need to access it from my Java code via C++ wrapper code. I've searched online and most examples show you how to take a simple piece of Fortran code and nothing as complex as I really need. My basic issue is that the Fortran code I used to make the dll is maintained by someone else. So I am not really authorized to make any changes to it. I'd like to be able to do everything I need inside the wrapper C++ code and simply call the dll to perform the necessary calculations.
That being said here are my questions:
1. Is there some kind of table so I can match up the datatypes between the Java/C/Fortran codes? The Fortran code is expecting reals, real arrays, int, int arrays, character*1, and character*(*). I'm not sure how to specify these in the extern line in the C++ code. Do I pass by reference or by value?
extern "C" void WIND(float*,float,float,const char*....) ??
Java is of course passing floats, 2d float arrays, and strings. I can't find an example that explains how to declare variables for the function prototype for the Fortran subroutine.
I know the conversion from Java to C++ code has items such as jstring, jobjectArray, and jfloatArrays which make sense and works fine for me.
2. Assuming I can correctly call my Fortran subroutine from the dll, how to I get values back. The subroutine accepts several input variables and returns several output variables. I understand that I have to convert the java arrays into native arrays to pass to Fortan and vice versa, once the Fortan code has returned the output values, I must convert those arrays back into something I can pass back to Java.
I have Fortran subroutines and not Fortran functions so will I still be able to get back a bunch of ouptut variables the same way such as this?
3. Assuming I can get back outA, outB, and outC does this mean I have to write getter/setter methods inside the C++ code so my java code can get back all of my data since Java limits me to one object for returning? What's the best way to do this? Should I just make global variables in the C++ code that get set once I get my data back from the Fortran dll call? Then I could tell Java to call the getter methods after the initial run of the calculations have been completed?
Any suggestions any one can give me with be very much appreciated. I have gotten a JNI working for some other C++ code so I just need help on how to extend this to work for a Fortran dll that I'm not allowed to alter.