- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
function Proof(a)
!DEC$ ATTRIBUTES DLLEXPORT,ALIAS:"FProof" :: Proof
integer, value :: a
INTEGER, DIMENSION (a) ::Proof
integer::i
DO i = 1, a
Proof(i) = 300
END DO
end function Proof
Now from Java code:package Component;
import com.sun.jna.*;
public class Union {
interface F95Test extends com.sun.jna.Library {
F95Test lib = (F95Test) Native.loadLibrary("C:/Flood/FloodProgram/FloodProgram/Debug/FloodProgram.dll",
F95Test.class);
int[] FProof (int b);
}
public static void main(String[] args) {
int[] result=F95Test.lib.FProof(2);
System.out.println(result);
}Exception in thread "main" java.lang.IllegalArgumentException: Unsupported return type class [I in function FProof
at com.sun.jna.Function.invoke(Function.java:424)
at com.sun.jna.Function.invoke(Function.java:276)
at com.sun.jna.Library$Handler.invoke(Library.java:216)
at Component.$Proxy0.FProof(Unknown Source)
at Component.Union.main(Union.java:46)
So I do not know if someone have moved arrays from fortran to java. I would appreciate so much any idea.
Thanks,
Miguel
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me suggest that you stick to Fortran procedures that are "interoperable", which puts some restrictions on what the arguments and return value can be. Here, you may want to make it a subroutine and pass a preallocated array and the array size as arguments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello sir.
i want tocall fortan function in java..bt m geting error.
here is my code:
public class FortanJava {
interface F95 extends com.sun.jna.Library
{
F95 test=(F95)Native.loadLibrary("F90Dyn", F95.class);
int foomult(int a, int b);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int result = F95.test.foomult(5,5);
System.out.println(result);
}
}
m getting error like this Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /tmp/jna5645755368766446105.tmp which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page