Re: Index of array from mask



Thomas Koenig wrote:
On 2008-04-30, hiphop <ratel.gilles@xxxxxxx> wrote:

Suppose V = (/103,102,103,104,105/)

a = 102
b = 105

I am interested get index for (V > a ) .AND. (V < b) ==> answer:
1,3, 4

program main
implicit none
integer, dimension(5) :: v
integer :: a, b, i

v = (/103,102,103,104,105/)
a = 102
b = 105
do i = 1, size(v)
if (v(i) > a .and. v(i) < b) write (*,'(1X,I0)',advance='no') i
end do
write (*,*)
end program main

Or am I missing something here?

I think he was looking for an intrinsic on the order of COUNT() or MAXLOC() but that would return the locations of array elements meeting the mask conditions...

That isn't available directly...

--
.



Relevant Pages

  • Re: Index of array from mask
    ... MAXLOC() but that would return the locations of array elements meeting the ... mask conditions... ... implicit none ...
    (comp.lang.fortran)
  • Re: Index of array from mask
    ... MAXLOC() but that would return the locations of array elements meeting the ... mask conditions... ... implicit none ...
    (comp.lang.fortran)
  • Re: Do loops until HUGE?
    ... Thomas Koenig wrote: ... implicit none ... acceppts it, printing 11, while ifort 8.1 on i686-linux loops back to negative values of i and takes a loooong time, as a result. ... That, indirectly, is what is causing the problem; ...
    (comp.lang.fortran)
  • Re: Short records on unformatted reads
    ... Thomas Koenig wrote: ... implicit none ... there is hidden loop when you set ia = 42. ...
    (comp.lang.fortran)