Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

How to use Java to talk to Fortran program?

Thread view: 
Shawn - 04 Oct 2006 16:53 GMT
Hi,

I am a Java programmer. Recently I need to build a Java gui which calls
Fortran programs doing computation. Could anybody give me some
suggestions how to get start with this?

Thank you very much.
opalpa opalpa@gmail.com opalinski - 04 Oct 2006 16:59 GMT
You can invoke Fortran executable from Java like any other executable.

If you're in an environment that blends C with Fortran you can JNI to C
and call Fortran from there.

Invoking executables is less work than JNI.

Opalinski
opalpa@gmail.com
http://www.geocities.com/opalpaweb/
Chris Uppal - 04 Oct 2006 17:12 GMT
> I am a Java programmer. Recently I need to build a Java gui which calls
> Fortran programs doing computation. Could anybody give me some
> suggestions how to get start with this?

Keep it as simple as you possibly can.  If you can meet your requirements by
running the Fortran code as an external program and communicating with it via
either or both of files or stdin/stdout then do that.

   -- chris
Simon Brooke - 04 Oct 2006 21:36 GMT
> Hi,
>
> I am a Java programmer. Recently I need to build a Java gui which calls
> Fortran programs doing computation. Could anybody give me some
> suggestions how to get start with this?

OK, approaches.

(i) Have the Fortran program open a port and listen on it. Have the GUI
talk to the Fortran program on that port. You'll need to develop a
protocol, and parsing the protocol at both ends is an overhead, but it
saves an awful lot of tricky code. This is what I would do because it
looks easiest to me.

(ii) Use a Fortran compiler that compiles to JVM. University of Tenesse
have one called f2j, but I don't know how complete it is:
http://icl.cs.utk.edu/f2j/overview/index.html

(iii) Use the GNU C compiler to compile Fortran for the JVM. Sounds
bizarre, but should be possible as GCC has JVM as one of the processors it
supports and Fortran 77 as one of the languages it supports.

(iv) Craft glue code using JNI. This is the 'official' way of doing it, but
my guess is that it would quickly get dark and dirty.

Signature

simon@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

               [ This .sig subject to change without notice ]



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.