Re: write the file into netcdf

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Nov 09 2012 - 14:57:04 MST

The error is telling you that a subscript is out of range.

>From the script you included below, line 30 would be this line:

        v2tem = f[:]->T2D(:,x,y)

My guess is that either "x" or "y" are not in the range of the size of the "T2D" variable on the file.

Do you perhaps have these swapped? That is, should it be:

        v2tem = f[:]->T2D(:,y,x)

Are you getting any other errors out of this script? It looks like you have an "end if" statement that has no corresponding "if" statement at about line 19.

--Mary

On Nov 9, 2012, at 11:15 AM, mary charusombat wrote:

> Dear all
> I try to do daily average of the hourly netcdf files.
> I wrote the scripts to extract data in each point and then average it in 24 hr for every points.
> Then I write the daily data back into a new netcdf file.
> I am not sure it is a good way to do that.
> This is my code and I get the script out of range and memory error.
> My netcdf files have
>
> // global attributes:
> :TITLE = "OUTPUT FROM CONSOLIDATE_GRIB v20110427" ;
> :missing_value = -1.e+36f ;
> :_FillValue = -1.e+36f ;
> :WEST-EAST_GRID_DIMENSION = 531 ;
> :SOUTH-NORTH_GRID_DIMENSION = 420 ;
> :DX = 4000.f ;
> :DY = -999.9f ;
> :TRUELAT1 = 42.627f ;
> :TRUELAT2 = 42.627f ;
> :LA1 = 34.48816f ;
> :LO1 = -103.878f ;
> :STAND_LON = -92.409f ;
> :MAP_PROJ = 1 ;
> :MMINLU = "USGS"
>
>
> Please help
> Mary
>
>
>
>
> This is my code
>
> begin
> delimiter = " "
> files = new(8760, string)
> n1 = 0
> a = "geo_em.d01.nc"
> do i = 1,12
> if (i .lt. 10) then
> tmp_files = systemfunc("ls ./2001/20010" + i + "*LDASIN*.nc")
> else
> tmp_files = systemfunc("ls ./2001/2001" + i + "*LDASIN*.nc")
> end if
> files(n1: n1 + dimsizes(tmp_files) - 1) = tmp_files
> n1 = n1 + dimsizes(tmp_files)
> print(n1)
> delete(tmp_files)
> end do
> f = addfiles(files, "r")
> a1 = addfile(a, "r")
> tmp_files = systemfunc("ls /scratch/lustreC/u/ucharuso/hrldas-v3.3/HRLDAS_COLLECT_DATA/run/2001/2001" + i + "*LDASIN*.nc")
> end if
> files(n1: n1 + dimsizes(tmp_files) - 1) = tmp_files
> n1 = n1 + dimsizes(tmp_files)
> print(n1)
> delete(tmp_files)
> end do
> f = addfiles(files, "r")
> a1 = addfile(a, "r")
> do x = 0,419
> do y = 0,530
> v2tem = f[:]->T2D(:,x,y)
> v3tem = f[:]->SWDOWN(:,x,y)
> v4tem = f[:]->RAINRATE(:,x,y)
> nv2 = dimsizes(v2tem)
> print(nv2)
> v2tem@_FillValue = -1e+36
> v3tem@_FillValue = -1e+36
> v4tem@_FillValue = -1e+36
> im = 0 ;start at 0700 UTC for MST time 24*14 = 336
> Tmin= new((/365,420,531/), float)
> Tmax = new((/365,420,531/), float)
> rain = new((/365,420,531/), float)
> sw = new((/365,420,531/), float)
> do i = 0,364
> Tmin(i,x,y) = min(v2tem(im:im+22))
> Tmax(i,x,y) = max(v2tem(im:im+22))
> sw(i,x,y) = sum(v3tem(im:im+22))
> rain(i,x,y) = sum(v4tem(im:im+22))
> im = im+22
> end do
> x = x +1
> end do
> y = y +1
> end do
> system ("/bin/rm -f 2001_daily.nc")
> ncdf = addfile("2001_daily.nc","c")
> filedimdef(ncdf,"time",-1,True)
> ncdf->Tmin = Tmin
> ncdf->Tmax = Tmax
> ncdf->sw = sw
> ncdf->rain = rain
> end
>
> fatal:Subscript out of range, error in subscript #1
> ^Mfatal:Memory allocation failure:[errno=12]
> ^Mfatal:Execute: Error occurred at or near line 30 in file gridextract.ncl
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Nov 9 14:57:13 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 13 2012 - 14:27:24 MST