title: How to arrange elements of vector in Fortran?
body: <p>I have two p*n arrays, y and ymiss. y contains real numbers and NA's. ymiss contains 1's and 0's, so that if y(i,j)==NA, ymiss(i,j)==0, and 1 otherwise. I also have 1*n array ydim which tells how many real numbers there is at y(1:p,n), so ydim has values 0 to p</p>
  
  <p>In R programming language, I can do following:  </p>
  
  <pre><code>if(ydim!=p &amp;&amp; ydim!=0)  
    y(1:ydim(t), t) = y(ymiss(,t), t)
  </code></pre>
  
  <p>That code arranges all real numbers of y(,t) in like this</p>
  
  <p>first there's for example
  y(,t) = (3,1,NA,6,2,NA)
  after the code it's
  y(,t) = (3,1,6,2,2,NA)</p>
  
  <p>Now I will only need those first 1:ydim(t), so it doesn't matter what those rest are.</p>
  
  <p>The question is, how can I do something like that in Fortran?</p>
  
  <p>Thanks,</p>
  
  <p>Jouni </p>