home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 30 fixes_v / 30-fixes_v.zip / c32_b.zip / GD44.B < prev    next >
Text File  |  1994-01-11  |  5KB  |  154 lines

  1. !
  2. ! _MATHERR.FOR    : math error handler
  3. !
  4.  
  5. c$pragma aux __imath2err "*_" parm( value, reference, reference )
  6. c$pragma aux __amath1err "*_" parm( value, reference )
  7. c$pragma aux __amath2err "*_" parm( value, reference, reference )
  8. c$pragma aux __math1err "*_" parm( value, reference )
  9. c$pragma aux __math2err "*_" parm( value, reference, reference )
  10. c$pragma aux __zmath2err "*_" parm( value, reference, reference )
  11. c$pragma aux __qmath2err "*_" parm( value, reference, reference )
  12.  
  13.  
  14.     integer function __imath2err( err_info, arg1, arg2 )
  15.     integer err_info
  16.     integer arg1, arg2
  17.     include 'mathcode.fi'
  18.     arg1 = arg1    ! to avoid unreferenced warning message
  19.     arg2 = arg2    ! to avoid unreferenced warning message
  20.     if( ( err_info .and. M_DOMAIN ) .ne. 0 )then
  21.         select( err_info .and. FUNC_MASK )
  22.         case( FUNC_POW )
  23.         print *, 'arg2 cannot be <= 0'
  24.         case( FUNC_MOD )
  25.         print *, 'arg2 cannot be 0'
  26.         end select
  27.     end if
  28.     __imath2err = 0
  29.     end
  30.  
  31.  
  32.     real function __amath1err( err_info, arg1 )
  33.     integer err_info
  34.     real arg1
  35.     include 'mathcode.fi'
  36.     arg1 = arg1    ! to avoid unreferenced warning message
  37.     if( ( err_info .and. M_DOMAIN ) .ne. 0 )then
  38.         select( err_info .and. FUNC_MASK )
  39.         case( FUNC_COTAN )
  40.         print *, 'overflow'
  41.         end select
  42.     end if
  43.     __amath1err = 0.0
  44.     end
  45.  
  46.  
  47.     real function __amath2err( err_info, arg1, arg2 )
  48.     integer err_info
  49.     real arg1, arg2
  50.     include 'mathcode.fi'
  51.     arg1 = arg1    ! to avoid unreferenced warning message
  52.     arg2 = arg2    ! to avoid unreferenced warning message
  53.     if( ( err_info .and. M_DOMAIN ) .ne. 0 )then
  54.         select( err_info .and. FUNC_MASK )
  55.         case( FUNC_MOD )
  56.         print *, 'arg2 cannot be 0'
  57.         end select
  58.     end if
  59.     __amath2err = 0.0
  60.     end
  61.  
  62.  
  63.     double precision function __math1err( err_info, arg1 )
  64.     integer err_info
  65.     double precision arg1, __math2err
  66.     __math1err = __math2err( err_info, arg1, arg1 )
  67.     end
  68.  
  69.  
  70.     double precision function __math2err( err_info, arg1, arg2 )
  71.     integer err_info
  72.     double precision arg1, arg2
  73.     include 'mathcode.fi'
  74.     arg1 = arg1    ! to avoid unreferenced warning message
  75.     arg2 = arg2    ! to avoid unreferenced warning message
  76.     if( ( err_info .and. M_DOMAIN ) .ne. 0 )then
  77.         select( err_info .and. FUNC_MASK )
  78.         case( FUNC_SQRT )
  79.         print *, 'argument cannot be negative'
  80.         case( FUNC_ASIN, FUNC_ACOS )
  81.         print *, 'argument must be less than or equal to one'
  82.         case( FUNC_ATAN2 )
  83.         print *, 'both arguments must not be zero'
  84.         case( FUNC_POW )
  85.         if( arg1 .eq. 0.0 )then
  86.             print *, 'a zero base cannot be raised to a ',
  87.      +                'negative power'
  88.         else ! base < 0 and non-integer power
  89.             print *, 'a negative base cannot be raised to a ',
  90.      +                'non-integral power'
  91.         endif
  92.         case( FUNC_LOG, FUNC_LOG10 )
  93.         print *, 'argument must not be negative'
  94.         end select
  95.     else if( ( err_info .and. M_SING ) .ne. 0 )then
  96.         if( ( ( err_info .and. FUNC_MASK ) .eq. FUNC_LOG ) .or.
  97.      &        ( ( err_info .and. FUNC_MASK ) .eq. FUNC_LOG10 ) )then
  98.         print *, 'argument must not be zero'
  99.         endif
  100.     else if( ( err_info .and. M_OVERFLOW ) .ne. 0 )then
  101.         print *, 'value of argument will cause overflow condition'
  102.     else if( ( err_info .and. M_UNDERFLOW ) .ne. 0 )then
  103.         print *, 'value of argument will cause underflow ',
  104.      +              'condition - return zero'
  105.     end if
  106.     __math2err = 0
  107.     end
  108.  
  109.  
  110.     complex function __zmath2err( err_info, arg1, arg2 )
  111.     integer err_info
  112.     complex arg1, arg2
  113.     include 'mathcode.fi'
  114.     arg1 = arg1    ! to avoid unreferenced warning message
  115.     arg2 = arg2    ! to avoid unreferenced warning message
  116.     if( ( err_info .and. M_DOMAIN ) .ne. 0 )then
  117.         select( err_info .and. FUNC_MASK )
  118.         case( FUNC_POW )
  119.         ! arg1 is (0,0)
  120.         if( imag( arg2 ) .ne. 0 )then
  121.             print *, 'a zero base cannot be raised to a',
  122.      +            ' complex power with non-zero imaginary part'
  123.         else
  124.             print *, 'a zero base cannot be raised to a',
  125.      +            ' complex power with non-positive real part'
  126.         endif
  127.         end select
  128.     end if
  129.     __zmath2err = (0,0)
  130.     end
  131.  
  132.  
  133.     double complex function __qmath2err( err_info, arg1, arg2 )
  134.     integer err_info
  135.     double complex arg1, arg2
  136.     include 'mathcode.fi'
  137.     arg1 = arg1    ! to avoid unreferenced warning message
  138.     arg2 = arg2    ! to avoid unreferenced warning message
  139.     if( ( err_info .and. M_DOMAIN ) .ne. 0 )then
  140.         select( err_info .and. FUNC_MASK )
  141.         case( FUNC_POW )
  142.         ! arg1 is (0,0)
  143.         if( imag( arg2 ) .ne. 0 )then
  144.             print *, 'a zero base cannot be raised to a',
  145.      +             ' complex power with non-zero imaginary part'
  146.         else
  147.             print *, 'a zero base cannot be raised to a',
  148.      +              ' complex power with non-positive real part'
  149.         endif
  150.         end select
  151.     end if
  152.     __qmath2err = (0,0)
  153.     end
  154.