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

From: Marston Johnston <shejo284_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 22 2013 - 13:36:56 MDT

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
Received on Tue Oct 22 13:37:16 2013

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