[ncl-talk] usage of "continue" [SEC=UNOFFICIAL]
Jack Ogaja
jack.ogaja at gmail.com
Tue Oct 27 13:49:56 MDT 2015
Thanks for the corrections and pointing out the misleading syntax I wrote.
Jack
> On 27 Oct 2015, at 19:59, Dennis Shea <shea at ucar.edu> wrote:
>
> YES!!!! 'break' ... sorry!!!! THX
>
>
> do i=0,10
> do j=0,20
> If(a(i).eq.b(j)) then
> X = j
> break ; exit 'j' loop; go to 1st statement after the end
> of the 'j' loop
> end if
> end do ; end 'j' loop
> end do ; end 'i' loop
>
> The above 'break' will jump to
> end do ; end 'i' loop
>
>
> On Tue, Oct 27, 2015 at 12:48 PM, David Brown <dbrown at ucar.edu> wrote:
>> Hi Dennis,
>> Don't you mean "break" rather than "exit"? "exit" would quit the whole script.
>> -dave
>>
>>
>> On Tue, Oct 27, 2015 at 12:38 PM, Dennis Shea <shea at ucar.edu> wrote:
>>> Actually,
>>>
>>> i+=1
>>>
>>> is not NCL legal.
>>>
>>> ===
>>>
>>> This code is certainly not NCL ...
>>>
>>> Do i=0,10
>>> Do j=0,20
>>> If(a(i).eq.b(j)) then
>>> X = j
>>> Go to 333
>>> End if
>>> End do
>>> 333 continue
>>> End do
>>>
>>> BUT
>>>
>>> do i=0,10
>>> do j=0,20
>>> If(a(i).eq.b(j)) then
>>> X = j
>>> exit ; exit 'j' loop
>>> end if
>>> end do ; end 'j' loop
>>> end do ; end 'i' loop
>>>
>>> The above 'exit' will jump to
>>> end do ; end 'i' loop
>>>
>>> On Tue, Oct 27, 2015 at 5:42 AM, Jack Ogaja <jack.ogaja at gmail.com> wrote:
>>>> Hi Eunpa,
>>>>
>>>> In this case “continue” is a terminal statement. I suppose in ncl you would
>>>> substitute that with a “while loop” syntax. For example
>>>>
>>>> ;———
>>>> i = 0
>>>> do j = n, m
>>>> do while ( i .lt. j)
>>>> X=j
>>>> i+=1
>>>> end do
>>>> end do
>>>> ;———
>>>>
>>>> see: http://www.ncl.ucar.edu/Document/Language/loops.shtml
>>>>
>>>> Jack
>>>>
>>>>
>>>>
>>>> On 27 Oct 2015, at 12:15, Eun-Pa Lim <E.Lim at bom.gov.au> wrote:
>>>>
>>>> Dear Jack
>>>>
>>>>
>>>>
>>>> Thanks for your reply J
>>>>
>>>>
>>>>
>>>> I was just trying to make very simple do loops looking like this in old
>>>> fortran
>>>>
>>>>
>>>>
>>>> Do i=0,10
>>>>
>>>> Do j=0,20
>>>>
>>>> If(a(i).eq.b(j)) then
>>>>
>>>> X = j
>>>>
>>>> Go to 333
>>>>
>>>> End if
>>>>
>>>> End do
>>>>
>>>> 333 continue
>>>>
>>>> End do
>>>>
>>>>
>>>>
>>>> But "Go to " is not a statement used in NCL, and there is not much
>>>> explanation about "continue" in the NCL page.
>>>>
>>>>
>>>>
>>>> There must be a way to do this in NCL I reckon!
>>>>
>>>>
>>>>
>>>> Cheers
>>>>
>>>>
>>>>
>>>> Eunpa
>>>>
>>>>
>>>>
>>>> Eun-Pa Lim
>>>>
>>>> Research Scientist
>>>>
>>>> Seasonal Prediction Science Team
>>>>
>>>> Centre for Australian Weather and Climate Research (CAWCR)
>>>>
>>>> Bureau of Meteorology
>>>>
>>>> Tel: +61-3-9669-4636
>>>>
>>>> http://www.cawcr.gov.au/staff/elim/index.php
>>>>
>>>>
>>>>
>>>> From: Jack Ogaja [mailto:jack.ogaja at gmail.com]
>>>> Sent: Tuesday, 27 October 2015 10:10 PM
>>>> To: Eun-Pa Lim
>>>> Cc: ncl-talk at ucar.edu
>>>> Subject: Re: [ncl-talk] usage of "continue" [SEC=UNOFFICIAL]
>>>>
>>>>
>>>>
>>>> Really…? I guess it will be easier if you show a piece of ncl script which
>>>> gives a hint of what you are trying to achieve. In principle if you
>>>> understand what “continue” means/does in ‘your preferred' language, then I
>>>> assume you should be able to implement or know whether it is possible to
>>>> implement a similar algorithm in ncl after reading the ncl-statements
>>>> documentation and probably going through a few examples.
>>>>
>>>>
>>>>
>>>> Or you can just provide a Pseudocode of your intended program to make it
>>>> easier for somebody to help.
>>>>
>>>>
>>>>
>>>> Jack
>>>>
>>>>
>>>>
>>>> On 27 Oct 2015, at 11:12, Eun-Pa Lim <E.Lim at bom.gov.au> wrote:
>>>>
>>>>
>>>>
>>>> Hi NCL users,
>>>>
>>>>
>>>>
>>>> Could anybody please teach me how to use "continue" in a do loop in NCL? I
>>>> can't find an example in
>>>> https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml
>>>>
>>>>
>>>>
>>>> Many thanks!
>>>>
>>>>
>>>>
>>>> Eunpa
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Eun-Pa Lim
>>>>
>>>> Research Scientist
>>>>
>>>> Seasonal Prediction Science Team
>>>>
>>>> Centre for Australian Weather and Climate Research (CAWCR)
>>>>
>>>> Bureau of Meteorology
>>>>
>>>> Tel: +61-3-9669-4636
>>>>
>>>> http://www.cawcr.gov.au/staff/elim/index.php
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
More information about the ncl-talk
mailing list