Re: fatal:Subscript out of range, error in subscript #0

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 04 2013 - 14:12:46 MDT

On Jun 3, 2013, at 11:10 AM, Luis Fernando Montana Roa wrote:

> Mary,
> What changes should I make to this script so that I can write the same variables for all grid points, all time steps and all levels?
>
> Thanks a lot!
>
> Fernando

Fernando,

Why do you want to read in a NetCDF file and write the values out to an ASCII file?

If you are doing this for several variables across time and levels, you are going to end up with a really big ASCII file. Also, it's not easy to represent multiple dimension arrays in an ASCII file.

If I know more about why you need an ASCII file, then there may be a better solution.

--Mary

>

> On Mon, Jun 3, 2013 at 11:46 AM, Luis Fernando Montana Roa <lfmontanar@unal.edu.co> wrote:
> Mary,
> According to your suggestion, I checked the variable time (with ncdump -h) and made the following change:
>
> do it = 0, ntimes-1
>
> and it worked perfectly!
>
> Thanks
>
> Fernando
>
>
>
>
> On Mon, Jun 3, 2013 at 11:15 AM, Mary Haley <haley@ucar.edu> wrote:
> Luis,
>
> We can't debug your script for you without the data files to run it.
>
> The error message is telling you what the problem is:
>
> > fatal:Subscript out of range, error in subscript #0
> > fatal:["Execute.c":8128]:Execute: Error occurred at or near line 95 in file write_ascii.ncl
>
>
> Look at line 95 of the file and see how you are subscripting any arrays on that line. You are apparently
> using a subscript value that is out-of-range of the array size.
>
> I *think* line 95 is this one:
>
> P_in = wrf_user_getvar(in, "PSFC", time) ; Extract surface temperature
>
> Perhaps "time" is out of range. "time" is coming from this loop:
>
> do it = 0,10 ;ntimes-1
>
> If you have 10 time steps on the file, then this loop should be:
>
> do it = 0,9
>
> Better yet, you should use "ntimes:
>
> do it = 0,ntimes-1
>
> Remember that NCL does its array subscripting starting at index 0. So, if you have
> a 1D array of length 100, you can only use subscript indexes from 0 to 99.
>
> --Mary
>
> On Jun 3, 2013, at 9:10 AM, Luis Fernando Montana Roa wrote:
>
> > Dear NCL users,
> >
> > When I run the script (attached), I get the following error:
> >
> > fatal:Subscript out of range, error in subscript #0
> > fatal:["Execute.c":8128]:Execute: Error occurred at or near line 95 in file write_ascii.ncl
> >
> > I just wonder how I can fix this, and how can write the same variables for all grid points, all time steps and all levels.
> >
> > Thanks in advance
> > --
> > Fernando
> > <extract.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 Tue Jun 4 14:13:02 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT