Object-oriented implementations of the MPDATA advection equation solver in C++, Python and Fortran

Sylwester Arabas,Dorota Jarecka,Anna Jaruga,Maciej Fijałkowski
DOI: https://doi.org/10.3233/SPR-140379
2013-03-19
Abstract:Three object-oriented implementations of a prototype solver of the advection equation are introduced. The presented programs are based on Blitz++ (C++), NumPy (Python), and Fortran's built-in array containers. The solvers include an implementation of the Multidimensional Positive-Definite Advective Transport Algorithm (MPDATA). The introduced codes exemplify how the application of object-oriented programming (OOP) techniques allows to reproduce the mathematical notation used in the literature within the program code. A discussion on the tradeoffs of the programming language choice is presented. The main angles of comparison are code brevity and syntax clarity (and hence maintainability and auditability) as well as performance. In the case of Python, a significant performance gain is observed when switching from the standard interpreter (CPython) to the PyPy implementation of Python. Entire source code of all three implementations is embedded in the text and is licensed under the terms of the GNU GPL license.
Computational Physics,Mathematical Software,Atmospheric and Oceanic Physics
What problem does this paper attempt to address?
The main problem that this paper attempts to solve is to show how to use object - oriented programming (OOP) techniques to implement prototype solvers for the multi - dimensional positive - definite transport algorithm (MPDATA) in C++, Python, and Fortran. Specifically, the paper focuses on: 1. **Modularization of code and separation of logical layers**: By using OOP techniques, the modular structure of the program can be better maintained, and different logical layers such as numerical algorithms, parallel mechanisms, data input/output, error handling, and physical process descriptions can be separated. 2. **Improvement of code simplicity and readability**: OOP allows the reproduction of mathematical symbols in the literature in the program logic, making the source code more concise and easier to read. 3. **Performance evaluation**: The paper conducts performance evaluations on the implementations in the three languages, especially exploring the significant performance improvement when switching from the standard Python interpreter (CPython) to the PyPy implementation. 4. **Trade - offs in programming language selection**: It discusses the advantages and disadvantages of different programming languages in terms of code simplicity, syntactic clarity (thus affecting maintainability and auditability), and performance. The core of the paper lies in showing, through specific implementation examples, how to effectively apply OOP techniques in scientific computing, especially the application potential in complex software systems such as weather and climate prediction systems. Through these implementations, the author hopes to provide a new perspective and promote the wider application of OOP techniques in numerical simulation software development.