[ncl-talk] A NCL Mystery Solved

Barry Lynn barry.h.lynn at gmail.com
Thu Oct 19 09:09:43 MDT 2017


and I am wondering why it is needed...

On Thu, Oct 19, 2017 at 5:49 PM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hi:
>
> It only gives the error when the : is included after Hits_1(i_day), as in
> :=.
>
> The : was needed before I subscripted the variable with i_day.
>
> Barry
>
> On Thu, Oct 19, 2017 at 5:31 PM, Marston Johnston <shejo284 at gmail.com>
> wrote:
>
>> Hi Barry,
>>
>>
>>
>> A couple things, not to be nit-picky but just my experience. I rewrote
>> the script a bit. But I’m confused, your arrays are always empty so Hits_1
>> will always be 0.
>>
>> This version of the script doesn’t give the error:
>>
>>
>>
>> begin
>>
>>   n_days  = 3
>>
>>   dims = 9
>>
>>   Hits_1 = new(n_days,"float")
>>
>>   Hits_4km = new(n_days,"float")
>>
>>   Hits_1 = 0.0
>>
>>   Hits_4km = 0.0
>>
>>   do ii_day = 0,dims-1
>>
>>     if (ii_day .eq.0)then
>>
>>       i_day = 0
>>
>>     else
>>
>>       i_day = (mod(ii_day,3))
>>
>>     end if
>>
>>     ;printVarSummary(i_day)
>>
>>     ;print("i_day = "+ i_day)
>>
>>     Hits_1(i_day) = Hits_4km(i_day) + Hits_1(i_day)
>>
>>     print(Hits_1(i_day))
>>
>>   end do
>>
>> end
>>
>>
>>
>> /M
>>
>>
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Marston S. Ward, PhD
>>
>> Department of Earth Sciences
>>
>> University of Gothenburg, Sweden
>>
>> Email: marston.johnston at gu.se
>>
>> SkypeID: marston.johnston
>>
>> Phone: +46-31-7864901 <+46%2031%20786%2049%2001>
>>
>> Only the fruitful thing is true!
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>>
>>
>>
>> *From: *ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of Barry Lynn <
>> barry.h.lynn at gmail.com>
>> *Date: *Thursday, 19 October 2017 at 16:18
>> *To: *ncl-talk <ncl-talk at ucar.edu>
>> *Subject: *[ncl-talk] A NCL Mystery Solved
>>
>>
>>
>> Hi:
>>
>>
>>
>> I have this error (it didn't obviously show up with a Google search).
>>
>>
>>
>> fatal:Assign: Hits_1 is undefined, can not subscript an undefined variable
>>
>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 17 in
>> file ./test.ncl
>>
>> Before defining Hits_1 as an array of size n_days, I needed the : to do
>> the sum.
>>
>> However, it is the : that causes the error when the variable is defined
>> as an array.
>>
>> I am not sure why, but I thought I would make a note of it for those who
>> encounter the same error message.
>>
>>
>>
>> begin
>>
>>   n_days  = 3
>>
>>   dims = 9
>>
>>   Hits_1 = new(n_days,float)
>>
>>   printVarSummary(Hits_1)
>>
>>   Hits_4km = new(n_days,float)
>>
>>   Hits_1 = 0
>>
>>   Hits_4km = 0
>>
>>   do ii_day = 0,dims,1
>>
>>    if (ii_day .eq.0)then
>>
>>    i_day = tointeger(0)
>>
>>    else
>>
>>    i_day = (mod(ii_day,3))
>>
>>    end if
>>
>>    printVarSummary(i_day)
>>
>>    print("i_day = " + i_day)
>>
>>     *Hits_1(i_day) := Hits_4km(i_day) + Hits_1(i_day) ; **remove colon
>> if Hits_1 is defined as an array.*
>>
>>   end do
>>
>> end
>>
>>
>>
>>
>>
>> --
>>
>> Barry H. Lynn, Ph.D
>>
>> Senior Lecturer,
>>
>> The Institute of the Earth Science,
>> The Hebrew University of Jerusalem,
>> Givat Ram, Jerusalem 91904, Israel
>>
>> Tel: 972 547 231 170
>> Fax: (972)-25662581
>>
>>
>>
>> C.E.O, Weather It Is, LTD
>> Weather and Climate Focus
>> http://weather-it-is.com
>> Jerusalem, Israel
>> Local: 02 930 9525
>> Cell: 054 7 231 170
>> Int-IS: x972 2 930 9525
>> US 914 432 3108 <(914)%20432-3108>
>>
>> _______________________________________________ ncl-talk mailing list
>> ncl-talk at ucar.edu List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108 <(914)%20432-3108>
>



-- 
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171019/5f802fb7/attachment.html>


More information about the ncl-talk mailing list