Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
8) PR #3371 towards #3012. Add workaround to bypass psyclonefc fixed-from
issues.

7) PR #3374 for 3366. Removes LFRicSymbolTable.

6) PR #3369 towards #1658. Switches NEMO scripts to use all of the
Expand Down
13 changes: 12 additions & 1 deletion src/psyclone/psyclonefc_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def compiler_wrapper(arguments):
'''
fortran_compiler = os.getenv("PSYCLONE_COMPILER", default=None)
psyclone_options = os.getenv("PSYCLONE_OPTS", default="").split(' ')
# TODO #3012: How does this interact with the script FILES_TO_SKIP
psyclone_exclude_files = (
os.getenv("PSYCLONEFC_EXCLUDE_FILES", default="").split(',')
)

# Validate mandatory PSYCLONE_COMPILER
if fortran_compiler is None:
Expand Down Expand Up @@ -119,7 +123,12 @@ def compiler_wrapper(arguments):
# And it will be followed by each of the original arguments ...
for argument in arguments:
# ... but for each fortran file:
if argument.endswith(FORTRAN_EXTENSIONS):

filename = Path(argument).name
if (
argument.endswith(FORTRAN_EXTENSIONS) and
(filename not in psyclone_exclude_files)
):
# 1) Run the preprocessor
# TODO #3012: preprocessing is currently ignored, this is not a
# problem for NEMO because the build system does the proprocessor
Expand All @@ -128,6 +137,8 @@ def compiler_wrapper(arguments):
# 2) Run psyclone
stem = Path(argument).stem
suffix = Path(argument).suffix
# TODO #3012: Keeping the suffix is wrong as psyclone processed
# files are always free-form
output = f"{stem}.psycloned{suffix}"
# Always add an include to the current directory, because even if
# it is the default, psyclone removes it when adding another -I.
Expand Down
12 changes: 8 additions & 4 deletions src/psyclone/tests/psyclonefc_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,23 @@ def test_psyclonefc(monkeypatch, capsys):
assert "-o source.psycloned.f90 source.f90" in stdout
assert "true source.psycloned.f90 -c -o source.o" in stdout

# Now with PSYCONE_OPTS and multiple files
# Now with PSYCONE_OPTS, PSYCLONEFC_EXCLUDE_FILES and multiple files
monkeypatch.setattr(os, 'environ', {
'PSYCLONE_COMPILER': 'true',
# Also check that multi-spaces are fine
'PSYCLONE_OPTS': ' -l output ',
'PSYCLONEFC_EXCLUDE_FILES': 'source3.f90',
})
with pytest.raises(SystemExit) as err:
compiler_wrapper(['source1.f90', 'source2.f90', '-c', '-o', 'app.exe'])
compiler_wrapper(['source1.f90', 'source2.f90', 'source3.f90', '-c',
'-o', 'app.exe'])
assert err.value.code == 0
stdout, _ = capsys.readouterr()
# This will execute:
assert "psyclone -l output -I " in stdout
assert "-o source1.psycloned.f90 source1.f90" in stdout
assert "-o source2.psycloned.f90 source2.f90" in stdout
assert ("true source1.psycloned.f90 source2.psycloned.f90 -c -o app.exe"
in stdout)
# source3 is ignored from the psyclonefc command conversion
assert "-o source3.psycloned.f90 source3.f90" not in stdout
assert ("true source1.psycloned.f90 source2.psycloned.f90 source3.f90 "
"-c -o app.exe" in stdout)
Loading