[gradsusr] Slow performance using 'sum'

Dan Leins theedge981 at gmail.com
Fri Feb 17 04:51:56 EST 2012


I took Jennifer's solution and without fail it solved the problem. Thanks
for the help everyone!

Dan

On Mon, Feb 13, 2012 at 6:05 AM, Jennifer Adams <jma at cola.iges.org> wrote:

>
> On Feb 11, 2012, at 11:02 PM, 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.
>
>
> It sounds like this expression is inside a loop where dis_t starts at 2
> and increases to the end of the time series. For each repetition of the
> loop, you are re-doing all the I/O for each time step from t=2 to t=dis_t.
> Try something like this instead:
>
> 'set gxout fwrite'
> 'define runtotal=apcpsfc.1(t=2)'
> 'd runtotal'
> t=3
> while (t<=dis_t)
>   'define runtotal=runtotal+apacpsfc.1(t='t')'
>   'd runtotal'
>   t=t+1
> endwhile
> 'disable fwrite'
>
> --Jennifer
>
>
>
> 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
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
> --
> Jennifer M. Adams
> IGES/COLA
> 4041 Powder Mill Road, Suite 302
> Calverton, MD 20705
> jma at cola.iges.org
>
>
>
>
> _______________________________________________
> 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/20120217/c13928cc/attachment-0003.html 


More information about the gradsusr mailing list