[ncl-talk] Making new variables in a loop

Barry Lynn barry.h.lynn at gmail.com
Tue Apr 13 23:58:07 MDT 2021


Dave:

The problem is that a new variable cannot be created more than once in a
loop over different files (where each file has a different number of
elements within).

The simple solution is to delete (varaible_name) after each loop.

Thank you for your suggestions,

Barry

On Tue, Apr 13, 2021 at 10:14 PM Dave Allured - NOAA Affiliate <
dave.allured at noaa.gov> wrote:

> Barry, no, you can not create new memory variables in a loop.  You CAN
> create new file variables in a loop.  But I sincerely doubt that is what
> you want to do.
>
> I recommend using the reassignment operator ":=".  If that gives you a
> different error, then debug that specifically.  If that is still a problem,
> please show us what you mean by "another error".  HTH.
>
>
> On Tue, Apr 13, 2021 at 1:04 PM Barry Lynn via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Hello:
>>
>> I define new variables:
>>
>>   height_gmax  = new(ng_lines,float)   ; Create array to hold marker
>> objects
>>   height_gmin  = new(ng_lines,float)   ; Create array to hold marker
>> objects
>>
>> The problem is that the second time around there is an error that their
>> size has changed.  But, if I add a colon (:) to the definition, I will get
>> another error.
>>
>> Is there a way to create a new variable every time step?
>>
>> Thanks
>>
>> --
>> Guest Editor of Special Issue “Extreme Hydroclimatic Events and
>> Prediction”
>> LINK:
>>
>> https://www.mdpi.com/journal/water/special_issues/Extreme_Hydroclimatic_Events
>>
>> Barry H. Lynn, Ph.D
>> Senior Associate Scientist, 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
>>
>

-- 
Guest Editor of Special Issue “Extreme Hydroclimatic Events and Prediction”
LINK:
https://www.mdpi.com/journal/water/special_issues/Extreme_Hydroclimatic_Events

Barry H. Lynn, Ph.D
Senior Associate Scientist, 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210414/50f71b6c/attachment.html>


More information about the ncl-talk mailing list