# Re: Ind function and do loops

From: Dennis Shea (shea AT cgd.ucar.edu)
Date: Tue Feb 15 2005 - 17:11:06 MST

• Next message: Saravanan Arunachalam: "Support for Variable Grid Resolution Plotting"

See below

>
>This is a follow up to a previous email of mine regarding ignoring indices. I
>can ignore indices using the ind function when it lies outside of a do loop,
>but when I embed the ind function in a do loop, I get several fatal errors and
>the do loop cannot continue. This is problematic because I need to create
>multiple (1D) arrays, using an outter do loop. Below is a subset of my
>script. Any help would be greatly appreciated!
>
> do j=0,5
> r(j)=j*(De/2)
> RR(j) = r(j)/12.49135
> RAZ(j) = r(j)/(MidRVal*.01623)
>
>
> angle = new((/20/),float)
> azAngle = new((/20/),float)
> vel_circle = new((/20/),float)
> aVec = new((/20/),float)
> bVec = new((/20/),float)
> cVec = new((/20/),float)
> aVecSq = new((/20/),float)
> bVecSq = new((/20/),float)
>
> do i=0,19
> angle(i) = (2*3.14*i)/20
> rr(i) = dim_rMid+RR(j)*sin(angle(i))
> az(i) = dim_azMid+RAZ(j)*cos(angle(i))
>
> azAngle(i) = az(floattoint(az(i)))
> azAngle(i) = azAngle(i)*(3.14/180)
>
> vel_circle(i) = vel(floattoint(az(i)),floattoint(rr
>(i)))*.01
>
> k=ind(.not.ismissing(vel_circle))

The dimension size of the variable "k"
can change from one iteration of "i" to the next.
>
> aVec(k) = sin(angle(k)-azAngle(k))
> bVec(k) = cos(angle(k)-azAngle(k))
> cVec(k) = vel_circle(k)-15*cos(1.4-azAngle(k))
>
> aVecSq(k) = (aVec(k))^2
> bVecSq(k) = (bVec(k))^2

delete(k) ; delete, might be different for next "1"
>
> end do
>
>end do

FYI: if u really want to have a robust script. The following only
does computations if their are non-msg vel_circle

k=ind(.not.ismissing(vel_circle))

if (.not.ismissing(k)) then
aVec(k) = sin(angle(k)-azAngle(k))
bVec(k) = cos(angle(k)-azAngle(k))
cVec(k) = vel_circle(k)-15*cos(1.4-azAngle(k))

aVecSq(k) = (aVec(k))^2
bVecSq(k) = (bVec(k))^2
end if

delete(k) ; delete, might be different size
; for next "i"

good luck
D

_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

This archive was generated by hypermail 2b29 : Wed Feb 16 2005 - 08:01:45 MST