The 2nd approach is the only way to correctly apply the indexing.
(I believe the 1st approach would work in fortran-90.)
--- Minimizing loops in any interpreted language is important for efficiency. I suggest you use some timing procedures to isolate those that are taking up time http://www.ncl.ucar.edu/Document/Functions/Contributed/wallClockElapseTime.shtml version 6.1.0 http://www.ncl.ucar.edu/Document/Functions/Built-in/get_cpu_time.shtml --- Using array syntax can significantly reduce CPU time. Sometimes you may have to loop but can use array syntax in the inner loops. replace do j=.. do i=... ... operations ... end do end do with do j=... ... array operations on i subscript... end do Good luck On 4/8/13 1:11 AM, astroqing wrote: > Hi, > > I am trying to use a simple loop with NCL sentences as followed: > > indices = ind_resolve(ind(dbz11D.gt.40),dsizes_dbz1) > printVarSummary(indices) > cs(indices(:,0),indices(:,1)) = 1 > > With "printVarSummary(indices)", it shows that 25098 points in indices, but after "cs(indices(:,0),indices(:,1)) = 1", 202211 points has changed with 1. It is wrong. > > But when I try to use the following sentences, > > indices = ind_resolve(ind(dbz11D.gt.40),dsizes_dbz1) > printVarSummary(indices) > Nind = dimsizes(indices) > do i = 0,Nind(0)-1 > cs(indices(i,0),indices(i,1)) = 1 > end do > > The NCL does right, with 25908 points same with indices changed with 1. > > Because in my ncl script there are so many loops, so I want to save time with using less loops as possible. > > Could you help me and tell me how to solve this problem? Thanks a lot > > Tao > > 2013-04-08 > > > > _______________________________________________ > 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-talkReceived on Mon Apr 8 07:45:45 2013
This archive was generated by hypermail 2.1.8 : Mon Apr 15 2013 - 20:12:25 MDT