Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Moderator
2 Views

pure requirement for contained procedures of a PURE procedure

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
Highlighted
2 Views

The basic restriction is that

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.)

Retired 12/31/2016
0 Kudos