<html>#2960: CarpetRegrid2: failure to regrid on relative radius change - possible underlying race condition
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Jordan Nicoules</td></tr>
<tr><td style='text-align:right'> Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'> Version:</td><td></td></tr>
<tr><td style='text-align:right'> Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>major</td></tr>
<tr><td style='text-align:right'>Component:</td><td>Carpet</td></tr>
</table>
<h3 id="markdown-header-initial-bug">Initial bug...</h3>
<p><code>CarpetRegrid2</code> does not properly check for a change of radius of the refinement levels (when they are steered by a <code>Trigger</code> for instance).
Looking a bit closer, it seems that the computed <code>drfac</code> in <code>CarpetRegrid2/src/regrid.cc</code> is <code>nan</code>, and thus <code>do_recompose</code> is not set to <code>true</code>.
In particular, it means it <em>is</em> possible to change the radii if something else triggers a regridding (for instance, changing the number of active levels).</p>
<h3 id="markdown-header-revealed-a-deeper-issue-race-condition-memory-or-compiler-issue">... revealed a deeper issue (race condition? Memory or compiler issue?)</h3>
<p>To figure out why <code>drfac</code> is <code>nan</code>, I added manual debugging information prints in the code. Depending on what information I ask, and in what order, I don't get consistent nor sensible results.<br>
<em>I haven't tried different compilers (I have gcc 11.4.0 locally), but this is happening even with a debug build (see attached make.config.defn file).</em></p>
<p>More precisely, printing <code>rad</code>, <code>oldrad</code>, <code>rad - oldrad</code>, their values are fine (done through <code>std::cout</code>).
Printing (<code>CCTK_VINFO</code>) the numerator and denominator of <code>drfac</code> separately gives the right values for them, but the quotient <code>drfac</code> is wrong (it is <code>0</code>, and not <code>nan</code> anymore, even when it shouldn't).<br>
If I create new local variables </p>
<div class="codehilite"><pre><span></span><code><span class="n">CCTK_REAL</span> <span class="k">const</span> <span class="n">num</span> <span class="o">=</span> <span class="nb">sqrt</span><span class="p">(</span><span class="n">sum</span><span class="p">(</span><span class="n">ipow</span><span class="p">(</span><span class="n">rad</span> <span class="o">-</span> <span class="n">oldrad</span><span class="p">,</span> <span class="mi">2</span><span
<p><table><tr><td>attachment:</td><td><a href="https://api.bitbucket.org/2.0/repositories/einsteintoolkit/tickets/issues/2960/attachments/CarpetRegrid2_bug.zip">CarpetRegrid2_bug.zip</a></td></tr>
</table></p>
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2960/carpetregrid2-failure-to-regrid-on'>https://bitbucket.org/einsteintoolkit/tickets/issues/2960/carpetregrid2-failure-to-regrid-on</a></p>
</html>