Book contents
- Frontmatter
- Contents
- Preface
- One Program Design
- Two Data Types
- Three Object-Oriented Programming Concepts
- Four Features of Programming Languages
- Five Object-Oriented Methods
- Six Inheritance and Polymorphism
- Seven OO Data Structures
- Eight Arrays and Matrices
- Nine Advanced Topics
- Appendix A Fortran 90 Overview
- Appendix B Selected Exercise Solutions
- Appendix C Companion C++ Examples
- Bibliography
- Glossary of Object-Oriented Terms
- Index
Nine - Advanced Topics
Published online by Cambridge University Press: 15 October 2009
- Frontmatter
- Contents
- Preface
- One Program Design
- Two Data Types
- Three Object-Oriented Programming Concepts
- Four Features of Programming Languages
- Five Object-Oriented Methods
- Six Inheritance and Polymorphism
- Seven OO Data Structures
- Eight Arrays and Matrices
- Nine Advanced Topics
- Appendix A Fortran 90 Overview
- Appendix B Selected Exercise Solutions
- Appendix C Companion C++ Examples
- Bibliography
- Glossary of Object-Oriented Terms
- Index
Summary
Managing Dynamic Memory
Grouping Tasks
Fortran 90 includes several features to give the programmer the tools necessary to manage dynamic memory usage. However, one tends to think of these tools as completely free-standing statements or functions. In practice, a large code often has several related arrays or pointers that need to be created and released from memory at the same time. Basically, that means we should supply subprograms that generalize the operations provided by the intrinsic functions allocated and associated.
Here we illustrate this concept with a segment of a class that came from a classic finite element analysis system. The attributes are various types of allocatable arrays – local integers that will establish the array sizes. Additional items required to manage the memory are accessed through the use association of the module, called system_constants. The encapsulated members include initialization, debugging, and printing subprograms as well as the actual memory management members.
Figure 9.1 shows segments of the code Elem_Type_Data_Class. Here the word “type” is not used in the language sense but to identify one of about 18 possible finite elements from an existing library (such as a line, triangle, tetrahedron, etc.). Among the class attributes note that the local integer array item, line 5, serves the purpose of checking for local fatal error checks. It is sized to receive the number of subgroup allocations. Recall that the allocate function has an optional status return code, stat=, lines 36, 37, and so forth.
- Type
- Chapter
- Information
- Object-Oriented Programming via Fortran 90/95 , pp. 209 - 228Publisher: Cambridge University PressPrint publication year: 2003