<div dir="ltr">To whom it may concern,<div><br></div><div>I&#39;m working on converting a plethora of datasets, many of them with daily and hourly temporal resolutions, into a monthly temporal resolution. </div><div><br></div><div>I am unsure how to write a script that I can run that changes, in this case, average daily data into average monthly data, with respect to leap years and such. I have tried to follow scripts from other users who have previously posted here, but they did not seem to work. </div><div><br></div><div>There is an example of the script I tried to run on this page: <a href="http://gradsusr.org/pipermail/gradsusr/2006-June/003290.html">http://gradsusr.org/pipermail/gradsusr/2006-June/003290.html</a></div><div><br></div><div>This is the script I am currently running: </div><div><br></div><div><div>reinit</div><div>mday = &#39;31 28 31 30 31 30 31 31 30 31 30 31&#39;</div><div>month = &#39;jan feb mar apr may jun jul aug sep oct nov dec&#39;</div><div><br></div><div> &#39;open file /data2/control/GPCC_FirstGuessDaily&#39;</div><div><br></div><div> &#39;set gxout fwrite&#39;</div><div> &#39;set fwrite /data2/control/GPCC_FirstGuessDailyScriptTest&#39;</div><div><br></div><div> yr1 = 2009</div><div> yr2 = 2013</div><div><br></div><div> yr = yr1</div><div> while(yr&lt;=yr2)</div><div> leap = 0</div><div>  if(math_mod(yr,400) = 0 | math_mod(yr,4) = 0 &amp; math_mod(yr,100) != 0)</div><div>   leap = 1</div><div>   say yr&#39; is a leap year.&#39;</div><div>  endif</div><div>  imon = 1</div><div>  while(imon &lt;= 12)</div><div>   md = subwrd(mday,imon)</div><div>   mc = subwrd(month,imon)</div><div>   if(imon = 2); md = md + leap; endif;</div><div>  time1 = &#39;01&#39;mc&#39;&#39;yr</div><div>   time2 = md&#39;&#39;mc&#39;&#39;yr</div><div>*   say time1&#39; &#39;time2</div><div>   &#39;d ave(p,time=&#39;time1&#39;,time=&#39;time2&#39;)&#39;</div><div>   imon = imon + 1</div><div>  endwhile</div><div>  yr = yr + 1</div><div> endwhile</div></div><div><br></div><div><br></div><div>Running this code gives me an error saying that it cannot open the file, yet it is pointed to the correct directory. However, it does output saying that &#39;2012 is a leap year&#39; which is correct.</div><div><br></div><div>Any help would be appreciated, as I&#39;m a terrible coder. </div><div><br></div><div>-Justin</div></div>