Key Points
Connecting to ARCHER2 and transferring data
- We should all understand and follow the ARCHER2 Code of Conduct to ensure this course is conducted in the best teaching environment.
- ARCHER2’s login address is
login.archer2.ac.uk. - You have to change the default text password the first time you log in
- MFA is mandatory in ARCHER2
Arrays
- Fortran supports both static- and dynamic-sized arrays
- Fortran arrays are objects, allowing out of bounds accesses to be checked
- The bounds of an array can be set by the programmer
Break
Arrays as arguments
- Arrays passed as arguments retain their size, not their bounds
- Array arguments behave as though passed by reference, however array sections may require copy-in, copy-out
More on pointers
- Fortran pointers describe what they are pointing to, not only its address.
- We must take care when programming with pointers to avoid aliasing.
- Procedure pointers create a binding between a variable and a procedure.
Lunch
Derived types
- Derived types enable creating custom data structures in Fortran.
- Access to components of derived types can be controlled via the
privateattribute.
Interfaces and overloading
- Interfaces allow us to write generic, high-level code.
- Designing a generic interface requires care, particularly for generic operators.
Break
Type extension and polymorphism
- Fortran supports polymorphism through the
classpointers and allocatable objects. - Types can be selected dynamically to support type-specific behaviours
Type-bound procedures
- Type-bound procedures allow Fortran objects to implement behaviour
- Redefining type-bound procedures allows behaviour to be specialised
- Types can prevent extended types from redefining type-bound procedures
- Generic type-bound procedures enable generic methods on types
Generic input/output for derived types
- Defined types can control how they are printed using type-bound procedures
Abstract types
- Abstract types allow Fortran programs to specify and use interfaces that are then provided by concrete implementations.
Break
Modules again
- Submodules provide the mechanism to separate interface and implementation in Fortran
Unlimited polymorphic entities
- Unlimited polymorphic entities provide a
void *-like type in Fortran - Without determining the unlimite polymorphic entity’s dynamic type, it cannot be used
Lunch
Type parameters
- The
kindof a user-defined type must be known at compile time (as for intrinsic types)
Intrinsic modules
- The
iso_fortran_envintrinsic module provides constants and functions that enable code portability - The IEEE intrinsic modules allow programs to check the conformance with IEEE features
Break
Interoperability with C
- The
iso_c_bindingmodule allows a programmer to write Fortran that is interoperable with C. - Care must be taken with pointers and arrays, and with variables which are to be passed to C by value.