<div dir="ltr"><div>My recollection is that the way fortran and NCL handled 'indirect subscripting' (my words) yielded different results. <br></div><div>Hence, the 'expected results' are colored by past expeerience in fortran.</div><div><br></div><div>Unfortunately, I can not find my NCL/fortran example. Sorry.</div><div><br></div><div>D<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 30, 2018 at 11:27 AM Rick Brownrigg <<a href="mailto:brownrig@ucar.edu">brownrig@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Axel,</div><div><br></div><div>Apologies in delay in getting back to you on this. As far as I can tell, the behavior ox "x(idx) = x(idx) + z" is the intended behavior (perhaps not the same as "desired" behavior in your case), in the sense that the right-hand side is completely evaluated before the (re)assignment to the variable "x": is performed.</div><div><br></div><div>The do-loop approach does work -- it it just unbearably slow? Without knowing more about your data, I don't have a suggestion for how to avoid looping.</div><div><br></div><div>Rick</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018 at 10:37 AM Axel Seifert <<a href="mailto:Axel.Seifert@dwd.de" target="_blank">Axel.Seifert@dwd.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p><br>
</p>
<p>Maybe I should add that the output of my little script is</p>
<p><br>
</p>
<p>(0) 0 0<br>
(1) 3 4<br>
(2) 2 2<br>
</p>
<p><br>
</p>
<p>This is with NCAR Command Language Version 6.3.0<br>
</p>
<p><br>
</p>
<p>The variables x and y are<br>
</p>
<p><br>
</p>
<p>Variable: x<br>
Type: float<br>
Total Size: 12 bytes<br>
3 values<br>
Number of Dimensions: 1<br>
Dimensions and sizes: [3]<br>
Coordinates: <br>
Number Of Attributes: 1<br>
_FillValue : 9.96921e+36<br>
(0) 0<br>
(1) 3<br>
(2) 2<br>
<br>
Variable: y<br>
Type: float<br>
Total Size: 12 bytes<br>
3 values<br>
Number of Dimensions: 1<br>
Dimensions and sizes: [3]<br>
Coordinates: <br>
Number Of Attributes: 1<br>
_FillValue : 9.96921e+36<br>
(0) 0<br>
(1) 4<br>
(2) 2<br>
<br>
</p>
<p><br>
</p>
<br>
<div class="m_6048245336473263855gmail-m_-6216440519127204226moz-cite-prefix">Am 24.11.2018 um 15:16 schrieb Seifert
Axel:<br>
</div>
<blockquote type="cite">
<p><br>
</p>
<p>Hi,<br>
</p>
<p><br>
</p>
<p>I have a somewhat unexpected behavior when using index lists.
Here a simplified example:<br>
</p>
<div><br>
</div>
<div> x = new( 3, float)</div>
<div> x = 0.0</div>
<div> y = x</div>
<div> </div>
<div> z = (/1.,2.,3./)<br>
</div>
<div> idx = (/1,2,1/)</div>
<div> </div>
<div> x(idx) = x(idx) + z</div>
<div><br>
</div>
<div> do i=0,dimsizes(idx)-1</div>
<div> y(idx(i)) = y(idx(i)) + z(i)</div>
<div> end do</div>
<div><br>
</div>
<div> print(" "+x+" "+y)</div>
<div><br>
I would have expected that x and y end up being the same, but
they are not. The double assignment to index 1 does not work for
the vector assignment. Is this the intended behavior for arrays
in ncl? <br>
</div>
<div><br>
</div>
<div>How can I get the 2nd behavior and still avoid the do-loop?<br>
</div>
<div><br>
</div>
<div>In my case I am assigning measured values from satellite
overpasses to a global grid and it can of course happen that I
have multiple overpasses for a grid point in an observation
vector. Hence, in addition to the sum of the values I would
count the number of overpasses<br>
</div>
<div><br>
</div>
<div>
<div> cnt = (/0,0,0/)</div>
<div> cnt(idx) = cnt(idx) + 1<br>
</div>
<div> print(" "+cnt)<br>
</div>
<div><br>
</div>
<div>and then xavg = x/cnt should give me the proper average
for, for example, one hour of data. What I need in the end is
the correct average for xavg and the number of measurements
used at each grid point.<br>
</div>
</div>
<div><br>
</div>
<div>Thanks in advance for any helpful comments and suggestions.<br>
</div>
<div><br>
</div>
<div>Axel<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<p><br>
</p>
<br>
<fieldset class="m_6048245336473263855gmail-m_-6216440519127204226mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
ncl-talk mailing list
<a class="m_6048245336473263855gmail-m_-6216440519127204226moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="m_6048245336473263855gmail-m_-6216440519127204226moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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>
</blockquote></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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>
</blockquote></div>