<div dir="ltr">Hi Jennifer,<div><br></div><div>thank you very much for your message and for your suggestions!</div><div><br></div><div>It's still unclear to me why in one case the script produced an output file and in the other (basically the same script) it didn't. Especially because in every other script using the "write" function I found on the web, they never included the "close" command. Another strange thing I noticed is that today the same script I sent you in case 1 worked smoothly, producing the output file (without the "close" command).</div><div>However from now on I will include the "close" command after every "write" function, as a general rule.</div><div><br></div><div>Kindest regards</div><div><br></div><div>Annibale</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 2, 2016 at 11:27 PM, Jennifer M Adams <span dir="ltr"><<a href="mailto:jadams21@gmu.edu" target="_blank">jadams21@gmu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
Hi, Annibale,
<div>You need to add a command to close the file at the end of your script:</div>
<div> rc=close(outfile)</div>
<div><br>
</div>
<div>If you add this to the script fragment in your Case #1, it will create a file that contains only one line: “LON LAT PREC”</div>
<div><br>
</div>
<div>If you want to write out the data, as well as the 1-line header, then take a look at examples under the heading ‘Output gridded data in ascii format” on this page: <a href="http://cola.gmu.edu/grads/gadoc/ascii.html" target="_blank">http://cola.gmu.edu/grads/gadoc/ascii.html</a></div>
<div><br>
</div>
<div>—Jennifer</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div><div><div class="h5">
<div>On May 31, 2016, at 6:03 PM, Annibale Vecere <<a href="mailto:annibale.vecere@umeschool.it" target="_blank">annibale.vecere@umeschool.it</a>> wrote:</div>
<br>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Dear GRADS Users,
<div><br>
</div>
<div>I'm trying to use the "write" intrinsic function to write on a file (.txt or dat) the daily mean precipitation for every day derived from a precipitation dataset (e.g. 2013 CMORPH daily precipitation estimates, see below).</div>
<div>At this stage, I'm just trying to create the output file, which is a result I'm not able to get yet.</div>
<div>I don't know for which reason, this function in one case works and in another doesn't.</div>
<div> </div>
<div><b>Case 1</b>: I can run the script with no errors but the .txt file is not generated within the defined current directory.</div>
<div><br>
</div>
<div>
<div>'sdfopen <a href="http://iridl.ldeo.columbia.edu/SOURCES/.NOAA/.NCEP/.CPC/.CMORPH/.daily/.mean/.morphed/.cmorph/T/%2801%20Jan%202013%29%2831%20Dec%202013%29RANGEEDGES/dods" target="_blank">
http://iridl.ldeo.columbia.edu/SOURCES/.NOAA/.NCEP/.CPC/.CMORPH/.daily/.mean/.morphed/.cmorph/T/%2801%20Jan%202013%29%2831%20Dec%202013%29RANGEEDGES/dods</a>'</div>
<div>outfile='C:/OpenGrADS/Contents/Resources/SampleDatasets/CMORPH.txt'</div>
<div>'set gxout print'</div>
<div>'set prnopts %0.3f 5 1'</div>
<div>rc=write(outfile, 'LON LAT PREC')</div>
</div>
<div><br>
</div>
<div><b>Case 2</b>: Take an example I found on the web and in this case I can actually get the NCEP.txt file in my current directory.</div>
<div><br>
</div>
<div>'sdfopen <a href="http://monsoondata.org:9090/dods/rean2d" target="_blank">http://monsoondata.org:9090/dods/rean2d</a>'</div>
<div>outfile='C:/OpenGrADS/Contents/Resources/SampleDatasets/NCEP.txt'</div>
<div>'set gxout print'</div>
<div>'set prnopts %6.2f 5 1'</div>
<div>rc=write(outfile, 'LON LAT PREC') </div>
<div><br>
</div>
<div>The first example is related to a precipitation dataset which I'm interested into, the second is an excerpt from a script I found on the web.</div>
<div><br>
</div>
<div>Could explain me why this happens?</div>
<div>Could you also provide me with some tested working scripts, which use this function within a while loop (which is what I would need to extract the mean daily precipitation from a given dataset)?</div>
<div><br>
</div>
<div>Thank you very much!</div>
<div><br>
</div>
<div>Kindest regards</div>
<div><br>
</div>
<div>Annibale</div>
<div><br>
</div>
</div></div></div>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote>
</div>
<br>
<div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="font-size:12px">--</div>
<div style="font-size:12px">Jennifer Miletta Adams<br>
Center for Ocean-Land-Atmosphere Studies (COLA)<br>
George Mason University<br>
<br>
<br>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br></div>