[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::fortran

Title:Digital Fortran
Notice:Read notes 1.* for important information
Moderator:QUARK::LIONEL
Created:Thu Jun 01 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1333
Total number of notes:6734

1153.0. "check power for 0.0**0.0 not working in Fortran 4.1 dunix?" by PEACHS::DALEY (Maybe I should drink more coffee...or less!) Wed Jan 29 1997 14:16

Hi,

I'm using the following program with DFA 4.1 on dUNIX 4.0a, 4.0b to test
-check power/-check nopower.  It never seems to check power and give me the
run time error for 0.0 ** 0.0.  Why not?

        PROGRAM TESTE

           REAL R1,R2,REXP

           REXP=0.0
           R1=0.0
	   R2=0.0
	   REXP=R1**R2

           PRINT *,REXP
	   STOP
	END 

My problem is that a customer is confused by this issue with our compilers
since reading the 3.6 release notes...do we think 0**0 is an error, or 1?

I told her that with check power, it's up to you.  That's what is implied 
in the man page.  But I can't get check power to work.  Even when I build 
with '-check power' on the command line it comes back 1.00000.  

Tried f77 and f90...same results.

From the man page for f90:

  -check nopower
      Suppresses the run-time errors for 0.0 ** 0.0 and <negative-value> **
      <integer-value-of-type-real>, so 0.0 ** 0 .0 is 1.0 and (-3.0) ** 3.0
      is -27.0.  The default is -check power, which causes fatal run-time
      errors.

Am I just missing the boat?

Regards,

John

What am I doing wrong?
T.RTitleUserPersonal
Name
DateLines
1153.1TLE::EKLUNDAlways smiling on the inside!Wed Jan 29 1997 16:0516
    	If I were in a mean mood, I would suggest that what you are
    seeing is NOT a "run-time error".  It's a compile-time error.
    Drop the optimization level (to -O0) to see what I mean.
    
    	This looks like a bug.  When the compiler cannot figure out
    what's going on (when the values of R1 and R2 are truly not
    known at compile time), the correct things happen.  If the
    compiler figures out that everything in sight is a constant,
    it seems to create the value (1.0) at compile time whether or
    not -check nopower is specified.  We will take a look at this.
    
    	Thanks for the simple example!
    
    Cheers!
    Dave Eklund
    
1153.2QUARK::LIONELFree advice is worth every centWed Jan 29 1997 16:294
    I have it as an open issue for F90 that we don't do the right thing for
    -check nopower for compile-time arithmetic.
    
    				Steve
1153.3Thanks!PEACHS::DALEYMaybe I should drink more coffee...or less!Wed Jan 29 1997 18:033
Should I QAR this?

JD
1153.4Whoops! reply collision...PEACHS::DALEYMaybe I should drink more coffee...or less!Wed Jan 29 1997 20:515
Sorry, hadn't seen .2 when I entered .3

BTW, f77 has the same problem.

JD
1153.5QUARK::LIONELFree advice is worth every centThu Jan 30 1997 09:433
No need to do anything else.  We'll handle it.

			Steve
1153.6FixedTLE::EKLUNDAlways smiling on the inside!Fri Jan 31 1997 14:4711
    	I've fixed this for f77 with edit 4-113.  I tried quite
    a number of cases using -check nopower, and got the answers
    which one would "expect".  It looks like most of the cases
    which were not working were the ones where the compiler was
    clever enough to do the computation at compile time (possibly
    after constant propagation or other optimizations), but then
    failed to use the -check option properly.
    
    Cheers!
    Dave Eklund