[ncl-talk] The slow down when addfile is used in do loop

Ruping Mo rupingmo at gmail.com
Fri Sep 12 15:36:48 MDT 2014


Thanks, Yuqiang and Kyle, for your quick responses. You are probably right
that it is an issue of RAM. I test deleting the variable [delete(dat)] at
the end of each loop. But it seems that the RAM doesn't respond fast enough
to improve the run.

Ruping

On Fri, Sep 12, 2014 at 2:12 PM, Yuqiang Zhang <yuqiangzhang.thu at gmail.com>
wrote:

> Maybe try to delete the variables using “delete” command after each loop.
>
>
>
> Regards,
>
> Yuqiang
>
>
>
> *From:* ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] *On
> Behalf Of *Ruping Mo
> *Sent:* Friday, September 12, 2014 4:31 PM
> *To:* ncl-talk
> *Subject:* [ncl-talk] The slow down when addfile is used in do loop
>
>
>
> Hi NCLers,
>
>
>
> I have an archive of large grib files. Each grib file contains a month of
> multiple daily global variables. I use the following script to extract a
> small part of one variable. The script, which uses addfile in a large loop,
> runs very fast for the first few months, then begins to slow down
> substantially. I let it run for a few years, then terminate the job
> (Ctrl-Z) and re-run the same script. Surprisingly, the new job runs very
> fast to the month when the previous job was terminated. I wonder why it
> behaves this way, and what I can do to avoid the slow down problem.
>
>
>
> Have a nice day!
>
>
>
> Ruping
>
>
>
> The script:
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> begin
>
>  nday = 12784     ; number of days from Jan 1979 to Dec 2013
>
>  temp = new((/nday, 9, 9/), float)
>
> ;;;;
>
>  t0 = 0
>
>  do yr = 1979, 2013
>
>    syr = tostring(yr)
>
>    do mo = 1, 12
>
>     smo = tostring(mo)
>
>     print(syr + "-" + smo)
>
>     fname = syr + "/" + syr + "-" + smo + ".grib"
>
>     dat = addfile(fname, "r")
>
>     mday = getfilevardimsizes(dat, "initial_time0") - 1
>
>     i1 = i0 + mday
>
>     temp(i0:i1, :, :) = (/ dat->2T_GDS0_SFC(:, 80:88, 146:154) /)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2T_GDS0_SFC(mday, 241, 480)
>
>     i0 = i1 + 1
>
>    end do
>
>  end do
>
> end
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140912/04ef2d48/attachment.html 


More information about the ncl-talk mailing list