* Re: Fortran 90 merge statement
1995-05-31 4:00 Fortran 90 merge statement Rodney James
@ 1995-05-31 4:00 ` Michael METCALF
1995-06-01 4:00 ` Steve Lionel
1 sibling, 0 replies; 3+ messages in thread
From: Michael METCALF @ 1995-05-31 4:00 UTC (permalink / raw)
In article <3qhucj$kgg@gaia.ucs.orst.edu>, rodney@oce.orst.edu says...
>
>I have a question about the Fortran 90 merge statement.
>
>Consider the following Fortran 90 program:
>
> program merge_test
> integer,parameter:: n=100
> real,dimension(-n:n):: x,y
> integer:: i
> real:: s
> do i=-n,n
> x(i) = real(i)
> enddo
> y = merge(1.0/x,0.0,x.ne.0.0)
> s = sum(y)
> write(*,*) 'sum = ',s
> end
>
>It works fine on an RS/6000 and a CM5, but on a Dec Alpha, I get
>
> forrtl: error (73): floating divide by zero
>
>at merge statement.
>
>Does the standard specify how the merge is implemented? Is it legal to
>evaluate the true and false statements _before_ checking the conditional
as
>the alpha compiler seems to be doing, or is the alpha compiler generating
>incorrect code?
>
>--
>
>-Rodney James (rodney@oce.orst.edu)
>
What the DEC compiler is doing is a legal interpretation of the
standard. You could achieve the same effect, however, using the
WHERE construct for masked assignment:
where(x.ne.0.0)
y = 1.0/x
elsewhere
y = 0.0
end where
Mike Metcalf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Fortran 90 merge statement
@ 1995-05-31 4:00 Rodney James
1995-05-31 4:00 ` Michael METCALF
1995-06-01 4:00 ` Steve Lionel
0 siblings, 2 replies; 3+ messages in thread
From: Rodney James @ 1995-05-31 4:00 UTC (permalink / raw)
I have a question about the Fortran 90 merge statement.
Consider the following Fortran 90 program:
program merge_test
integer,parameter:: n=100
real,dimension(-n:n):: x,y
integer:: i
real:: s
do i=-n,n
x(i) = real(i)
enddo
y = merge(1.0/x,0.0,x.ne.0.0)
s = sum(y)
write(*,*) 'sum = ',s
end
It works fine on an RS/6000 and a CM5, but on a Dec Alpha, I get
forrtl: error (73): floating divide by zero
at merge statement.
Does the standard specify how the merge is implemented? Is it legal to
evaluate the true and false statements _before_ checking the conditional as
the alpha compiler seems to be doing, or is the alpha compiler generating
incorrect code?
--
-Rodney James (rodney@oce.orst.edu)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fortran 90 merge statement
1995-05-31 4:00 Fortran 90 merge statement Rodney James
1995-05-31 4:00 ` Michael METCALF
@ 1995-06-01 4:00 ` Steve Lionel
1 sibling, 0 replies; 3+ messages in thread
From: Steve Lionel @ 1995-06-01 4:00 UTC (permalink / raw)
In article <3qhucj$kgg@gaia.ucs.orst.edu>, rodney@oce.orst.edu (Rodney James)
writes:
|>Does the standard specify how the merge is implemented? Is it legal to
|>evaluate the true and false statements _before_ checking the conditional as
|>the alpha compiler seems to be doing, or is the alpha compiler generating
|>incorrect code?
As Mike Metcalf says, the standard does not say that the expression is not
evaluated if the mask value is false - the minimal text in the standard
implies to me that it is only the "store" into the function value which is
affected by the mask value.
I have a suspicion that the other compilers are also evaluating the expression
for all values - the difference on the Alpha system is that our default for
exceptions is to report them rather than store an IEEE exceptional value.
Some other systems store the IEEE exceptional value (NaN, Infinity). You can
get the IEEE exceptional values if you want by compiling with the -fpe1
switch. I tried this and the program ran to completion. Our philosophu is
that most users prefer a default which provides the best performance and which
highlights potential program bugs. If IEEE exceptional values are wanted,
the programmer can easily select that behavior.
--
Steve Lionel Mail: lionel@quark.enet.dec.com
DEC Fortran Development WWW: http://www.digital.com/info/slionel.html
Digital Equipment Corporation CompuServe: 75263,3001
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For a summary of Digital's Internet services, send mail to info@digital.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1995-06-01 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-05-31 4:00 Fortran 90 merge statement Rodney James
1995-05-31 4:00 ` Michael METCALF
1995-06-01 4:00 ` Steve Lionel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox