[ncl-talk] Loop Breaking on 3rd pass
Zach Rieck
zrr817 at gmail.com
Thu May 9 20:19:10 MDT 2019
No. All it says is execute error
-Zach Rieck
zrr817 at gmail.com
(513)-502-5652
On Thu, May 9, 2019, 8:15 PM Rick Brownrigg <brownrig at ucar.edu> wrote:
> I don't think that's quite right; you've got this:
> ....
> n_years = dimsizes(years)
> WRF_tot = new(n_years-1, "float")
> do i = 0, n_years-1
> s_date1 = years(i) + "110100"
> e_date1 = years(i+1) + "033100"
> ....
>
> n_years is the size of the array years, but the valid indices into the
> array are [0..n_years-1]. So on the last iteration of the loop, i=nyears-1,
> and i+1 = n_years which is outside the range of valid indices. You should
> be getting an error message like:
>
> fatal:Subscript out of range, error in subscript #0
>
> Are you not?
>
>
>
>
>
> On Thu, May 9, 2019 at 8:05 PM Zach Rieck <zrr817 at gmail.com> wrote:
>
>> That was my thought initially as well, but I actually have the code wired
>> to handle that. The loop only runs for the length of the years -1, so i+1
>> should pull in the last value.
>>
>> I didn't include the error since it was vague and didn't seem to tell me
>> anything. All it said was fatal exec and pointed to the line where I pull
>> on the gridpoint value in the loop.
>>
>> -Zach Rieck
>> zrr817 at gmail.com
>> (513)-502-5652
>>
>> On Thu, May 9, 2019, 7:16 PM Rick Brownrigg <brownrig at ucar.edu> wrote:
>>
>>> Hi Zach,
>>>
>>> Its always helpful to include error messages. If I were to speculate,
>>> I'd say its probably this line:
>>>
>>> e_date1 = years(i+1) + "033100"
>>>
>>> The "i+1" probably exceeds the dimensionality of the variable years
>>>
>>> Rick
>>>
>>>
>>> On Thu, May 9, 2019 at 6:11 PM Zach Rieck <zrr817 at gmail.com> wrote:
>>>
>>>> That just about did it! I made a few minor changes to the array lengths
>>>> and added the colon and it now runs until the final pass through before
>>>> breaking. I'm not sure why though, I can query all the values for that pass
>>>> without any issue.
>>>>
>>>> Attached the updated code with the changes. Thanks for the help and
>>>> patience!
>>>>
>>>> -Zach Rieck
>>>> zrr817 at gmail.com
>>>> (513)-502-5652
>>>>
>>>>
>>>> On Thu, May 9, 2019 at 7:51 AM Dennis Shea <shea at ucar.edu> wrote:
>>>>
>>>>> NCL is strongly typed. By default, NCL will not allow different size
>>>>> arrays to the left and right of the assignment operator [ *=* ].
>>>>>
>>>>> Use NCL's reassignment operator *:=*
>>>>>
>>>>> WRF_gridpoints *:=* f_in[:]->PREC_ACC_NC(s_time3:e_time3,553,412)
>>>>> ===
>>>>> *https://www.ncl.ucar.edu/Document/Language/varb_assign.shtml*
>>>>> <https://www.ncl.ucar.edu/Document/Language/varb_assign.shtml>
>>>>>
>>>>> On Wed, May 8, 2019 at 7:02 PM Zach Rieck <zrr817 at gmail.com> wrote:
>>>>>
>>>>>> To Whom it May Concern-
>>>>>>
>>>>>> I have a loop where I am trying to pull precip for different time
>>>>>> periods for each winter. The loop is successfully pulling in the write
>>>>>> dates and totals, and runs EXACTLY how it is supposed to until the 3rd pass
>>>>>> through. I'm confused by this since if the loop wasn't repeatable it should
>>>>>> error out no later than the 2nd pass. The error I am getting is that on the
>>>>>> 3rd pass, the left and right side dimensions do not match when I try to
>>>>>> pull in the gridpoint data
>>>>>>
>>>>>> I have verified the lengths on my variable and all are long enough to
>>>>>> pass through the loop as they are meant to. The loop is at the end of the
>>>>>> code, from ~ line 73-78.
>>>>>>
>>>>>> Thanks for the help!
>>>>>>
>>>>>> -Zach Rieck
>>>>>> zrr817 at gmail.com
>>>>>> (513)-502-5652
>>>>>> _______________________________________________
>>>>>> ncl-talk mailing list
>>>>>> ncl-talk at ucar.edu
>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>
>>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> 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/20190509/7afa4d46/attachment.html>
More information about the ncl-talk
mailing list