Re: Keep it or not?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 20 Apr 2009 10:21:32 -0600 (MDT)

On Mon, 20 Apr 2009 Oliver.Fuhrer_at_meteoswiss.ch wrote:

> Hi ncl-talk,
>
> I am somewhat confused about which variables I need to keep until the
> end of my scripts and which ones I can delete on the fly... Here's a
> generic example script...
>
> pl = new(6,graphic)
> do i=0,5
> mp = gsn_map(...)
> gg = gsn_add_polyline(mp, ...)
> cn = gsn_contour(...)
> pl(i) = overlay( (/mp,cn/) )
> delete(mp)
> delete(gg)
> delete(cn)
> end do
> gsn_panel(pl,...)
>
> The script contains a base map (mp), an additional polyline (gg) drawn
> onto each map, a contour plot (cn) and an overlay (pl) of the map and
> the contour. In the end, the overlays are put into a panel plot. Since
> the pl are panelled, they must be allocated as an array before the loop
> and kept in memory. My question now is, if the mp, gg and cn need to be
> handled the same way as pl (allocate beforehand and kept in memory) or
> if deleting them is ok.

Hi Oli,

I think "mp" and "cn" can be deleted, but I don't think this
saves you much. You generally want to delete
big arrays that you read off a file.

Of course, if you are doing lots of loops, then deleting these
may save you some memory.

"gg" should not be deleted, and, in fact, it should be unique
each time in the loop. I recommend this:

  pl = new(6,graphic)
  gg = new(6,graphic)
  do i=0,5
   mp = gsn_map(...)
   gg(i) = gsn_add_polyline(mp, ...) ; Must save return value
   cn = gsn_contour(...)
   pl(i) = overlay( (/mp,cn/) )

   delete(mp) ; Really needed?
   delete(cn) ; Really needed?

  end do
  gsn_panel(pl,...)

--Mary

> Thanks for any advice,
> Oli
>
> ________________________________________
>
> Oliver Fuhrer
> Numerical Models
>
> Federal Departement of Home Affairs FDHA
> Federal Office of Meteorology and Climatology MeteoSwiss
>
> Kraehbuehlstrasse 58, P.O. Box 514, CH-8044 Zurich, Switzerland
>
> Tel. +41 44 256 93 59
> Fax +41 44 256 92 78
> oliver.fuhrer_at_meteoswiss.ch
> www.meteoswiss.ch - First-hand information
>
> _______________________________________________
> 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 Mon Apr 20 2009 - 10:21:32 MDT

This archive was generated by hypermail 2.2.0 : Tue Apr 21 2009 - 11:04:41 MDT