Basic Examples and Programs

These pages contain sample programs that can be down-loaded and run. They have been tested on the IBM RS/6000 using the IBM xlf90 Fortran 90 compiler (version 4.1), the HP 9000 using the HP Fortran 90 compiler (version 1.00), the Cray C90 using the Cray CF90 compiler (version 3.0.2.0), the DEC station 250 using the DEC f90 compiler (version V5.1-594), the Fujitsu compiler (version 2.0.3*patch*), the SUN Sparc 20 using the SUN f90 compiler (version 1.0.1), the SGI compiler (version 7.2), the Absoft compiler (version 1.0), the NAG compiler (version 2.2(260)), and the Lahey compiler (version 3.5e), These programs are provided AS IS for educational purposes only.

Basic Examples

The first set of examples are programs translated into Fortran 77 and Fortran 90 from the paper: The Fortran 90 example, a translation from the C++ code, shows how basic object-oriented concepts can be represented for a short program. The Fortran 77 version, a translation of the C version from the Fisher and Mitchell paper, allows comparison between the Fortran 77 and Fortran 90 programs.

Fortran 77 Version of Fisher & Mitchell Examples Fortran 90 Version of Fisher & Mitchell Examples
View with button1 or down-load with button3

The following examples are from the appendices of:

Description of Examples Source Code
Appendix A: This example shows how to encapsulate an old, ugly, but fast library FFT to increase program safety and ease of use. One-Dimensional FFT Module
Appendix B: Shows how to encapsulate a new type and a particle pushing operation in a Fortran 90 module. This simplifies the interface to the original, complicated, but efficient particle pushing routine. Species Module
Appendix C: An example showing how to construct classes using Fortran 90 modules and derived types. Encapsulation and operator overloading are used in defining a complex number class where the data components are private. Private_Complex Class
Appendix D: Inheritance using class composition is applied in building private_complex arrays. The derived class was constructed by the definitions and procedures defined in a base class. Complex_Array Class
Appendix E: Inheritance using class sub-typing is emulated in building a monitor_complex class. All of the base class procedures have been extended to work in the derived class. Monitor_Complex Class
Appendices F & G: This examples introduces improvements and extensions on Appendix B. Information describing a particle species is encapsulated into new class that is "inherited" by a derived species class. Species Class
Appendix H: An example of how run-time polymorphism can be supported using a dynamic dispatching approach. (Currently produces incorrect results with the Absoft compiler.) Complex_Subtype Class
View with button1 or down-load with button3

The following set of examples are for those who are already familiar with the C++ Programming Language. They have been translated from the text:

showing the direct mapping of object-oriented features from the C++ programming language into the Fortran 90 language.
Document Reference Source Code
Lippman, pp. 73-77 Stack Class
Lippman, pp. 150-163. List Class
Lippman, pp. 277-279 Word Class
Lippman, pp. 279-298 String Class
View with button1 or down-load with button3

Additional examples may be forthcoming.

UP