<div dir="ltr"><div><div>Hi ,<br></div>Could someone help me to fix this bug? I don&#39;t whats the fatal error says about. <br></div>Thank you<br><div><br><div><div>;***************************************************<br>begin<br>;***************************************************<br>  yrStrt = 196501<br>  yrLast = 200512<br><br>  season = &quot;SON&quot;    ; choose Dec-Jan-Feb seasonal mean<br>;####################################################<br>............<br>f    = addfile(&quot;<a href="http://hgt.mon.mean.nc">hgt.mon.mean.nc</a>&quot;, &quot;r&quot;)   ; note the &quot;s&quot; of addfile<br>u = f-&gt;hgt<br>printVarSummary (u)<br>   YYYYMM = cd_calendar( f-&gt;time, -1)<br><br>   iStrt  = ind(YYYYMM.eq.yrStrt)<br>   iLast  = ind(YYYYMM.eq.yrLast)<br>n=u(level|:,lat|:,lon|:,time|iStrt:iLast)<br>anew=n({500},:,:,:)<br>printVarSummary (anew)<br>;############################################################<br>;anomalies-------------------------<br>temp= rmMonAnnCycTLL(anew(time|:,lat|:,lon|:))<br>printVarSummary(temp)<br>;dtrend the values/------------------<br>anew1Dtrend = dtrend(temp(lat|:,lon|:,time|:),True)<br>printVarSummary(anew1Dtrend)<br>;print(anew1Dtrend@slope)<br>;print(anew1Dtrend@y_intercept)<br>copy_VarCoords(anew,anew1Dtrend)<br><br>; ==============================================================<br>; compute desired global seasonal mean: month_to_season (contributed.ncl)<br>; ==============================================================<br>  anew1a    = month_to_season (anew1Dtrend(time|:,lat|:,lon|:), season)<br>  nyrs   = dimsizes(anew1a&amp;time)<br>  printVarSummary(anew1a)<br>printMinMax(anew1a,False)<br>;%%%%%%%%%%%%%%%EOF%%%%%%%%%%%%%%%%%%%%%%%%<br>;Dont change at all . Here is a trick..<br>;Globe<br>  latS   = 37<br>  latN   =  49. <br> lonL     =  -116<br> lonR     = -90 <br><br>;Center=0<br><br>;%%%%%%%%%%%%%%%EOF%%%%%%%%%%%%%%%%%%%%%%%%<br>  <br><br>neof   = 3        ; number of EOFs<br>  optEOF = True<br>  optEOF@jopt = 0   ; This is the default; most commonly used; no need to specify.<br>;;optEOF@jopt = 1   ; **only** if the correlation EOF is desired<br>; ==============================================================<br>; dataset longitudes span 0=&gt;357.5<br>; Because EOFs of the North Atlantic Oscillation are desired<br>; use the &quot;lonFlip&quot; (contributed.ncl) to reorder<br>; longitudes to span -180 to 177.5: facilitate coordinate subscripting<br>; ==============================================================<br>  anew1a   = lonFlip(anew1a)<br>  printVarSummary(anew1a)                              ; note the longitude coord<br>orig=anew1a({lat|latS:latN},{lon|lonL:lonR},time|:)<br>  printVarSummary(orig)<br><br>; =================================================================<br>; create weights:  sqrt(cos(lat))   [or sqrt(gw) ]<br>; =================================================================<br>  rad    = 4.*atan(1.)/180.<br>  clat   = anew1a(0,:,0)<br>  printVarSummary(clat)    <br>  clat   = sqrt( cos(rad*clat) )                 ; gw for gaussian grid<br>  printVarSummary(clat)    <br>; =================================================================<br>; weight all observations <br>; =================================================================<br>  wSLP   = anew1a                                   ; copy meta data<br>  printVarSummary(wSLP)<br>  printMinMax(wSLP,False)<br>  wSLP   = anew1a*conform(anew1a, clat, 1)<br>  wSLP@long_name = &quot;Wgt: &quot;+anew1a@long_name<br>  printVarSummary(wSLP)<br>printMinMax(wSLP,False)<br>; =================================================================<br>; Reorder (lat,lon,time) the *weighted* input data<br>; Access the area of interest via coordinate subscripting<br>; =================================================================<br>  x      = wSLP({lat|latS:latN},{lon|lonL:lonR},time|:)<br>  printVarSummary(x)<br>print(min(x))<br>print(max(x))<br> dimx   = dimsizes( x )<br>  mln    = dimx(1)<br>  sumWgt = mln*sum( clat({lat|latS:latN}) )<br>printMinMax(sumWgt,False)<br>  eof    = eofunc_Wrap(x, neof, optEOF)      <br>  printVarSummary(eof)<br><br>print(eof(0,:,:))<br>;return<br>;;;;EOF spatial patterns may be tested for orthogonality by using the dot product: <br>d01 = sum(eof(0,:,:)*eof(1,:,:))<br>  d12 = sum(eof(1,:,:)*eof(2,:,:))<br>  d02 = sum(eof(0,:,:)*eof(2,:,:))<br>  print(&quot;d01=&quot;+d01+&quot;  d12=&quot;+d12+&quot;  d02=&quot;+d02)  ; may be +/- 1e-8<br>;return<br>printMinMax(eof(0,:,:),False)<br>;To retain same unit<br>  do ne=0,neof-1<br>     eof(ne,:,:) = eof(ne,:,:)*sqrt( eof@eval(ne) )<br>  end do<br>;print(eof(:,:,:))<br>printMinMax(eof(0,:,:),False)<br>;return<br>;========================================================<br>;Print the Percentage variance;;;;;;<br>; print(&quot;% var=&quot;+ eof@pcvar(0))<br>;========================================================<br>eof_ts = eofunc_ts_Wrap (x, eof, False)<br> printVarSummary( eof_ts )<br>  print( eof_ts )<br>;=======================================================<br>;To test the EOF time series for orthogonality, compute correlations;;;;;<br>  r01 = escorc(eof_ts(0,:), eof_ts(1,:))<br>  r12 = escorc(eof_ts(1,:), eof_ts(2,:))<br>  r02 = escorc(eof_ts(0,:), eof_ts(2,:))<br>  print(&quot;r01=&quot;+r01+&quot;  r12=&quot;+r12+&quot;  r02=&quot;+r02)   ; numbers may be +/- 1e-8<br>; =================================================================<br>; Normalize time series: Sum spatial weights over the area of used<br>; =================================================================<br>;  dimx   = dimsizes( x )<br>;  mln    = dimx(1)<br>;  sumWgt = mln*sum( clat({lat|latS:latN}) )<br>;eof_ts = eof_ts/sumWgt<br>;nlat = dimsizes(eof&amp;lat)    ; lat==&gt; whatever the coordinate name is<br>;  mlon= dimsizes(eof&amp;lon)<br>;print(eof_ts)<br>  eof_ts = dim_standardize_n( eof_ts, 0, 1)      ; normalize<br>  eof_regres = eof                               ; create an array w meta data<br>  do ne=0,neof-1<br>     eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),orig(lat|:,lon|:,time|:)) /)<br>  end do<br>printMinMax(eof_regres(0,:,:),False)<br>printVarSummary( eof_regres )<br>;print(eof_ts)<br>;print(eof(0,:,:))<br>;===================================================================<br>  nlat = dimsizes(eof&amp;lat)    ; lat==&gt; whatever the coordinate name is<br>  mlon= dimsizes(eof&amp;lon)<br>;------------------------------------------------------------<br><br>; =================================================================<br>; Extract the YYYYMM from the time coordinate<br>; associated with eof_ts [same as SLP&amp;time]<br>; =================================================================<br><br>  yyyymm = cd_calendar(eof_ts&amp;time,-2)/100<br>;;yrfrac = yyyymm_to_yyyyfrac(yyyymm, 0.0); not used here<br>;*******************************************<br>; North significance test: any pcvar, eval_transpose, eval can be used<br>;*******************************************<br><br>  dimp   = dimsizes(x)<br>  ntim   = dimp(0)                                            ; max # eigenvalues possible<br><br>  prinfo = True<br>  sig    = eofunc_north(eof@pcvar, ntim, prinfo)<br><br>;************************************************<br>; plotting parameters <br>;************************************************<br>;wks = gsn_open_wks(&quot;x11&quot;,&quot;SlpReconst_Anom_eof_Reanal_&quot;+season+&quot;_temp1965-2005&quot;)<br>wks = gsn_open_wks(&quot;x11&quot;,&quot;heightReconst_Anom_eof_Reanal_&quot;+season+&quot;_temp1965-2005&quot;)<br> gsn_define_colormap(wks,&quot;NCV_jaisnd&quot;) <br> plot = new(neof,graphic)                ; create graphic array<br>                                          ; only needed if paneling<br>; EOF patterns<br><br>  res                      = True<br>  res@gsnDraw              = False        ; don&#39;t draw yet<br>  res@gsnFrame             = False        ; don&#39;t advance frame yet<br><br>;---This resource not needed in V6.1.0<br>  res@gsnSpreadColors      = True         ; spread out color table<br>res@cnLevelSelectionMode = &quot;ManualLevels&quot;  ; set manual contour levels<br>  res@cnMinLevelValF       = -10.0       ; set min contour level<br>  res@cnMaxLevelValF       = 10.0   ; set max contour level<br>  res@cnLevelSpacingF      = 0.5      ; set contour spacing<br><br>  res@gsnAddCyclic         = False        ; plotted dataa are not cyclic<br><br>  res@mpFillOn             = False        ; turn off map fill<br><br>  res@mpMinLatF            = eof&amp;lat(0)+3         ; zoom in on map<br>  res@mpMaxLatF            = eof&amp;lat(nlat-1)<br>  res@mpMinLonF            = eof&amp;lon(0)<br>  res@mpMaxLonF            = eof&amp;lon(mlon-1)<br><br>res@cnLineLabelsOn       = False<br> res@cnFillOn             = True         ; turn on color fill<br>  res@cnLinesOn            = False        ; True is default<br>  res@lbLabelBarOn         = False        ; turn off individual lb&#39;s<br>; res@mpPerimOn              = True                    ; draw box around map<br>res@mpGeophysicalLineThicknessF = 3.0<br>res@mpGeophysicalLineColor = &quot;Black&quot;; (/22/)<br>res@mpOutlineBoundarySets = &quot;GeophysicalAndUSStates&quot; ; add state boundaries<br>res@mpNationalLineColor  = res@mpGeophysicalLineColor<br>res@mpUSStateLineThicknessF = 3.0<br>res@mpUSStateLineColor  = res@mpGeophysicalLineColor<br><br><br>                                          ; set symmetric plot min/max<br>;  symMinMaxPlt(eof, 16, False, res)       ; contributed.ncl<br><br>; panel plot only resources<br>  resP                     = True         ; modify the panel plot<br>  resP@gsnMaximize         = True         ; large format<br>  resP@gsnPanelLabelBar    = True         ; add common colorbar<br>  resP@lbLabelAutoStride   = True         ; auto stride on labels<br>  resP@lbLabelFontHeightF      = 0.017     ; label bar font<br><br>  yStrt                    = yyyymm(0)/100<br>  yLast                    = yyyymm(nyrs-1)/100<br>  resP@txString            = &quot;Regres_Reanal_height(m): &quot;+season+&quot;: &quot;+yStrt+&quot;-&quot;+yLast<br><br>;*******************************************<br>; first plot<br>;*******************************************<br>  do n=0,neof-1<br>     res@gsnLeftStringFontHeightF   = 0.02        ; instead of using txFontHeightF or gsnStringFontHeightF <br>  res@gsnCenterStringFontHeightF = 0.02            ; to set the gsnLeft/Center/RightString font heights,<br>  res@gsnRightStringFontHeightF  = 0.02        ; individually set each string&#39;s font height.<br>     res@gsnLeftString  = &quot;EOF &quot;+(n+1)<br>     res@gsnCenterString= &quot;NORTH=&quot;+sig(n)<br>     res@gsnRightString = sprintf(&quot;%5.1f&quot;, eof@pcvar(n)) +&quot;%&quot;<br>     plot(n)=gsn_csm_contour_map_ce(wks,eof_regres(n,:,:),res)<br>  end do<br>  gsn_panel(wks,plot,(/neof,1/),resP)               ; now draw as one plot<br><br><br>  frame(wks)<br><br><br>end<br><br><br><br></div><div>ERROR printed: <br></div><div><br>fatal:Loop variable must be scalar, can&#39;t execute loop<br>fatal:[&quot;Execute.c&quot;:8575]:Execute: Error occurred at or near line 242 in file heightReconstruct_Temp_eof_Reanal.ncl<br><br><br></div></div></div></div>