PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

Support for Fortran EXTERNAL statement?

Open arporter opened this issue 3 months ago • 0 comments

Martin has been trying to run PSyclone on code that has old-style INCLUDE mpif.h lines in it. These of course then pull in the (often ancient) MPI header files and that brings pain. A particular problem is that a lot of routines are declared EXTERNAL, e.g.:

  EXTERNAL :: MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN
  EXTERNAL :: MPI_COMM_NULL_COPY_FN, MPI_COMM_NULL_DELETE_FN
  EXTERNAL :: MPI_TYPE_NULL_COPY_FN, MPI_TYPE_NULL_DELETE_FN
  EXTERNAL :: MPI_DUP_FN, MPI_COMM_DUP_FN, MPI_TYPE_DUP_FN
  EXTERNAL :: MPI_WIN_NULL_COPY_FN
  EXTERNAL :: MPI_WIN_NULL_DELETE_FN
  EXTERNAL :: MPI_WIN_DUP_FN
  EXTERNAL :: MPI_CONVERSION_FN_NULL
  EXTERNAL :: MPI_WTIME, MPI_WTICK, PMPI_WTICK, PMPI_WTIME
  DOUBLE PRECISION :: MPI_WTIME, MPI_WTICK, PMPI_WTICK, PMPI_WTIME
  EXTERNAL :: MPI_AINT_ADD, MPI_AINT_DIFF

and the fparser2 frontend can't handle these, resulting in the whole program unit containing them ending up in a CodeBlock:

!PSyclone CodeBlock (unsupported code) reason:
! - Error processing declarations: fparser2 node of type 'External_Stmt' not supported
SUBROUTINE blah(...)

Since we know that the named symbols must be RoutineSymbols, I think it should be possible to add support for these by perhaps adding a new kind of Interface, e.g. ExternalInterface?

arporter avatar Sep 18 '25 18:09 arporter