<div dir="ltr"><div>Hi,</div><div><br></div><div>The meaning of the error message is rather descriptive -- it means there was an attempt to index in an array that's first dimension (0-th) was, say N, using and index outside the range of 0..N-1. Note that NCL uses zero-based indexing.<br></div><div><br></div><div>I could not align line #102 with anything meaningful in the copy/pasted script of the email, but fortunately that script seems to have ample print statements embedded throughout it. Based upon what got printed -- and what didn't -- I suspect the line where the error occurred was:</div><div><br></div><div> data = tofloat( fin->$varName$(time({tmin:tmax}),{zmin:zmax},{ymin:ymax},:) )</div><div><br></div><div>It's impossible for me to know what "time({tmin:tmax})" evaluates to, but that might be the problem. Perhaps try putting in a print statement just before this line to print what "time({tmin:tmax})" yields -- are those value outside the dimensions of the variable "varName" (which seems to be the variable "u" from the file")?</div><div><br></div><div>Rick<br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 5, 2019 at 8:16 PM ANDIKA FAUZIAH HAPSARI, A.P via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">Hi NCL expert<br>
I try to filter Kelvin waves in U and V wind data from ECMWF. But I got this error..</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal"> </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">
<div>fatal:["NclFile.c":2120]:Subscript out of range, error in subscript #0<br>
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 102 in file filter_waves4_uwnd.ncl</div>
<div> </div>
</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal"><img alt="" src="cid:16ed947fca36a5d204d1" width="540" height="322"></div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">Does anyone know what the error means and what should I do? Thanks in advance..</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal"> </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">Here is Carl Shreck's script that I have modified</div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal"> </div>
<div style="font-family:tahoma;color:rgb(0,0,0);font-size:13.3333px;font-weight:400;font-style:normal">
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
; filter_waves.ncl<br>
; Carl Schreck (<a href="mailto:carl@cicsnc.org" target="_blank">carl@cicsnc.org</a>)<br>
; February 2011<br>
; Updated for style October 2011<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
; Description: Filter data for each equatorial wave type<br>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"<br>
;load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br>
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/kf_filter.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/print_clock.ncl"<br>
;load "$CJS_NCL_LIB/print_clock.ncl"</div>
<div><br>
begin<br>
<br>
print_clock( "Here we go! " )</div>
<div>; These are some parameters that could be useful to have up top<br>
mis = -999<br>
mis@_FillValue = -999</div>
<div>; xmin = 70<br>
; xmax = 170<br>
ymin = -15<br>
ymax = 15<br>
zmin = 1000<br>
zmax = 10<br>
units = "hours since 1900-01-01 00:00:00.0"<br>
tmin = cd_inv_calendar( 2018, 12, 01, 00, 0, 0, units, 0 )<br>
tmax = cd_inv_calendar( 2018, 12, 31, 00, 0, 0, units, 0 )</div>
<div><br>
if( .not.isvar("filtName") ) then<br>
filtName = "k09"<br>
end if<br>
obsPerDay = 4<br>
if( .not.isvar("varName") ) then<br>
varName = "u"<br>
end if<br>
print( varName )</div>
<div> basePath = "/home/sarihmmm/datareanly/reanalysis/ecmwf/"<br>
; basePath = "~/data/nasa_ymc/fcst_verif/"<br>
; basePath = "~/data/olr/current/"<br>
; pathIn = basePath + ".<a href="http://std.nc" target="_blank">std.nc</a>"<br>
; pathOut = basePath + ".<a href="http://waves.std.nc" target="_blank">waves.std.nc</a>"<br>
pathIn = basePath + "UVwind_dec2018.nc"<br>
pathOut = basePath + "<a href="http://anginU_dec2018.kelvin.nc" target="_blank">anginU_dec2018.kelvin.nc</a>"<br>
; pathOut = basePath + "trmm3b42." + filtName + ".nc"<br>
; pathIn = basePath + varName + ".<a href="http://anom.nc" target="_blank">anom.nc</a>"<br>
; pathOut = basePath + varName + "." + filtName + ".nc"<br>
; pathIn = basePath + "anom/" + varName + ".<a href="http://anom.nc" target="_blank">anom.nc</a>"<br>
; pathOut = basePath + "waves/" + varName + ".<a href="http://anom.waves.nc" target="_blank">anom.waves.nc</a>"</div>
<div> calcHigh = False<br>
calcLow = False<br>
calcMrg = False<br>
calcMjo = False<br>
calcKelvin = True<br>
calcEr = False<br>
calcMtd = False<br>
calcTd = False<br>
calcWig = False<br>
makeNewFile = True</div>
<div>; Open the input files<br>
fin = addfile( pathIn, "r" )<br>
longitude = fin->longitude<br>
latitude = fin->latitude({ymin:ymax})<br>
; level = fin->level<br>
level = fin->level({zmin:zmax})<br>
time = fin->time({tmin:tmax})</div>
<div> latitude@actual_range = (/ min(latitude), max(latitude) /)</div>
<div>; Open the output files<br>
setfileoption("nc","Format","LargeFile")<br>
; setfileoption("nc","Format","NetCDF4")<br>
; setfileoption("nc","CompressionLevel",1)<br>
if( makeNewFile ) then<br>
system( "rm " + pathOut )<br>
fout = addfile( pathOut, "c" )<br>
fout->time = time<br>
fout->latitude = latitude<br>
fout->longitude = longitude<br>
else<br>
fout = addfile( pathOut, "w" )<br>
end if</div>
<div> print_clock( "Reading the input data... " )</div>
<div><br>
data = tofloat( fin->$varName$(time({tmin:tmax}),{zmin:zmax},{ymin:ymax},:) )<br>
data&time@beginning_date = cd_string( data&time(0), "" )<br>
data&time@ending_date = cd_string( data&time(dimsizes(data&time)-1), "" )</div>
<div> if( any( ismissing(data) ) ) then<br>
print_clock( "WARNING: Setting missing data to zero" )<br>
data = where( ismissing(data), 0, data )<br>
end if</div>
<div> printVarSummary(data)<br>
fout->unfilt = data</div>
<div><br>
if( calcHigh ) then<br>
print_clock( "Filtering High..." )</div>
<div> high = data<br>
high@long_name = "High frequency"<br>
high@filter = "Highpass time filter"<br>
high@wavenumber = (/ -9999, 9999 /)<br>
high@period = (/ 0.01, 120 /)<br>
high@depth = (/ mis, mis /)</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> high(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
high@period(0), high@period(1), \\<br>
high@wavenumber(0), high@wavenumber(1), \\<br>
high@depth(0), high@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing high... " )<br>
fout->high = high<br>
delete(high)<br>
end if</div>
<div><br>
if( calcLow ) then<br>
print_clock( "Filtering Low..." )</div>
<div> low = data<br>
low@long_name = "Low frequency"<br>
low@filter = "Lowpass time filter"<br>
if( filtName.eq."wk99" ) then<br>
low@wavenumber = (/ -99, 99 /)<br>
low@period = (/ 120, 9999 /)<br>
low@depth = (/ mis, mis /)<br>
else<br>
low@wavenumber = (/ -10, 10 /)<br>
low@period = (/ 120, 9999 /)<br>
low@depth = (/ mis, mis /)<br>
end if</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> low(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
low@period(0), low@period(1), \\<br>
low@wavenumber(0), low@wavenumber(1), \\<br>
low@depth(0), low@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing Low... " )<br>
fout->low = low<br>
; delete(low)<br>
end if</div>
<div><br>
if( calcMrg ) then<br>
print_clock( "Filtering MRG..." )</div>
<div> mrg = data<br>
mrg@long_name = "Mixed Rossby-Gravity Waves in " + str_upper(varName)<br>
mrg@filter = "Wheeler & Kiladis (1999)"<br>
mrg@wavenumber = (/ -10, -1 /)<br>
mrg@period = (/ 3, 96 /)<br>
mrg@depth = (/ 8, 90 /)</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> mrg(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
mrg@period(0), mrg@period(1), \\<br>
mrg@wavenumber(0), mrg@wavenumber(1), \\<br>
mrg@depth(0), mrg@depth(1), \\<br>
"mrg" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing MRG... " )<br>
fout->mrg = mrg<br>
delete(mrg)<br>
end if</div>
<div><br>
if( calcMjo ) then<br>
print_clock( "Filtering MJO..." )</div>
<div> mjo = data<br>
mjo@long_name = "Madden-Julian Oscillation in " + str_upper(varName)<br>
if( filtName.eq."wk99" ) then<br>
mjo@filter = "Wheeler & Kiladis (1999)"<br>
mjo@wavenumber = (/ 1, 5 /)<br>
mjo@period = (/ 30, 96 /)<br>
mjo@depth = (/ mis, mis /)<br>
else<br>
mjo@filter = "Kiladis et al. (2005 JAS) for 20-100"<br>
mjo@wavenumber = (/ 0, 9 /)<br>
mjo@period = (/ 20, 100 /)<br>
mjo@depth = (/ mis, mis /)<br>
end if</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> mjo(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
mjo@period(0), mjo@period(1), \\<br>
mjo@wavenumber(0), mjo@wavenumber(1), \\<br>
mjo@depth(0), mjo@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing MJO... " )<br>
fout->mjo = mjo</div>
<div> sumOfModes = data<br>
sumOfModes = low + mjo<br>
sumOfModes@long_name = "Low+MJO"<br>
fout->low_mjo = sumOfModes<br>
; delete(mjo)<br>
end if</div>
<div><br>
if( calcEr ) then<br>
print_clock( "Filtering ER..." )</div>
<div> er = data<br>
er@long_name = "Equatorial Rossby Waves in " + str_upper(varName)<br>
if( filtName.eq."wk99" ) then<br>
er@filter = "Wheeler & Kiladis (1999)"<br>
er@wavenumber = (/ -10, -1 /)<br>
er@period = (/ 9.7, 48 /)<br>
er@depth = (/ 8, 90 /)<br>
else<br>
er@filter = "Kiladis et al. (2009 Rev. Geophys.)"<br>
er@wavenumber = (/ -10, -1 /)<br>
er@period = (/ 9.7, 72 /)<br>
if( filtName.eq."k09" ) then<br>
er@depth = (/ mis, 90 /)<br>
else ; wide<br>
er@depth = (/ mis, mis /)<br>
end if<br>
end if</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> er(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
er@period(0), er@period(1), \\<br>
er@wavenumber(0), er@wavenumber(1), \\<br>
er@depth(0), er@depth(1), \\<br>
"er" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing ER... " )<br>
fout->er = er</div>
<div> sumOfModes = sumOfModes + er<br>
sumOfModes@long_name = "Low+MJO+ER"<br>
fout->low_mjo_er = sumOfModes<br>
; delete(er)<br>
end if</div>
<div> if( calcKelvin ) then<br>
print_clock( "Filtering KELVIN..." )</div>
<div> kelvin = data<br>
kelvin@long_name = "Kelvin Waves in " + str_upper(varName)</div>
<div> if( filtName.eq."wk99" ) then<br>
kelvin@filter = "Wheeler & Kiladis (1999)"<br>
kelvin@wavenumber = (/ 1, 14 /)<br>
kelvin@period = (/ 2.5, 30 /)<br>
kelvin@depth = (/ 8, 90 /)<br>
else if( filtName.eq."k09" ) then<br>
kelvin@filter = "Straub & Kiladis (2002) to 20 days"<br>
kelvin@wavenumber = (/ 1, 14 /)<br>
kelvin@period = (/ 2.5, 20 /)<br>
kelvin@depth = (/ 8, 90 /)<br>
else if( filtName.eq."wide" ) then<br>
kelvin@filter = "Broader square filter"<br>
kelvin@wavenumber = (/ 1, 14 /)<br>
kelvin@period = (/ 2.5, 20 /)<br>
kelvin@depth = (/ mis, mis /)<br>
end if<br>
end if<br>
end if</div>
<div><br>
do y = 0, ( dimsizes(latitude) - 1 )<br>
; print_clock( y + " " + ( dimsizes(latitude) - 1 ) + " " )</div>
<div> kelvin(time|:,{latitude|latitude(y)},longitude|:) = (/ kf_filter( \\<br>
data(time|:,{latitude|latitude(y)},longitude|:), obsPerDay, \\<br>
kelvin@period(0), kelvin@period(1), \\<br>
kelvin@wavenumber(0), kelvin@wavenumber(1), \\<br>
kelvin@depth(0), kelvin@depth(1), \\<br>
"kelvin" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing KELVIN... " )<br>
fout->kelvin = kelvin</div>
<div>; sumOfModes = sumOfModes + kelvin<br>
; sumOfModes@long_name = "Low+MJO+ER+Kelvin"<br>
; fout->low_mjo_er_kelvin = sumOfModes<br>
; delete(kelvin)<br>
end if</div>
<div> </div>
<div> if( calcMtd ) then<br>
print_clock( "Filtering MRG/TD..." )</div>
<div> td = data<br>
td@long_name = "MRG/TD in " + str_upper(varName)<br>
td@filter = "Frank and Roundy (2006), extended to wavenumber -20"<br>
td@wavenumber = (/ -20, -0 /)<br>
td@period = (/ 2.5, 10 /)<br>
td@depth = (/ mis, mis /)</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> td(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
td@period(0), td@period(1), \\<br>
td@wavenumber(0), td@wavenumber(1), \\<br>
td@depth(0), td@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing TD... " )<br>
fout->td = td<br>
delete(td)<br>
end if</div>
<div><br>
if( calcTd ) then<br>
print_clock( "Filtering TD..." )</div>
<div> td = data<br>
td@long_name = "TD-type Disturbances in " + str_upper(varName)<br>
td@filter = "Roundy and Frank (2004), extended to wavenumber -20"<br>
td@wavenumber = (/ -20, -6 /)<br>
td@period = (/ 2.5, 5 /)<br>
td@depth = (/ 90, mis /)</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> td(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
td@period(0), td@period(1), \\<br>
td@wavenumber(0), td@wavenumber(1), \\<br>
td@depth(0), td@depth(1), \\<br>
"none" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing TD... " )<br>
fout->td = td<br>
delete(td)<br>
end if</div>
<div> if( calcWig ) then<br>
print_clock( "Filtering WIG..." )</div>
<div> wig = data<br>
wig@long_name = "Westward Inertial-Gravity Waves in " + str_upper(varName)<br>
wig@filter = "Wheeler & Kiladis (1999), n=1"<br>
wig@wavenumber = (/ -15, -1 /)<br>
wig@period = (/ 1.25, 3 /)<br>
wig@depth = (/ 12, 90 /)</div>
<div> do y = 0, ( dimsizes(lat) - 1 )<br>
; print_clock( y + " " + ( dimsizes(lat) - 1 ) + " " )</div>
<div> wig(time|:,{lat|lat(y)},lon|:) = (/ kf_filter( \\<br>
data(time|:,{lat|lat(y)},lon|:), obsPerDay, \\<br>
wig@period(0), wig@period(1), \\<br>
wig@wavenumber(0), wig@wavenumber(1), \\<br>
wig@depth(0), wig@depth(1), \\<br>
"ig1" ) /)</div>
<div> end do</div>
<div> print_clock( "Writing WIG... " )<br>
fout->wig = wig<br>
delete(wig)<br>
end if</div>
<div> </div>
<div><br>
print_clock( "Closing file..." )<br>
delete(fout)</div>
<div> print_clock( "Thank you, come again. " )</div>
<div>end ; filter_waves</div>
</div>
</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>