title: Write elements of matrix into vector using OpenMP
body: <p>I am rather new with OpenMP. I want to write all elements of a big matrix into a vector using OpenMP threading to speed things up. </p>
  
  <p>In my serial code I am simply doing the following:</p>
  
  <pre><code>m=1
  DO k=1,n_lorentz
     DO i=1,n_channels 
       DO p=1,n_lorentz
            DO j=1,n_channels
             vector(m) = Omega(j,p,i,k)
             m=m+1
         END DO
       END DO
     END DO 
  END DO 
  </code></pre>
  
  <p>Now I'd like to use an OMP loop to write the elements of Omega into vector in a parallel fashion: </p>
  
  <pre><code>!$OMP PARALLEL DO PRIVATE(k,i,p,j)
    ! bla bla 
  !$OMP END PARALLEL DO  
  </code></pre>
  
  <p>The question is how to keep track of the current vector index, since in this case the <code>m</code> parameter from the serial code will be incremented by different threads, resulting in a total mess. </p>