c ieeestuff.f
c
c GNU g77 doesn't provide r_max_normal and friends to determine whether
c a value is noninfinite and NaN.  This is IEEE 754 stuff.  Instead, 
c I go straight to the IEEE754 definitions for infinity for 32-bit and
c 64-bit values.   Hard coding sucks, but we do need to make sure that 
c values are sane.  This should be conservative.  -CAK, 2003 Aug 19
c


      double precision function d_max_normal()
      d_max_normal = 1.7976E+308
      return 
      end

      real function r_max_normal()
      r_max_normal = 3.4028E+38
      return
      end

      double precision function d_min_normal()
      d_min_normal = -1.7976E+308
      return 
      end

      real function r_min_normal()
      r_min_normal = -1.1754E-38
      return
      end

c-----------------------------
c
      real function rinfinity()
c
      rinfinity = 3.4028235677973365E+38
      return
      end
c
c-----------------------------
c
      double precision function dinfinity()
c
      dinfinity = 1.7976931348623158E+308
      return
      end
c
c-----------------------------
c
      logical function okreal8(value)
c
c     Checks that VALUE is not +/- infinity and NaN.
c
      double precision value
c
      if(abs(value) .le. 1.7976E+308) then
	okreal8 = .true.
      else
	okreal8 = .false.
      endif
c
      return
      end
c
c-----------------------------
c
      logical function okreal4(value)
c
c     Checks that VALUE is not +/- infinity and NaN.
c
      real value
c
      if(abs(value) .le. 3.4028E+38) then
	okreal4 = .true.
      else
	okreal4 = .false.
      endif
c
      return
      end
c

      double precision function dmaxnormal()

      double precision d_max_normal
      dmaxnormal = d_max_normal()
      return
      end
c
c-----------------------------
c
      double precision function dminnormal()
      double precision d_min_normal
      dminnormal = d_min_normal()
      return
      end
c
c-----------------------------
c
      real function rmaxnormal()
      real r_max_normal
      rmaxnormal = r_max_normal()
      return
      end
c
c-----------------------------
c
      real function rminnormal()
      real r_min_normal
      rminnormal = r_min_normal()
      return
      end
c
c      
c-----------------------------
c
      real function r_quiet_nan()
      real r_max_normal
      r_quiet_nan = r_max_normal()
      return
      end
c 
c-----------------------------
c
      double precision function d_quiet_nan()
      double precision d_max_normal
      d_quiet_nan = d_max_normal()
      return
      end
c     

c--------------------------------------------------------------
 
