Consider the following function
|
The a "normal" call to this might be:
|
Assume that for most calls to find_y we can assume some default value for cin, say zero. It might be useful to call find_y without specifing cin. For example:
|
With optional arguments in Fortran 90, this is legal.
The function shown above would need to be modified slightly.
|
Note we have declared cin as optional. The intrinsic function "present" allows the procedure to determine the presence of an optional argument in the invocation argument list. If cin is present then c is assigned the value of cin, else c gets assigned a default value.
We can declare other parameters as optional.
|
One other feature available is that we can specify the names of the parameters in the function call.
|
When this is done, the order is not significant. We could say
|
One place where specifing the names of the parameters is required is if you leave out parameters in the middle of the argument list.
|
Where bin was not specified.