[gradsusr] Problem with "write" instrinsic function in GRAD

Annibale Vecere annibale.vecere at umeschool.it
Mon Jun 6 14:05:12 EDT 2016


Hi Jennifer,

thank you very much for your message and for your suggestions!

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).
However from now on I will include the "close" command after every "write"
function, as a general rule.

Kindest regards

Annibale

On Thu, Jun 2, 2016 at 11:27 PM, Jennifer M Adams <jadams21 at gmu.edu> wrote:

> Hi, Annibale,
> You need to add a command to close the file at the end of your script:
>     rc=close(outfile)
>
> 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”
>
> 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: http://cola.gmu.edu/grads/gadoc/ascii.html
>
> —Jennifer
>
>
>
>
> On May 31, 2016, at 6:03 PM, Annibale Vecere <annibale.vecere at umeschool.it>
> wrote:
>
> Dear GRADS Users,
>
> 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).
> At this stage, I'm just trying to create the output file, which is a
> result I'm not able to get yet.
> I don't know for which reason, this function in one case works and in
> another doesn't.
>
> *Case 1*: I can run the script with no errors but the .txt file is not
> generated within the defined current directory.
>
> 'sdfopen
> http://iridl.ldeo.columbia.edu/SOURCES/.NOAA/.NCEP/.CPC/.CMORPH/.daily/.mean/.morphed/.cmorph/T/%2801%20Jan%202013%29%2831%20Dec%202013%29RANGEEDGES/dods
> '
> outfile='C:/OpenGrADS/Contents/Resources/SampleDatasets/CMORPH.txt'
> 'set gxout print'
> 'set prnopts %0.3f 5 1'
> rc=write(outfile, 'LON    LAT    PREC')
>
> *Case 2*: Take an example I found on the web and in this case I can
> actually get the NCEP.txt file in my current directory.
>
> 'sdfopen http://monsoondata.org:9090/dods/rean2d'
> outfile='C:/OpenGrADS/Contents/Resources/SampleDatasets/NCEP.txt'
> 'set gxout print'
> 'set prnopts %6.2f 5 1'
> rc=write(outfile, 'LON    LAT    PREC')
>
> 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.
>
> Could explain me why this happens?
> 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)?
>
> Thank you very much!
>
> Kindest regards
>
> Annibale
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
> --
> Jennifer Miletta Adams
> Center for Ocean-Land-Atmosphere Studies (COLA)
> George Mason University
>
>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20160606/3a1dc3a0/attachment-0001.html 


More information about the gradsusr mailing list