title: How to Read/Store many files using GrADS?
body: <p>I would like to know if anyone can help me to find the issue about this code in GrADS language.</p>
  
  <p>I'd like to read many files and compute and store them, but when I perform that in GraDS, I have the same answer for all imput file.</p>
  
  <p>Could anyone help me in this problem, please?</p>
  
  <pre><code>'reinit'
  
  ****Modify here******
  var = v10
  
  ano = 1980
  
  while(ano &lt;= 2013)
  
      *Desire point
      local = IAG
      **lat = -22.3
      **lon = 314.62
  
      latInitialP = -34.58
      lonInitialP = 305.43
      *******************************************************
      'sdfopen C:\Pesquisa_Michelle\dados_amandenha\V10m_'ano'.nc' 
  
      *Storing out
      'set gxout print'
      'set prnopts %10.2f 1 1'
  
      in = 1
  
      test = 1460
      if ( math_fmod(ano,4) = 0 )
        test = 1464
      endif
  
      while(in &lt;= test)
          'set t 'in
          in2 = in + 3
  
          say in
          say in2 
  
          'define m = ave('var',t='in',t='in2')'
          'set lat 'latInitialP''
          'set lon 'lonInitialP''
          'd m'
  
          valor = sublin(result,2)
          lixo = write('C:\Pesquisa_Michelle\dados_amandenha\'var'_'ano'.txt',valor)
          in = in + 4
      endwhile
      lixo = close(''var'_'ano'.txt')
      ano = ano + 1
  endwhile
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p>I don't get an error (message) about that. That works fine, the problem is the result files. All result files have the first result, like a file replication. When I perform that not using a loop, but changing each value for "ano" by myself, I got different result.</p>
  
  <p>The problem is, in my point of view, the command:</p>
  
  <p>'sdfopen C:\Pesquisa_Michelle\dados_amandenha\V10m_'ano'.nc'</p>
  
  <p>This command aren't replace the files for each "ano".</p>