Re: seeking advice for "translate" Fortran code to Java code




Ancient_Hacker wrote:

That's a fine start, with caveats. Many old FORTRAN programs would, to
save memory, redefine a common block as needed for each subroutine.
i.e: one might use: COMMON /VOLATILE/A(100,100,100) and another
unrelated subroutine: COMMON/VOLATILE/ Z(20,20,20). Ugly but very,
um, common. A lot of very useful programs were written back when
memory was $1 a word or more, and you couldnt put more than 256K on a
lot of computers, no matter how much money you had.

"Modernizers" exist that translate such archaisms into modern-style
POINTER aliasing
(with MODULES instead of COMMONs). Still, Java has no pointers, so I
wonder if
this is doable.
(d) 4-D array slices passed as 2D arrays, as VAR parameters

Java arrays are always what C would call arrays of pointers
to arrays. If you want slices, create arrays of object
references to the appropriate subarrays.

I dunno, can you define a Java array of references to reals, referring
to a column of another array? Cool if doable. Unfortunately it
probably has to be done at run-time, while FORTRAN can do it at
compile-time.
Not sure what you mean. Fortran standard doesn't know compile-time or
run-time.
Unless a subroutine is inlined, slices are (in all compilers I know)
passed by a runtime-created array descriptor (for assumed shape) or by
runtime temporary copy (for explicit shape and assumed size, if
necessary).


(e) PURE and INTRINSIC functions

I don't know that Java has anything like this.

Well you can kinda fake it by writing an array-handling class that
can accept a function pointer or class type, if that's doable.
I don't quite understand. Surely you would have to program all
necessary
Fortran intrinsics in Java appropriately. But I don't recall Java
having anything like PURE.


(g) about 300 FORMAT statements

I believe Java finally has something close to C's printf.
It took a long time, though.

FORTRAN I/O can be hard to convert, especially things like implied
do-loops, repeated format specs, and binary I/O. I was hoping for a
FORTRAN I/O class that would emulate formatted and binary I/O.


(i) Calling over 30 routines from the FORTRAN IMSL and other libraries.

Probably through JNI, but if you really want to translate a program
to Java you might as well translate the library routines, too.
Probably from netlib to avoid copyright problems, though a translated
version would likely get around copyright. That is, it would be
a different expression of the ideas.

Yep, only problem is a lot of those libraries are matrix manipulation
packages, which suffer in Java from the very different array models,
not to mention speed issues.

I believe that Visual Numerics sells JMSL for Java. Of course, only
portions
of IMSL functionality are covered.

(j) ASSIGNED go-to for error exit and recovery.

I thought ASSIGNed GOTO was removed from Fortran.
It's "deprecated" I think, but really comes in handy for error exits.
No, it's deleted as of Fortran 95. SELECT should be used instead.

(k) EQUIVALENCE,

What do you want to do with it?

Sooo many old programs would economize on memory by defining arrays on
top of each other by using EQUIVALENCE. Or matrix packages would map
variables onto well-known locations into an array. Ugly but still a
lot of that out there.

I agree that a general Fortran-to-Java converter is a difficult task
(and probably Fortran-to-anything). I would recommend to take advantage
of some Fortran "modernizers" already available and focus on converting
modern Fortran, which should be simpler. F could be a good start.

.



Relevant Pages

  • Re: intersection of two sets
    ... sets(say two 1D arrays) in Fortran? ... is there any function that can find out intersection of these two ... SUBROUTINE remove_from_list ...
    (comp.lang.fortran)
  • Re: How to write the NAME of the variable in a string or a file?
    ... > to give the size of arrays. ... > (already inside subroutine) determine how large ... The real reason is that Fortran is a compiled language ... As that is outside the standard, no standard method ...
    (comp.lang.fortran)
  • Re: Passing array slices to subroutines
    ... and in a subroutine i want to access omega at tlevs-2: ... Assumed shape arrays, as introduced in Fortran 90, may be ... The usual ways of causing memory leaks involve allocating arrays ...
    (comp.lang.fortran)
  • Re: Double precision arrays and subroutines
    ... arrays. ... What happens is that, in Fortran, these two program units are ... The subroutine and the program that calls it are compiled ... and normally the compiler doesn't know about one when it's ...
    (comp.lang.fortran)
  • Re: Java Generic programming using subclassing (OT)
    ... >> mismatched ranks are caught at compile time. ... > that Fortran multi-dimensional arrays don't offer everything ... Java features also don't offer everything a Fortran ...
    (comp.lang.java.programmer)