[ncl-talk] assignment type missmatch

Dennis Shea shea at ucar.edu
Wed Aug 31 05:39:45 MDT 2016


NCL is a strongly typed language. It will not allow

   i = f _d   ; i= variable of type integer, f_d= variable of type float or
double

You would have to use a function (toint, totype, etc)
=====
Further, you did not indicate twhat line 195 is. Please use print
statements and look at the 'type' on the left and right sides of the
assignment statement.

   x = ...
   y = ...
   printVarSummary(x)
   printVarSummary(y)

   y = ... x ...    <line 195

=====================================================

hp1 = "/home/pknu/pknuicon/util/KOR_adm/KOR_adm1.shp"

  o = addfile("/home/pknu/pknuicon/util/GLOBAL_FRLAND.nc","r")
  oro = o->fr

  a1 = addfile("./ensmean/icon_T2M_2016SON_compare.grb","r")
  i_data = a1->TMP_P1_L103_GLL0

  i_temp = where(oro.gt.0.5, i_temp-273.16, i_temp at _FillValue)

; look at variable 'evolution'

  printVarSummary(i_temp)
  copy_VarCoords(i_data, i_temp)
  printVarSummary(i_temp)
  i_temp at long_name = i_data at long_name
  i_temp at units = "degC"
  printVarSummary(i_temp)


  do the same for g_temp ... *look* at variable types.

==An excellent tutorial=>

http://www.ncl.ucar.edu/Document/Manuals/

See the DKRZ tutorials


On Wed, Aug 31, 2016 at 5:07 AM, 김가은 <gaeun.kim0921 at gmail.com> wrote:

> Hi
>
> I have been tried 'copy_VarCoords' several times and in this way it
> normally works. but this time I cannot!
>
> below is ncl script I wrote:
> begin
>   shp1 = "/home/pknu/pknuicon/util/KOR_adm/KOR_adm1.shp"
>
>   o = addfile("/home/pknu/pknuicon/util/GLOBAL_FRLAND.nc","r")
>   oro = o->fr(0,:,:)
>
>   a1 = addfile("./ensmean/icon_T2M_2016SON_compare.grb","r")
>   i_data = a1->TMP_P1_L103_GLL0
>   time=a1->initial_time0_hours
>   lon=a1->lon_0
>   lat=a1->lat_0
>   nlon=dimsizes(lon)
>   nlat=dimsizes(lat)
>
>   lon at units="degrees_east"
>   lat at units="degrees_north"
>   i_data&lon_0=lon
>   i_data&lat_0=lat
>   i_data&initial_time0_hours=time
>
>   i_temp = i_data
>
>   do n = 1, 3
>      i_temp(n-1,:,:) = i_data(n-1,:,:)
>      i_temp(n-1,:,:) = i_temp(n-1,:,:) - 273.16
>      i_temp(n-1,:,:) = where(oro.gt.0.5,i_temp(n-1,:,:),i_temp at _FillValue)
>   end do
>
>   printVarSummary(i_temp)
>
>   b1 = addfile("./gme_out/gme_T2M_2016SON_compare.grb","r")
>   g_data = b1->T_GDS0_HTGL
>
>   printVarSummary(g_data)
>   copy_VarCoords(i_temp, g_data)
>
>   g_temp = g_data
>
>   do n = 1, 3
>      g_temp(n-1,:,:) = g_data(n-1,:,:)
>      g_temp(n-1,:,:) = g_temp(n-1,:,:) - 273.16
>      g_temp(n-1,:,:) = where(oro.gt.0.5,g_temp(n-1,:,:),g_temp at _FillValue)
>   end do
>
>   temp_diff = i_temp - g_temp
>   temp_diff at units = "degree C"
>
>
> and I keep getting this error message:
>
> Variable: i_data
> Type: float
> Total Size: 4870800 bytes
>             1217700 values
> Number of Dimensions: 3
> Dimensions and sizes: [initial_time0_hours | 3] x [lat_0 | 451] x [lon_0
> | 900]
> Coordinates:
>             initial_time0_hours: [1899264..1900728]
>             lat_0: [-90..90]
>             lon_0: [ 0..359.6]
> Number Of Attributes: 12
>   center : Offenbach (RSMC)
>   production_status : Operational products
>   long_name : Temperature
>   units : K
>   _FillValue : 1e+20
>   grid_type : Latitude/longitude
>   parameter_discipline_and_category : Meteorological products, Temperature
>   parameter_template_discipline_category_number : ( 1, 0, 0, 0 )
>   level_type : Specified height level above ground (m)
>   level : 2
>   forecast_time : 0
>   forecast_time_units : hours
>
> Variable: g_data
> Type: float
> Total Size: 4870800 bytes
>             1217700 values
> Number of Dimensions: 3
> Dimensions and sizes: [forecast_time0 | 3] x [g0_lat_1 | 451] x [g0_lon_2
> | 900]
> Coordinates:
>             forecast_time0: [1008..2472]
>             g0_lat_1: [-90..90]
>             g0_lon_2: [ 0..359.6]
> Number Of Attributes: 10
>   center : Offenbach (RSMC)
>   long_name : temperature
>   units : K
>   _FillValue : 1e+20
>   level_indicator : 105
>   gds_grid_type : 0
>   parameter_table_version : 2
>   parameter_number : 11
>   level : 2
>   initial_time : 07/21/2016 (00:00)
> fatal:["NclVar.c":1382]:Assignment type mismatch, right hand side can't
> be coerced to type of left hand side
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 195 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 40 in
> file 6.compare_monthly.ncl
>
> thanks for your help!
>
> Gaeun
>
> _______________________________________________
> 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/20160831/3f5dd12f/attachment.html 


More information about the ncl-talk mailing list