From: Michael.METCALF@cern.ch (Michael METCALF)
Subject: Re: Fortran 90 merge statement
Date: 1995/05/31 [thread overview]
Message-ID: <D9G7o8.H0y@news.cern.ch> (raw)
In-Reply-To: 3qhucj$kgg@gaia.ucs.orst.edu
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
next prev parent reply other threads:[~1995-05-31 4:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-05-31 4:00 Fortran 90 merge statement Rodney James
1995-05-31 4:00 ` Michael METCALF [this message]
1995-06-01 4:00 ` Steve Lionel
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox