Designing Functions

Syntax

In addition to intrinsic functions, Fortran allows you to design your own functions. A Fortran function, or more precisely, a Fortran function subprogram, has the following syntax:
type FUNCTION  function-name (arg1, arg2, ..., argn)
   IMPLICIT  NONE
   [specification part]
   [execution part]
   [subprogram part]
END FUNCTION  function-name

Here are some elaborations of the above syntax:

If a function does not need any formal argument, it can be written as
type FUNCTION  function-name ()
   IMPLICIT  NONE
   [specification part]
   [execution part]
   [subprogram part]
END FUNCTION  function-name
where arg1, arg2, ..., argn are left out. But, the pait of parenthesis must be there.

Semantics

The meaning of a function is very simple: