# Attribute for "pure" procedures that do I/O

**URL:** <https://fortran-lang.discourse.group/t/attribute-for-pure-procedures-that-do-i-o/2694>\
**Category:** Language enhancement\
**Created:** [January 30, 2022, 5:51pm UTC](https://fortran-lang.discourse.group/t/attribute-for-pure-procedures-that-do-i-o/2694 "2022-01-30T17:51:52Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [January 30, 2022, 9:45pm UTC](https://fortran-lang.discourse.group/t/attribute-for-pure-procedures-that-do-i-o/2694/6 "2022-01-30T21:45:09Z")

</div>

Just my 2 cents but I’ve always felt that the concept of purity (or more specifically impurity) should be more fine grain. Yes we can declare a procedure to be IMPURE but what I’m thinking about would be along the lines of two changes to the standard.

1. First, allow for impure blocks (or scoping units) inside a otherwise pure procedure,

ie.  
PURE Function a  
BLOCK,IMPURE or BLOCK(IMPURE) etc  
do some impure io on some variables that are local to the block  
END BLOCK  
End Function a

1. Introduce the concept of PURE io by allowing a file to be declared a “PURE” file which would mean that it is effectively open as WRITE only (and cannot be reopened as READ/WRITE during the course of the execution. You would obvously want to be able to read it later but only after a STOP or ERROR STOP statement has closed the file

Open (newunit=pure\_unit,file=“pure.dat”, ACCESS=PURE, Form=xxx, STATUS=xxx)

I’m sure there are a million reasons why this wouldn’t work and is probably undesirable but I’m just throwing a couple of thoughts out for discussion

---

_[View the full topic](https://fortran-lang.discourse.group/t/attribute-for-pure-procedures-that-do-i-o/2694)._
