<div dir="ltr"><div><span id="gmail-m_5600268266641284251gmail-result_box" class="gmail-m_5600268266641284251gmail-" lang="en"><span class="gmail-m_5600268266641284251gmail-">Dear ncl users</span><br><br><span class="gmail-m_5600268266641284251gmail-">I&#39;m
 trying to use the mjoclivar_2.ncl script with daily total precipitation data 
from Era Interim, </span></span><span id="gmail-m_5600268266641284251gmail-result_box" class="gmail-m_5600268266641284251gmail-" lang="en"><span class="gmail-m_5600268266641284251gmail-"><span class="gmail-m_5600268266641284251gmail-" id="gmail-m_5600268266641284251gmail-result_box" lang="en"><span class="gmail-m_5600268266641284251gmail-">however an error is occurring</span></span></span><br><br><span>Could someone help me?</span> <span>Thank you very much in advance!</span></span><br><br>Variable: xAnom_sm<br>Type: float<br>Total Size: 951857280 bytes<br>            237964320 values<br>Number of Dimensions: 3<br>Dimensions and sizes:    [time | 1826] x [latitude | 181] x [longitude | 720]<br>Coordinates: <br>            time: [920436..964236]<br>            latitude: [-45..45]<br>            longitude: [-180..179.5]<br>Number Of Attributes: 3<br>  _FillValue :    -32767<br>  long_name :    Anomalies from Smooth Daily Climatology<br>  units :    m<br>(0)     <br>(0)    Anomalies from Smooth Daily Climatology: min=-0.0362034   max=0.329606<br>FileAddVar, in file: NclFile.c, line: 412<br>fatal:FileAddVar: Dimension (latitude) is not currently defined, can&#39;t add variable<br>fatal:[&quot;Execute.c&quot;:8578]:<wbr>Execute: Error occurred at or near line 130 in file 01mjoelaine_2_pr.ncl<br><br></div>And the script<br><br>; ncl 01mjoelaine_2_pr.ncl<br><br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;  <br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;  <br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot; <br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl&quot;<br><br>begin<br>;-------------------------------------------------------------<br>; User specifications<br>;-------------------------------------------------------------<br>   NC      = True                             ; Deseja criar o arquivo netCDF? True = sim e False = não       <br>   PLOT    = False                            ; sample plots? Não cria figura<br><br>   ymdStrt = 20050101                         ; start yyyymmdd<br>   ymdLast = 20091231                         ; last  <br>   yrStrt  = ymdStrt/10000<br>   yrLast  = ymdLast/10000<br>  <br>   nhar    = 4                                ; number of fourier comp      <br><br>   var     = &quot;tp&quot;                            ; name of file. Nome da variável do seu arquivo de entrada<br>   vName   = &quot;TP&quot;                            ; name for plots. Nome da variável do arquivo netCDF que será gerado<br><br>  ;diri    = &quot;/project/cas/shea/CDC/&quot;         ; input directory   <br>   diri    = &quot;../../dados/diario/&quot;               ; input directory. Diretório de entrada dos dados<br>   fili    = var+&quot;.<a href="http://era.interim.2005.2009.invert.nc">era.interim.2005.2009.invert.nc</a>&quot;       ; input file. Nome do arquivo a ser lido.       <br><br>   if (NC) then<br>       diro= &quot;./&quot;                             ; output dir. Onde será gerado o arquivo netCDF. &quot;./&quot; quer dizer no mesmo diretório do script<br>      ;filo= var+&quot;.<a href="http://day.anomalies.nc">day.anomalies.nc</a>&quot;          ; output file  <br>       filo= var+&quot;.day.anomalies.&quot;+yrStrt+&quot;-&quot;+yrLast+&quot;.nc&quot;  ; output file. Nome do arquivo netCDF a ser criado.<br>   end if<br><br>   if (PLOT) then<br>       wksType = &quot;pdf&quot;                        ; extensão da figura. eps, pdf, ps, png<br>       wksName = &quot;mjoclivar&quot;                  ; &quot;mjo.&quot;+yrStrt+&quot;_&quot;+yrLast. Nome da figura a ser gerada.<br>   end if<br><br>;***********************************************************<br>; Read user specified time and create required yyyyddd                    <br>;***********************************************************<br>   f       = addfile (diri+fili , &quot;r&quot;)                          <br><br>   time    = f-&gt;time                          ; all times on file<br>   ymd     = cd_calendar(time, -2)            ; yyyymmdd<br>   iStrt   = ind(ymd.eq.ymdStrt)              ; index start<br>   iLast   = ind(ymd.eq.ymdLast)              ; index last <br>   delete(time)<br>   delete(ymd)<br><br>;***********************************************************<br>; Read user specified time and create required yyyyddd                    <br>;***********************************************************<br>   time    = f-&gt;time(iStrt:iLast)             ; time:units = &quot;hours since&quot;<br>   TIME    = cd_calendar(time, 0)             ; type float <br>   year    = floattointeger( TIME(:,0) )<br>   month   = floattointeger( TIME(:,1) )<br>   day     = floattointeger( TIME(:,2) ) <br>   ddd     = day_of_year(year, month, day) <br>   yyyyddd = year*1000 + ddd                  ; needed for input<br><br>;***********************************************************<br>; Read data: short2flt                                     <br>;*********************************************************** <br>   x       =  short2flt( f-&gt;$var$(iStrt:iLast,:,:) )    ; convert to float <br>   printVarSummary( x ) <br><br>   <br>;***********************************************************<br>; Compute daily climatology: raw and then &#39;smoothed&#39;  <br>;***********************************************************<br>   xClmDay = clmDayTLL(x, yyyyddd)     ; daily climatology at each grid point<br>   printVarSummary(xClmDay)            <br><br>;***********************************************************<br>; Compute smoothed daily climatology using &#39;nhar&#39; harmonics<br>;***********************************************************<br>   xClmDay_sm = smthClmDayTLL(xClmDay, nhar)<br>   printVarSummary(xClmDay_sm)<br><br>;***********************************************************<br>; Compute daily anomalies using raw and smoothed climatologies<br>;***********************************************************<br>    xAnom      = calcDayAnomTLL (x, yyyyddd, xClmDay)     <br>    printVarSummary(xAnom)<br>    printMinMax(xAnom, True)<br><br>    xAnom_sm   = calcDayAnomTLL (x, yyyyddd, xClmDay_sm)     <br>    xAnom_sm@long_name = &quot;Anomalies from Smooth Daily Climatology&quot;<br>    printVarSummary(xAnom_sm)<br>    printMinMax(xAnom_sm, True)<br><br>    delete( x )    ; no longer needed<br><br><br>;***********************************************************<br>; Create netCDF: convenience use &#39;simple&#39; method<br>;***********************************************************<br><br>    dimx   = dimsizes(xAnom)<br>    ntim   = dimx(0)<br>    nlat   = dimx(1)<br>    mlon   = dimx(2)<br><br>    if (NC) then<br><br>        lat    = f-&gt;latitude<br>        lon    = f-&gt;longitude<br><br>        system(&quot;/bin/rm -f &quot;+diro+filo)      ; rm any pre-exist file, if any<br>        fnc    = addfile (diro+filo, &quot;c&quot;)<br><br>        filAtt = 0<br>        filAtt@title         = vName+&quot;: Daily Anomalies: &quot;+yrStrt+&quot;-&quot;+yrLast  <br>    filAtt@source_file   = fili<br>        filAtt@creation_date = systemfunc(&quot;date&quot;)<br>        fileattdef( fnc, filAtt )         ; copy file attributes  <br><br>        setfileoption(fnc,&quot;DefineMode&quot;,True)<br>        <br>        varNC      = vName+&quot;_anom&quot;<br>        varNC_sm   = vName+&quot;_anom_sm&quot;<br><br>        dimNames = (/&quot;time&quot;, &quot;lat&quot;, &quot;lon&quot;/)  <br>    dimSizes = (/ -1   ,  nlat,  mlon/) <br>    dimUnlim = (/ True , False, False/)   <br>    filedimdef(fnc,dimNames,dimSizes,dimUnlim)<br><br>        filevardef(fnc, &quot;time&quot;  ,typeof(time),getvardims(time)) <br>        filevardef(fnc, &quot;lat&quot;   ,typeof(lat) ,getvardims(lat)) <br>        filevardef(fnc, &quot;lon&quot;   ,typeof(lon) ,getvardims(lon))<br>        filevardef(fnc, varNC   ,typeof(xAnom)   ,getvardims(xAnom))    <br>        filevardef(fnc, varNC_sm,typeof(xAnom)   ,getvardims(xAnom))    <br><br>        filevarattdef(fnc,&quot;time&quot;  ,time)                    ; copy time attributes<br>        filevarattdef(fnc,&quot;lat&quot;   ,lat)                     ; copy lat attributes<br>        filevarattdef(fnc,&quot;lon&quot;   ,lon)                     ; copy lon attributes<br>        filevarattdef(fnc,varNC   ,xAnom)                <br>        filevarattdef(fnc,varNC_sm,xAnom_sm)                <br><br>        fnc-&gt;time       = (/time/)     <br>        fnc-&gt;lat        = (/lat/)<br>        fnc-&gt;lon        = (/lon/)<br>        fnc-&gt;$varNC$    = (/xAnom   /)<br>        fnc-&gt;$varNC_sm$ = (/xAnom_sm/)<br>    end if<br><br>;************************************************<br>; plotting parameters<br>;************************************************<br>    if (PLOT) then<br>        LAT   = (/ 60, 45,  5,  -5, -45, 60 /)<br>        LON   = (/270, 30, 90,  90, 180,  0 /)<br>        nPts  = dimsizes( LAT )<br><br>        plot  = new ( nPts, graphic)<br>        data  = new ( (/2,366/), typeof(xClmDay), getFillValue(xClmDay))<br><br>        wks   = gsn_open_wks (wksType,wksName)    <br><br>        res                   = True                      ; plot mods desired<br>        res@gsnDraw           = False<br>        res@gsnFrame          = False<br>        res@trXMinF           =   1<br>        res@trXMaxF           = 366<br>       ;res@tiMainString      = &quot;&quot;<br>       <br>        res@xyLineThicknesses = (/1.0, 2.0/)              ; make 2nd lines thicker<br>        res@xyLineColors      = (/&quot;blue&quot;,&quot;red&quot;/)          ; change line color<br>        res@xyMonoDashPattern = True                      ; all solid<br><br>        do np=0,nPts-1 <br>           data(0,:) = xClmDay(:,{LAT(np)},{LON(np)})<br>           data(1,:) = xClmDay_sm(:,{LAT(np)},{LON(np)})<br>           res@gsnCenterString = &quot;lat=&quot;+LAT(np)+&quot;  lon=&quot;+LON(np)<br>           plot(np)  = gsn_csm_y (wks,data,res) ; create plot<br>        end do<br>       <br>        resP                     = True                ; modify the panel plot<br>        resP@txString            = vName+&quot;: Raw/Smooth Daily Climatology: &quot;+yrStrt+&quot;-&quot;+yrLast<br>        resP@gsnMaximize         = True<br>        resP@gsnPaperOrientation = &quot;portrait&quot;<br>        gsn_panel(wks,plot,(/(nPts/2),2/),resP)               ; now draw as one plot<br><br>       ;==========<br>       ; Plot anomalies for an arbitrarily selected near equatorial location<br>       ; Time: Oct 1, 1996 to April 1,1997  [arbitrary selection]<br>       ;==========<br>        LATX    = 0<br>        LONX    = 90<br><br>        yyyymmdd  = cd_calendar(time, -2)<br>      ;;yrfrac    = yyyymmdd_to_yyyyfrac (yyyymmdd, 0)<br>      ;;delete(yrfrac@long_name)<br><br>        xAnom@long_name    = &quot;Anomalies from Raw&quot;   ; short labels for plot<br>        xAnom_sm@long_name = &quot;Anomalies from Smooth&quot;<br><br>        ntBegin   = ind(yyyymmdd.eq.20051001)<br>        ntEnd     = ind(yyyymmdd.eq.20060401)<br>       <br>        monthLabels    = (/1,4,7,10/)<br>        monNam = (/&quot;Jan&quot;,&quot;Feb&quot;,&quot;Mar&quot;,&quot;Apr&quot;,&quot;May&quot;,&quot;Jun&quot; \<br>                  ,&quot;Jul&quot;,&quot;Aug&quot;,&quot;Sep&quot;,&quot;Oct&quot;,&quot;Nov&quot;,&quot;Dec&quot; /)<br>        xVal   = new(ntim, typeof(xAnom&amp;time) , &quot;No_FillValue&quot;) ; bigger than<br>        xLab   = new(ntim, &quot;string&quot;, &quot;No_FillValue&quot;)        ; needed<br>        xValm  = new(ntim, typeof(xAnom&amp;time) , &quot;No_FillValue&quot;) ; bigger than<br><br>        ntm            = -1<br>        cr             = inttochar(10)                     ; carriage return<br>        do nt=ntBegin,ntEnd<br>         if (day(nt).eq.1) then<br>             ntm       = ntm + 1<br>             xVal(ntm) = xAnom&amp;time(nt)<br>             xLab(ntm) = monNam(month(nt)-1)<br>             if (month(nt).eq.1) then<br>                 xLab(ntm) = xLab(ntm) + cr +sprinti(&quot;%0.4i&quot;, year(nt))<br>             end if<br>         end if<br>        end do<br><br>        rxy  = True      <br>        rxy@gsnDraw     = False<br>        rxy@gsnFrame    = False<br>        rxy@gsnYRefLine = 0.0                    ; create a reference line   <br>        rxy@gsnAboveYRefLineColor = &quot;red&quot;        ; above ref line fill red<br>        rxy@gsnBelowYRefLineColor = &quot;blue&quot;       ; below ref line fill blue<br>        rxy@xyLineThicknessF  = 2.0                                               <br>        rxy@vpHeightF  = 0.4                     ; resize            <br>        rxy@vpWidthF   = 0.8                  <br>        rxy@tmXBMode   = &quot;Explicit&quot;<br>        rxy@tmXBValues = xVal(0:ntm)<br>        rxy@tmXBLabels = xLab(0:ntm)<br><br>        plot(0)  = gsn_csm_xy (wks,time(ntBegin:ntEnd) \<br>                              ,xAnom(ntBegin:ntEnd,{0},{90}),rxy) <br>        plot(1)  = gsn_csm_xy (wks,time(ntBegin:ntEnd) \<br>                              ,xAnom_sm(ntBegin:ntEnd,{0},{90}),rxy) <br>        resP@txString  = vName+&quot;: Anomalies: (0,90E)&quot;<br>        gsn_panel(wks,plot(0:1),(/2,1/),resP)   <br><br>    end if<br>end<br><div><br><br></div></div>