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
Received on Wed Sep 25 11:20:41 2013
This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT