<html>#2571: runtime failure due to useing character*8 in DECLARE_CCTK_ARGUMENTS_CHECKED macro
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Roland Haas</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>development version</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>Cactus</td></tr>
</table>

<p>I just learned (via Skype) that Cactus' use of <code>character*8</code> variables can cause runtime errors in Fortran:</p>
<div class="codehilite"><pre><span></span><span>At line 13 of file Cactus/arrangements/EinsteinBase/TmunuBase/src/SetStressEnergyState.F90</span>
<span>Fortran runtime error: Actual string length is shorter than the declared one for dummy argument &#39;dtbetax_p&#39; (0/8)</span>
</pre></div>


<p>and digging down a bit and looking at the processed Fortran file (configs/sim/build/TmunuBase/SetStressEnergyState.f90) one finds:</p>
<div class="codehilite language-fortran"><pre><span></span><span class="kt">characTer</span><span class="o">*</span><span class="mi">8</span><span class="p">,</span> <span class="k">intent</span><span class="p">(</span><span class="n">IN</span><span class="p">)</span> <span class="kd">::</span> <span class="n">dtbetax_p</span>
<span class="kt">integer</span><span class="p">,</span> <span class="k">parameter</span> <span class="kd">::</span> <span class="n">cctki_use_dtbetax_p</span> <span class="o">=</span> <span class="nb">kind</span><span class="p">(</span><span class="n">dtbetax_p</span><span class="p">)</span>
</pre></div>


<p>and <a data-is-external-link="true" href="https://stackoverflow.com/questions/4780069/passing-a-string-as-an-argument-when-the-dummy-has-specified-length" rel="nofollow">https://stackoverflow.com/questions/4780069/passing-a-string-as-an-argument-when-the-dummy-has-specified-length</a> where the Fortran 2003 standard gets quoted with an explanation:</p>
<blockquote>
<p>If a scalar dummy argument is of type default character, the length len of the dummy argument shall be less than or equal to the length of the actual argument. The dummy argument becomes associated with the leftmost len characters of the actual argument.</p>
</blockquote>
<p>This all used gfortran 11.</p>
<p>Safest would be if we could declare as <code>characTer*0</code> if that is allowed. Of course it’s still wrong in that the actual argument passed to <code>dtbetax_p</c
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2571/runtime-failure-due-to-useing-character-8'>https://bitbucket.org/einsteintoolkit/tickets/issues/2571/runtime-failure-due-to-useing-character-8</a></p>
</html>