Something like:
http://www.ncl.ucar.edu/Document/Functions/Built-in/wgt_areasum2.shtml
--- Also gridPointTot = dim_sum_n_Wrap( aFCH4 , 0) gridTot = gridPointTot*WGTS where WGTS is the area of each drid point. --- In *all* interpreted languages multiple level doo loops with multiple steps should be avoided if possible. Unlike (say) fortran, there is no compiler to perform code optimization. For example, > diff_lon = 2.8152d*3.14159265d/180.0d > R=6371.0d*1000.0d ; unit is meterncd WHy repeat this every step? Lei Meng wrote: > Hi, > I was wondering if there are some faster ways to calculate globally > total emissions. I used the following code and it looped over each grid > cell to calculate total values. It takes so long to finish the calculation. > -------------------------- > totalfch4=0.0d > do i =0, natime-1 > do j=0,nalat-1 > rlat2= (alat(j)+1.429)*3.14159265/180.0 ; convert degree to radians > rlat1= (alat(j)-1.429)*3.14159265/180.0 > temp1 = sin(rlat2) > temp2 = sin(rlat1) > temp = temp1-temp2 > > do k=0,nalon-1 > if(.not.ismissing(aFCH4(i,j,k))) > then > diff_lon = 2.8152d*3.14159265d/180.0d > R=6371.0d*1000.0d ; unit is meterncd > area=R*R*diff_lon*temp > if(area.lt.0) then > area=0.0 > end if > totalfch4=aFCH4(i,j,k)*area ; convert > from kgC/m2/s to kgC/s by multiplying area > afch4(i) = afch4(i)+totalfch4 > end if > end do > end do > end do > ------------------------------------ > Any suggestions would be appreciated. Thanks, > Lei > > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 Tue Dec 15 16:19:00 2009
This archive was generated by hypermail 2.1.8 : Thu Dec 17 2009 - 17:15:52 MST