Re: strange issue with deleting a list of variables

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Sep 30 2013 - 16:23:10 MDT

Brian,

Thanks for the nice script that shows the problem clearly. I had the same issue as you, so I went ahead and created a ticket for this.

There may be some weird "pointer" issue going on with coordinate variables, such that by doing this inside your function:

wgt = lat

it's created a situation where "wgt3" and "z&lat" are now "linked" together, and hence it can't delete "wgt3" because it would mess up z&lat.

I was able to get your script to work simply by changing the above line to:

wgt = (/lat/)

This basically turns "wgt" into a simply array of numbers, and gets rid of potentially any links between "wgt" and "z&lat".

--Mary

On Sep 25, 2013, at 11:21 AM, Brian Medeiros <brianpm@atmos.ucla.edu> wrote:

> Hi NCLers,
>
> I've got a silly problem with deleting a list of variables (i.e., using delete( [/ … /] ) ). It works great, except for this apparently bizarre special case:
>
> If a variable is returned from a custom function that has been called with the argument referencing another variable's coordinate variable, then delete will not remove the returned variable.
>
> I know, sounds crazy. Here's a test script, that I've tested with Mac OSX (10.8.5), NCL 6.1.2 and on Yellowstone with NCL 6.2.0-25Sep2013_0234:
>
>
> function gen_area_wgt(lat)
> begin
> ;; wgt is the latitude weight
> wgt = lat
> wgt!0 = "lat"
> wgt&lat = wgt
> wgt = (/cos( 4.*atan(1.)*wgt/180.) /)
> return(wgt)
> end
>
> begin
>
> lat = fspan( -90.d, 90.d, 91 )
>
> z = new( dimsizes( lat ), float )
> z!0 = "lat"
> z&lat = lat
>
> wgt = z&lat
> wgt!0 = "lat"
> wgt&lat = wgt
> wgt = (/ cos( 4. * atan(1.) * wgt / 180. ) /) ;; This one gets deleted normally.
>
> wgt2 = gen_area_wgt( lat ) ;; This one gets deleted normally.
>
> wgt3 = gen_area_wgt( z&lat ) ;; THIS ONE PERSISTS THROUGH DELETE (when using list as arg to delete).
>
> print( "(pre) is variable: " + str_join( (/ isvar("z"), isvar("wgt"), isvar("wgt2"), isvar("wgt3")/) , ", ") )
>
> delete( [/lat, z, wgt , wgt2, wgt3 /] )
>
> print( "(post) is variable: " + str_join( (/isvar("z"), isvar("wgt"), isvar("wgt2"), isvar("wgt3")/) , ", ") )
>
> ;; BUT WE CAN DELETE IT SEPARATE FROM THE LIST:
> delete( wgt3 )
> print("final check: " + isvar("wgt3") )
>
> end
>
>
>
>
> Any thoughts? Thanks,
>
> .brian
> _______________________________________________
> 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 Sep 30 16:23:19 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT