Printing selected values from an array is often required during debugging (selection criteria are hard to impose in debuggers). But, printing inside PURE procedures is restricted. Being an avid user of small PURE functions and do concurrent, in other words functional style, I have to modify the code unnecessarily just for debugging. Moreover, this leads to a cascade of changes as PURE procedures can only call PURE procedures, and thus I need to modify every other PURE procedure that calls the one under consideration.
There are three ways out that I can think of:
-
Use preprocessor to change from PURE to non PURE procedures, from DO CONCURRENT to simple DO in debugging mode. But, this will be non standard.
-
Use error stop cleverly. It cannot cover all use cases, however.
-
Carry around an extra argument for storing the desired value(s) and print it after you have exited all pure procedures. This will only work for pure subroutines.
Which way, from or other than those listed, is better?