Monday, 11 January 2016
Hall E ( New Orleans Ernest N. Morial Convention Center)
Many computer programs for the computation of important quantities in atmospheric science were previously written in compiled languages such as FORTRAN as it offered greater mathematical performance as well as improved array functionality versus C and other compiled languages. As time has progressed, Python has gained greater acceptance due to the expansive portable open source libraries of scientific tools available via the internet allowing for faster prototyping of new ideas without the need to recompile each time. However, many software libraries specific to the atmospheric science community are still only available as the older FORTRAN code. Previously, when compiled languages were the only options, this would mean one would need to rewrite the original tool from FORTRAN to the target language. But in this work, we show that a complete rewrite is unnecessary while preserving the speed of FORTRAN and expanding the original source codes' capabilities through parallelization with MPI. F2PY is a free, open source utility that allows a programmer to take the original FORTRAN source code and wrap it using a Python interface so that no code rewriting is necessary. This utility takes any function or subroutine capable of standing alone and turns it into a pre-compiled shared library file which is accessed with an interface that specifies the necessary input and outputs to the program. Once the shared library and interface have been created with the F2PY utility, using the newly created object is as simple as importing it like any other Python module. A practical example of using this wrapping process is shown using a FORTRAN subroutine from the CM1 model created by George Bryan of the National Center for Atmospheric Research. The subroutine calculates Convectively Available Potential Energy (CAPE), Convective Inhibition (CIN), as well as the heights of the Lifted Condensation Level (LCL) and Level of Free Convection (LFC). While the source code was designed for use with the CM1 model, in this example it is shown how the wrapping allows us to apply it to output from the WRF model without any alterations to the underlying FORTRAN source. Once the FORTRAN subroutine has been wrapped for use with Python, it can been treated like any other Python function. Because of this, the capabilities of the original source can be extended using additional Python libraries such as MPI4PY. The MPI4PY library is an interface that also uses Python wrapping capabilities to create an interface to the installed MPI version. With this, a Python script is demonstrated that shows that the original serial FORTRAN code can now be run in parallel over large, high-resolution domains with better performance than the originally wrapped serial implementation.
- Indicates paper has been withdrawn from meeting
- Indicates an Award Winner