[ncl-talk] convert string to fortran character

Rick Brownrigg brownrig at ucar.edu
Mon Nov 4 20:05:11 MST 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191104/0e3f70f8/attachment.html>


More information about the ncl-talk mailing list