Silverfrost Forums

Welcome to our forums

Jave calling Fortran EXE

13 Oct 2012 6:25 #10829

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(); } } }

13 Oct 2012 7:04 #10830

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.

14 Oct 2012 9:34 #10834

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

Please login to reply.