next up previous contents
Next: Internal Procedures Up: More on Procedures Previous: Argument Intent   Contents

Pure Functions

A pure function is free of side effects. A function is pure if all of the following three requirements are fullfilled:

We can declare a function to be pure, and the compiler will check the above conditions. Example:
pure real function norm_2(x, y, z)
implicit none
  real, intent(in) :: x,y,z
  norm2 = sqrt(x*x+y*y+z*z)
end function norm_2

Adrian Sandu 2001-08-26