Re: Fortran 90 and GUIs
- From: Mark Westwood <markc.westwood@xxxxxxxxx>
- Date: Mon, 30 Jun 2008 02:15:39 -0700 (PDT)
Hi Brady
Well, I slapped a Java front-end on to an existing Fortran code. It
was either that or rewrite the Fortran into Java; commercial pressure
required one or the other. One of the problems I tackled is that Java
doesn't have a very flexible approach to integrating with 'foreign'
languages. There is the JNI (Java Native Interface) which is intended
for integration with 'legacy' code, as long as that code is written in
C or C++. My eventual solution was to first wrap the Fortran in C++,
then to integrate that with the Java. After a lot of head-scratching
I got it working on both Linux (64 bit, 32 bit, .so libraries) and
Windows (32 bit DLL).
My advice to anyone proposing to follow the same route is -- don't if
you can possibly avoid it. Spend your employer's money on one of the
Fortran GUI builders available -- the O($1000) cost of a bit of
software is way less than the O($10000) cost of a couple or three
week's work by a programmer. If you must then you should first learn
enough C++ to figure out the translations to and from Fortran, not
forgetting pointers, arrays (one and two dimension), value-returning
function calls and all the other minor niggles where the languages
don't quite fit. I knew almost no C++ when I began, and it proved a
real handicap.
I'd also observe that Java is very strange to a Fortran programmer --
especially the GUI parts of Java. Given my own choice I would look
further into using Python as the GUI language. Get your hands on a
copy of Python Scripting for Computational Science by Hans Petter
Langtangen for details. GUIs are still strange in Python (from the
perspective of a Fortran number-cruncher) but you'll probably feel
right at home with the rest of Python.
Of course, with Python (as with C and C++) to build GUIs you'll need a
GUI library or toolkit -- of which there are many. Java has Swing,
but there's also the SWT and probably others to choose from.
I guess it boils down to the question Why do you want to implement a
GUI ? You might want to:
-- learn how to build a GUI;
-- integrate your Fortran with an existing GUI-fronted system;
-- inflict severe mental pain on yourself;
-- lots of other things.
So, yes, it's feasible. It will be much easier to use a language you
know already -- I'd definitely recommend that your first project in C
(or C++ or Java or any other language) should NOT be writing a GUI to
interface to a Fortran code. There's plenty of online advice in
integrating codes written in different languages.
Good luck
Mark
On Jun 27, 5:51 pm, brady.m.ad...@xxxxxxxxx wrote:
I have a Fortran program that I would like to implement a GUI with. In
doing a little reading around the net it seems that I will probably
want to call a different programming language such as C++, Java, or
Python. Starting out the GUI will be really simple: something like
"You are running blah blah blah. Continue?" --- with yes and no
buttons. If things go smoothly the GUI could get considerably more
complex.
My question: is this feasible? If so what would be the best language
to do this with? I know nothing about C, C++, or Java, but I know a
little Python. Or is there something else that would be better? Are
there any good books or online references on interfacing two different
languages (one of which being Fortran)?
Thank you!
.
- References:
- Fortran 90 and GUIs
- From: brady . m . adams
- Fortran 90 and GUIs
- Prev by Date: Re: Fortran bashing in the MATLAB newsgroup
- Next by Date: Re: Fortran 90 and GUIs
- Previous by thread: Re: Fortran 90 and GUIs
- Next by thread: Re: Fortran 90 and GUIs
- Index(es):