View previous topic :: View next topic |
Author |
Message |
BILLDOWS
Joined: 22 Jul 2005 Posts: 86 Location: Swansea, UK
|
Posted: Sat Oct 13, 2012 7:25 am Post subject: Jave calling Fortran EXE |
|
|
I am attempting to help a PhD student in his research by supplying him with a fortran EXE (+ SALFLIBC.DLL) - 32 bit - which he can call from Java. The routine will read from existing files and write results to a new output file. He can successfully call other 16 and 32 bit EXE's (not fortran based). However when attempting to run even the simple program below (reading from an existing file numbers 1 to 5 and writing the same to a new file) from Java, whilst no error message occur and the Java code reports the program has run OK no output file linktest4 is produced!?
dimension k(5 )
1 format(i4)
open(8,file='linktest.txt')
do 20 j = 1,5
read(8,1)k(j)
20 continue
close(8)
open(9,file='linktest4.txt')
do 30 l=1,5
write(9,1) k(l)
30 continue
close(9)
I appreciate that this is presumably a Java issue - or is there something associated with the fortran that makes calls to run a Fortran based EXE different. Any pointers would be gratefully received
Bill
------
package runexe;
public class Main
{
public static void main(String[] args)
{
try
{
Process proc = Runtime.getRuntime().exec("C:\\cargont\\runcargo.exe");
proc.waitFor();
System.out.println("Execution complete");
}catch(Exception e)
{
e.printStackTrace();
}
}
} |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Sat Oct 13, 2012 8:04 am Post subject: |
|
|
I would start with only PRINT*,Hello' in the Fortran code.
Also is the exception being raised in the Java?
Maybe the Fortran exe cannot "see" salflibc.dll. |
|
Back to top |
|
 |
BILLDOWS
Joined: 22 Jul 2005 Posts: 86 Location: Swansea, UK
|
Posted: Sun Oct 14, 2012 10:34 am Post subject: |
|
|
Thanks Paul.
Solved - In the end it transpired that whilst the call to the EXE - which did have to give the full path reference as per the Java in the original posting - was essential, what the student had failed to do was place the Java plus the EXE plus the salflubc.dll and data files ALL in the same folder - as I had suggested!! The addition of 'prints' helped identy this. Having the student machine 200 miles away does not help!
Thanks again
Bill |
|
Back to top |
|
 |
|