------- Comment #2 from ray at ultramarine dot com  2007-02-27 18:00 -------
Subject: Re:  Program "Hangs"


On Tue, 27 Feb 2007, burnus at gcc dot gnu dot org wrote:

> 
> 
> ------- Comment #1 from burnus at gcc dot gnu dot org  2007-02-27 17:07 
> -------
> Could you post an example?
> 
> pow_r4_i4 means that you have x**a = <real(4)>**<integer(4)>
> 
> I don't see how the exponent "a" can be infinity if it is an integer(4).
> 
      subroutine num_normalize(sigfig,number,   n_normal,exponent)
c
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c
c     ---------------     num_normalize     ---------------
c
c                                             Copyright Ultramarine,inc.
c                                             August 1997
c
c.D
c.D NAME=num_normalize
c.D      Routine to crack NUMBER to characters in ARRAY
c.D OUTPUT
c.D      ARRAY               = Character array of NUMBER
c.D      NPLACE              = Integer*4 Number of Characters used
c.D                            if NPLACE < 0 then could not convert
c.D
c
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
c
c
c
c*********************************************      no implicit
c
      implicit none
c
c*********************************************      externals
c
c
c*********************************************      global variables
c
      include '$(where)/amos/include/essential.ecm'
c
c*********************************************      local variables
c
      TYPE_INTEGER exponent,sigfig,pow
      TYPE_REAL number,temp,n_normal,eps
      parameter (eps = 1e-6)
c
c*********************************************      initialize
c
      temp     = abs(number)
      if( temp .lt. r_tiny_n) then
         exponent = 0.
         n_normal = 0.
      else
         exponent = log10(temp)
c hangs after here.
         temp     = temp / (10.**exponent)
         pow      = max(sigfig,(exponent+1))
         n_normal = temp + 5./10.**pow
      endif
c
c*********************************************      fix?
c
      if ( n_normal .ge. 10.-eps .and. n_normal .le. 10+eps ) then
         exponent = 0
         n_normal = 10 - eps
      elseif( n_normal .ge. 10. ) then
         exponent = exponent + 1
         temp     = temp * .1
         pow      = max(sigfig,(exponent+1))
         n_normal = temp + 5./10.**pow
      elseif( n_normal.lt. 1.) then
         exponent = exponent - 1
         temp     = temp * 10.
         pow      = max(sigfig,(exponent+1))
         n_normal = temp + 5./10.**pow
      endif
c
c*********************************************      all done
c
      return
c
      end


> And the following program executes in <4 ms with gfortran 4.3.0 20070227 and
> 4.1.3 20070218 (prerelease) (SUSE Linux).
> 
> You might want to try an newer GCC (4.1.2 or 4.2 or 4.3).
> Nightly builds of the latter two are available from:
> http://gcc.gnu.org/wiki/GFortranBinaries#GNU/Linux

  Thanks, I know about the newer versions, but what I have here is 
  basically working. I just reported this because I hate hangs
  even when I have a bug and generate infinity and then try
  to convert it to a string.

  Thanks again,

  Ray

  PS. Notice the "eps" in the last segment of code. This is 
  really a bug also. It originally was

      If ( n_normal .eq. 10. ) then

  But in some cases it missed the proper branch.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30981

Reply via email to