Re: strings questions]

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed, 20 Sep 2006 19:20:47 -0600

You
On Sep 20, 2006, at 6:57 PM, Kate Hedstrom wrote:

>> Kate,
>> I have no problem executing the 3 lines of code you have here:
>>
>> ncl 0> sflag = new(1,"character")
>> ncl 1> str = stringtochar("F")
>> ncl 2> sflag = str(0)
>> ncl 3> print(sflag)
>>
>>
>> Variable: sflag
>> Type: character
>> Total Size: 1 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> Number Of Attributes: 1
>> _FillValue : 0x00
>> (0) F
>>
>> Are you sure the error does not apply to a following line? By the way,
>> the new
>> version of NCL fixes the problem of inaccurate line numbers in error
>> messages.
>> I don't know of anything that has changed since the last version of
>> NCL
>> that
>> would affect this bit of code, but if you are sure that it is not a
>> subsequent line,
>> then I would investigate further.
>> -dave
>
> OK, that's weird. I can run it interactively too, plus in a
> shortened script, but still not in my full script. I've got:
> NCAR Command Language Version 4.2.0.a033

OK, I can explain.

You need

delete(str)

somewhere before the line
str = stringtochar("F")

Using my suggested code you had earlier created 'str' as a string type
variable.
Noting that NCL is willing to automatically coerce a character arrays
of any length to string,
the line above modifies the previously existing variable 'str' to a one
character string "F".
But you cannot automatically assign a string to a character variable.
Hence the the error.
  -dave

>
> Some files enclosed...
>
> Kate
> --
> Kate HedstrĄZm Arctic Region Supercomputing Center
> kate_at_arsc.edu University of Alaska, Fairbanks
> Phone: 907-450-8678
> <short.ncl><grid_cdf.ncl><java2.grd>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 20 2006 - 19:20:47 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 25 2006 - 11:45:07 MDT