[ncl-talk] Change type of coordinate variable

David Brown dbrown at ucar.edu
Tue Aug 15 12:12:25 MDT 2017


The simple way is to use the reassignment operator (':=") instead of
simple assignment using '='

var&pre := pi

The longer way is to delete the integer coordinate and then assign the
float values

delete(var&pre)
var&pre = pi

 -dave


On Tue, Aug 15, 2017 at 11:29 AM, James Russell <jorussel at ncsu.edu> wrote:
> Hi all,
>
> I'm trying to change the coordinate of a variable from an integer to a
> float. Specifically, I have a variable with the vertical coordinate of
> pressure which is currently an integer. I'm changing the vertical coordinate
> to pi (non-dimensionalized pressure) which will need be a float. However
> whenever I try to assign the new coordinate pi, with the code:
>
> var&pre = pi
>
> I obviously get the error:
>
> fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be
> coerced to type of left hand side
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 74 in file
> ert_inv.ncl
>
> Since it's a coordinate variable I can't think of a way to use tofloat to
> convert the current coordinate array from an integer to a float as I don't
> want to re-write the whole variable.
>
> Does anyone know of a way that I can assign the new coordinate without just
> re-writing the whole variable?
>
> Thanks,
> James
>
> ------------------------------------------------------------------------------------
> Graduate Research & Teaching Assistant
> PhD Student: Atmospheric Science
> Department of Marine, Earth, and Atmospheric Sciences
> North Carolina State University
> http://www4.ncsu.edu/~jorussel
> --------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list