Closed arporter closed 2 years ago
This Issue will also fix #396.
In #500 I've done some experimentation by adding the following to NemoPSy.gen()
:
from psyclone.psyir.backend.fortran import FortranWriter
fvisitor = FortranWriter()
result = fvisitor(self._invokes._container)
return result
In sbcblk.f90 we get a CodeBlock within a WHERE/ELSEWHERE block which results in the script attempting to put KERNELS around the individual statements within the WHERE. This is wrong because they are not implicit loops.
CodeBlock[[<class 'fparser.two.Fortran2003.Masked_Elsewhere_Stmt'>]]
comes from:
ELSEWHERE(phs(:, :, :) <= 0._wp .AND. phi(:, :, :) >= 0.1_wp)
If I do what I said earlier (and allow for cases with a missing Container) then test_api_no_alg
shows that we get the body of the routine OK but we have no surrounding Subroutine or Module declaration. Probably the problem is that we have no Container
.
We have no Container because this particular test is for a Program which then of course has no enclosing module. We generate an Invoke for the Program and this Invoke has a Schedule which is what enables us to generate the body of the routine. (That Schedule also has an associated symbol table.) However, we have no way of generating the Program declaration.
I now realise this is precisely the problem that #430 is addressing!
Currently the NEMO API works by manipulating the fparser2 parse tree and then using the de-parsing functionality of that tree to produce the final Fortran code. Although this has enabled us to get up and running fairly quickly it has limitations. Once the Fortran backend to the PSyIR is sufficiently complete we will migrate the NEMO API to use that.