<div dir="ltr"><div><div>Hi,<br><br></div>I&#39;m wondering if there is a way to speed up the do loops in the code below?<br></div>I&#39;m not sure it can be done, but I&#39;m not an expert. <br><div><br></div><div>;***** 2D histogram ******<br></div><div>; x and y axis<br></div><div>darr = ispan(-80,80,1)<br>sarr = new(dimsizes(darr),string)<br>sarr = &quot; &quot;<br>char = ispan(150,300,1)<br><br></div><div>; histogram bins<br></div><div>hist5m4 = new((/dimsizes(darr),dimsizes(char)/),float)<br>hist5m4@_FillValue = default_fillvalue(&quot;float&quot;)<br>hist5m4!0 = &quot;diff&quot;<br>hist5m4!1 = &quot;Tb&quot;<br>hist5m4&amp;diff = darr<br>hist5m4&amp;Tb = char<br>ndarr = dimsizes(darr)<br>nchar = dimsizes(char)<br>hist5m4 = 0.0<br>hist5m3 = hist5m4<br>hist5m3 = 0.0<br>hist4m3 = hist5m4<br>hist4m3 = 0.0<br><br>tb5m4 = mhs(4,:,:) - mhs(3,:,:)<br>copy_VarMeta(mhs(3,:,:),tb5m4)<br>tb5m3 = mhs(4,:,:) - mhs(2,:,:)<br>copy_VarMeta(mhs(2,:,:),tb5m3)<br>tb4m3 = mhs(3,:,:) - mhs(2,:,:)<br>copy_VarMeta(mhs(2,:,:),tb5m3)<br><br>mhs5 := round(ndtooned(mhs(4,:,:)),0)<br>mhs4 := round(ndtooned(mhs(3,:,:)),0)<br>mhs3 := round(ndtooned(mhs(2,:,:)),0)<br><br>tb5m4 := round(ndtooned(tb5m4),0)<br>tb5m3 := round(ndtooned(tb5m3),0)<br>tb4m3 := round(ndtooned(tb4m3),0)<br><br>; print(darr(y)+&quot; &lt;= DARR:CH5AR =&gt; &quot;+ch5ar(x))<br></div><div>; Fill the bins<br></div><div>do x = 0, nchar - 1<br>   do y = 0, ndarr - 1<br>      tmp := ind(mhs5.eq.char(x) .and. tb5m4.eq.darr(y))<br>      if(dimsizes(tmp).gt.1) then<br>        hist5m4(y,x) = hist5m4(y,x) + (dimsizes(tmp) - 1)<br>      end if<br>      tmp := ind(mhs5.eq.char(x) .and. tb5m3.eq.darr(y))<br>      if(dimsizes(tmp).gt.1) then<br>        hist5m3(y,x) = hist5m3(y,x) + (dimsizes(tmp) - 1)<br>      end if<br>      tmp := ind(mhs4.eq.char(x) .and. tb4m3.eq.darr(y))<br>      if(dimsizes(tmp).gt.1) then<br>        hist4m3(y,x) = hist4m3(y,x) + (dimsizes(tmp) - 1)<br>      end if<br>  end do<br>end do<br><div><div><br></div><div>Appreciate your help with this,<br></div><div>/M<br clear="all"></div><div><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><font color="#0000ff">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</font></div><div><font color="#0000ff">Marston S. Johnston, PhD</font></div><div><font color="#0000ff">Department of Earth Sciences</font></div><div><font color="#0000ff">University of Gothenburg</font><span style="color:rgb(0,0,255)">, Sweden</span></div><div><font color="#0000ff">Email: <a href="mailto:marston.johnston@gu.se" target="_blank">marston.johnston@gu.se</a> </font></div><div><font color="#0000ff">Phone: +46-31-7864901 <br></font></div><div><font color="#0000ff">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</font></div><div><font color="#0000ff">Only the fruitful thing is true!</font></div></div></div></div></div></div>
</div></div></div></div>