3 !Pure procedures are procedures declared with the PURE keyword and which
4 !satisfy certain constraints that ensure they have no side
5 !effects. They can be used in specification expressions and
6 !within FORALL constructs and statements.
8 !Elemental procedures can be written in Fortran 95 using the ELEMENTAL
9 !keyword. Elemental procedures are automatically ``pure''.
13 PURE
REAL FUNCTION pure_func(x
,y
) ! pure okay
15 REAL, INTENT(IN
) :: x
, y
16 pure_func
= x
*x
+ y
*y
+ 2*x
*y
+ ASIN(MIN(x
/y
,y
/x
))
17 END FUNCTION pure_func
19 PURE
REAL FUNCTION F(x
,y
) ! pure broken returns 'PURE REAL FU'
21 REAL, INTENT(IN
) :: x
, y
22 F
= x
*x
+ y
*y
+ 2*x
*y
+ ASIN(MIN(x
/y
,y
/x
))
26 ELEMENTAL
REAL FUNCTION elem_maxabs(a
,b
) ! elemental broke
28 REAL,INTENT(IN
) :: a
,b
29 elem_maxabs
= MAX(ABS(a
),ABS(b
))
32 PURE
REAL FUNCTION pure_maxabs2(a
,b
) ! pure okay
34 REAL,INTENT(IN
) :: a
,b
35 pure_maxabs2
= MAX(ABS(a
),ABS(b
))