<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Dear all,</p>
<p><br>
</p>
<p>A couple of weeks ago, I found out that there was a bug in CarpetRegrid2. Namely, it does not properly check for a change of radius of the refinement levels (when they are steered by a Trigger for instance). Looking a bit closer, it seems that the computed
 `drfac` in `CarpetRegrid2/src/regrid.cc` is nan, and thus `do_recompose` is not set to true. In particular, it means it
<i>is</i> possible to change the radii if something else triggers a regridding (for instance, changing the number of active levels).</p>
<p><br>
</p>
<p><b></b>However, while I was trying to understand and fix this bug, it appeared there might be a deeper issue. I'm struggling to understand if it may be related to memory, compilation, ...<b></b></p>
<p><b></p>
<div><span style="font-weight: normal;">It would be helpful if any of you had some insight to share, or could try to replicate the issue. To that effect, I'm attaching a minimal parfile adapted from CarpetRegrid2/test/<span>regrid2_granularity.par</span>, as
 well as a modified regrid.cc file that should allow you to reproduce the situation. More details on the situation below. </span></div>
<div><span style="font-weight: normal;"><br>
</span></div>
<div><span style="font-weight: normal;">Best,</span></div>
<div><span style="font-weight: normal;"><br>
</span></div>
<div><span style="font-weight: normal;">Jordan</span></div>
<br>
</b>
<p></p>
<p>----------------------------</p>
<p><b></b>----- More details -----<b></b></p>
<p><b></b>----------------------------<b></b></p>
<p><b><br>
</b></p>
<p>To figure out why drfac is nan, 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. I'm reaching out here first instead of opening a ticket because
 I can't pinpoint the precise issue. </p>
<p>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).</p>
<p><br>
</p>
<p>More precisely, printing `rad`, `oldrad`, `rad - oldrad` is fine (done through std::cout).</p>
<p>Printing (CCTK_VINFO) the numerator and denominator of `drfac` separately gives the right values for them, but the quotient `drfac` is wrong (it is 0, and not nan anymore, even when it shouldn't).</p>
<p>If I create new local variables </p>
<p>```</p>
<p></p>
<div>CCTK_REAL const num = sqrt(sum(ipow(rad - oldrad, 2)));<br>
CCTK_REAL const den = sqrt(sum(ipow(oldrad, 2)));</div>
<div>```</div>
<div>and print them, they both contain the same value. It looks like the values are as if it uses rad=0 and whatever oldrad used to have before (which can be thus changed, depending on the order of the print lines).</div>
<div>Finally, if I do print a lot of other info (in particular the intermediate computation steps), it seems it finally gets drfac right.</div>
<div><br>
</div>
<div>I had a look at CarpetLib's vect.hh and defs.hh too, but I can't seem to understand what is going on. Note that there might be another small bug in the thorn, but fixing that didn't impact what I'm describing. I'm just attaching the other modified files
 (schedule.ccl and initialise.cc) for completeness, as it may lead to a fix eventually.</div>
<p></p>
</div>
</body>
</html>