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. The course is open to all, but is mainly targeted at existing ARCHER users.
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.
Location
The course will take place in Library at the Culham Centre for Fusion Energy, Abingdon, Oxon, OX14 3DB.
Registration
Please use the registration page to register for ARCHER courses.
Questions?
If you have any questions please contact the ARCHER Helpdesk.