[ncl-talk] How to change datatype of dimension in NCL?
haley at ucar.edu
Tue Feb 13 15:09:22 MST 2018
It is hard to debug your problem without seeing your code. For future
purposes, if you ever get an error you don't understand, you can check out
our error page at:
You can then use the browser search to search for the error message you're
Assignment type mismatch, right hand side can't be coerced to type of left
It will take you to this link:
As you pointed out, the issue is simply that you are trying to assign a
variable to another variable that already exists, but that has a type that
it can't be coerced to.
For example, if you do this:
y = 5.5 ; type float
x = 3.8d ; type double
y = x
You will get the error because you are trying to put a double (x) into a
float (y). NCL will not allow you to coerce a "larger" type to a smaller
type, unless you explicitly force it with one of the coercion functions,
y = tofloat(x)
If you are still ending up with a double, then you need to check your
assignment statement very closely.
Possibly there's another variable that's of type double, thus causing the
whole equation to be of type double. Use printVarSummary to verify the type
of every variable in your equation to see if any of them are double.
If you continue to have problems, then it would help us if we could see
your code and the exact line where the error occurs. It would also help to
see a printVarSummary of every variable in the equation.
On Mon, Feb 12, 2018 at 11:45 PM, Shikha SIngh <08.singhshikha at gmail.com>
> Dear all,
> I am trying to do a multivariate EOF analysis with two variiables
> (following the example from mjoclivar_14).
> However, when I try to combine all data in one array it gives me the error:
> 'fatal:Assignment type mismatch, right hand side can't be coerced to type
> of left hand side'
> I checked and found that the both the variables are of type float,
> however, dimension (lat, lon, time) in one variable are of data-type float,
> whereas in the other are of type double.
> I tried converting by extracting the dimension individually, converting
> them to float and reassigning to the variable, but it is not working. The
> data type still remains double.
> How do I do it? Kindly help.
> Shikha Singh
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ncl-talk