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

From: Marston Johnston <shejo284_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 23 2013 - 03:00:56 MDT

Hi Dave,

Yes, the script was complicated, far more complicated than needed. I've had
this problem since last Fri and I did as you suggested. The problem comes
in when I write data to fout and then read data from fout and then try to
write to fout again.
It is then that I get the error that the fout->IWC time dimension is only
1. It seems as if fout, when created with "c", is meant only to write. When
I read from fout, something changes and then I cannot write to it again. It
could also be a problem in the underlying netcdf library but I don't have
time to dig into this.
Anyway, I've had a good night's sleep and decided to simplify the script. I
made it so that I only write to fout, never reading and then writing again.
It works now, but I'm afraid the real reason for the error I reported will
remain a mystery for now.
In parting, is the "c" flag in addfile, meant only as a writing so that if
one reads from a file handle that has "c", then one cannot write to fout
again? Does this ring any bells?

Thanks,
Marston

On Tue, Oct 22, 2013 at 10:29 PM, David Brown <dbrown@ucar.edu> wrote:

> OK, sorry I didn't look at the script carefully enough. I do see now that
> fout is a file handle as you say. This is a pretty complicated script, and
> I think you will need to
> debug it using print statements to find the location of the error.
> You could first try running NCL with the -x option ( -x: echo NCL
> commands). Comment out the begin and end from your main program (not the
> functions) first.
> If this doesn't tell you what you need to know, I think from your existing
> print output you can tell that the script is encountering an error inside
> the Pro3D function. So I
> would concentrate on putting debugging print statements in it. You need to
> figure out which line is causing the error.
> I do see that your time dimension in the file is supposed to be unlimited
> but somewhere you are exceeding the defined dimension bounds.
> -dave
>
>
> On Oct 22, 2013, at 1:36 PM, Marston Johnston <shejo284@gmail.com> wrote:
>
> Hi Dave,
>
> I was unaware of this ":=" issue. I simply thought "fout" was a file
> handle. After your recommended changes I still got the error. I even passed
> fout to the function and returned 0 to a dummy variable but I still got the
> same error. In order to speed up the script I moved the fout->time(itime) =
> (/f->time(itime)/)/60.0 into the loop. The speeds things up tremendously
> when the time dimension is set to unlimited. But there is something going
> on that I cannot grasp about NCL.
>
> print("Regridding the variables...")
>
>
> do itime = 0, 3;endtime
>
>
> print("Processing time step: "+itime)
>
>
> fout->time(itime) = (/f->time(itime)/)/60.0 ; change the time to hours
>
>
> do n = 0, nsize ; loop over the different variables
>
>
> print("Processing variable:-> "+name(n)+" mapping to:->"+Sname(n))
>
>
> if(name(n).eq."var26" .or.\
>
>
> name(n).eq."var142" .or.\
>
>
> name(n).eq."var143" .or.\
>
>
> name(n).eq."var178" .or.\
>
>
> name(n).eq."var179" .or.\
>
>
> name(n).eq."var184" .or.\
>
>
> name(n).eq."var245" .or.\
>
>
> name(n).eq."var246" .or.\
>
>
> name(n).eq."var247" .or.\
>
>
> name(n).eq."var248" .or.\
>
>
> name(n).eq."var249" .or.\
>
>
> name(n).eq."var251" .or.\
>
>
> name(n).eq."var252" .or.\
>
>
> name(n).eq."var253") then
>
>
> fout :=
> Pro2D(f,fout,Sname(n),name(n),itime,LAT1x1,LON1x1,LAT2x2,LON2x2,n)
>
> end if
>
>
>
>
>
> if(name(n).eq."var21" .or.\
>
>
> name(n).eq."var22" .or.\
>
>
> name(n).eq."var23" .or.\
>
>
> name(n).eq."var24" .or.\
>
>
> name(n).eq."var25" .or.\
>
>
> name(n).eq."var223") then
>
>
> do level = 0, nlevs
>
>
> fout :=
> Pro3D(f,fout,Sname(n),name(n),itime,level,f->lev_2(level),LAT1x1,LON1x1,LAT2x2,LON2x2,n)
>
> end do
>
>
> end if
>
>
> end do
>
>
> ;print("Time in file: "+fout->time(itime))
> end do
>
> @a7 ncl_codes]$ ncl echam_regrid.ncl
> Copyright (C) 1995-2013 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.2
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) Names in nc file: var26
> (1) Names in nc file: var142
> (2) Names in nc file: var143
> (3) Names in nc file: var178
> (4) Names in nc file: var179
> (5) Names in nc file: var184
> (6) Names in nc file: var245
> (7) Names in nc file: var246
> (8) Names in nc file: var247
> (9) Names in nc file: var248
> (10) Names in nc file: var249
> (11) Names in nc file: var251
> (12) Names in nc file: var252
> (13) Names in nc file: var253
> (14) Names in nc file: var21
> (15) Names in nc file: var22
> (16) Names in nc file: var23
> (17) Names in nc file: var24
> (18) Names in nc file: var25
> (19) Names in nc file: var223
> (20) Names in nc file: var243
> (21) Names in nc file: var244
> (0) Create a large file to hold the data
> (0) Regridding the variables...
> (0) Processing time step: 0
> (0) Processing variable:-> var26 mapping to:->SP
> (0) Processing variable:-> var142 mapping to:->LSP
> (0) Processing variable:-> var143 mapping to:->CP
> (0) Processing variable:-> var178 mapping to:->TSIR
> (0) Processing variable:-> var179 mapping to:->TTR
> (0) Processing variable:-> var184 mapping to:->SI
> (0) Processing variable:-> var245 mapping to:->sunlit_ISCCP
> (0) Processing variable:-> var246 mapping to:->TCC_ISCCP
> (0) Processing variable:-> var247 mapping to:->CTP_ISCCP
> (0) Processing variable:-> var248 mapping to:->CALB_ISCCP
> (0) Processing variable:-> var249 mapping to:->TAU_ISCCP
> (0) Processing variable:-> var251 mapping to:->DCFLAG
> (0) Processing variable:-> var252 mapping to:->SCFLAG
> (0) Processing variable:-> var253 mapping to:->MCFLAG
> (0) Calculate the ALBEDO...
> (0) Processing variable:-> var21 mapping to:->R
> (0) Processing variable:-> var22 mapping to:->Q
> (0) Processing variable:-> var23 mapping to:->CLWC
> (0) Processing variable:-> var24 mapping to:->CIWC
> (0) Processing variable:-> var25 mapping to:->T
> (0) Processing variable:-> var223 mapping to:->CC
> (0) Processing variable:-> var243 mapping to:->CC_ISCCP_3D
> (0) Processing variable:-> var244 mapping to:->TAU_ISCCP_3D
> (0) Processing time step: 1
> (0) Processing variable:-> var26 mapping to:->SP
> (0) Processing variable:-> var142 mapping to:->LSP
> (0) Processing variable:-> var143 mapping to:->CP
> (0) Processing variable:-> var178 mapping to:->TSIR
> (0) Processing variable:-> var179 mapping to:->TTR
> (0) Processing variable:-> var184 mapping to:->SI
> (0) Processing variable:-> var245 mapping to:->sunlit_ISCCP
> (0) Processing variable:-> var246 mapping to:->TCC_ISCCP
> (0) Processing variable:-> var247 mapping to:->CTP_ISCCP
> (0) Processing variable:-> var248 mapping to:->CALB_ISCCP
> (0) Processing variable:-> var249 mapping to:->TAU_ISCCP
> (0) Processing variable:-> var251 mapping to:->DCFLAG
> (0) Processing variable:-> var252 mapping to:->SCFLAG
> (0) Processing variable:-> var253 mapping to:->MCFLAG
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> (0) Calculate the ALBEDO...
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
> fatal:Subscript out of range, error in subscript #0
>
>
>
> On Tue, Oct 22, 2013 at 8:50 PM, David Brown <dbrown@ucar.edu> wrote:
>
>> Hi Marston,
>> You are using 'fout' as the variable for both the 2D and the 3D
>> variables. Once the variable is initialized, any attempt to assign
>> different dimensions or sizes will cause an error.
>> The fix, most likely, is either to call
>> delete(fout)
>> at the end of each loop iteration, or (recommended) to use the new
>> 'reassignment' operator ':=', e.g.:
>>
>> fout : =
>> Pro2D(f,fout,Sname(n),name(n),itime,LAT1x1,LON1x1,LAT2x2,LON2x2,n)
>>
>> and later
>>
>> fout :=
>> Pro3D(f,fout,Sname(n),name(n),itime,level,f->lev_2(level),LAT1x1,LON1x1,LAT2x2,LON2x2,n)
>>
>> -dave
>>
>>
>> On Oct 22, 2013, at 12:09 PM, Marston Johnston <shejo284@gmail.com>
>> wrote:
>>
>> Hi all,
>>
>> I know this error: fatal:Subscript out of range, error in subscript #0,
>> seems like a simple enough error message to understand but I cannot seem to
>> find the cause of the problem. I'm writing data to a file and after some
>> variables are written, I read the data from the newly written file and
>> create a new variable, then I write the new variable to the outfile. It is
>> when I write this new variable that I get this error which frankly boggles
>> my mind. The error occurs on the 2nd time step. I would love some
>> assistance in understanding and solving this error.
>>
>> I have attached the script and below is a copy of the output for two time
>> steps:
>>
>> %@a7 ncl_codes]$ ncl echam_regrid.ncl
>> Copyright (C) 1995-2013 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 6.1.2
>> The use of this software is governed by a License Agreement.
>> See http://www.ncl.ucar.edu/ for more details.
>> (0) Names in nc file: var26
>> (1) Names in nc file: var142
>> (2) Names in nc file: var143
>> (3) Names in nc file: var178
>> (4) Names in nc file: var179
>> (5) Names in nc file: var184
>> (6) Names in nc file: var245
>> (7) Names in nc file: var246
>> (8) Names in nc file: var247
>> (9) Names in nc file: var248
>> (10) Names in nc file: var249
>> (11) Names in nc file: var251
>> (12) Names in nc file: var252
>> (13) Names in nc file: var253
>> (14) Names in nc file: var21
>> (15) Names in nc file: var22
>> (16) Names in nc file: var23
>> (17) Names in nc file: var24
>> (18) Names in nc file: var25
>> (19) Names in nc file: var223
>> (20) Names in nc file: var243
>> (21) Names in nc file: var244
>> (0) Create a large file to hold the data
>> (0) Regridding the variables...
>> (0) Processing time step: 0
>> (0) Processing variable:-> var26 mapping to:->SP
>> (0) Processing variable:-> var142 mapping to:->LSP
>> (0) Processing variable:-> var143 mapping to:->CP
>> (0) Processing variable:-> var178 mapping to:->TSIR
>> (0) Processing variable:-> var179 mapping to:->TTR
>> (0) Processing variable:-> var184 mapping to:->SI
>> (0) Processing variable:-> var245 mapping to:->sunlit_ISCCP
>> (0) Processing variable:-> var246 mapping to:->TCC_ISCCP
>> (0) Processing variable:-> var247 mapping to:->CTP_ISCCP
>> (0) Processing variable:-> var248 mapping to:->CALB_ISCCP
>> (0) Processing variable:-> var249 mapping to:->TAU_ISCCP
>> (0) Processing variable:-> var251 mapping to:->DCFLAG
>> (0) Processing variable:-> var252 mapping to:->SCFLAG
>> (0) Processing variable:-> var253 mapping to:->MCFLAG
>> (0) Calculate the ALBEDO...
>> (0) Processing variable:-> var21 mapping to:->R
>> (0) Processing variable:-> var22 mapping to:->Q
>> (0) Processing variable:-> var23 mapping to:->CLWC
>> (0) Processing variable:-> var24 mapping to:->CIWC
>> (0) Processing variable:-> var25 mapping to:->T
>>
>> (0) Processing variable:-> var223 mapping to:->CC
>> (0) Processing variable:-> var243 mapping to:->CC_ISCCP_3D
>> (0) Processing variable:-> var244 mapping to:->TAU_ISCCP_3D
>> (0) Processing time step: 1
>> (0) Processing variable:-> var26 mapping to:->SP
>> (0) Processing variable:-> var142 mapping to:->LSP
>> (0) Processing variable:-> var143 mapping to:->CP
>> (0) Processing variable:-> var178 mapping to:->TSIR
>> (0) Processing variable:-> var179 mapping to:->TTR
>> (0) Processing variable:-> var184 mapping to:->SI
>> (0) Processing variable:-> var245 mapping to:->sunlit_ISCCP
>> (0) Processing variable:-> var246 mapping to:->TCC_ISCCP
>> (0) Processing variable:-> var247 mapping to:->CTP_ISCCP
>> (0) Processing variable:-> var248 mapping to:->CALB_ISCCP
>> (0) Processing variable:-> var249 mapping to:->TAU_ISCCP
>> (0) Processing variable:-> var251 mapping to:->DCFLAG
>> (0) Processing variable:-> var252 mapping to:->SCFLAG
>> (0) Processing variable:-> var253 mapping to:->MCFLAG
>> fatal:Subscript out of range, error in subscript #0
>> fatal:Subscript out of range, error in subscript #0
>> fatal:Subscript out of range, error in subscript #0
>> fatal:Subscript out of range, error in subscript #0
>> fatal:Subscript out of range, error in subscript #0
>> fatal:Subscript out of range, error in subscript #0
>>
>> The input file is very large but if you have room on the NCL server I
>> could upload it.
>>
>> Thanks in advance,
>> /Marston
>> <echam_regrid.ncl>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>
>
> --
> Only the fruitful thing is true!
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

-- 
Only the fruitful thing is true!

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 23 03:01:17 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT