title: find match between random lists as fast as possible in fortran (+openmp)
body: <p>I have two lists, I need to match elements in one against the other and output those elements into a new matrix (output). What is the fastest way to this in Fortran? Brute force so far:</p>
  
  <pre><code>do i = 1,Nlistone
     do j = 1,Nlisttwo
       if A(i).eq.B(j) then
          output(i) = B(j)
       end if
     end do
  end do
  </code></pre>
  
  <p>openmp version:</p>
  
  <pre><code>!$OMP PARALLEL PRIVATE(i,j)
  do i = 1,NA
     do j = 1,NB
       if A(i).eq.B(j) then
          filtered(i) = A(j)
       end if
     end do
  end do
  !$OMP END PARALLEL DO
  </code></pre>
  
  <p>There are definitely better ways to do this and sorting is not an option here sorry (+ the vector elements are not in any particular order). Is there a boolean argument similar to <code>mask</code> in python?</p>