[ncl-talk] convert string to fortran character
Zhifeng Yang
yangzf01 at gmail.com
Tue Nov 5 05:55:47 MST 2019
Hi Dennis and Rick,
I found tochar will give me an array with 2 dimensions. Now I can use the
following to get what I want
times = f->Times
times_tmp = tochar(tostring(5))
times(0,3) = times_tmp(0)
then it works. Thank you for your help.
Best,
Zhifeng
On Mon, Nov 4, 2019 at 11:25 PM Dennis Shea <shea at ucar.edu> wrote:
> The question is not clear. Possibly:
>
> times = f->Times
> times(0,3) = tochar(tostring(5))
> print(times)
>
> On Mon, Nov 4, 2019 at 8:10 PM Rick Brownrigg via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Hi,
>>
>> You can convert characters to strings via the tostring() function:
>>
>> http://ncl.ucar.edu/Document/Functions/Built-in/tostring.shtml
>>
>> With regard to "...change 4 to 5." I'm not sure what you are trying to
>> do there, but NCL is strongly typed, in both data type and array
>> dimensions. Perhaps use tostring() in conjunction with a new array name (?)
>>
>> Rick
>>
>> On Mon, Nov 4, 2019 at 7:41 PM Zhifeng Yang via ncl-talk <
>> ncl-talk at ucar.edu> wrote:
>>
>>> Hi
>>> I am reading wrf output which has variable Times as character. When I
>>> read it using NCL, the Times variable is still character, not string. I
>>> want to change the Times variable using NCL. For example,
>>>
>>> Variable: times
>>>
>>> Type: character
>>>
>>> Total Size: 19 bytes
>>>
>>> 19 values
>>>
>>> Number of Dimensions: 2
>>>
>>> Dimensions and sizes: [Time | 1] x [DateStrLen | 19]
>>>
>>> Coordinates:
>>>
>>> Number Of Attributes: 0
>>>
>>> (0,0) 2
>>>
>>> (0,1) 0
>>>
>>> (0,2) 1
>>>
>>> (0,3) 4
>>>
>>> (0,4) -
>>>
>>> (0,5) 0
>>>
>>> (0,6) 5
>>>
>>> (0,7) -
>>>
>>> (0,8) 2
>>>
>>> (0,9) 5
>>>
>>> (0,10) _
>>>
>>> (0,11) 0
>>>
>>> (0,12) 0
>>>
>>> (0,13) :
>>>
>>> (0,14) 0
>>>
>>> (0,15) 0
>>>
>>> (0,16) :
>>>
>>> (0,17) 0
>>>
>>> (0,18) 0
>>>
>>> I want to change 4 to 5. I tried
>>>
>>> times(0, 3) = "5"
>>> "5" is a string, not a character. I got the following error.
>>>
>>> fatal:Assignment type mismatch, right hand side can't be coerced to type
>>> of left hand side
>>>
>>> Do you have any suggestions? Thank you
>>>
>>> Zhifeng
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191105/cf1921e9/attachment.html>
More information about the ncl-talk
mailing list