My purpose in posting this message is to locate others in the
community that may have implemented or be interested in implementing
certain OO capabilities using some preprocessor (PERL?) and an F95
compiler.
Many OO features can be directly emulated in F95. There is some
excellent work by Decyk, Norton and Symanski
<http://www.cs.rpi.edu/~szymansk/oof90.html>. Their method is
essentially to imitate true inheritance/polymorphism by explicitly
oveloading routines for derived types (derived class) to call the
same-named routine on a component of the derived type (the parent or
base class).
Although such techniques allow a relatively full set of OO techniques
entirely within Fortran, the burden for each extension lies
compeletely on the programmers shoulders rather than on the compiler
where it really belongs. OTOH, languages such as C++ make this aspect
of programming relatively trivial and thereby encourage an OO style
of programming.
What I'm interested in is using some sophisticated preprocessor to
automate most of the work and thereby effectivel provide F95 with the
ability to have abstract base classes. One could then declare
classes (and their lineage), and the preprocessor would create
an appropriate set of Fortran modules with corresponding derived
types. The preprocessor would have to do much of the same work
that C++ compilers must do, and we may even be able to leverage some
of the code from public compilers ...
In case you want to know why I'd like to do this:
For an upcoming project within NASA, we are attempting to develop
"frameworks" to allow various related scientific codes to interact.
Interoperability _and_ parallel performance are both of utmost
importance. For the framework aspect, the natural choice is C++,
whereas from the vantage point of preserving vast amounts of existing
numerical code, Fortran would be preferable.
If none of the scientists had ever ventured beyond F77, then the
solution would be to write the framework in C++ and call F77 routines
as needed. However, many scientists have started using various F90
extensions which introduce _nontrivial_ inter-language issues. (E.g.
how to pass the dope vector for F90 arrays.)
I see 4 solutions.
1) Rewrite any necessary F90 code in C++.
Some scientists will probably resist this to the point that the
project will fail. On the plus side, we could hire some new
software engineers that would otherwise be unwilling to work in
Fortran. (Begging the question of whether NASA can afford to hire
C++ software engineers ...)
2) Wait for F2k compilers to be released (and stable). F2k provides
almost everything that is needed to develop a framework.
However, we cannot wait that long, and it is very difficult to find
software engineers that will work in any variant of Fortran..
3) Provide "handles" for any complex F90 derived type variables, and
use the handles as an ugly interface to the C++ framework layer.
This is functional, but relatively inelegant. (Special thanks to
Jing Guo for this suggestion.)
4) Use some sort of preprocessor that allows us to bootstrap fortran
towards something like F2k/C++.
I look forward to seeing your responses.
Cheers,
- Tom
--
--
Thomas Clune, Ph.D. Parallel Applications Consultant
SGI [log in to unmask]
Code 931 NASA GSFC 301-286-4635 (work)
Greenbelt, MD 20771 301-286-1634 (fax)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|