HELPLIB.HLB  —  FORTRAN  Statements  FUNCTION  RESULT Keyword
  Specifies a name for the result variable of a function.  Its name
  must be different from the name of the function.

  If RESULT is not specified, the function name is the result
  variable.  All references to the function are references to the
  function result variable.

  If RESULT is specified, the result name is the result variable.
  In this case, all references to the function name are recursive
  calls, and the function name must not appear in specification
  statements.

  The following is an example of a recursive function specifying a
  RESULT variable:

    RECURSIVE FUNCTION FACTORIAL(P) RESULT(L)
      INTEGER, INTENT(IN) :: P
      INTEGER L
      IF (P == 1) THEN
        L = 1
      ELSE
        L = P * FACTORIAL(P - 1)
      END IF
    END FUNCTION
Close Help