On Thu, 30 Jul 2009, Tompkins Adrian wrote:
> hello all,
>
> I am running NCL 5.0.0
>
> I have a 2D array, cprmask(x,z), and want to rotate the contents of each
> x-slice to the right by "nshift" places with cyclic boundary conditions.
>
> As nshift itself is a function of height, I resorted to a Do-Loop as
> follows:
>
> do i=0,nhgtr-1
> nshift = round(hgtr(i)*tan_sza_dx,3)
> index = mod(ispan(0,npts-1,1)+nshift,npts)
> shiftmask(:,i) = cprmask(index,i)
> delete(index)
> end do
Hi Adrian,
We've got your script (thanks). One thing about loops is you
you want to keep as much as possible out of them. :-)
In the above, you can take the "round" and "ispan" functions out of
the loop. Also, I'm not sure you need to delete "index", unless
I'm missing something here.
nshift = round(hgtr*tan_sza_dx,3)
ii = ispan(1,npts-1,1)
do i=0,nhgtr-1
index = mod(ii+nshift(i),npts)
shiftmask(:,i) = cprmask(index,i)
delete(index)
end do
We will still look into the memory leak.
--Mary
> This works, BUT I suffer from a nasty memory leak problem that is not
> allowing be to run the program for large amounts of data, despite the
> fact that I also have a "delete(shiftmask)" statement later in the
> "mother" do loop.
>
> does anyone have any ideas how to prevent the memory leak?
>
> thanks,
>
> Adrian
>
> --
> +39 040 2240579 (office) | Earth System Physics
> +39 040 2240449 (fax) | ICTP (UNESCO-IAEA)
> esp.ictp.it | Strada Costiera 11
> www.ictp.it/~tompkins | 34014 Trieste, Italy
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 30 2009 - 09:44:39 MDT
This archive was generated by hypermail 2.2.0 : Fri Jul 31 2009 - 14:51:03 MDT