Using Print Statements to Debug

I have found it convenient to create a handy utility routine that prints out a character string and some data. It needs to be EXTRINSIC, in order to get per-node printouts. Having environment variables such as MP_LABELIO is handy, if it will cause the operating system to attach node numbers to lines of output.

Since all parameters are intent(in) this can be declared as a PURE extrinsic and invoked from within a parallel loop. Here is an example that prints out elapsed time for a loop on a given processor, but it could be modified to print out other data as well.

        SUBROUTINE sayit (t1,t2,message)
        real*8:: t1,t2,t3
        character*(*)::message
        t3=t2-t1
        write (*,890) t3,message
890     format(f10.2,' Seconds wallclock ', a)
        return
        end

This gets compiled with your serial Fortran compiler.
(back to main talk)