<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Jayant,<div class=""><br class=""></div><div class=""><div>I found several lines of code that I think might be contributing to this issue.</div><div><br class=""></div><div>First of all, the values that have been assigned in this snippet of code might not be what you expect them to be:</div><div><font face="Menlo" class="">  dNames = getvardims(xo)<br class="">  time  = dNames(0)<br class="">  lev   = dNames(1)<br class="">  lat   = dNames(2)<br class="">  lon   = dNames(3)<br class=""></font><br class=""></div><div>If you print() any of the variables “time”, “lev”, “lat”, or “lon”, the result will just be the scalar <b class="">string</b> “time”, “lev”, “lat”, or “lon”, respectively. Based on the rest of the code, I suspect we really want those variables to contain the coordinate arrays from the variable “xo”.</div><div><br class=""></div><div>When NCL reaches the line:</div><div><font face="Menlo" class="">filevardef(fout, "time" ,typeof(time),getvardims(time))</font></div><div><br class=""></div><div>“typeof(time)” will be “string” as mentioned above, and “getvardims(time)” will actually be a missing value. Really what we want is the coordinate array for “time”, which should show “typeof(time)” as “double” and “getvardims(time)” as “time”.</div><div><br class=""></div><div>Since “time”, “lev”, “lat”, and “lon” are all coordinate arrays associated with the dimensions of the variable “xo”, we can instead access them using NCL’s coordinate array operator ‘&’:</div><div><span style="font-family: Menlo;" class="">  time  = xo&time</span><br class="" style="font-family: Menlo;"><span style="font-family: Menlo;" class="">  lev   = xo&lev</span><br class="" style="font-family: Menlo;"><span style="font-family: Menlo;" class="">  lat   = xo&lat</span><br class="" style="font-family: Menlo;"><span style="font-family: Menlo;" class="">  lon   = xo&lon</span><br class="" style="font-family: Menlo;"></div><div><br class=""></div><div>After making this change, the script should run without showing any error messages. <i class="">However</i>, there is one other issue I found near the end of your script when assigning variables in the output data file:</div><div><font face="Menlo" class="">  fout->time   = (/time/)<br class="">  fout->lev    = (/lev/)<br class="">  fout->lat    = (/lat/)<br class="">  fout->lon    = (/lon/)<br class="">  fout->xo     = (/xo/)<br class=""></font><br class=""></div><div>In this case, “fout->xo” will be assigned only the <b class="">data array</b> of the “xo” script variable. Previously in the script, the <b class="">metadata</b> from the script variable “xo” was assigned to the output file variable named “OX_VMR_avrg”:</div><div><font face="Menlo" class="">  filevarattdef(fout,"OX_VMR_avrg",xo)<br class=""></font></div><div><font face="Menlo" class=""><br class=""></font></div><div>Essentially what this means is that the output file will have a variable named “xo” containing the <b class="">data</b> and a variable named “OX_VMR_avrg” containing only the <b class="">metadata</b>.</div><div><br class=""></div><div>Changing the line:</div><div><span style="font-family: Menlo;" class="">  </span><span style="font-family: Menlo;" class="">fout->xo</span><span style="font-family: Menlo;" class="">     </span><span style="font-family: Menlo;" class="">= </span><span style="font-family: Menlo;" class="">(/</span><span style="font-family: Menlo;" class="">xo</span><span style="font-family: Menlo;" class="">/)</span></div><div>to instead be:</div><div><span style="font-family: Menlo;" class="">  </span><span style="font-family: Menlo;" class="">fout->OX_VMR_avrg</span><span style="font-family: Menlo;" class="">     </span><span style="font-family: Menlo;" class="">= </span><span style="font-family: Menlo;" class="">(/</span><span style="font-family: Menlo;" class="">xo</span><span style="font-family: Menlo;" class="">/)</span></div><div><br class=""></div><div>should eliminate the unnecessary “xo” variable in the output file.</div><div><br class=""></div><div>I hope this helps!</div><div>Kevin</div><div><br class=""><blockquote type="cite" class=""><div class="">Begin forwarded message:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;" class="">From: <b class="gmail_sendername">Jayant</b> <span dir="ltr" class=""><<a href="mailto:jayantkp2979@gmail.com" class="">jayantkp2979@gmail.com</a>></span></div><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class=""><div class=""><div class="gmail_quote">Date: Tue, Oct 31, 2017 at 9:06 PM<br class="">Subject: Re: [ncl-talk] hyi2hyo: rightmost dimension of ps and xi must be the same<br class="">To: Dennis Shea <<a href="mailto:shea@ucar.edu" class="">shea@ucar.edu</a>><br class="">Cc: "<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a>><br class=""><br class=""><br class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Hi Denis,<br class=""></div>Thank you for the corrections. I am expanding the script to write the output in a netcdf file.<br class=""></div>I am getting error with 'filevardef' function. Can you help me fix teh error? Below I paste the complete code.</div><div class="">Thanks in advance,</div><div class="">Jayant</div><div class="">----------------------------</div><div class="">the error code</div><div class=""><span style="font-family: monospace, monospace;" class="">fatal:["Execute.c":8575]:<wbr class="">Execute: Error occurred at or near line 103 in file scr_vregrid_ham.ncl</span><br class=""></div><div class="">----------------------------</div><div class=""><span style="font-family: monospace, monospace;" class="">load "$NCARG_ROOT/lib/ncarg/<wbr class="">nclscripts/csm/gsn_code.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/<wbr class="">nclscripts/csm/gsn_csm.ncl"   <wbr class="">      <span class="Apple-converted-space"> </span><br class="">load "$NCARG_ROOT/lib/ncarg/<wbr class="">nclscripts/csm/contributed.<wbr class="">ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/<wbr class="">nclscripts/esmf/ESMF_<wbr class="">regridding.ncl"<br class="">;<br class="">begin<br class="">;<div class=""><div class="h5"><br class="">  f    = addfile("ham_oxi_aps_T63L31.<wbr class="">nc","r")<br class="">  hyai = f->hyam          ; input A(k)<br class="">  hybi = f->hybm          ; input B(k)<br class="">  xi   = f->OX_VMR_avrg   ; variable to be interpolated<br class="">  printVarSummary(xi)     ; (time,lev,lon,lat);  (0,1,2,3)<br class="">  print("---")<br class=""><br class="">  xi  := xi(time|:,lev|:,lat|:,lon|:)  ; (time,lev,lat,lon); REORDER<br class="">  printVarSummary(xi)     ; (time,lev,lat,lon);  (0,1,2,3)<br class="">  print("---")<br class=""><br class="">  xi   = dim_rmvmean_Wrap(xi)        ; remove zonal means<br class=""> ;xi   = dim_rmvmean_n_Wrap(xi, 0)   ; remove time mean<br class="">  printVarSummary(xi)          ; rmvmean_op_NCL:  dim_rmvmean over dimension(s): lon<br class="">  print("---")<br class=""><br class="">  fP   = addfile("<a href="http://surf_pres_new_exp_echam_exp.nc/" target="_blank" class="">surf_pres_new_exp_<wbr class="">echam_exp.nc</a>","r")<br class="">  psfc = fP->aps          ; surface pressure (Pa)<br class="">  printVarSummary(psfc)   ; (time,lat,lon)<br class="">  print("---")<br class=""><br class="">  PSFC = conform( xi(:,0,:,:), psfc(0,:,:), (/1,2/) )<br class="">  copy_VarMeta(psfc(0,:,:), PSFC(0,:,:))<br class="">  printVarSummary(PSFC)<br class=""><br class="">  sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945, 0.11654, 0.14916, \<br class="">         0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529, 0.60135, 0.66482,    \<br class="">         0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459, 0.97418, 0.99000,    \<br class="">         1.00000/)<br class=""><br class="">  hybo = sigma            ; *your* B(k) [ sigma levels ]<br class="">  nsig = dimsizes(hybo)<br class="">  hyao = new(nsig,typeof(hybo))<br class="">  hyao = 0.0             ; set output A(k) to 0.0<br class=""><br class="">  p0   = 101325           ; reference pressure (Pa)<br class="">  p0@units = "Pa"<br class=""><br class="">  xo   = hyi2hyo_Wrap(p0,hyai,hybi,<wbr class="">PSFC,xi,hyao,hybo,0) ; contributed.ncl<br class="">  printVarSummary(xo)<br class=""></div></div>  ;<br class="">  ; writing output in netdf<br class="">  ;<br class="">  dNames = getvardims(xo)<br class="">  time  = dNames(0)<br class="">  lev   = dNames(1)<br class="">  lat   = dNames(2)<br class="">  lon   = dNames(3)<br class=""><br class="">  ntim  = dimsizes(time)                 ; get dimension sizes <span class="Apple-converted-space"> </span><br class="">  klev  = dimsizes(lev)                 <wbr class="">                             <span class="Apple-converted-space"> </span><br class="">  nlat  = dimsizes(lat) <span class="Apple-converted-space"> </span><br class="">  nlon  = dimsizes(lon)     <span class="Apple-converted-space"> </span><br class=""><br class="">  diro = "./"                     ; Output directory<br class="">  filo = "<a href="http://example.nc/" target="_blank" class="">example.nc</a>"             ; Output file<br class="">  system("/bin/rm -f " + diro + filo)    ; remove if exists<br class="">  fout  = addfile (diro + filo, "c")  ; open output file<br class=""><br class="">  ; explicitly declare file definition mode. Improve efficiency.<br class="">  setfileoption(fout,"<wbr class="">DefineMode",True)<br class=""><br class="">  ; create global attributes of the file<br class="">  fAtt               = True            ; assign file attributes<br class="">  fAtt@title         = "NCL Efficient Approach to netCDF Creation" <span class="Apple-converted-space"> </span><br class="">  fAtt@source_file   = "ham_oxi_aps_T63L31.nc"<br class="">  fAtt@Conventions   = "None"  <span class="Apple-converted-space"> </span><br class="">  fAtt@creation_date = systemfunc ("date")       <span class="Apple-converted-space"> </span><br class="">  fileattdef( fout, fAtt )            ; copy file attributes<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; predefine the coordinate variables and their dimensionality<br class="">  ; Note: to get an UNLIMITED record dimension, we set the dimensionality<br class="">  ; to -1 (or the actual size) and set the dimension name to True.<br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  dimNames = (/"time", "lat", "lon", "lev"/) <span class="Apple-converted-space"> </span><br class="">  dimSizes = (/ ntim ,  nlat,  nlon, klev /)<span class="Apple-converted-space"> </span><br class="">  dimUnlim = (/ True , False, False, False/)  <span class="Apple-converted-space"> </span><br class="">  filedimdef(fout,dimNames,<wbr class="">dimSizes,dimUnlim)<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; predefine the the dimensionality of the variables to be written out<br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; Here we are using NCL functions to facilitate defining<span class="Apple-converted-space"> </span><br class="">  ; each variable's dimension name(s) and type.<span class="Apple-converted-space"> </span><br class="">  ; The following could be replaced with explicit, user defined dimension<span class="Apple-converted-space"> </span><br class="">  ; names different from those associated with the variable in memory.<span class="Apple-converted-space"> </span><br class="">  ; Say, PS(time,lat,lon) in the NCL script. They could be redefined for the file via:<span class="Apple-converted-space"> </span><br class="">  ; filevardef(fout, "PS"   ,typeof(PS) ,(/"TIME","latitude","<wbr class="">longitude"/))<span class="Apple-converted-space"> </span><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  filevardef(fout, "time" ,typeof(time),getvardims(time)<wbr class="">)<span class="Apple-converted-space"> </span><br class="">  filevardef(fout, "lev"  ,typeof(lev),getvardims(lev) )                          <span class="Apple-converted-space"> </span><br class="">  filevardef(fout, "lat"  ,typeof(lat),getvardims(lat)) <wbr class="">                        <span class="Apple-converted-space"> </span><br class="">  filevardef(fout, "lon"  ,typeof(lon),getvardims(lon)) <wbr class="">                        <span class="Apple-converted-space"> </span><br class="">  filevardef(fout, "OX_VMR_avrg"    ,typeof(xo)  ,getvardims(xo))<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; Copy attributes associated with each variable to the file<br class="">  ; All attributes associated with each variable will be copied.<br class="">  ;=============================<wbr class="">==============================<wbr class="">=========<br class="">  filevarattdef(fout,"OX_VMR_<wbr class="">avrg",xo)                ; copy T attributes<br class="">  filevarattdef(fout,"time" ,time)                    ; copy time attributes<br class="">  filevarattdef(fout,"lev"  ,lev)                     ; copy lev attributes<br class="">  filevarattdef(fout,"lat"  ,lat)                     ; copy lat attributes<br class="">  filevarattdef(fout,"lon"  ,lon)                     ; copy lon attributes   <span class="Apple-converted-space"> </span><br class=""> <span class="Apple-converted-space"> </span><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; explicitly exit file definition mode. **NOT REQUIRED**<br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  setfileoption(fout,"<wbr class="">DefineMode",False)<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; output only the data values since the dimensionality and such have<br class="">  ; been predefined. The "(/", "/)" syntax tells NCL to only output the<br class="">  ; data values to the predefined locations on the file.<br class="">  ;=============================<wbr class="">==============================<wbr class="">=========<br class="">  fout->time   = (/time/)    <span class="Apple-converted-space"> </span><br class="">  fout->lev    = (/lev/)<br class="">  fout->lat    = (/lat/)<br class="">  fout->lon    = (/lon/)<span class="Apple-converted-space"> </span><br class="">  fout->xo      = (/xo/)<br class=""><br class="">end</span><br class=""><br class=""></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Oct 31, 2017 at 6:17 PM, Dennis Shea<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:shea@ucar.edu" target="_blank" class="">shea@ucar.edu</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><span style="font-family: monospace, monospace;" class="">I think the refrain 'look at your data' applies here.<br class=""><br class="">===<br class="">There are several<b class=""><span class="Apple-converted-space"> </span>dimension related<span class="Apple-converted-space"> </span></b>issues with your data.<br class=""><br class=""></span></div><div class=""><span style="font-family: monospace, monospace;" class="">[A]</span><span class="Apple-converted-space"> </span>Variable<span class="Apple-converted-space"> </span><b class="">xi<br class=""><br class=""></b></div><div class=""><b class="">xi: <span class="Apple-converted-space"> </span></b><span style="font-family: monospace, monospace;" class=""><span style="color: rgb(0, 0, 255);" class="">[time |<span class="Apple-converted-space"> </span><b class="">12</b>]</span><span class="Apple-converted-space"> </span>x [lev | 31] x<span class="Apple-converted-space"> </span><span style="color: rgb(255, 0, 0);" class=""><b class="">[lon | 192] x [lat | 96]</b></span><br class=""></span><b class=""><span style="font-family: monospace, monospace;" class=""></span></b></div><div class=""><span style="font-family: monospace, monospace;" class=""><br class=""></span><span style="font-family: monospace, monospace;" class=""><span style="font-family: monospace, monospace;" class=""></span></span></div><div class=""><span style="font-family: monospace, monospace;" class="">Note the two rightmost 'spatial' dimensions: names and sizes<br class=""><br class=""></span></div><div class=""><span style="font-family: monospace, monospace;" class="">[B] Variable psfc<br class=""></span><br class=""><span style="font-family: monospace, monospace;" class=""><span style="font-family: monospace, monospace;" class=""><b class="">psfc</b>:<span class="Apple-converted-space"> </span><span style="color: rgb(0, 0, 255);" class="">[time |<span class="Apple-converted-space"> </span><b class="">1</b>]</span><span class="Apple-converted-space"> </span>x<span class="Apple-converted-space"> </span><span style="color: rgb(255, 0, 0);" class=""><b class="">[lat | 96] x [lon | 192]</b></span></span></span></div><div class=""><span style="font-family: monospace, monospace;" class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">----------------------<br class=""><br class=""></span></div><div class=""><span style="font-family: monospace, monospace;" class="">spatial dimensions:<br class=""></span></div><span style="font-family: monospace, monospace;" class="">xi has order (...,lon,lat)     ==> (...,192,96)<br class=""></span></div><span style="font-family: monospace, monospace;" class="">psfc gas order (...,lat,lon)   ==> (...,96,192)<br class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">temporal dimension size<br class=""></span></div><span style="font-family: monospace, monospace;" class="">xi has time=12, psfc=1<br class=""><br class="">-----------------------<br class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">You could expand psfc 12 size 12 but I am not sure that is wht you want to do.<br class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">[C]<br class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">P0 must have a units attribute<br class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">[D]<br class=""><br class=""></span></div><span style="font-family: monospace, monospace;" class="">Did you want to remove the zonal means or the time mena???<br class=""></span><div class=""><div class=""><span style="font-family: monospace, monospace;" class=""><br class="">++++++++++++++++++++++++++++++<wbr class="">++++++++++++++<br class=""><br class=""> <span class="Apple-converted-space"> </span>f    = addfile("ham_oxi_aps_T63L31.nc<wbr class="">","r")<span class=""><br class=""> <span class="Apple-converted-space"> </span>hyai = f->hyam          ; input A(k)<br class=""> <span class="Apple-converted-space"> </span>hybi = f->hybm          ; input B(k)<br class=""></span> <span class="Apple-converted-space"> </span>xi   = f->OX_VMR_avrg   ; variable to be interpolated<br class=""> <span class="Apple-converted-space"> </span>printVarSummary(xi)     ; (time,lev,lon,lat);  (0,1,2,3)<br class=""> <span class="Apple-converted-space"> </span>print("---")<br class=""><br class=""> <span class="Apple-converted-space"> </span>xi  := xi(time|:,lev|:,lat|:,lon|:)  ; (time,lev,lat,lon); REORDER<br class=""> <span class="Apple-converted-space"> </span>printVarSummary(xi)     ; (time,lev,lat,lon);  (0,1,2,3)<br class=""> <span class="Apple-converted-space"> </span>print("---")<br class=""><br class=""> <span class="Apple-converted-space"> </span>xi   = dim_rmvmean_Wrap(xi)        ;<span class="Apple-converted-space"> </span><b class="">remove zonal means</b><br class=""></span></div><div class=""><span style="font-family: monospace, monospace;" class=""> ;xi   = dim_rmvmean_n_Wrap(xi, 0)  <span class="Apple-converted-space"> </span><b class="">; remove time mean</b><br class=""></span></div><div class=""><span style="font-family: monospace, monospace;" class=""> <span class="Apple-converted-space"> </span>printVarSummary(xi)          ; rmvmean_op_NCL:  dim_rmvmean over dimension(s): lon<br class=""> <span class="Apple-converted-space"> </span>print("---")<span class=""><br class=""><br class=""> <span class="Apple-converted-space"> </span>fP   = addfile("<a href="http://surf_pres_new_exp_echam_exp.nc/" target="_blank" class="">surf_pres_new_exp_ech<wbr class="">am_exp.nc</a>","r")<br class=""> <span class="Apple-converted-space"> </span>psfc = fP->aps          ; surface pressure (Pa)<br class=""></span> <span class="Apple-converted-space"> </span>printVarSummary(psfc)   ; (time,lat,lon)<br class=""> <span class="Apple-converted-space"> </span>print("---")<br class=""><br class=""> <span class="Apple-converted-space"> </span>PSFC = conform( xi(:,0,:,:), psfc(0,:,:), (/1,2/) )<br class=""> <span class="Apple-converted-space"> </span>copy_VarMeta(psfc(0,:,:), PSFC(0,:,:))<br class=""> <span class="Apple-converted-space"> </span>printVarSummary(PSFC)<span class=""><br class=""><br class=""> <span class="Apple-converted-space"> </span>sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945, 0.11654, 0.14916, \<br class="">        <span class="Apple-converted-space"> </span>0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529, 0.60135, 0.66482,    \<br class="">        <span class="Apple-converted-space"> </span>0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459, 0.97418, 0.99000,    \<br class="">        <span class="Apple-converted-space"> </span>1.00000/)<br class=""><br class=""> <span class="Apple-converted-space"> </span>hybo = sigma            ; *your* B(k) [ sigma levels ]<br class=""> <span class="Apple-converted-space"> </span>nsig = dimsizes(hybo)<br class=""> <span class="Apple-converted-space"> </span>hyao = new(nsig,typeof(hybo))<br class=""> <span class="Apple-converted-space"> </span>hyao = 0.0             ; set output A(k) to 0.0<br class=""><br class=""></span><span class=""> <span class="Apple-converted-space"> </span>p0   = 101325           ; reference pressure (Pa)<br class=""></span> <span class="Apple-converted-space"> </span>p0@units = "Pa"<br class=""><br class=""> <span class="Apple-converted-space"> </span>xo   = hyi2hyo_Wrap(p0,hyai,hybi,PSFC<wbr class="">,xi,hyao,hybo,0) ; contributed.ncl<br class=""> <span class="Apple-converted-space"> </span>printVarSummary(xo)<br class=""></span><div class=""><div class=""><span style="font-family: monospace, monospace;" class=""><br class=""><br class=""></span></div></div></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Tue, Oct 31, 2017 at 11:01 AM, Jayant<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:jayantkp2979@gmail.com" target="_blank" class="">jayantkp2979@gmail.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""></span><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class="m_-5819008324443537227h5"><div dir="ltr" class=""><div class=""><div class="">Dear,<br class=""><br class=""></div>I am following the steps given in thread (<a href="https://www.ncl.ucar.edu/Support/talk_archives/2006/0001.html" target="_blank" class="">https://www.ncl.ucar.edu/Supp<wbr class="">ort/talk_archives/2006/0001.ht<wbr class="">ml</a>) to convert a file from hybrid level to sigma levels. I paste below my script and the outputs. I am not able to understand where I am going wrong. Please advice. Also, let me know if I need to send my netcdf files as well.</div><div class="">Thanks in advance,</div><div class="">Jayant<br class=""></div><div class=""><br class=""><span style="font-family: monospace, monospace;" class=""> <span class="Apple-converted-space"> </span>f=addfile("ham_oxi_aps_T63L31.<wbr class="">nc","r")<br class=""> <span class="Apple-converted-space"> </span>hyai = f->hyam         ; input A(k)<br class=""> <span class="Apple-converted-space"> </span>hybi = f->hybm         ; input B(k)<span class="Apple-converted-space"> </span><br class=""> <span class="Apple-converted-space"> </span>xi   = f->OX_VMR_avrg        ; (0,:,:,:)     ; variable to be interpolated<br class=""> <span class="Apple-converted-space"> </span>dims = getvardims(xi)<br class=""> <span class="Apple-converted-space"> </span>xin  = dim_rmvmean_Wrap(xi($dims(0)$|<wbr class="">:,$dims(1)$|:,$dims(3)$|:,$dim<wbr class="">s(2)$|:))<br class=""> <span class="Apple-converted-space"> </span>printVarSummary(xin)<br class=""> <span class="Apple-converted-space"> </span>p0   = 101325            ; reference pressure (Pa)<br class=""><br class=""> <span class="Apple-converted-space"> </span>fP   = addfile("<a href="http://surf_pres_new_exp_echam_exp.nc/" target="_blank" class="">surf_pres_new_exp_ech<wbr class="">am_exp.nc</a>","r")<br class=""> <span class="Apple-converted-space"> </span>psfc = fP->aps            ; surface pressure (Pa)<br class=""> <span class="Apple-converted-space"> </span>printVarSummary(psfc)<br class=""> <span class="Apple-converted-space"> </span>; dims = getvardims(psfc)<br class=""> <span class="Apple-converted-space"> </span>; psfcr = dim_rmvmean_Wrap(psfc($dims(0)<wbr class="">$|:,$dims(2)$|:,$dims(1)$|:))<br class=""> <span class="Apple-converted-space"> </span>; psfc2d = psfcr(0,:,:)<br class=""><br class=""> <span class="Apple-converted-space"> </span>sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945, 0.11654, 0.14916, \<br class="">        <span class="Apple-converted-space"> </span>0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529, 0.60135, 0.66482,    \<br class="">        <span class="Apple-converted-space"> </span>0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459, 0.97418, 0.99000,    \<br class="">        <span class="Apple-converted-space"> </span>1.00000/)<br class=""><br class=""> <span class="Apple-converted-space"> </span>hybo = sigma            ; *your* B(k) [ sigma levels ]<span class="Apple-converted-space"> </span><br class=""> <span class="Apple-converted-space"> </span>nsig = dimsizes(hybo)<br class=""> <span class="Apple-converted-space"> </span>hyao = new(nsig,typeof(hybo))<br class=""> <span class="Apple-converted-space"> </span>hyao = 0.0             ; set output A(k) to 0.0<span class="Apple-converted-space"> </span><br class=""><br class=""> <span class="Apple-converted-space"> </span>; xo = hyi2hyo_Wrap(p0,hyai,hybi,psfc<wbr class="">r,xi,hyao,hybo,0) ; contributed.ncl<span class="Apple-converted-space"> </span><br class=""> <span class="Apple-converted-space"> </span>xo = hyi2hyo_Wrap(p0,hyai,hybi,psfc<wbr class="">,xin,hyao,hybo,0) ; contributed.ncl<span class="Apple-converted-space"> </span><br class=""> <span class="Apple-converted-space"> </span>printVarSummary(xo)</span><br class=""><br class=""></div>On running, I am getting the following error:<br class=""><br class=""><span style="font-family: monospace, monospace;" class="">Variable: xin<br class="">Type: float<br class="">Total Size: 27426816 bytes<br class="">           <span class="Apple-converted-space"> </span>6856704 values<br class="">Number of Dimensions: 4<br class="">Dimensions and sizes:    [time | 12] x [lev | 31] x [lat | 96] x [lon | 192]<br class="">Coordinates:<span class="Apple-converted-space"> </span><br class="">           <span class="Apple-converted-space"> </span>time: [   0..  11]<br class="">           <span class="Apple-converted-space"> </span>lev: [ 1..31]<br class="">           <span class="Apple-converted-space"> </span>lat: [88.5721685140073..-88.5721685<wbr class="">140073]<br class="">           <span class="Apple-converted-space"> </span>lon: [   0..358.125]<br class="">Number Of Attributes: 5<br class=""> <span class="Apple-converted-space"> </span>rmvmean_op_NCL :    dim_rmvmean over dimension(s): lon<br class=""> <span class="Apple-converted-space"> </span>long_name :    Deviation from mean<br class=""> <span class="Apple-converted-space"> </span>grid_type :    gaussian<br class=""> <span class="Apple-converted-space"> </span>units :    VMR<br class=""> <span class="Apple-converted-space"> </span>_FillValue :    9.96921e+36<br class=""><br class="">Variable: psfc<br class="">Type: float<br class="">Total Size: 73728 bytes<br class="">           <span class="Apple-converted-space"> </span>18432 values<br class="">Number of Dimensions: 3<br class="">Dimensions and sizes:    [time | 1] x [lat | 96] x [lon | 192]<br class="">Coordinates:<span class="Apple-converted-space"> </span><br class="">           <span class="Apple-converted-space"> </span>time: [30.99166666666667..30.9916666<wbr class="">6666667]<br class="">           <span class="Apple-converted-space"> </span>lat: [88.57216851400727..-88.572168<wbr class="">51400727]<br class="">           <span class="Apple-converted-space"> </span>lon: [   0..358.125]<br class="">Number Of Attributes: 5<br class=""> <span class="Apple-converted-space"> </span>grid_type :    gaussian<br class=""> <span class="Apple-converted-space"> </span>table :    128<br class=""> <span class="Apple-converted-space"> </span>code :    134<br class=""> <span class="Apple-converted-space"> </span>units :    Pa<br class=""> <span class="Apple-converted-space"> </span>long_name :    surface pressure<br class="">fatal:hyi2hyo: The rightmost dimensions of 'ps' and 'xi' must be the same<br class="">fatal:["Execute.c":8575]:Execu<wbr class="">te: Error occurred at or near line 9139 in file $NCARG_ROOT/lib/ncarg/nclscrip<wbr class="">ts/csm/contributed.ncl<br class=""></span></div><br class=""></div></div><span class="">______________________________<wbr class="">_________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" target="_blank" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailma<wbr class="">n/listinfo/ncl-talk</a><br class=""><br class=""></span></blockquote></div><br class=""></div></blockquote></div></div></div></div></div></div></div></div></div><br class=""></div></blockquote></div><br class=""></div></body></html>