fprettify
fprettify copied to clipboard
Disable whitespace disrupting CUDA chevrons
Previously, fprettify did not understand CUDA fortran's triple-chevron syntax for calling kernel functions, e.g.
call example_kernel<<<1, 1>>>(args)
As a result, each symbol in the chevrons <<< would have whitespace added, resulting in the incorrect syntax:
call example_kernel < < < 1, 1 > > > (args)
This problem only occurs when adding whitespace around relational operators is enabled.
This commit adds an escape hatch to the function that handles whitespace around operators add_whitespace_context which disables the whitespace handling for any line that matches the REGEX "<<<.*>>>":
CUDA_CHEVRONS_RE = re.compile(r"<<<.*>>>", RE_FLAGS)
...
if not ( ... or CUDA_CHEVRONS_RE.search(line) ):
This change should not break any Fortran syntax, however any relational operator that appears in a line that also features a triple-chevron will not be formatted, e.g.
call example_kernel<<<1, 1>>>(3< 4, var1 ==var2)
This fixes #124.
Good morning, Please someone can validate this PR? Thank you