Object-Oriented Programming with Fortran
This course provides an introduction to Object-Oriented Programming (OOP) with Fortran. Fortran is often used for scientific applications, but applications are mainly developed using the standard procedural programming techniques that Fortran was initially designed for.
OOP is a programming methodology designed to enable safe and reusable programming, coupling procedures with the data they operate on in classes and using them as objects. More commonly associated with large programs, and programs written in industry/companies, there are many scientific applications that become very large and long-lived and therefore could benefit from such programming techniques to make development, maintenance, and extension of the code simpler and safer.
Whilst Fortran is generally viewed as a procedural programming language there are features in the most recent versions of the Fortran standards (90, 95, and 2003) that enable development in OOP or OOP-like ways. We will introduce these language features and discuss/explore how they can be used in scientific applications.
Familiarity with a Unix or Linux environment is assumed, and some experience with Fortran is advisable for getting the most out of the course material.
Trainer
Adrian Jackson
Adrian Jackson is a Research Architect at EPCC, where he works on a range of different research, from investigating new memory hardware and programming models, to optimising and porting parallel codes, and working with application scientists to enable their computational simulation or data analysis. He also teaches on EPCC's MSc in HPC, giving lectures on Programming Skills, HPC Architecture, and Performance Programming.
Details
Topics include: object-oriented programming, fortran modules, datatypes, polymorphic variables and procedures, constructors and destructors, and inheritance.
Intended learning outcomes
On completion of this course students should be able to:
- Develop modularised Fortran programs.
- Define new datatypes and operators in Fortran.
- Understand basic OO concepts and strategies.
- Develop OO programs in Fortran.
- Compile and run Fortran programs on ARCHER.
- Understand basic design trade-offs for OOP in Fortran.
Prerequisites
Whilst there are no prerequisites for this course, a familiarity with a Unix or Linux environment is assumed and to fully benefit from the course some familiarity with Fortran programming would be beneficial.
Timetable
Details are subject to change, but start, end and break times will stay the same.
Day 1
- 09:30 Introduction to Fortran
- 10:15 PRACTICAL: Fortran programming
- 11:00 BREAK
- 11:30 Introduction to Object Oriented Programming
- 12:00 PRACTICAL: Designing an object oriented program
- 12:15 Modules
- 13:00 BREAK: Lunch
- 14:00 PRACTICAL: Modules
- 14:30 Derived types and operators
- 15.00 PRACTICAL: Derived types
- 15:30 BREAK
- 16:00 PRACTICAL: Continuing practicals
- 16:30 CLOSE
Day 2
- 09:30 Classes and data visibility
- 10:15 PRACTICAL: Fortran classes
- 11:15 BREAK
- 11:45 Inheritance and overloading
- 12.30 PRACTICAL: Generic classes and extensions
- 13.00 BREAK: Lunch
- 14.00 Design and performance considerations
- 14.45 PRACTICAL: Continuing practicals
- 15:15 BREAK
- 15:45 Further features
- 16:15 Summary
- 16:30 CLOSE
Course Materials
Slides and exercise material for this course are available here.