Moritz:<br><br>>As Glynn suggests:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br>
<br>
for i = 1 to 10<br></div>
sum_new = sum + i<br>
g.remove rast=sum<br>
g.rename rast=sum_new,sum<br>
<br>
<br></blockquote><div><br>OK, sorry, I got so scared I overlooked Glynn's suggestion. I did another experiment to see the differences in processing time. Since I iterate 1260 times in my script, I tried the following alternatives with "i" varying from 1 to 1260:<br>
<br>1 - r.mapcalc "sum=sum+$i" # my suspicious way<br><br>2 - r.mapcalc "sum_new = sum + $i" # Glynn's suggestion after Moritz's explanation<br> g.remove rast=sum --q<br>
g.rename rast=sum_new,sum --q<br><br>3 - r.mapcalc "sum_new = sum + $i" # Moritz's suggestion<br> g.rename rast=sum_new,sum --overwrite --q<br><br>Results:<br><br>1 - 125 seconds<br>
2 - 183 seconds<br>3 - 154 seconds<br><br>Bottom line:<br><br>If Glynn says Moritz suggestion with the g.rename --overwrite is OK, I will give back the 30 seconds Moritz had saved me before :) and end up with 30 seconds more of processing time, but with no undefined behaviour. <br>
<br>If method number 2 must be used, I will end up with 60 seconds more, what won't do me any harm anyway.<br><br>Thanks a lot for this interesting exercise. <br><br>Cheers,<br>Marcello.<br><br><br><br><br><br><br><br>
<br><br></div></div>