`Consider the following function
`

my_exp(x, tol, n_max)

`When we call the function
we have to specify the argument and the desired tolerance,
and the maximal order, for example
`

Y = my_exp(x, 1.E-6, 10)

`We can do this in F90 by specifying the tol
and n_max as optional arguments.
`

real function my_exp(x, tol, n_max) implicit none real, intent(in) :: x real, intent(in), optional :: tol real :: err_max integer, intent(in), optional :: n_max integer :: order_max ... if( present(tol) ) then err_max = tol else err_max = 1.e-6 end if if( present(n_max) ) then order_max = n_max else order_max = 10 end if ... end function my_exp

`The OPTIONAL parameter
allow tol and n_max to be omitted
when the function is called. For example,
`

y = my_exp(x)

`In the function body, the intrinsic function PRESENT(tol) returns
.TRUE. if the current function call explicitly
had tol as argument, and .FALSE. if
tol was omitted. This distinction allows us
to know when the optional arguments are not present and
replace them by their default values.
`

`Note that, when an optional argument is missing, the space on the
stack associated with it is not allocated; in consequence
missing optional arguments ``do not exist''
in the function body and we cannot read and write them
(we can only test their existence with PRESENT()).
For example the statement
`

{l} if( .not.present(tol))~ tol=1.e-6

`Finally, let us mention that only some of the optional arguments might be
missing. For example
`

y = my_exp(x, 1.e-8)

y = my_exp(x,12)

y = my_exp(x,n_max=12)

`Some built in functions ( OPEN, READ, WRITE) have
optional arguments and keywords - remember?
`