<div dir="ltr"><div>When the "if" statement gets complicated, I like to precompute the test condition. I think it makes the code easier to understand. Also I like to put parentheses around free-standing boolean expressions to make them distinct, even though they are not required.</div><div><br> if (input .eq. 0) then<br> test1 = (x1(i) .ge. xvalue)<br> else<br> test1 = (x1(i) .le. xvalue)<br> end if<br><br> if (test1) then<br> long if block ...<br> end if<br></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 7:37 AM Cathy Smith via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div>
<p>NCLers</p>
<p>I have need in NCL to set a comparison type based on a subroutine
input. That is, if the input is "0", then I want to check if
something is .ge. to a number. If it is "0", I want to check if it
is .le. <br>
</p>
<p>My 'if' block is long so I would like to avoid repeating that.
Any ideas?<br>
</p>
<p> if(x1(i)<b>.ge.</b>xvalue)then</p>
<p> etc.. many lines<br>
</p>
<p>end if</p>
<p>I am looking for runs, by the way. I saw some NCL runs
subroutines but they don't quite do what I need.</p>
<p>Thanks</p>
<p>Cathy Smith</p>
<p>(long live NCL!)</p>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div></div>