News and Blog

EPSRC CDT in Next Generation Computational Modelling

Fortran Modernization Workshop

Modern Fortran at the University of Southampton.

Dr Wadud Miah introducing modern Fortran features.

The University of Southampton hosted a two day Fortran modernization workshop organized by Dr Wadud Miah (Numerical Algorithms Group), and Dr Nico De Tullio (University of Southampton). Centred around software engineering for computational sciences, the workshop gave participants hands on experience in modern Fortran programming and introduced them to commonly used tools and software packages.

Computational science work flow.

Work flow for computational science. Image source.

Wadud led the workshop, and began day one by stressing the importance of good software engineering practices for science and engineering, which are often neglected in academic code development. Scientific teams need to be able to track and organize work between multiple users, check for correctness with systematic testing procedures, and write code that is both scalable and capable of reproducible results. Software engineering can aid developers with these requirements, and help improve the efficiency of the computational science work flow.

Dr Fatima Chami (Durham University) introduced the NAG Fortran compiler, outlined the history of the Fortran programming language and highlighted important revisions to the standard, before an overview of obsolete and discarded features and their replacements was given by Dr Kyle Fernandes (University of Cambridge).

The image below illustrates the dominance of Fortran in scientific computing, which despite its age is still a primary choice for numerical codes. This is largely due to its excellent performance, natural array handling ability, and extensive numerical libraries. Many of the codes however are written in legacy Fortran, and do not use the modern features which compilers are able to take advantage of; motivating the need for workshops such as this.

Programming languages in HPC.

Workshop slide on programming language usage on the UK HPC facility ARCHER.

Fatima started the afternoon session with a detailed look at these modern Fortran additions, such as derived data types, submodules, and pure and elemental subroutines. Automation of the build process with make was covered, before an introduction to the documentation tool Doxygen. The remainder of the afternoon was devoted to the practical exercises, where participants were required to update a Fortran77 code for solving the 1D heat equation to modern standards. Step by step instructions were provided to assist with this task, giving participants valuable insight into the modernization process.

Advances in computational capability have led to ever larger and more sophisticated numerical simulations, creating the need for efficient data management strategies. Popular choices are the self-describing file formats NetCDF, and HDF5, which were introduced by Fatima in the morning session of day two. In each case example Fortran code was provided to show how these tools are used in practice.

Verification of both the correctness of a code and the accuracy of results is vital in scientific research, and robust testing procedures are needed to achieve this aim. Wadud described possible sources of numerical error, and discussed multi-level approaches ranging from individual unit tests to system wide integration and regression testing. Notable inclusions were the Fortran specific unit testing system pFUnit, and the role that integrated development environments (IDEs) can play.

Following on with a similar topic was Dr Dominic Orchard (University of Cambridge), a developer of the open-source CamFort tool, used for verifying scientific codes in Fortran. Among its features, CamFort includes the addition of physical units to Fortran variables to avoid errors from incorrect unit conversions, and systems to verify the correctness of numerical differencing stencils.

Parallel Fortran programming.

Dr Kyle Fernandes comparing parallel programming options in Fortran.

The afternoon session was led by Kyle who covered the variety of parallel programming implementations that are available to Fortran. Kyle presented example code for the well known shared memory system OpenMP, and distributed memory system MPI. This was followed by a demonstration of Fortran Coarrays, which were introduced in the Fortran 2008 standard as a Fortran specific alternative to MPI. Additional topics included Fortran programming on GPUs with CUDA, and OpenACC.

Approaching the end of day two, the final guest speaker was Dr Patrick Wohlschlegel (Allinea), demonstrating the software development suite Allinea Forge, and its debugging tool Allinea DDT. Patrick gave an impressive demonstration of how Allinea DDT can be used to debug a parallel MPI code, gave tips on vectorizing loops, and how to generate performance profiles for Fortran code. Finishing up the taught section was Wadud with a brief discussion of interoperability of Fortran with other programming languages, version control and continuous integration.

Having updated and modularized the legacy code from day one, day two exercises allowed participants to gain experience using the third party tools mentioned above. This involved the generation of makefiles for the build process and documentation in Doxygen, with version control software Git used throughout. The last set of exercises covered NetCDF, pFUnit, and the in-memory visualization package PLplot.

Overall I enjoyed the experience, and I would recommend it to anyone interested in scientific computing and software engineering. Throughout the workshop there were interesting contributions from the audience, and good levels of attendance were seen. Thank you to everyone involved in delivering this free event, further information and future dates for this workshop can be found on the Numerical Algorithms Group website.