Re: do loop

From: Hobbs, Will R (3244-CalTech) <William.R.Hobbs_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 14 2011 - 18:52:43 MST

Manisha

At each loop, NCL increments the loop indices i, j and k. Since you are also incrementing them yourself (i.e. k = k+1, j = j+1 etc) you are effectively incrementing twice. Remove those lines and your code should be fine.

Hope that helps,

Will

On 1/14/11 5:35 PM, "Manisha Ganeshan" <manisha.ganeshan86@gmail.com> wrote:

Hi,

I am having trouble understanding the increment of do-loop variable.
Here is my code:
begin
;*******************************************
; open file and read in data
;*******************************************
indir = "/data1/mganesha/proposal/st4/2006/"
all_files=systemfunc("ls "+indir+"ST4.2006????12.24h.grb")
P = addfiles(all_files,"r")
P_tmp = new((/93,199,120/),float)
 do i = 0,92
   do j=0,198
      do k=0,119
        P_tmp(i,j,k) = P[i]->A_PCP_GDS5_SFC_acc24h(j+452,k+595)
        k=k+1
      end do
      j=j+1
   end do
   i=i+1
 end do

print(i)
print(j)
print(k)
end

The values of i,j, k are
i = 94
j = 200
k = 120

Could you please tell me why i and j are increased by 2, while k is increased by 1?

Nisha

**********************************************************
Will Hobbs, Ph.D. William.R.Hobbs@jpl.nasa.gov
Jet Propulsion Laboratory
4800 Oak Grove Dr. office: 300-324a
M/S 300-323 phone: (818) 354-0466
Pasadena, CA 91109 fax: (818) 354-0966
**********************************************************

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 14 18:52:53 2011

This archive was generated by hypermail 2.1.8 : Tue Jan 25 2011 - 14:22:16 MST