Re: fatal:MultiDValDelParent when returning logical attribute

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 5 Oct 2009 05:37:37 -0600

Hi Alvaro,

The reason you were seeing this weird error message is because rather
than
passing in a variable equal to "True" or "False", you were actually
passing
in True and False.

You want to be careful about doing something like this if your function
or procedure is going to try to reference this value as if it were a
variable.

In your case, the "get_att_value" function potentially is trying to
reference "res@$resname$", which, given that you were just passing
in the value "True" directly, would make no sense.

In Wei's solution, he created a variable to hold the "True" and "False"
values, which makes the code work.

Another work-around, would have been to change the two main lines of
your code:

   proc(True)
   proc(False)

to be:

   res2 = True
   proc(res2)
   res2 = False
   proc(res2)

Dave Brown is looking into why this code causes a bus error and such
an obscure error message. :-)

--Mary

On Oct 4, 2009, at 10:46 AM, Wei Huang wrote:

> Alvaro,
>
> If you change the way to use your defined procedure/function,
> things will be probably easier.
>
> Below is a modified script from yours.
> I guess that should be the way you invoke your procedure/function.
>
> Wei Huang
> huangwei_at_ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
> -------------------------
>
> ; simplified version of get_res_value_keep
> ;-----------------
> function get_att_value(res,resname[1]:string,default_val[1])
> local return_val
> begin
> if(isatt(res,resname)) then
> return_val = res@$resname$
> else
> return_val = default_val
> end if
> return(return_val)
> end
> ;-----------------
> ;
> ;-----------------
> procedure proc(res[1]:logical,resname[1]:string)
> local aux
> begin
> aux=False
> print(" "+res+"@"+get_att_value(res,resname,aux))
> aux=True
> print(" "+res+"@"+get_att_value(res,resname,aux))
> print(" "+res+"@"+get_att_value(res,resname,False))
> print(" "+res+"@"+get_att_value(res,resname,True))
> end
> ;-----------------
> ;
> ;-----------------
> begin
> a = True
> proc(a, "name")
>
> a = False
> a_at_att = True
> proc(a, "att")
>
> b = 1
> b_at_lon = 5
> b_at_name = "b"
> proc(b, "lon")
> proc(b, "name")
> end
>
>
>
> On Oct 4, 2009, at 8:52 AM, alvaro.valdebenito_at_met.no wrote:
>
>> Dear all,
>>
>> I have found the most strange behaviour on a simple function
>> returning a logical attribute (e.g. get_res_value).
>> For different combinations of the values of the logical variable and
>> the (default) logical attribute
>> I get a fatal:MultiDValDelParent or even a Segmentation fault.
>>
>> The attached script is an minimal example.
>> The example returns:
>> True_at_False
>> True_at_True
>> True_at_False
>> fatal:MultiDValDelParent: Attempt to delete parent from empty list
>> True_at_True
>> False_at_False
>> False_at_True
>> fatal:MultiDValDelParent: Attempt to delete parent from empty list
>> False_at_False
>> False_at_True
>> fatal:Variable res is still undefined, can not continue
>> Segmentation fault
>>
>> I am at lost here. Does any one else get the same error messages?
>> Is if this a bug in NCL or there is something wrong with my local
>> install?
>>
>> Thanks in advance,
>> Álvaro.
>>
>> Álvaro M. Valdebenito B., Dr. rer. nat.
>> alvaro.valdebenito_at_met.no
>> Air Pollution Section/Research Department Tel. +47-2296 3397
>> Norwegian Meteorological Institute http:\\www.met.no
>> P.O. Box 43 Blindern, 0313 Oslo, NORWAY http:\\www.emep.int/CWF
>> <crash_ex.ncl>_______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 05 2009 - 05:37:37 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 05 2009 - 13:28:35 MDT