Re: replacing the do loops

From: Alessandra Giannini <alesall_at_nyahnyahspammersnyahnyah>
Date: Wed, 06 Jun 2007 16:42:35 -0400

Hi Debasish,

not a full-blown suggestion, sorry, just a couple of hints... You should
try with multidimensional arrays.
Create latitude and longitude arrays of the same dimension as T1, by
repeating the original array as fit - you can use onedtond to do that.
(And reorder by indexing the dimensions appropriately).
And then use "mask".

Hope this helps... Or else, I may have misunderstood what you are trying
to do.

cheers, alessandra

-- 
Alessandra Giannini
IRI for Climate and Society - The Earth Institute at Columbia University
P.O. Box 1000, Palisades NY 10964-8000
phone/fax: +1 845 680-4473/4864 - email: alesall_at_iri.columbia.edu
Debasish Pai Mazumder wrote:
> Hi,
>
>  
>
> Does anyone have a suggestion how to do this without using a do loop 
> and if statement, so it's faster?
>
>  
>
> T1=new ((/24, 848, 70,150/), double)
>
> T1 (:,:,:,:) =-9999.
>
> T1@_FillValue = -9999.         ; sets _FillValue to -9999
>
> m= -1
>
> do i=0,15
>
>    do j=0,52
>
>       m=m+1
>
>       do k=0,69
>
>          do l=0,149
>
>             if(lat(k).ge.lat1(i).and.lat(k).le.lat1(i+1)) then
>
>             if(lon(l).ge.lon1(j).and.lon(l).le.lon1(j+1)) then
>
>             T1(:,m,k,l)= TLand(:,k,l)
>
>             end if
>
>             end if
>
>          end do
>
>        end do
>
>        print(m)
>
>     end do
>
> end do
>
> printVarSummary(T1)
>
>  
>
> Thanks
>
>  
>
> Debasish
>
>  
>
> ---------------------------------------------------------------------------------
>
>  
>
> Debasish Pai Mazumder
>
> Graduate Research Assistant
> Geophysical Institute,University of Alaska Fairbanks,
>
> 903 Koyukuk Drive
>
> Fairbanks, AK 99775
>
> USA
>
>  
>
> Phone :  +1 907 474 7618
>
> Email : debasish_at_gi.alaska.edu <mailto:debasish_at_gi.alaska.edu>
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>ncl-talk mailing list
>ncl-talk_at_ucar.edu
>http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>  
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 06 2007 - 14:42:35 MDT

This archive was generated by hypermail 2.2.0 : Fri Jun 15 2007 - 12:34:56 MDT