Sun Studio 12:Fortran 编程指南

10.5 调试并行化的程序

Fortran 源代码:


    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

运行时输出:


*** 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

调试已并行化的程序需要做一些额外工作。下列方案提出了处理该任务的方法。

10.5.1 调试时的首要步骤

有一些步骤可以直接进行尝试以确定错误原因。

替换:


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

使用:


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