The OPEN statement allows the ACTION specifier which can be READ, WRITE, OR READWRITE, analogous to INTENT(IN), INTENT(OUT), and INTENT(INOUT) respectively. The programmer knows how an opened file is to be used, and using a file connection in a way contrary to the ACTION will produce a runtime error. Adding a check that each OPEN includes an ACTION could therefore help reveal bugs where a file that is intended to be read-only is written to. This would improve code correctness and security.
It would be even better not to rely on the runtime error, and instead check that no WRITE statement is applied to a unit opened as ACTION='READ' and vice versa.
The
OPENstatement allows theACTIONspecifier which can beREAD,WRITE, ORREADWRITE, analogous toINTENT(IN),INTENT(OUT), andINTENT(INOUT)respectively. The programmer knows how an opened file is to be used, and using a file connection in a way contrary to theACTIONwill produce a runtime error. Adding a check that eachOPENincludes anACTIONcould therefore help reveal bugs where a file that is intended to be read-only is written to. This would improve code correctness and security.It would be even better not to rely on the runtime error, and instead check that no
WRITEstatement is applied to a unit opened asACTION='READ'and vice versa.