Re: How to accomplish a loop with negative stride?

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 22 2012 - 16:36:25 MDT

See the reference manual at http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml#Loops

Here's what it says about looping backwards:

The following shows how to specify a loop with an explicit stride. The following form is also necessary to loop backwards. With this form, if start is greater than end, then the identifier is decremented by the stride value, which must always be positive. If the start is less than the end, then the identifier is incremented by the stride value.

    do loop_identifier = scalar_start_expr , scalar_end_expr , scalar_stride_expr
         statement list
    end do

On Oct 22, 2012, at 4:15 PM, Wen.J.Qu wrote:

> Hi, all
>
> Would you please give some suggestions on how to accomplish a loop with negative stride? Just as below?
>
> Thanks a lot.
>
> Shawn
>
>
>
> **************************************************
> do i=lon90,lon180
> n588(year_index,day_index,i)=0.0
> do j=lat80,lat10,-1
> if((h(year_index,day_index,j,i)/10.0 .le. 588.0) .and. (h(year_index,day_index,j-1,i)/10.0 .le. 588.0))then
> n588(year_index,day_index,i)=j
> break
> end if
> end do
> end do
> **************************************************
>
> Wen.J.Qu
> 2012-10-22
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 22 16:36:36 2012

This archive was generated by hypermail 2.1.8 : Tue Oct 23 2012 - 11:10:04 MDT