fparser icon indicating copy to clipboard operation
fparser copied to clipboard

Supporting OpenMP Sentinels

Open hiker opened this issue 11 months ago • 1 comments

Some UM code contains declarations in OpenMP sentinels, e.g.:

!$ USE compute_chunk_size_mod, ONLY: compute_chunk_size  ! Note OpenMP sentinel

Fparser skips these lines as comment lines, and as a result, FAB misses dependencies if compilation is done with OpenMP enabled.

While I have a FAB patch that fixes it (if a comment is found, check if it starts with !$, and then try Use_Stmt.match(...), and that works fine for me), I think it could be useful if fparser could be instructed to handle !$. That should be easier than pre-processing directive (since the string following !$ must be valid Fortran - I believe we could simply pass a flag to the reader to delete the first two characters if they are !$?

If you don't think that this could be useful for fparser, let me know, and I'll get my current FAB workaround merged in.

hiker avatar Mar 21 '24 13:03 hiker

As discussed in the telco, this is considered useful. It will be implemented using an optional flag to enable this. And it is expected to be handled in the reader - detect the sentinels and remove them. We just need to take care not to remove !$ for real openmp statements. According to the standard, an OpenMP directive may not have a whitespace between !$ and omp, while a sentinel must have a whitespace after !$.

hiker avatar Mar 25 '24 22:03 hiker