[gradsusr] Slow performance using 'sum'

Ricardo Hallak hallak at model.iag.usp.br
Sun Feb 12 23:36:45 EST 2012


Dan,

I haven't seen you had already undefined that variable in your original script.
Well, if the processing time is really bothering you, you can try to code a more complex script.

For example, a second try would be to fwrite a runtotal file (e.g., runtotal.gra), which would save the grib2 precip field for each iteration.
In this case, the runtotal.gra file will change its content every time your script advance in time.

For each iteration, your script will have to open a control file to access the runtotal.gra data (with a fix runtotal.ctl file), define a var with the sum of totalrunprecip field and the present grib2 precip field, close the runtotal.ctl file, and finally make a figure and fwrite a new runtotal.gra (over the older one). These 4 steps have to be repeated for each iteration, spending always the same time in each iteration. A cumbersome part will be to handle the time correctly to access the runtotal.gra data, since the runtotal.ctl file will have a different TDEF form from that of your grib2 file. An easy way to handle this, is to keep an runtotal.ctl with the same initial TDEF that that your grib2 files, and call the runtotal.gra data with something like: 'd precip.2(t=1) + precip.1', where precip.2(t=1) is the VAR from the runtotal.ctl file.

Is it clear? Hope yes.

Anyway, if you are interested in trying to code it, I can help you if necessary.
Regards,
Ricardo

On Sun, 12 Feb 2012 19:06:54 -0700, Dan Leins wrote
> I gave that a shot and still no luck. I'm somewhat at a loss as to why the performance degrades so much over time given this command.
> 
> Dan
> 
> On Sun, Feb 12, 2012 at 8:09 AM, Ricardo Hallak <hallak at model.iag.usp.br> wrote:
> 
> Hi Dan,
> 
> maybe using:
> 
> undefine runtotal
> 
> after each iteration may help in the performance.
> 
> Regards,
> Ricardo
> 
> On Sat, 11 Feb 2012 21:02:18 -0700, Dan Leins wrote
> 
> > All,
> > 
> > I have a GrADS script I use, among other things, to calculate run total precip over my model domain throughout my model run (output format is grib2). I create images of numerous fields on an hourly basis (say 72hrs worth for example), so I produce 72 runtotal precip images. As the script runs and iterates through a loop, my code to calculate the runtotal looks like this:
> > 
> > 'define runtotal=sum(apcpsfc.1, t=2, t='dis_t')'
> > 'display runtotal'
> > 
> > where dis_t is the hour I am currently working on.
> > 
> > My script works fine and fast early on, but slows down over time. Naturally, I assume the amount of time it takes to 'sum' hours of precip will increase as I get further into my run. However, if I kill and restart my script at an arbitrary time (dis_t=60) for example, this calculation speeds right back up again.   Likewise if I comment out this portion of my script, the rest of my script moves along at the same pace the entire time. I'm thinking some resources aren't being released properly while the script is running since the problem seems to go away if I kill/restart my script. 
> > 
> > Is there a more efficient way to calculate a runtotal than the method shown above?  I've been careful to undefine any variables after each iteration of my loop so I don't think that's a factor. 
> > 
> > Any help would be great!
> > Thanks,
> > Dan Leins
> 
> Ricardo Hallak 
> 
> Department of Atmospheric Sciences (DCA) 
> Institute of Astronomy, Geophysics and Atmospheric Sciences (IAG) 
> University of São Paulo (USP) 
> Rua do Matão, 1226 - Cidade Universitária - São Paulo SP 05508-900 
> Phone.: +55 (11) 3091-2850; 3091-4703 
> Fax: +55 (11) 3091-4714 
> 
> 
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
> 
>

Ricardo Hallak

Department of Atmospheric Sciences (DCA) 
Institute of Astronomy, Geophysics and Atmospheric Sciences (IAG) 
University of São Paulo (USP) 
Rua do Matão, 1226 - Cidade Universitária - São Paulo SP 05508-900 
Phone.: +55 (11) 3091-2850; 3091-4703 
Fax: +55 (11) 3091-4714

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20120213/2b1d45a4/attachment-0003.html 


More information about the gradsusr mailing list