Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

Formula translation in Blitz++, NumPy and modern Fortran: A case study of the language choice tradeoffs

Published: 01 July 2014 Publication History

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 constitute implementations of the Multidimensional Positive-Definite Advective Transport Algorithm MPDATA. The introduced codes serve as examples for how the application of object-oriented programming OOP techniques and new language constructs from C++11 and Fortran 2008 allow 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. All performance tests are carried out using free and open-source compilers. 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.

References

[1]
B.J. Abiodun, W.J. Gutowski, A.A. Abatan and J.M. Prusa, CAM-EULAG: A non-hydrostatic atmospheric climate model with grid stretching, Acta Geophys. 59(6) (2011), 1158-1167.
[2]
J.A. Añel, The importance of reviewing the code, Comm. ACM 54(5) (2011), 40-41.
[3]
A. Arakawa and V.R. Lamb, Computational design of the basic dynamical process of the UCLA general circulation model, in: Methods in Computational Physics, Vol. 17, Academic Press, New York, 1977, pp. 173-265.
[4]
N. Barnes and D. Jones, Clear climate code: Rewriting legacy science software for clarity, IEEE Software 28(6) (2011), 36-42.
[5]
C.F. Bolz, A. Cuni, M. Fijalkowski, M. Leuschel, S. Pedroni and A. Rigo, Runtime feedback in a meta-tracing JIT for efficient dynamic languages, in: ICOOOLPS'11: Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, 2011.
[6]
F. Buschmann, To pay or not to pay technical debt, IEEE Software 28(6) (2011), 29-31.
[7]
J.R. Cary, S.G. Shasharina, J.C. Cummings, J.V.W. Reynders and P.J. Hinker, Comparison of C++ and Fortran 90 for object-oriented scientific programming, Comp. Phys. Comm. 105(1) (2011), 20-36.
[8]
P. Charbonneau and P.K. Smolarkiewicz, Modeling the solar dynamo, Science 340(6128) (2013), 42-43.
[9]
B. Einarsson (ed.), Accuracy and Reliability in Scientific Computing, SIAM, Philadelphia, PA, USA, 2005.
[10]
T. Ezer, H. Arango and A.F. Shchepetkin, Developments in terrain-following ocean models: intercomparisons of numerical aspects, Ocean Model. 4(3) (2002), 249-267.
[11]
S.M. Freeman, T.L. Clune and R.W. Burns III, Latent risks and dangers in the state of climate model software development, in: Proceedings of the FSE/SDP Workshop on Future of Software Engineering Research, ACM, 2010, pp. 111-114.
[12]
S.M. Griffies, C. Boning, F.O. Bryan, E.P. Chassignet, R. Gerdes, H. Hasumi, A. Hirst, A.-M. Treguier and D. Webb, Developments in ocean climate modelling, Ocean Model. 2(3,4) (2000), 123-192.
[13]
K. Iglberger, G. Hager, J. Treibig and U. Rüde, Expression templates revisited: a performance analysis of current methodologies, SIAM J. Sci. Comput. 34(2) (2012), C42-C69.
[14]
R. Kendall, J.C. Carver, D. Fisher, D. Henderson, A. Mark, D. Post, C.E. Rhoades, Jr. and S. Squires, Development of a weather forecasting code: A case study, IEEE Software 25(4) (2008), 59-65.
[15]
D.E. Knuth, Structured programming with go to statements, Comput. Surv. 6(4) (1974), 261-301.
[16]
S. Legutke, Building Earth system models, in: Earth System Modelling - Volume 5: Tools for Configuring, Building and Running Models, R. Ford, G. Riley, R. Budich and R. Redler, eds, Springer, 2012, pp. 45-54.
[17]
J.W.-B. Lin, Why python is the next wave in earth sciences computing, Bull. Amer. Meteor. Soc. 93(12) (2012), 1823-1824.
[18]
A. Markus, Modern Fortran in Practice, Cambridge Univ. Press, 2012.
[19]
Z. Merali, Computational science:... Error... why scientific programming does not compute, Nature 467 (2010), 775-777.
[20]
C.D. Norton, V.K. Decyk, B.K. Szymanski and H. Gardner, The transition and adoption to modern programming concepts for scientific computing in Fortran, Sci. Prog. 15(1) (2007), 27-44.
[21]
S. Paoli, C++ coding standard specification, Technical report, CERN European Laboratory for Particle Physics, 2000, available at: http://pst.web.cern.ch/PST/HandBookWorkBook/Handbook/Programming/CodingStandard/c++standard.pdf.
[22]
M. Pilgrim, Dive Into Python, Apress, 2004.
[23]
D.E. Post and L.G. Votta, Computational science demands a new paradigm, Phys. Today 58(1) (2005), 35-41.
[24]
W.H. Press, S.A. Teukolsky, W.T. Vetterling and B.P. Flannery, Numerical Recipes in Fortran 90. The Art of Parallel Scientific Computing, 2nd edn, Cambridge Univ. Press, 1996.
[25]
W.H. Press, S.A. Teukolsky, W.T. Vetterling and B.P. Flannery, Numerical Recipes. The Art of Scientific Computing, 3rd edn, Cambridge Univ. Press, 2007.
[26]
D. Rouson, J. Xia and X. Xu, Scientific Software Design. The Object-Oriented Way, Cambridge Univ. Press, 2012.
[27]
P.K. Smolarkiewicz, A fully multidimensional positive definite advection transport algorithm with small implicit diffusion, J. Comp. Phys. 54(2) (1984), 325-362.
[28]
P.K. Smolarkiewicz, Multidimensional positive definite advection transport algorithm: an overview, Int. J. Numer. Meth. Fluids 50(10) (2006), 1123-1144.
[29]
R. Stallman et al., GNU General Public License, Free Software Foundation, 2007, available at: http://gnu.org/licenses/gpl, version 3.
[30]
V. Stodden, I. Mitchell and R. LeVeque, Reproducible research for scientific computing: Tools and strategies for changing the culture, Comput. Sci. Eng. 14(4) (2012), 13-17.
[31]
B. Stroustrup, The C++ Programming Language, 4th edn, Addison Wesley, 2013.
[32]
M. Sundberg, The everyday world of simulation modeling: The development of parameterizations in meteorology, Sci. Technol. Hum. Val. 34(2) (2009), 162-181.
[33]
J.P.M. Syvitski, S.D. Peckham, O. David, J.L. Goodall, C. Deluca and G. Theurich, Cyberinfrastructure and community environmental modeling, in: Handbook of Environmental Fluid Dynamics: Systems, Pollution, Modeling, and Measurements, Vol. 2, H.J.S. Fernando, ed., CRC Press/Taylor & Francis Group, Boca Raton, FL, USA, 2013, pp. 399-410.
[34]
T. Veldhuizen and M. Jernigan, Will C++ be faster than Fortran?, in: Scientific Computing in Object-Oriented Parallel Environments, Y. Ishikawa, R. Oldehoeft, J. Reynders and M. Tholburn, eds, Lecture Notes in Computer Science, Vol. 1343, Springer, Berlin/Heidelberg, 1997, pp. 49-56.
[35]
H.G. Weller, G. Tabor, H. Jasak and C. Fureby, A tensorial approach to computational continuum mechanics using object-oriented techniques, Comput. Phys. 12(6) (1998), 620-631.
[36]
G. Wilson, Where's the real bottleneck in scientific computing?, Am. Sci. 94(1) (2006), 5-6.
[37]
G. Wilson, D.A. Aruliah, C. Titus Brown, N.P. Chue Hong, M. Davis, R.T. Guy, S.H.D. Haddock, K. Huff, I.M. Mitchell, M. Plumbley, B. Waugh, E.P. White and P. Wilson, Best practices for scientific computing, PLoS Biol. 12(1) (2014), e1001745.
[38]
D.J. Worth, State of the art in object oriented programming with Fortran, Technical Report RAL-TR-2008-002, Science and Technology Facilities Council, 2008.
[39]
M.Z. Ziemianski, M.J. Kurowski, Z.P. Piotrowski, B. Rosa and O. Fuhrer, Toward very high horizontal resolution NWP over the Alps: Influence of increasing model resolution on the flow pattern, Acta Geophys. 59(6) (2011), 1205-1235.
  1. Formula translation in Blitz++, NumPy and modern Fortran: A case study of the language choice tradeoffs

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Scientific Programming
    Scientific Programming  Volume 22, Issue 3
    July 2014
    69 pages
    ISSN:1058-9244
    EISSN:1875-919X
    Issue’s Table of Contents

    Publisher

    Hindawi Limited

    London, United Kingdom

    Publication History

    Published: 01 July 2014

    Author Tags

    1. Advection Equation
    2. C++
    3. Fortran
    4. Mpdata
    5. Object-Oriented Programming
    6. Python

    Qualifiers

    • Article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 0
      Total Downloads
    • Downloads (Last 12 months)0
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 16 Jan 2025

    Other Metrics

    Citations

    View Options

    View options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media