Procedures and modules

Subroutines and functions, the INTENT of a dummy argument, optional and keyword arguments, and the PURE and ELEMENTAL procedures a compiler can inline. Explicit interfaces and generic interfaces follow, then operator overloading, which makes a derived type behave like a number. The part ends on the module: what USE brings in, what a SUBMODULE keeps out of the interface, and how a procedure is passed as an argument.

059 Subroutines and functions SUBROUTINE and FUNCTION, CALL, the result variable, RETURN and a result that is a value Open 060 INTENT and the dummy argument rules INTENT(IN), INTENT(OUT), INTENT(INOUT), what each promises, and the error the compiler gives Open 061 OPTIONAL arguments and PRESENT an OPTIONAL dummy, PRESENT, a default when it is absent, and a call with keywords Open 062 Keyword arguments the dummy name in a call, the order that then does not matter, and a call that mixes both Open 063 PURE, ELEMENTAL and side effects a PURE function and what it may not do, ELEMENTAL over an array, and the automatic interface Open 064 Recursion a recursive FUNCTION, the RESULT clause, a base case, and the depth a stack allows Open 065 Interfaces and explicit interfaces an INTERFACE block, why a module gives it for free, EXTERNAL and the mismatch it hides Open 066 Generic interfaces INTERFACE with a generic name, several specific procedures, and a call resolved by the argument type Open 067 Operator overloading and ASSIGNMENT(=) INTERFACE OPERATOR(+), INTERFACE ASSIGNMENT(=), and a vector type with arithmetic Open 068 Modules, USE and ONLY MODULE, CONTAINS, USE and USE ... ONLY, renaming, and the .mod file gfortran writes Open 069 Submodules a module interface with a MODULE PROCEDURE, a SUBMODULE that implements it, and the build order Open 070 Procedures as arguments and procedure pointers a dummy procedure, an INTERFACE for it, a PROCEDURE POINTER and a table of functions Open

Lessons