<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">In addition to the code Dennis sent. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Simple stand alone example of how the different statements work. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default">do t=0, 10</div><div class="gmail_default">if( t .eq. 3 )</div><div class="gmail_default"> continue</div><div class="gmail_default">end if</div><div class="gmail_default">if( t .eq. 6)</div><div class="gmail_default"> break</div><div class="gmail_default">end if</div><div class="gmail_default">print ( (/t/) )</div><div class="gmail_default">end do</div><div class="gmail_default"><br></div><div class="gmail_default">;;; output</div><div class="gmail_default">0</div><div class="gmail_default">1</div><div class="gmail_default">2 ; 3 continued so not printed. but loop "continue"s</div><div class="gmail_default">4</div><div class="gmail_default">5 ; 6 break. parent do loop is exited. </div><div class="gmail_default"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 27, 2015 at 11:48 AM, David Brown <span dir="ltr"><<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dennis,<br>
Don't you mean "break" rather than "exit"? "exit" would quit the whole script.<br>
-dave<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Oct 27, 2015 at 12:38 PM, Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br>
> Actually,<br>
><br>
> i+=1<br>
><br>
> is not NCL legal.<br>
><br>
> ===<br>
><br>
> This code is certainly not NCL ...<br>
><br>
> Do i=0,10<br>
> Do j=0,20<br>
> If(a(i).eq.b(j)) then<br>
> X = j<br>
> Go to 333<br>
> End if<br>
> End do<br>
> 333 continue<br>
> End do<br>
><br>
> BUT<br>
><br>
> do i=0,10<br>
> do j=0,20<br>
> If(a(i).eq.b(j)) then<br>
> X = j<br>
> exit ; exit 'j' loop<br>
> end if<br>
> end do ; end 'j' loop<br>
> end do ; end 'i' loop<br>
><br>
> The above 'exit' will jump to<br>
> end do ; end 'i' loop<br>
><br>
> On Tue, Oct 27, 2015 at 5:42 AM, Jack Ogaja <<a href="mailto:jack.ogaja@gmail.com">jack.ogaja@gmail.com</a>> wrote:<br>
>> Hi Eunpa,<br>
>><br>
>> In this case “continue” is a terminal statement. I suppose in ncl you would<br>
>> substitute that with a “while loop” syntax. For example<br>
>><br>
>> ;———<br>
>> i = 0<br>
>> do j = n, m<br>
>> do while ( i .lt. j)<br>
>> X=j<br>
>> i+=1<br>
>> end do<br>
>> end do<br>
>> ;———<br>
>><br>
>> see: <a href="http://www.ncl.ucar.edu/Document/Language/loops.shtml" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/Document/Language/loops.shtml</a><br>
>><br>
>> Jack<br>
>><br>
>><br>
>><br>
>> On 27 Oct 2015, at 12:15, Eun-Pa Lim <<a href="mailto:E.Lim@bom.gov.au">E.Lim@bom.gov.au</a>> wrote:<br>
>><br>
>> Dear Jack<br>
>><br>
>><br>
>><br>
>> Thanks for your reply J<br>
>><br>
>><br>
>><br>
>> I was just trying to make very simple do loops looking like this in old<br>
>> fortran<br>
>><br>
>><br>
>><br>
>> Do i=0,10<br>
>><br>
>> Do j=0,20<br>
>><br>
>> If(a(i).eq.b(j)) then<br>
>><br>
>> X = j<br>
>><br>
>> Go to 333<br>
>><br>
>> End if<br>
>><br>
>> End do<br>
>><br>
>> 333 continue<br>
>><br>
>> End do<br>
>><br>
>><br>
>><br>
>> But "Go to " is not a statement used in NCL, and there is not much<br>
>> explanation about "continue" in the NCL page.<br>
>><br>
>><br>
>><br>
>> There must be a way to do this in NCL I reckon!<br>
>><br>
>><br>
>><br>
>> Cheers<br>
>><br>
>><br>
>><br>
>> Eunpa<br>
>><br>
>><br>
>><br>
>> Eun-Pa Lim<br>
>><br>
>> Research Scientist<br>
>><br>
>> Seasonal Prediction Science Team<br>
>><br>
>> Centre for Australian Weather and Climate Research (CAWCR)<br>
>><br>
>> Bureau of Meteorology<br>
>><br>
>> Tel: <a href="tel:%2B61-3-9669-4636" value="+61396694636">+61-3-9669-4636</a><br>
>><br>
>> <a href="http://www.cawcr.gov.au/staff/elim/index.php" rel="noreferrer" target="_blank">http://www.cawcr.gov.au/staff/elim/index.php</a><br>
>><br>
>><br>
>><br>
>> From: Jack Ogaja [mailto:<a href="mailto:jack.ogaja@gmail.com">jack.ogaja@gmail.com</a>]<br>
>> Sent: Tuesday, 27 October 2015 10:10 PM<br>
>> To: Eun-Pa Lim<br>
>> Cc: <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>> Subject: Re: [ncl-talk] usage of "continue" [SEC=UNOFFICIAL]<br>
>><br>
>><br>
>><br>
>> Really…? I guess it will be easier if you show a piece of ncl script which<br>
>> gives a hint of what you are trying to achieve. In principle if you<br>
>> understand what “continue” means/does in ‘your preferred' language, then I<br>
>> assume you should be able to implement or know whether it is possible to<br>
>> implement a similar algorithm in ncl after reading the ncl-statements<br>
>> documentation and probably going through a few examples.<br>
>><br>
>><br>
>><br>
>> Or you can just provide a Pseudocode of your intended program to make it<br>
>> easier for somebody to help.<br>
>><br>
>><br>
>><br>
>> Jack<br>
>><br>
>><br>
>><br>
>> On 27 Oct 2015, at 11:12, Eun-Pa Lim <<a href="mailto:E.Lim@bom.gov.au">E.Lim@bom.gov.au</a>> wrote:<br>
>><br>
>><br>
>><br>
>> Hi NCL users,<br>
>><br>
>><br>
>><br>
>> Could anybody please teach me how to use "continue" in a do loop in NCL? I<br>
>> can't find an example in<br>
>> <a href="https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml" rel="noreferrer" target="_blank">https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml</a><br>
>><br>
>><br>
>><br>
>> Many thanks!<br>
>><br>
>><br>
>><br>
>> Eunpa<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Eun-Pa Lim<br>
>><br>
>> Research Scientist<br>
>><br>
>> Seasonal Prediction Science Team<br>
>><br>
>> Centre for Australian Weather and Climate Research (CAWCR)<br>
>><br>
>> Bureau of Meteorology<br>
>><br>
>> Tel: <a href="tel:%2B61-3-9669-4636" value="+61396694636">+61-3-9669-4636</a><br>
>><br>
>> <a href="http://www.cawcr.gov.au/staff/elim/index.php" rel="noreferrer" target="_blank">http://www.cawcr.gov.au/staff/elim/index.php</a><br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> ncl-talk mailing list<br>
>> <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>> List instructions, subscriber options, unsubscribe:<br>
>> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> ncl-talk mailing list<br>
>> <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>> List instructions, subscriber options, unsubscribe:<br>
>> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
>><br>
> _______________________________________________<br>
> ncl-talk mailing list<br>
> <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
> List instructions, subscriber options, unsubscribe:<br>
> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</div></div></blockquote></div><br></div>