<html>#2386: CCTK_LOOP3_INT and friends broken for Fortran OpenMP code
<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>open</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>minor</td></tr>
<tr><td style='text-align:right'>Component:</td><td></td></tr>
</table>

<p>Comment (by Roland Haas):</p>
<p>I have not yet gotten to LoopControl proper, but I have at least made the plain Cactus CCTK_LOOP macros work (the one you get if you do not have #include "loopcontrol.h").</p>
<p>They are in the branch "rhaas/loops" of the flesh and I have also updated / fixed / generated the tests in TestLoop where I have checked that Fortran and C code (which I have not touched) produce the same result.</p>
<p>You can use them via:</p>
<div class="codehilite"><pre><span></span>cd repos/flesh
git fetch
git checkout rhaas/loops
cd ../repos/cactustest
git fetch
git checkout rhaas/loops
</pre></div>


<p>then build (no need to clean).</p>
<p>You will have to take care of making your loop variables private on your own (unless you trust OpenMP + Fortran to be smart enough to do so for you, I believe the standard claims is should be... but that may only apply to the loop directly following the "omp do" directive) and use CCTK_LOOP3_XXX_OMP_PRIVATE(name). See TestLoopFortran.F90 for examples (the default(none) is purely optional and just helped me debug things).</p>
<p>So basically:</p>
<div class="codehilite"><pre><span></span>!$OMP PARALLEL private(i,j,k) CCTK_LOOP3_INT_OMP_PRIVATE(int3)
CCTK_LOOP3_INT(int3, i,j,k)
   ! do something
CCTK_ENDLOOP3_INT(int3)
!$OMP END PARALLEL
</pre></div>


<p>The calling syntax of the PRIVATE and DECLARE macros may still change.  Right now the C LOOP macros internally declare the loop and normal variables (i, ni) while my current set of Fortran DECLARE and PRIVATE variables do not declare them or make them private (they cannot, they do not now know their name).</p>
<p>So the options are to have either (1):</p>
<div class="codehilite"><pre><span></span>integer :: i,ni
CCTK_LOOP1_DECLARE(foo)
!$OMP PARALLEL private(i,ni) CCTK_LOOP1_BND_OMP_PRIVATE(int1)
CCTK_LOOP1_INT(int1, i,ni)
   ! do something
CCTK_ENDLOOP1_INT(int1)
!$OMP END PARALLEL
</pre></div>


<p>or (2):</p>
<div class="codehilite"><pre><span></span>CCTK_LOOP1_DECLARE(foo, i,ni)
!$OMP PARALLEL CCTK_LOOP1_BND_OMP_PRIVATE(int1,i,ni)
CCTK_LO
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2386/cctk_loop3_int-and-friends-broken-for'>https://bitbucket.org/einsteintoolkit/tickets/issues/2386/cctk_loop3_int-and-friends-broken-for</a></p>
</html>