[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

1238.0. "floating invalid operation on WNT" by COL01::VSEMUSCHIN (Duck and Recover !) Tue Mar 25 1997 07:08

Customer has following problem:

c
c DEC Fortran for WNT version 1.2 tested on both
c WNT 4.0 and 3.51
c
	program power3
	implicit double precision (a-z)

c following works:

	r=-2**3
	write(*,*)r

c following produces:
c forrtl: severe: Program Exception - floating invalind operation

	x=-2.
	y=3.
	w=x**y
	write(*,*)w

	end

I suspect RTL errors ...
Help !

=Seva
T.RTitleUserPersonal
Name
DateLines
1238.1use /check=nopower to get C semantics from **TLE::WHITLOCKStan WhitlockTue Mar 25 1997 08:1326
there are several things going on here:

>>	r=-2.**3.

is evaluated as -(2.**3.) since ** takes precedence over unary - in standard
Fortran rules.  So the answer is -8.

>>	(-2.)**3.

is illegal Fortran, both by Fortran 77 and Fortran 90.  Therefore you get an
error at run-time.

But DFANT v1.2 has the "/check=nopower" switch, which changes the semantics of
** to be like C, ie, 

    o	0.**0.  == 1.

    o	negative number to an odd integer power works

so if you compile with "/check=nopower" {the deafult is "/check=power"}, you'll
get -8. from (-2.)**3.

"/check=[no]power" is available in f90 and f77 on Alpha/VMS, Alpha/UNIX, and
Alpha/NT {spelled appropriately for the platform}.

/Stan