[ncl-talk] Error: dimension sizes of left and right hand side do not match

Toni Klemm toni-klemm at tamu.edu
Wed Oct 23 14:11:51 MDT 2019


Adam and Rick,

Adam’s suggestion worked! I added this at the beginning:

	lat_1!0 = "lat_1"
	lat_1&lat_1 = lat_1
	lat_2!0 = "lat_2"
	lat_2&lat_2 = lat_2
	lat_3!0 = "lat_3"
	lat_3&lat_3 = lat_3

and deleted all these variables after each loop:

	delete([/lat_1,lat_2,lat_3/])

which made it work.


Thank you both so much!

Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://www.twitter.com/toniklemm>
Editorial Board member, Early Career Climate Forum <http://www.eccforum.org/>








> On Oct 23, 2019, at 3:00 PM, Adam Phillips <asphilli at ucar.edu> wrote:
> 
> Hi Toni,
> I think it is due to the lat coordinate variable being different sizes between lat_1, and lat_2/lat_3. This would result in the error you are seeing, as NCL is trying to write lat of size 169 for lat_1, but lat of size 145 for the other two arrays. The solution would be to rename the lat coordinate variable for lat_2 and lat_3 to something other than lat. 
> Best,
> Adam
> 
> 
> 
> On Wed, Oct 23, 2019 at 1:50 PM Toni Klemm via ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>> wrote:
> Hi Rick,
> 
> Sadly, that’s not the problem. It occurs in the very first loop already.
> 
> However, I just commented out 
> 
> ;		ncdf->lat_1 = lat_1
> 
> which is three lines above the line that doesn’t work, and now the script runs without problems. I still don’t understand why this is happening. Could it be a bug in NCL, some sort of problem with too many variables in an output file?
> 
> Toni
> 
> 
> Toni Klemm, Ph.D.
> Postdoctoral Research Associate
> Department of Ecosystem Science and Management
> College of Agriculture and Life Sciences
> Texas A&M University, College Station, TX
> www.toni-klemm.de <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm.de&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=3goynaUxE6bIGN_BwfKDegMujDbwQEyUIv55NedpoMY&s=MLkGvux6ITgYfOIaq3-xftJDmDiFBusmvySaj-9vBUA&e=> | @toniklemm <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.twitter.com_toniklemm&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=3goynaUxE6bIGN_BwfKDegMujDbwQEyUIv55NedpoMY&s=Qc1X2aAVzYRgKHesvKdoUUSayNLtAFtq0VNT4EfFsgw&e=>
> Editorial Board member, Early Career Climate Forum <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=3goynaUxE6bIGN_BwfKDegMujDbwQEyUIv55NedpoMY&s=3bIXuf0rWhXZIYu6SvXwzBHFlBWUujDNBBUcNw7RZpQ&e=>
> 
> 
> 
> 
> 
> 
> 
> 
>> On Oct 23, 2019, at 2:43 PM, Rick Brownrigg <brownrig at ucar.edu <mailto:brownrig at ucar.edu>> wrote:
>> 
>> Hi (offline for a moment):
>> 
>> I can not see the problem either. I note that the lines in question are in a doubly-nested loop. Does this error occur on the very first attempt at writing a netcdf?  Each time through the loop(s), you are reassigning the filevariable ncdf -- I'm wondering if the "previous" file is not getting closed or perhaps the var ncdf retains some stale information?  Perhaps just before the end of the "if (netCDF1) " statement, place a delete(ncdf), which somewhat counterintuitively, will close the file.
>> 
>> Rick
>> 
>> On Wed, Oct 23, 2019 at 1:03 PM Toni Klemm via ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>> wrote:
>> Hello NCL Community,
>> 
>> I am perplexed by what seems to be a very simple error in my script (attached). I am analyzing gridded data for the U.S. Great Plains region and have divided the region into 6 parts, Northern, Central, and Southern Plains as well as each of them into east and west. 
>> 
>> After analyzing the data I am assembling everything to save in an output file, but for some reason this line in my code
>> 
>> ncdf->lat_2 = lat_2
>> 
>> gets this error message and the program crashes:
>> 
>> Dimension sizes of left hand side do not match right hand side
>> 
>> “lat_2” is the latitude dimension associated with the Central Plains data.
>> 
>> “lat_1” three lines above it does not get an error, but when I comment lat_2 out, then lat_3, three lines down, gets the same error.
>> 
>> I looked very carefully and changed the script in a number of ways, but I cannot find the reason for this error. lat_1 is longer than lat_2 and lat_3 (see below), but that shouldn’t be the reason.
>> 
>> I did a printVarSummary on all three, but it didn’t give me any clues:
>> 
>> Variable: lat_1
>> Type: float
>> Total Size: 676 bytes
>>             169 values
>> Number of Dimensions: 1
>> Dimensions and sizes:	[lat | 169]
>> Coordinates: 
>>             lat: [42..49]
>> Number Of Attributes: 2
>>   long_name :	latitude
>>   units :	degrees_north
>> 
>> Variable: lat_2
>> Type: float
>> Total Size: 580 bytes
>>             145 values
>> Number of Dimensions: 1
>> Dimensions and sizes:	[lat | 145]
>> Coordinates: 
>>             lat: [36..42]
>> Number Of Attributes: 2
>>   long_name :	latitude
>>   units :	degrees_north
>> 
>> Variable: lat_3
>> Type: float
>> Total Size: 580 bytes
>>             145 values
>> Number of Dimensions: 1
>> Dimensions and sizes:	[lat | 145]
>> Coordinates: 
>>             lat: [30..36]
>> Number Of Attributes: 2
>>   long_name :	latitude
>>   units :	degrees_north
>> 
>> Does anyone have a suggestion? I appreciate your help!
>> 
>> Tank you very much,
>> Toni
>> 
>> 
>> Toni Klemm, Ph.D.
>> Postdoctoral Research Associate
>> Department of Ecosystem Science and Management
>> College of Agriculture and Life Sciences
>> Texas A&M University, College Station, TX
>> www.toni-klemm.de <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm.de&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=sDafbGmyKPR5OQ8WtRt5k5Mo7DoX0xF9js_2lyVQZdE&s=OS40pGsx6HC0-JwGgMzYsIvQgnHirMy8x7lQ1OPcwfQ&e=> | @toniklemm <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.twitter.com_toniklemm&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=sDafbGmyKPR5OQ8WtRt5k5Mo7DoX0xF9js_2lyVQZdE&s=8187HO3W45kOnzV2tJWGiB-WuN9l4rtyMeaHDTvEHqY&e=>
>> Editorial Board member, Early Career Climate Forum <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=sDafbGmyKPR5OQ8WtRt5k5Mo7DoX0xF9js_2lyVQZdE&s=-lfhexfh0FBaS_GYU8rbB3vthAgLH5fzVyWB07-f3Qw&e=>
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=sDafbGmyKPR5OQ8WtRt5k5Mo7DoX0xF9js_2lyVQZdE&s=CPhrZgPJaFLOgKilmyK2qkZkapwM62TOpy6F73wuchc&e=>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=3goynaUxE6bIGN_BwfKDegMujDbwQEyUIv55NedpoMY&s=HV3A5oXW80snmixH2uuI_EeDIWHC3ThGBDiaSDLzQIs&e=>
> 
> -- 
> Adam Phillips 
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cgd.ucar.edu_staff_asphilli_&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=3goynaUxE6bIGN_BwfKDegMujDbwQEyUIv55NedpoMY&s=kLNENGAFYGBsoZ7pJcAmCRkp3vGQAWqPWSheHn7cQUw&e=>   303-497-1726
> 
>  <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cgd.ucar.edu_staff_asphilli&d=DwMFaQ&c=u6LDEWzohnDQ01ySGnxMzg&r=zmhRVp0i4wZ5_1Ujh0fnRXAExHgKLTQu0rZLW7PxKA4&m=3goynaUxE6bIGN_BwfKDegMujDbwQEyUIv55NedpoMY&s=Ex5uYXTeXulrfVBHgUBlW3NGZUhpxxVTIJjpdMqDwjQ&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191023/a738679f/attachment.html>


More information about the ncl-talk mailing list