[ncl-talk] How to do the following array manipulation without using loop?

zuibeidemei zuibeidemei at 126.com
Mon Sep 14 20:22:49 MDT 2015


Dear all:


             I'd like to apply the following array manipulation to a multi-dimentional array, but given the volume of the array, 
         
             a loop operation cannot be accepted. How can this be done without using a loop? Thanks in advance for any suggestion.


                  x  = 1e20
                  a  = (/1,2,3,4,5,6,x,x,x,x,x,x,x,x,x/)
                  b  = (/x,x,x,x,x,x,x,x,x,1,2,3,4,5,6/)
                  c1 = (/x,1,x,1,x,1,x,1,x,1,x,x,x,x,x/)
                  c2 = (/x,1,x,1,x,1,1,1,1,1,1,x,x,x,x/)


                  index_up  = max(ind(a.ne.x))
                  index_low = min(ind(b.ne.x))


                  if(.not.all(c1(index_up:index_low).ne.x))then
                          c1(index_up:index_low)  = x
                  end if


                  if(.not.all(c2(index_up:index_low).ne.x))then
                      c2(index_up:index_low) = x
                  end if




For example, in a 2D case:


                  a   = (/(/1,2,3,4,5,6,x,x,x,x,x,x,x,x,x/),(/1,2,3,4,5,6,x,x,x,x,x,x,x,x,x/)/)
          b   = (/(/x,x,x,x,x,x,x,x,x,1,2,3,4,5,6/),(/x,x,x,x,x,x,x,x,x,1,2,3,4,5,6/)/)
          c1 = (/(/x,1,x,1,x,1,x,1,x,1,x,x,x,x,x/),(/x,1,x,1,x,1,x,1,x,1,x,x,x,x,x/)/)
                  c2 = (/(/x,1,x,1,x,1,1,1,1,1,1,x,x,x,x/),(/x,1,x,1,x,1,1,1,1,1,1,x,x,x,x/)/)


                  The above operation should be copied to the other dimension, which should yield same results as in the first dimension.


Best




               


              


             


             
             
             
            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150915/973f5288/attachment.html 


More information about the ncl-talk mailing list