Next: Pure Functions
Up: More on Procedures
Previous: Side Effects
  Contents
In order to increase robustness to side-effects, and to
facilitate efficient compilation, dummy arguments
in the procedure declaration can be
tagged with an intent attribute:
- INTENT(IN) Input only arguments; they cannot be written
inside the procedure (or the compiler will complain);
- INTENT(OUT) Output only arguments; they cannot
be read until they are written inside the procedure
(assume they come in with garbage); also, if they are not
assigned at all in the procedure body, a compilation error will
result;
- INTENT(INOUT) Both input and output; assumed to
hold valid data at entry, but this value can be modified
by the procedure and passed back to the calling program.
For example, in our norm2s subroutine we may declare
real, intent(in) :: x,y,z
real, intent(out) :: r
Also, the norm2 function declarations may be
real, intent(in) :: x,y,z
Adrian Sandu
2001-08-26