Re: Coordinate subscript type mismatch.

From: H.Dang <danghy_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 10 2012 - 15:59:11 MDT

Hi Dave,

The type of the variable seems to be very strict? It didn't work for me by
any means, so I had to avoid using it, as I explained to Mary.

The other similar problem in the same code is also related to the convert
of variable types:

205 ;data = new((/2,28/),float, -999.)
206 data = new((/2,28/),double, -999.)
207 ;nox_MIPAS_ave_40_60NS = dble2flt(nox_MIPAS_ave_40_60NS)
208 data(0,:) = nox_MIPAS_ave
209 data(1,:) = nox_modelEY_ave_40_60NS

Originally my code uses line 205 and line 207. The error message is also
like "....can not be coerced to type of...". The problem is solved when I
commented out line 205 and 207, and add line 206. It seems to me that the
float variable can be assigned to double, but a double one has higher
priority? It won't stay in the right hand side of "=" when the left side
hand is a float.

Thank you.

Hongyan
On Wed, Oct 10, 2012 at 1:15 PM, David Brown <dbrown@ucar.edu> wrote:

> I think the problem is that you initially create the variable 'pre_MIPAS'
> as a double with the statement:
>
> pre_MIPAS = plev_MIPAS(ipressure)
>
> In NCL once a variable has been created its type cannot be changed, so the
> next statement:
>
> pre_MIPAS = dble2flt(plev_MIPAS(ipressure))
>
> does indeed create a float value on the right side of the assignment, but
> then it is converted using normal type coercion back into a double for
> assignment to a pre-existing double variable. (See
> http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclDataTypes.shtml#Coercion
> .)
>
> The cure, I think, is simply to eliminate the first statement:
>
> pre_MIPAS = plev_MIPAS(ipressure)
>
> so that you are creating 'pre_MIPAS' as a float in the first place.
> -dave
>
>
> On Oct 10, 2012, at 10:30 AM, Mary Haley wrote:
>
> > Hongyan,
> >
> > I don't think I've see this type of error before, so I don't fully
> understand it. (Dave, can you help out here?)
> >
> > Line 168 is
> >
> >> 168 nox_modelEY_ave_40_60NS(ipressure) =
> avg(vNOx({pre_MIPAS},{40:60},:))
> >
> > I need to see what those variables look like:
> >
> > printVarSummary(nox_modelEY_ave_40_60NS)
> > printVarSummary(vNOx)
> >
> > My feeling is that there's an issue with the way you are subscripting
> vNOx, so
> > I need to see what its coordinate arrays look like.
> >
> > --Mary
> >
> > On Oct 8, 2012, at 8:37 PM, H.Dang wrote:
> >
> >> Dear all,
> >>
> >> I got the following error information in my NCL code:
> >>
> >> fatal:Coordinate subscript type mismatch. Subscript (0) can not be
> coerced to type of coordinate variable
> >> fatal:["Execute.c":7556]:Execute: Error occurred at or near line 168 in
> file obs_mdl.ncl
> >>
> >>
> >> 161 do ipressure = 0,28 - 1
> >> 162 pre_MIPAS = plev_MIPAS(ipressure)
> >> 163 pre_MIPAS = dble2flt(plev_MIPAS(ipressure))
> >> 164
> >> 165 printVarSummary(pre_MIPAS)
> >> 166 printVarSummary(ple40)
> >> 167 ;
> >> 168 nox_modelEY_ave_40_60NS(ipressure) =
> avg(vNOx({pre_MIPAS},{40:60},:))
> >> 179 end do
> >>
> >> The summary of the variables are:
> >>
> >> Variable: pre_MIPAS
> >> Type: double
> >> Total Size: 8 bytes
> >> 1 values
> >> Number of Dimensions: 1
> >> Dimensions and sizes: [1]
> >> Coordinates:
> >> Number Of Attributes: 7
> >> typeConversion_op_ncl : double converted to float
> >> units : hPa
> >> long_name : pressure
> >> axis : Z
> >> positive : down
> >> standard_name : air_pressure
> >> plev : 300
> >>
> >> Variable: ple40
> >> Type: float
> >> Total Size: 160 bytes
> >> 40 values
> >> Number of Dimensions: 1
> >> Dimensions and sizes: [ple | 40]
> >> Coordinates:
> >> ple: [964..0.1]
> >> Number Of Attributes: 1
> >> units : mb
> >>
> >> I though the error is caused by the variable type, but when I used
> "dble2flt" to convert the type from double to float, the error message is
> till the same. So is my idea of converting correct or not? How should I
> fix this problem? Thank you!
> >>
> >> Hongyan
> >>
> >> _______________________________________________
> >> ncl-talk mailing list
> >> List instructions, subscriber options, unsubscribe:
> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 10 16:00:01 2012

This archive was generated by hypermail 2.1.8 : Fri Oct 12 2012 - 15:38:19 MDT