Object-Oriented Programming with Fortran90

V. K. Decyk, C. D. Norton, and B. K. Szymanski

Objective: Fortran90 is a modern programming language with many new features, some of which can be used in support of object-oriented programming (OOP). Although not all the features needed in OOP are present in Fortran90, one would like to emulate those that are missing in a straightforward way [1].

Approach: A class is built by combining a derived type definition with the methods which work on that type. Static class members are emulated by adding data to the module. Encapsulation of any of these elements is directly supported. Polymorphism is implemented by ordinary function overloading, since objects are ordinary arguments. Class composition is directly supported, while simple inheritance is implemented as a special case of class composition. Full subtyping is emulated by means of a special subtype class, which contains a structure of pointers and a dispatch table for each class method.

Accomplishments: Object-oriented versions of plasma particle-in-cell (PIC) codes have been written for parallel computers using both Fortran90 and C++. The functionality of the languages and their performance were compared. In general, most object-oriented features useful for PIC codes were easily modeled in Fortran90, and the performance of the Fortran90 codes was always better than the C++ code, often by a factor of two [2].

Significance: An object-oriented methodology in Fortran90 allows one to modernize old Fortran77 codes in an incremental fashion. As a result, the codes are easier to understand, modify, share, explain and extend. Since High Performance Fortran (HPF) is built on top of Fortran90, this also provides a powerful migration path for parallel computers.

Status/Future Plans: The current work has not focused on the performance penalty for using abstractions. The future work will try to determine what constructs in Fortran90 enhance or degrade performance.

Point of contact:
Viktor K. Decyk, JPL
vdecyk@olympic.jpl.nasa.gov
(818) 393-2690


References

  1. V. K. Decyk, C. D. Norton, and B. K. Szymanski, "Introduction to Object-Oriented Concepts using Fortran90," submitted to Computers in Physics, 1996.

  2. C. D. Norton, V. K. Decyk, and B. K. Szymanski, "On Parallel Object Oriented Programming in Fortran 90," to be published in ACM Applied Computing Review, October, 1996.

Back to top