Home > Archive > Fortran > October 2006 > FORALL STATEMENT
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| jdturner 2006-10-30, 7:16 pm |
| Experts,
I have a recurring application need where I have many conditions to be
evaluated simultaneously, with only a single valid response. For
example, one might have the following code fragment:
forall( 1 = 1:n, all( mask=v-a(i) == 0 ) ) tmp(1) = i
ans: tmp(1)
I know that forall wants an array solution==> I have provided a
artifical array with one location being set equal to i. My question
is: (1) is there another way, (2) is this portable?
Jim Turner
| |
| Craig Powers 2006-10-30, 7:16 pm |
| jdturner wrote:
> Experts,
>
> I have a recurring application need where I have many conditions to be
> evaluated simultaneously, with only a single valid response. For
> example, one might have the following code fragment:
>
> forall( 1 = 1:n, all( mask=v-a(i) == 0 ) ) tmp(1) = i
> ans: tmp(1)
>
> I know that forall wants an array solution==> I have provided a
> artifical array with one location being set equal to i. My question
> is: (1) is there another way, (2) is this portable?
FORALL is, fundamentally, an array assignment statement, but it appears
to me that you're trying to turn it into a loop.
Since you're trying to find a single index i, I suspect that the most
efficient (and also least tortured) way to do what you want is to use a
vanilla DO loop to locate the correct index, save it, and EXIT out of
the loop.
|
|
|
|
|