[ncl-talk] Subscript out of range error

Dennis Shea shea at ucar.edu
Tue Sep 9 12:10:41 MDT 2014


The NCL Examples are meant as a guide toward usage ..... not plugin a
dataset
and it will work.

---

The whole point of my previous response

     ii = ind(apr.ge.levels(i).and.apr.lt.levels(i+1))
     print("i="+i+"   ii="+ii)    ; basic debug approach
     data2d(i,ii) = apr(ii)

was to examine the printed output. You did not include any of the
information. Only

 "warning:Argument 0 of the current function or procedure was coerced to
the appropriate type
and thus will not change if the function or procedure modifies its value
fatal:Dimension size mismatch on subscript #1, left-hand and right-hand
side dimensions do not match"

===
subscript 1 is 'ii' in data2d.

Here is even more info for you to print and look at:

    do i=0,nlevels-2

        print("i="+i+"   levels(i)="+levels(i)+"
levels(i+1)="+levels(i+1) )

        ii = ind(apr.ge.levels(i).and.apr.lt.levels(i+1))
        if (.any(ismissing(ii))) then
            print("ii has missing values: ii="+ii)
        else

            nii = dimsizes(ii)
            print("i="+i+"   nii="+nii)

            data2d(i,ii) = apr(ii)
            labels(i) = levels(i) + ":" + levels(i+1)

            delete(ii)
       end if
    end do




On Tue, Sep 9, 2014 at 11:26 AM, Ipsita Putatunda <
ipsita.putatunda at gmail.com> wrote:

> Hi Dennis,
>     Thanks for your reply. But instead of my own script I have tried the
> ncl script http://www.ncl.ucar.edu/Applications/Scripts/scatter_5.ncl,
> where I didn't change anything except the npts from 300 to 56,and then run
> the script which is also giving similar error message.Why is it so? I
> didn't even change a single letter in the script scatter_5.ncl except the
> array size. Though may be am wrong but this seems to me it is depending
> upon the array size.
>
> In my own script if I am debugging as per your suggestion it is giving
>
>  "warning:Argument 0 of the current function or procedure was coerced to
> the appropriate type and thus will not change if the function or procedure
> modifies its value
> fatal:Dimension size mismatch on subscript #1, left-hand and right-hand
> side dimensions do not match"
> it is clear that data2d(i,ii) and apr(ii) have different dimensions, but I
> need to make a two dimensional array data2d as per the scatter_5.ncl script
> using apr(ii). Could you please suggest if there is some way to do it.
>
> Thanks in advance,
> Ipsita
>
>
> On Tue, Sep 9, 2014 at 6:10 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> This is basic debugging. It is not the size of the arrays, rather the
>> subscripts
>> that are referencing some location out of range.
>>
>> The error message:
>> fatal:Subscript out of range, error in subscript #1
>> fatal:["Execute.c":7743]:
>> Execute: Error occurred at or near line 28 in file
>>
>>
>>  26   do i=0,nlevels-2
>>  27     ii = ind(apr.ge.levels(i).and.apr.lt.levels(i+1))
>>  28     data2d(i,ii) = apr(ii)
>>  29     labels(i) = levels(i) + ":" + levels(i+1)
>>  30     delete(ii)
>>  31   end do
>>
>> Well ...... Put prints *before* line 28 printing the values of i and ii.
>>
>>      ii = ind(apr.ge.levels(i).and.apr.lt.levels(i+1))
>>      print("i="+i+"   ii="+ii)    ; basic debug approach
>>      data2d(i,ii) = apr(ii)
>>
>> ii could even be missing ...
>>
>>
>> On Tue, Sep 9, 2014 at 5:01 AM, Ipsita Putatunda <
>> ipsita.putatunda at gmail.com> wrote:
>>
>>> In continuation of my previous mail, I have a little query.
>>> http://www.ncl.ucar.edu/Applications/Scripts/scatter_5.ncl in the same
>>> script I simply tried to see how does it works with npts=56 instead of 300
>>> and the same script is giving the similar error (Subscript out of range,
>>> error in subscript #1) as am getting in my script. It is working only with
>>> some larger number like 200 and above. Why is it happening? can anyone give
>>> me some idea?
>>>
>>> Thanks,
>>> Ipsita
>>>
>>> On Tue, Sep 9, 2014 at 3:31 PM, Ipsita Putatunda <
>>> ipsita.putatunda at gmail.com> wrote:
>>>
>>>> Hi all,
>>>>    Am doing something similar to
>>>> http://www.ncl.ucar.edu/Applications/Scripts/scatter_5.ncl
>>>> this scatter plot. While doing this am getting error:
>>>>
>>>> fatal:Subscript out of range, error in subscript #1
>>>> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 28 in
>>>> file
>>>>
>>>> I have checked the dimension and size of my array at line 28.
>>>> Which gives :
>>>>
>>>> Variable: data2d
>>>> Type: float
>>>> Total Size: 1568 bytes
>>>>             392 values
>>>> Number of Dimensions: 2
>>>> Dimensions and sizes:    [7] x [56]
>>>> Coordinates:
>>>> Number Of Attributes: 1
>>>>   _FillValue :    9.96921e+36
>>>>
>>>> Variable: apr
>>>> Type: float
>>>> Total Size: 224 bytes
>>>>             56 values
>>>> Number of Dimensions: 1
>>>> Dimensions and sizes:    [56]
>>>> Coordinates:
>>>> Number Of Attributes: 1
>>>>   _FillValue :    9.96921e+36
>>>>
>>>> But still am getting the same error. Any help will be appreciated.
>>>> My script is attached herewith.
>>>>
>>>> Thanks in advance,
>>>> Ipsita
>>>>
>>>>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140909/684766d5/attachment.html 


More information about the ncl-talk mailing list