<div dir="ltr">Dear NCL users,<div><br></div><div>I&#39;ve been using NCL for post-processing some WRF output files: the script &quot;crops&quot; the domain and interpolates some variables at some pressure levels. When I run my script, I get this error:</div><div><br></div><div><div>fatal:Dimension sizes of left hand side do not match right hand side</div><div>fatal:[&quot;Execute.c&quot;:8575]:Execute: Error occurred at or near line 140 in file test_crop_3d.ncl</div><div><br></div><div>fatal:Dimension sizes of left hand side do not match right hand side</div><div>fatal:[&quot;Execute.c&quot;:8575]:Execute: Error occurred at or near line 141 in file test_crop_3d.ncl</div><div><br></div><div>fatal:Dimension sizes of left hand side do not match right hand side</div><div>fatal:[&quot;Execute.c&quot;:8575]:Execute: Error occurred at or near line 142 in file test_crop_3d.ncl</div><div><br></div><div>fatal:Dimension sizes of left hand side do not match right hand side</div><div>fatal:[&quot;Execute.c&quot;:8575]:Execute: Error occurred at or near line 143 in file test_crop_3d.ncl</div></div><div><br></div><div>I looked at this kind of error in the archives, but didn&#39;t find any solution. Lines 140 to 143 are the following lines:</div><div><br></div><div><div>fout-&gt;U250 = (/u250/)</div><div>fout-&gt;U500 = (/u500/)</div><div>fout-&gt;V250 = (/v250/)</div><div>fout-&gt;V500 = (/v500/)</div></div><div><br></div><div>Here&#39;s the full script:</div><div><br></div><div><div>;------------------------------------------------------------</div><div>;Getting coordinates and indices to crop the domain</div><div>;------------------------------------------------------------</div><div>fname_coords = &quot;./<a href="http://wrfout_constants.nc">wrfout_constants.nc</a>&quot;</div><div>f_coords = addfile(fname_coords,&quot;r&quot;)</div><div><br></div><div>lon = f_coords-&gt;XLONG(0,:,:)</div><div>lat = f_coords-&gt;XLAT(0,:,:)</div><div><br></div><div>latN = 60.0</div><div>latS = 40.0</div><div>lonW = -140.0</div><div>lonE = -85.0</div><div><br></div><div>hpa = 0.01</div><div><br></div><div>ij = region_ind(lat,lon,latS,latN,lonW,lonE)</div><div><br></div><div>iStrt = ij(0)</div><div>iLast = ij(1)</div><div>jStrt = ij(2)</div><div>jLast = ij(3)</div><div><br></div><div>new_lat = lat(iStrt:iLast,jStrt:jLast)</div><div>new_lon = lon(iStrt:iLast,jStrt:jLast)</div><div><br></div><div>;------------------------------------------------------------</div><div>;Opening files</div><div>;------------------------------------------------------------</div><div>f = addfile(&quot;wrf3d_d01_2013-06-01_00:00:00&quot;,&quot;r&quot;)</div><div><br></div><div>;-------------------------------------------------------------</div><div>;Create new netCDF file</div><div>;-------------------------------------------------------------</div><div>dims = dimsizes(new_lat)</div><div>ny = dims(0)</div><div>nx = dims(1)</div><div><br></div><div>i=0</div><div><br></div><div>time = f-&gt;Times(i,:)</div><div>tk = f-&gt;TK(i,:,iStrt:iLast,jStrt:jLast)</div><div>p = f-&gt;P(i,:,iStrt:iLast,jStrt:jLast)</div><div>z_tmp = f-&gt;Z(i,:,iStrt:iLast,jStrt:jLast)</div><div>qvapor = f-&gt;QVAPOR(i,:,iStrt:iLast,jStrt:jLast)</div><div>u_tmp = f-&gt;U(i,:,iStrt:iLast,jStrt:jLast)</div><div>v_tmp = f-&gt;V(i,:,iStrt:iLast,jStrt:jLast)</div><div><br></div><div>;Unstagger some variables</div><div>z = wrf_user_unstagger(z_tmp,z_tmp@stagger)</div><div>;u = wrf_user_unstagger(u_tmp,u_tmp@stagger)</div><div>;v = wrf_user_unstagger(v_tmp,v_tmp@stagger)</div><div>u = u_tmp</div><div>v = v_tmp</div><div><br></div><div>;Compute RH</div><div>rh = wrf_rh(qvapor,p,tk)</div><div><br></div><div>;Interpolation at pressure levels</div><div>;250 mb</div><div>u250 = wrf_user_intrp3d(u,p*hpa,&quot;h&quot;,250,0.,False)</div><div>v250 = wrf_user_intrp3d(v,p*hpa,&quot;h&quot;,250,0.,False)</div><div>z250 = wrf_user_intrp3d(z,p*hpa,&quot;h&quot;,250,0.,False)</div><div>t250 = wrf_user_intrp3d(tk,p*hpa,&quot;h&quot;,250,0.,False)</div><div>rh250 = wrf_user_intrp3d(rh,p*hpa,&quot;h&quot;,250,0.,False)</div><div>;500 mb</div><div>u500 = wrf_user_intrp3d(u,p*hpa,&quot;h&quot;,500,0.,False)</div><div>v500 = wrf_user_intrp3d(v,p*hpa,&quot;h&quot;,500,0.,False)</div><div>z500 = wrf_user_intrp3d(z,p*hpa,&quot;h&quot;,500,0.,False)</div><div>t500 = wrf_user_intrp3d(tk,p*hpa,&quot;h&quot;,500,0.,False)</div><div>rh500 = wrf_user_intrp3d(rh,p*hpa,&quot;h&quot;,500,0.,False)</div><div>;sfc</div><div>psfc = p(0,:,:)</div><div>slp = wrf_slp(z,tk,p,qvapor)</div><div>rh0 = rh(0,:,:)</div><div><br></div><div>;Output Files</div><div>diro = &quot;./&quot;</div><div>filo = &quot;wrf_lvls_&quot;+time+&quot;.nc&quot;</div><div>system(&quot;/bin/rm -f &quot;+diro+filo)    ; remove if exists</div><div>fout  = addfile(diro+filo,&quot;c&quot;)  ; open output file</div><div><br></div><div>setfileoption(fout,&quot;DefineMode&quot;,True)</div><div><br></div><div>;Global attributes</div><div>fAtt = True</div><div>fAtt@title = &quot;Cropped and interpolated (sfc, 500 mb and 250 mb) data files from Liu et al. (2016) simulations&quot;</div><div>fAtt@Conventions = &quot;None&quot;</div><div>fAtt@creation_date = systemfunc(&quot;date&quot;)</div><div>fileattdef(fout,fAtt)</div><div><br></div><div>;Dimensions of coordinates</div><div>dimNames = (/&quot;Time&quot;,&quot;south_north&quot;,&quot;west_east&quot;,&quot;south_north_stag&quot;,&quot;west_east_stag&quot;,&quot;DateStrLen&quot;/)</div><div>dimSizes = (/-1,ny,nx,ny+1,nx+1,19/)</div><div>dimUnlim = (/True,False,False,False,False,False/)</div><div>filedimdef(fout,dimNames,dimSizes,dimUnlim)</div><div><br></div><div>;... of variables</div><div>filevardef(fout,&quot;Times&quot;,typeof(time),getvardims(time))</div><div>filevardef(fout,&quot;XLAT&quot;,typeof(new_lat),getvardims(new_lat))</div><div>filevardef(fout,&quot;XLONG&quot;,typeof(new_lon),getvardims(new_lon))</div><div>filevardef(fout,&quot;U250&quot;,typeof(u250),getvardims(u250))</div><div>filevardef(fout,&quot;U500&quot;,typeof(u500),getvardims(u500))</div><div>filevardef(fout,&quot;V250&quot;,typeof(v250),getvardims(v250))</div><div>filevardef(fout,&quot;V500&quot;,typeof(v500),getvardims(v500))</div><div>filevardef(fout,&quot;Z250&quot;,typeof(z250),getvardims(z250))</div><div>filevardef(fout,&quot;Z500&quot;,typeof(z500),getvardims(z500))</div><div>filevardef(fout,&quot;T250&quot;,typeof(t250),getvardims(t250))</div><div>filevardef(fout,&quot;T500&quot;,typeof(t500),getvardims(t500))</div><div>filevardef(fout,&quot;RH250&quot;,typeof(rh250),getvardims(rh250))</div><div>filevardef(fout,&quot;RH500&quot;,typeof(rh500),getvardims(rh500))</div><div>filevardef(fout,&quot;RH0&quot;,typeof(rh0),getvardims(rh0))</div><div>filevardef(fout,&quot;PSFC&quot;,typeof(psfc),getvardims(psfc))</div><div>filevardef(fout,&quot;SLP&quot;,typeof(slp),getvardims(slp))</div><div><br></div><div>;Copy attributes</div><div>;filevarattdef(fout,&quot;Times&quot;,time)</div><div>filevarattdef(fout,&quot;XLAT&quot;,new_lat)</div><div>filevarattdef(fout,&quot;XLONG&quot;,new_lon)</div><div>filevarattdef(fout,&quot;U250&quot;,u250)</div><div>filevarattdef(fout,&quot;U500&quot;,u500)</div><div>filevarattdef(fout,&quot;V250&quot;,v250)</div><div>filevarattdef(fout,&quot;V500&quot;,v500)</div><div>filevarattdef(fout,&quot;Z250&quot;,z250)</div><div>filevarattdef(fout,&quot;Z500&quot;,z500)</div><div>filevarattdef(fout,&quot;T250&quot;,t250)</div><div>filevarattdef(fout,&quot;T500&quot;,t500)</div><div>filevarattdef(fout,&quot;RH250&quot;,rh250)</div><div>filevarattdef(fout,&quot;RH500&quot;,rh500)</div><div>filevarattdef(fout,&quot;RH0&quot;,rh0)</div><div>filevarattdef(fout,&quot;PSFC&quot;,psfc)</div><div>filevarattdef(fout,&quot;SLP&quot;,slp)</div><div><br></div><div>setfileoption(fout,&quot;DefineMode&quot;,False)</div><div><br></div><div>;Output variables</div><div>fout-&gt;Times = (/time/)</div><div>fout-&gt;XLAT = (/new_lat/)</div><div>fout-&gt;XLONG = (/new_lon/)</div><div>fout-&gt;U250 = (/u250/)</div><div>fout-&gt;U500 = (/u500/)</div><div>fout-&gt;V250 = (/v250/)</div><div>fout-&gt;V500 = (/v500/)</div><div>fout-&gt;Z250 = (/z250/)</div><div>fout-&gt;Z500 = (/z500/)</div><div>fout-&gt;T250 = (/t250/)</div><div>fout-&gt;T500 = (/t500/)</div><div>fout-&gt;RH250 = (/rh250/)</div><div>fout-&gt;RH500 = (/rh500/)</div><div>fout-&gt;RH0 = (/rh0/)</div><div>fout-&gt;PSFC = (/psfc/)</div><div>fout-&gt;SLP = (/slp/)</div></div><div>-------------------------------------------------------------------------------------------------------</div><div><br></div><div>I think there is a problem with the staggered coordinates, but I can&#39;t put the finger on it...</div><div><br></div><div>Thanks for the help,</div><div>Sebastien.</div></div>