At 12:36 AM 3/15/2005, you wrote:
>My point was to avoid exceptions (underflows?) in "exp" that
>slow down the whole thing.
> > I'd probably just do the whole thing with DO loops. I doubt that you
> > will see any actual benefit from using WHERE and FORALL.
>Yes, the only true f95 version I was able to write (down there, commented)
>was really slow. Loops also didnt impress me, maybe because of "if" inside.
>This one worked OK:
>
> subroutine radial0_where()
> real(r8_kind) :: ar2(vl)
> do i_exp = 1, n_exps
> alpha = exps(i_exp)
> norm = norms(i_exp)
> ar2 = alpha * r2(:vl)
> where( ar2 .lt. 50.0_r8_kind )
> rad0(:vl,i_exp) = norm * exp( - ar2(:vl) )
> elsewhere
> rad0(:vl,i_exp) = 0.0_r8_kind
> endwhere
> enddo
> end subroutine radial0_where
Is it really so fast? How does your platform avoid the same kind of
conditional branch for each element which IF() would imply? You as much as
informed us you didn't want the exp() to be parallelized. Apparently, you
expect your library to take even longer to handle underflows than branching
in your own code would take. If you are willing to accept this level of
discontinuity in your results, why not simply invoke abrupt underflow?
Tim Prince
|