Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-processor directives created by fparser do not compile #441

Open
hiker opened this issue Jan 23, 2024 · 0 comments
Open

Pre-processor directives created by fparser do not compile #441

hiker opened this issue Jan 23, 2024 · 0 comments

Comments

@hiker
Copy link
Collaborator

hiker commented Jan 23, 2024

fparser has limited support for preprocessor directives. Example:

MODULE lfric_abort_mod
  IMPLICIT NONE
  CONTAINS
  SUBROUTINE parallel_abort(ierr)
    #ifdef NO_MPI
    #else
    USE mpi, ONLY: mpi_abort, MPI_COMM_WORLD
    #endif

But the indentation causes gfortran to abort:

gfortran -C -g -O0 -c lfric_abort_mod.F90
lfric_abort_mod.F90:5:6:

    5 |     #ifdef NO_MPI
      |      1
Error: Invalid character in name at (1)

And intel issues a warning:

 ifort -C -g -O0 -c lfric_abort_mod.F90
lfric_abort_mod.F90(5): warning #5117: Bad # preprocessor line
    #ifdef NO_MPI
-----^

Using the pre-processor explicitly (cpp -P) works.

As a discussion: It might be useful to avoid indentation for preprocessor directives. I don't strongly needed it, I can add a pre-processing step instead, but I think it could be useful for some applications? But I am equally happy to close this ticket since our preprocessor support is documented to be very limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant