<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Mike,<div><br></div><div>I think you need to put in some debug writes to determine where the problem is.</div><div><br></div><div>For one, do you know if the code is ever making it inside the "if (.not.ismissing(latN_lgth(k)) .and. latN_lgth(k) .eq. 134) then" statement? If not, then layer_top will always be set to -9999.</div><div><br></div><div>First, though, I think we can clean up this code so there aren't as many nested "do" loops. Do loops run slow in NCL (as well as other interpreted languages).</div><div><br></div><div>For example, instead of:</div><div><br></div><div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>&nbsp;&nbsp; &nbsp; &nbsp;do l = 0,3 &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;do m=0,134</div><div>&nbsp;&nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space: pre; ">        </span>&nbsp;if (ftr_chk(k,m,l) .eq. 6) then</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&nbsp;&nbsp; &nbsp;layer_top_(k,m,l) = layer_top(k,m,l)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&nbsp;else</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&nbsp;&nbsp; &nbsp;layer_top_(k,m,l) = -9999</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&nbsp;end if</div><div>&nbsp;&nbsp; &nbsp; &nbsp; end do</div><div>&nbsp;&nbsp; &nbsp; &nbsp; end do</div><div>&nbsp;&nbsp;&nbsp;</div></div></div></div></blockquote><br></div><div>you can use the "where" statement:</div><div><br></div><div>layer_top_ = where(ftr_chk(k,:,:).eq.6,layer_top(k,:,:),-9999)</div><div><br></div><div>To make sure that ftr_chk(k,:,:) actually contains some values that equal 6, you can print this:</div><div><br></div><div>&nbsp;&nbsp; print("# of values where ftr_chk is 6 = " + num(ftr_chk(k,:,:).eq.6))</div><div><br></div><div>to get the count of how many values are equal to 6.</div><div><br></div><div>Please put some debug statements like this in your code to see if you can narrow down the problem.</div><div><br></div><div>--Mary</div><div><br><div><div>On Feb 23, 2010, at 3:02 PM, Mike wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "> I am using 5km CALIPSO aerosol layer data and the aerosol classification and layer top variables. What I want to do is assign a value in the array called "layer_top_" from the array "layer_top" which I read from the file. However, I only want this value to be assigned to "layer_top_" if the aerosol is classified as "smoke", that is when ftr_chk (the feature classification, unpacked integer value) = 6. The code runs fine, but when I go back and check to see if everywhere the aerosol was classified as smoke, the corresponding "layer top" value has been put into the array "layer_top_" I notice that it didn't work correctly. Namely, ftr_chk(k,m,l) = 6, but layer_top_(k,m,l) = -9999 even though layer_top(k,m,l) = *value* (as reported in the original dataset). I've attached the code below (the latN_top and latN_btm are just there so I can just remove values for the latitude range I'm interested in):<div><div><br></div><div><div>do k = 0,37</div><div>&nbsp;&nbsp; if (.not.ismissing(latN_lgth(k)) .and. latN_lgth(k) .eq. 134) then</div><div>&nbsp;&nbsp; &nbsp; &nbsp;ftr_flg(k,:,:) = ftr_flg_tst(k,latN_top(k):latN_btm(k),:)</div><div>&nbsp;&nbsp; &nbsp; &nbsp;ftr_chk(k,:,:) = dim_gbits(ftr_flg(k,:,:),4,3,13,8)</div><div>&nbsp;&nbsp; &nbsp; &nbsp;layer_top(k,:,:) = layer_top_tst(k, latN_top(k):latN_btm(k),:)</div><div>&nbsp;&nbsp; &nbsp; &nbsp;lon1(k,:) = lonN(k, latN_top(k):latN_btm(k))</div><div>&nbsp;&nbsp; &nbsp; &nbsp;do l = 0,3 &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;do m=0,134</div><div>&nbsp;&nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> if (ftr_chk(k,m,l) .eq. 6) then</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;layer_top_(k,m,l) = layer_top(k,m,l)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> else</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;layer_top_(k,m,l) = -9999</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> end if</div><div>&nbsp;&nbsp; &nbsp; &nbsp; end do</div><div>&nbsp;&nbsp; &nbsp; &nbsp; end do</div><div>&nbsp;&nbsp; else</div><div>&nbsp;&nbsp; &nbsp; &nbsp;ftr_flg(k,:,:) = -999</div><div>&nbsp;&nbsp; &nbsp; &nbsp;layer_top(k,:,:) = -9999</div><div>&nbsp;&nbsp; end if</div><div>end do</div><div><br></div><div>Thanks for your help!</div><div><br></div><div>-Mike</div><br><div> <span class="Apple-style-span" style="font-size: 12px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div>Michael Tosca</div><div>Ph.D. Candidate</div><div>Dept. Earth System Science</div><div>University of California, Irvine</div><div>Irvine, CA 92697</div><div><a href="http://dust.ess.uci.edu/mtosca/web">http://dust.ess.uci.edu/mtosca/web</a></div></span></span> </div><br></div></div></div>_______________________________________________<br>ncl-talk mailing list<br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br></blockquote></div><br></div></body></html>