Re: array error

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Mon, 09 Feb 2009 15:27:16 -0700

Strange. Try this to see in detail what's going on. Line 6 will
probably fail. That's okay, that is what we are trying to trace.

nlats = dimsizes (LAT)
nlons = dimsizes (LON)

printVarSummary (nt)
printVarSummary (nlats)
printVarSummary (nlons)

dims = (/nt,nlats,nlons/)
print (dims)

--Dave

Erik Noble wrote:
> Dear Debasish,
> Thank you. ....just trying to understand, though.
> You wrote:
> "Instead of using
> daily_arr = new((/29,LAT,LON/),float)
> Please use
> daily_arr = new((/12,dimsizes(LAT),dimsizes(LON)/),float)
> ..."
> I did a similar command already.
> ncl 22> daily_arr = new((/nt,dimsizes(LAT),dimsizes(LON)/),float)
> fatal:_NclBuildArray: each element of a literal array must have the same
> dimension sizes, at least one item doesn't
> fatal:Execute: Error occurred at or near line 22
>
> Shouldn't this work? I'm trying the other suggestions, too.
> -Erik
>
>
> On Mon, Feb 9, 2009 at 3:50 PM, Debasish Pai Mazumder
> <debasish_at_gi.alaska.edu <mailto:debasish_at_gi.alaska.edu>> wrote:
>
> Dear Erik,
>
>
>
> Instead of using
>
> daily_arr = new((/29,LAT,LON/),float)
>
>
>
> Please use
>
>
>
> daily_arr = new((/12,dimsizes(LAT),dimsizes(LON)/),float)
>
>
>
> Then you can declare daily_arr's dimension as LAT and LON
>
>
>
> daily_arr!1="LAT"
>
> daily_arr!2="LON"
>
> daily_arr &LAT=LAT
>
> daily_arr &LON=LON
>
>
>
> Thanks
>
>
>
> Debasish
>
>
>
>
>
> ------------------------------------------------------------------------
>
> *From:* ncl-talk-bounces_at_ucar.edu <mailto:ncl-talk-bounces_at_ucar.edu>
> [mailto:ncl-talk-bounces_at_ucar.edu
> <mailto:ncl-talk-bounces_at_ucar.edu>] *On Behalf Of *Erik Noble
> *Sent:* Monday, February 09, 2009 11:23 AM
> *To:* ncl-talk_at_ucar.edu <mailto:ncl-talk_at_ucar.edu>
> *Subject:* [ncl-talk] array error
>
>
>
> Hi.
>
> Could I have help understanding why this error is occurring when
> creating an array in NCL?
>
> When I create the array with numbers, I have no problem:
>
> ncl 17> daily_arr = new((/29,15,21/),float)
>
> ncl 18>
>
>
>
> Yet, when I try to use scripting, I get an error:
>
> ncl 23> daily_arr = new((/nt,LAT,LAN/),float)
>
>
> fatal:_NclBuildArray: each element of a literal array must have the
> same dimension sizes, at least one item doesn't
>
>
>
> Also, where is this error described in the NCL docs?
>
> Thank you for your time ahead of time.
>
> Sincerely,
>
> Erik
>
>
>
> bash-3.1$ ncl
>
> Copyright (C) 1995-2007 - All Rights Reserved
>
> University Corporation for Atmospheric Research
>
> NCAR Command Language Version 5.0.0
>
> The use of this software is governed by a License Agreement.
>
> See http://www.ncl.ucar.edu/ for more details.
>
> ncl 0> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>
> ncl 1> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> ncl 2> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> ncl 3> a =
> addfile("Daily_Region_2_WRF-GFS_SEP_1st-24-hours-forecasts-00Z.nc","r")
>
> ncl 4> lat2d = a->XLAT(0,0,:,:) ; WRF_grid lats
>
> ncl 5> lon2d = a->XLONG(0,0,:,:) ; WRF_grid lons
>
> ncl 6> rainnc = a->RAINNC ; Total Grid Scale Precipitation
>
> ncl 7> rainc = a->RAINC ; Accumulated Total Cumulus Precipitation
>
> ncl 8> times=a->Times
>
> ncl 9>
>
> ncl 10> nt = times(:,0,0) ; should be 29 days
>
> ncl 11> ;nt = 29
>
> ncl 12> printVarSummary(nt)
>
>
>
>
>
> Variable: nt
>
> Type: character
>
> Total Size: 29 bytes
>
> 29 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes: [record | 29]
>
> Coordinates:
>
> Number Of Attributes: 0
>
> ncl 13> LAT = lat2d(:,0)
>
> ncl 14> LON = lon2d(0,:)
>
> ncl 15> printVarSummary(LAT)
>
>
>
>
>
> Variable: LAT
>
> Type: float
>
> Total Size: 60 bytes
>
> 15 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes: [south_north | 15]
>
> Coordinates:
>
> Number Of Attributes: 5
>
> stagger :
>
> units : degree_north
>
> description : LATITUDE, SOUTH IS NEGATIVE
>
> MemoryOrder : XY
>
> FieldType : 104
>
> ncl 16> printVarSummary(LON)
>
>
>
>
>
> Variable: LON
>
> Type: float
>
> Total Size: 84 bytes
>
> 21 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes: [west_east | 21]
>
> Coordinates:
>
> Number Of Attributes: 5
>
> stagger :
>
> units : degree_east
>
> description : LONGITUDE, WEST IS NEGATIVE
>
> MemoryOrder : XY
>
> FieldType : 104
>
> ncl 17> daily_arr = new((/29,15,21/),float)
>
> ncl 18> printVarSummary(daily_arr)
>
>
>
>
>
> Variable: daily_arr
>
> Type: float
>
> Total Size: 36540 bytes
>
> 9135 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes: [29] x [15] x [21]
>
> Coordinates:
>
> Number Of Attributes: 1
>
> _FillValue : -999
>
> ncl 19> delete(daily_arr)
>
> ncl 20> daily_arr = new((/29,LAT,LON/),float)
>
> fatal:_NclBuildArray: each element of a literal array must have the
> same dimension sizes, at least one item doesn't
>
> fatal:Execute: Error occurred at or near line 20
>
>
>
> ncl 21> delete(daily_arr)
>
> fatal:Variable (daily_arr) is undefined
>
> fatal:Execute: Error occurred at or near line 21
>
>
>
> ncl 22> daily_arr = new((/nt,dimsizes(LAT),dimsizes(LON)/),float)
>
> fatal:_NclBuildArray: each element of a literal array must have the
> same dimension sizes, at least one item doesn't
>
> fatal:Execute: Error occurred at or near line 22
>
>
>
> ncl 23> daily_arr = new((/nt,LAT,LAN/),float)
>
>
> fatal:_NclBuildArray: each element of a literal array must have the
> same dimension sizes, at least one item doesn't
>
> fatal:Execute: Error occurred at or near line 23
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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 Mon Feb 09 2009 - 15:27:16 MST

This archive was generated by hypermail 2.2.0 : Thu Feb 12 2009 - 10:16:44 MST