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

Jennifer M Adams jadams21 at gmu.edu
Thu Jun 2 17:27:39 EDT 2016


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<mailto: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<mailto:gradsusr at gradsusr.org>
http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer Miletta Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
George Mason University



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20160602/7c46b1c4/attachment-0001.html 


More information about the gradsusr mailing list