Sun Studio 12: Fortran Programming Guide

10.5 Debugging Parallelized Programs

Fortran source code:


    real x / 1.0 /, y / 0.0 /
    print *, x/y
    end
    character  string*5, out*20
    double precision value
    external exception_handler
    i = ieee_handler(’set’, ’all’, exception_handler)
    string = ’1e310’
    print *, ’Input string ’, string, ’ becomes: ’, value
    print *, ’Value of 1e300 * 1e10 is:’, 1e300 * 1e10
    i = ieee_flags(’clear’, ’exception’, ’all’, out)
    end

    integer function exception_handler(sig, code, sigcontext)
    integer sig, code, sigcontext(5)
    print *, ’*** IEEE exception raised!’
    return
    end

Runtime output:


*** IEEE exception raised!
 Input string 1e310 becomes:  Infinity
 Value of 1e300 * 1e10 is: Inf
 Note: Following IEEE floating-point traps enabled;
   see ieee_handler(3M):
 Inexact;  Underflow;  Overflow;  Division by Zero;  Invalid
   Operand;
 Sun’s implementation of IEEE arithmetic is discussed in
  the Numerical Computation Guide.
Debugging Parallelized Programs

Debugging parallelized programs requires some extra effort. The following schemes suggest ways to approach this task.

10.5.1 First Steps at Debugging

There are some steps you can try immediately to determine the cause of errors.

Replace:


    DO I=1,N
      ...
      CALL SNUBBER(I)
      ...
    ENDDO

With:


      DO I1=1,N
      I=I1
      ...
      CALL SNUBBER(I)
      ...
    ENDDO