THEN ! test for presence of actual argument : allows us to call mincon by CALL mincon (n, f, x, upper) Arguments may be keyword rather than positional (which come first): CALL mincon(n, f, x, equalities=0, xstart=x0) Optional and keyword arguments are handled by explicit interfaces, that is with internal or module procedures or with interface blocks. Interface blocks Any reference to an internal or module subprogram is through an interface that is 'explicit' (that is, the compiler can see all the details). A reference to an external (or dummy) procedure is usually 'implicit' (the compiler assumes the details). However, we can provide an explicit interface in this case too. It is a copy of the header, specifications and END statement of the procedure concerned, either placed in a module or inserted directly: REAL FUNCTION minimum(a, b, func) ! returns the minimum value of the function func(x) ! in the interval (a,b) REAL, INTENT(in) :: a, b INTERFACE REAL FUNCTION func(x) REAL, INTENT(IN) :: x END FUNCTION func END INTERFACE REAL f,x : f = func(x) ! invocation of the user function. : END FUNCTION minimum An explicit interface is obligatory for optional and keyword arguments; POINTER and TARGET arguments (see Pointers); POINTER function result; new-style array arguments and array functions (Array handling). It allows full checks at compile time between actual and dummy arguments. In general, the best way to ensure that a procedure interface is explicit is either to place the procedure concerned in a module or to use it as an internal procedure. Overloading and generic interfaces Interface blocks provide the mechanism by which we are able to define generic names for specific procedures: INTERFACE gamma ! generic name FUNCTION sgamma(X) ! specific name REAL (SELECTED_REAL_KIND( 6)) sgamma, x END FUNCTION dgamma(X) ! specific name REAL (SELECTED_REAL_KIND(12)) dgamma, x END END INTERFACE where a given set of specific names corresponding to a generic name must all be of functions or all of subroutines. If this interface is within a module, then it is simply INTERFACE gamma MODULE PROCEDURE sgamma, dgamma END INTERFACE We can use existing names, e.g. SIN, and the compiler sorts out the correct association. We have already seen the use of interface blocks for defined operators and assignment (see Modules). Recursion Indirect recursion is useful for multi-dimensional integration. For volume = integrate(fy, ybounds) We might have RECURSIVE FUNCTION integrate(f, bounds) ! Integrate f(x) from