Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28383 Discussions

pure requirement for contained procedures of a PURE procedure

Ron_Green
Moderator
176 Views

A question for a customer for which I don't have a good answer.  This is one for Doctor Fortran

The question posed: "Why is it that contained functions in pure routines need to be pure? If they capture state from the parent, and only use that state, the expectations of the caller can still be met.  It seems to me there should be several weaker forms of pure, for example, just that the contained function references no global variables through USE statements."

0 Kudos
1 Reply
Steven_L_Intel1
Employee
176 Views

The basic restriction is that a PURE procedure can call only other PURE procedures. There's really no distinction between a contained procedure and an external one here. This requirement helps enforce the PURE requirements of the outer procedure.

I suppose I'd have to ask what it is that needs to be done in a non-PURE internal procedure that is called from a PURE procedure?

I'll also comment that Fortran 2008 offers IMPURE ELEMENTAL if that's what you want, and that's now supported by Intel Fortran. (ELEMENTAL procedures are PURE otherwise.)

0 Kudos
Reply