<div dir="ltr"><div class="gmail_default" style="font-size:small">I'm not sure if anybody responded to this, but given the complexity of the logic, I'm not sure there's one statement that you can use to handle this without some kind of looping. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I assume that the index locations index_up and index_low could potentially be different each time through the loop?<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I tried to think of a way that you could actually combine a and b into one array, for example:</div><div class="gmail_default" style="font-size:small">
<p class=""><font face="monospace, monospace"><span class="">ab = </span><span class="">where</span><span class="">(a</span><span class="">.eq.</span><span class="">x</span><span class="">.and.</span><span class="">b</span><span class="">.ne.</span><span class="">x,b,a)<br></span><span class="">ab = </span><span class="">where</span><span class="">(b</span><span class="">.eq.</span><span class="">x</span><span class="">.and.</span><span class="">a</span><span class="">.ne.</span><span class="">x,a,ab)</span></font></p><p class=""><span class="">and then use this to simplify the logic, but this isn't quite right, and, in addition, the logic you need to apply with c1 and c2 is too complex for a single line.</span></p></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I would suggest writing a small Fortran subroutine that does the looping, and then wrap this subroutine using WRAPIT so you can call it from NCL. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">For some examples, see:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><a href="http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#Examples">http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml#Examples</a><br></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style="">--Mary</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 14, 2015 at 8:22 PM, zuibeidemei <span dir="ltr"><<a href="mailto:zuibeidemei@126.com" target="_blank">zuibeidemei@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="font:14px/1.5 'Lucida Grande','\005fae\008f6f\0096c5\009ed1';color:#333"><div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7">Dear all:</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> I'd like to apply the following array manipulation to a multi-dimentional array, but given the volume of the array, </div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> </div><div><font face="Arial" color="#000000"><span style="line-height:1.7"> a loop operation </span></font><span style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7">cannot be accepted. How can this be done without using a loop? </span><font face="Arial" color="#000000"><span style="line-height:23px">Thanks in advance for any suggestion.</span></font></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> x = 1e20</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> a = (/1,2,3,4,5,6,x,x,x,x,x,x,x,x,x/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> b = (/x,x,x,x,x,x,x,x,x,1,2,3,4,5,6/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> c1 = (/x,1,x,1,x,1,x,1,x,1,x,x,x,x,x/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> c2 = (/x,1,x,1,x,1,1,1,1,1,1,x,x,x,x/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> index_up = max(ind(a.ne.x))</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> index_low = min(ind(b.ne.x))</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> if(.not.all(c1(index_up:index_low).ne.x))then</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> c1(index_up:index_low) = x</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> end if</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> if(.not.all(c2(index_up:index_low).ne.x))then</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> c2(index_up:index_low) = x</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> end if</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7">For example, in a 2D case:</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> <span style="line-height:1.7">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/)/)</span></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> <span style="white-space:pre-wrap">        </span> 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/)/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> <span style="white-space:pre-wrap">        </span> 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/)/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> 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/)/)</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> The above operation should be copied to the other dimension, which should yield same results as in the first dimension.</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7">Best</div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"><br></div><div style="color:rgb(0,0,0);font-family:Arial;font-size:14px;line-height:1.7"> </div></div><div><font face="Arial" color="#000000"><span style="line-height:23px"><br></span></font></div><div><font face="Arial" color="#000000"><span style="line-height:23px"> <br></span></font><br><br><font style="color:rgb(0,0,0)" face="Arial"><span style="line-height:1.7"> </span></font><br><br><br><font style="color:rgb(0,0,0)" face="Arial"><span style="line-height:1.7"> </span></font><br><font style="color:rgb(0,0,0)" face="Arial"><span style="line-height:1.7"> </span></font><br><font style="color:rgb(0,0,0)" face="Arial"><span style="line-height:1.7"> </span></font><br><font style="color:rgb(0,0,0)" face="Arial"><span style="line-height:1.7"> </span></font><br></div></div></div><br><br><span title="neteasefooter"><p> </p></span><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>