title: Using MINLOC with Fortran: Incompatible ranks 0 and 1 in assignment
body: <h2>Version that gives an error message</h2>
  
  <pre><code>program hello
     integer a(9)
     integer index; ! note no dimension here
     a=(/1, 3, 4, 5, 6, 7, 8, 9, 10/)
     index = MINLOC(a, MASK=(a &gt; 5))
     Print *, index
  end program Hello
  </code></pre>
  
  <h2>Error message</h2>
  
  <p>main.f95:5.3:</p>
  
  <p>index = MINLOC(a, MASK=(a > 5))
     1
  Error: Incompatible ranks 0 and 1 in assignment at (1)</p>
  
  <h2>Working version</h2>
  
  <pre><code>program hello
     integer a(9)
     integer index(1) ! note dimension 1 here which looks redundant at first
     a=(/1, 3, 4, 5, 6, 7, 8, 9, 10/)
     index = MINLOC(a, MASK=(a &gt; 5))
     Print *, index
  end program Hello
  </code></pre>
  
  <h2>Search</h2>
  
  <p><a href="http://morecakelessfish.blogspot.com.au/2008/12/incompatible-ranks.html" rel="nofollow">Here</a> I could find related discussion but I don't find it sufficiently verbose for me to understand the difference.</p>