How to use Java to talk to Fortran program?

Discussion in 'Java' started by Shawn, Oct 4, 2006.

  1. Shawn

    Shawn Guest

    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.
    Shawn, Oct 4, 2006
    #1
    1. Advertising

  2. 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

    http://www.geocities.com/opalpaweb/
    opalpa opalinski, Oct 4, 2006
    #2
    1. Advertising

  3. Shawn

    Chris Uppal Guest

    Shawn wrote:

    > 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
    Chris Uppal, Oct 4, 2006
    #3
  4. Shawn

    Simon Brooke Guest

    in message <eg0ld7$v7j$>, Shawn ('')
    wrote:

    > 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.

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

    [ This .sig subject to change without notice ]
    Simon Brooke, Oct 4, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shawn
    Replies:
    2
    Views:
    1,440
    Shawn
    Dec 6, 2006
  2. Luna Moon
    Replies:
    9
    Views:
    597
    Guest
    Sep 4, 2007
  3. W. eWatson
    Replies:
    6
    Views:
    964
    Gib Bogle
    Dec 21, 2009
  4. deadpickle
    Replies:
    1
    Views:
    941
    Jens Thoms Toerring
    Nov 7, 2010
  5. Phrogz
    Replies:
    4
    Views:
    214
    Austin Ziegler
    Sep 6, 2006
Loading...

Share This Page