From 710333cbf48f90a44567841724c56639ce9cab30 Mon Sep 17 00:00:00 2001 From: SCHREIBER Martin Date: Thu, 12 Mar 2026 19:11:25 +0100 Subject: [PATCH 1/5] exclude feature for psyclone --- src/psyclone/psyclonefc_cli.py | 6 +++++- src/psyclone/tests/psyclonefc_cli_test.py | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/psyclone/psyclonefc_cli.py b/src/psyclone/psyclonefc_cli.py index 2deaece34d..742c28da40 100644 --- a/src/psyclone/psyclonefc_cli.py +++ b/src/psyclone/psyclonefc_cli.py @@ -82,6 +82,7 @@ def compiler_wrapper(arguments): ''' fortran_compiler = os.getenv("PSYCLONE_COMPILER", default=None) psyclone_options = os.getenv("PSYCLONE_OPTS", default="").split(' ') + psyclone_exclude_files = os.getenv("PSYCLONE_EXCLUDE_FILES", default="").split(',') # Validate mandatory PSYCLONE_COMPILER if fortran_compiler is None: @@ -119,7 +120,10 @@ 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): + print(filename, 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 diff --git a/src/psyclone/tests/psyclonefc_cli_test.py b/src/psyclone/tests/psyclonefc_cli_test.py index 24aac810d0..a902da0087 100644 --- a/src/psyclone/tests/psyclonefc_cli_test.py +++ b/src/psyclone/tests/psyclonefc_cli_test.py @@ -92,14 +92,16 @@ def test_psyclonefc(monkeypatch, capsys): 'PSYCLONE_COMPILER': 'true', # Also check that multi-spaces are fine 'PSYCLONE_OPTS': ' -l output ', + 'PSYCLONE_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" + 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) From 84b344e1d0267df59837757657bf4ff7254f6ea1 Mon Sep 17 00:00:00 2001 From: SCHREIBER Martin Date: Thu, 12 Mar 2026 19:16:39 +0100 Subject: [PATCH 2/5] cleanup --- src/psyclone/psyclonefc_cli.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/psyclone/psyclonefc_cli.py b/src/psyclone/psyclonefc_cli.py index 742c28da40..18fb994f5e 100644 --- a/src/psyclone/psyclonefc_cli.py +++ b/src/psyclone/psyclonefc_cli.py @@ -123,7 +123,6 @@ def compiler_wrapper(arguments): filename = Path(argument).name if argument.endswith(FORTRAN_EXTENSIONS) and (filename not in psyclone_exclude_files): - print(filename, 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 From 567e28f56b120ede2412517d9c3f572672f99505 Mon Sep 17 00:00:00 2001 From: SCHREIBER Martin Date: Mon, 16 Mar 2026 10:35:21 +0100 Subject: [PATCH 3/5] Renaming of PSYCLONE_EXCLUDE_FILES to PSYCLONEFC_EXCLUDE_FILES --- src/psyclone/psyclonefc_cli.py | 2 +- src/psyclone/tests/psyclonefc_cli_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/psyclone/psyclonefc_cli.py b/src/psyclone/psyclonefc_cli.py index 18fb994f5e..a523ed472a 100644 --- a/src/psyclone/psyclonefc_cli.py +++ b/src/psyclone/psyclonefc_cli.py @@ -82,7 +82,7 @@ def compiler_wrapper(arguments): ''' fortran_compiler = os.getenv("PSYCLONE_COMPILER", default=None) psyclone_options = os.getenv("PSYCLONE_OPTS", default="").split(' ') - psyclone_exclude_files = os.getenv("PSYCLONE_EXCLUDE_FILES", default="").split(',') + psyclone_exclude_files = os.getenv("PSYCLONEFC_EXCLUDE_FILES", default="").split(',') # Validate mandatory PSYCLONE_COMPILER if fortran_compiler is None: diff --git a/src/psyclone/tests/psyclonefc_cli_test.py b/src/psyclone/tests/psyclonefc_cli_test.py index a902da0087..8568b3a3c3 100644 --- a/src/psyclone/tests/psyclonefc_cli_test.py +++ b/src/psyclone/tests/psyclonefc_cli_test.py @@ -92,7 +92,7 @@ def test_psyclonefc(monkeypatch, capsys): 'PSYCLONE_COMPILER': 'true', # Also check that multi-spaces are fine 'PSYCLONE_OPTS': ' -l output ', - 'PSYCLONE_EXCLUDE_FILES': 'source3.f90', + 'PSYCLONEFC_EXCLUDE_FILES': 'source3.f90', }) with pytest.raises(SystemExit) as err: compiler_wrapper(['source1.f90', 'source2.f90', 'source3.f90', '-c', '-o', 'app.exe']) From 2c8e0816ff17cf44abc5d9f692b39a14046f0706 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Wed, 22 Apr 2026 12:57:01 +0100 Subject: [PATCH 4/5] #3012 Add TODOs and fix flake8 --- src/psyclone/psyclonefc_cli.py | 12 ++++++++++-- src/psyclone/tests/psyclonefc_cli_test.py | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/psyclone/psyclonefc_cli.py b/src/psyclone/psyclonefc_cli.py index a523ed472a..cd36352cba 100644 --- a/src/psyclone/psyclonefc_cli.py +++ b/src/psyclone/psyclonefc_cli.py @@ -82,7 +82,10 @@ def compiler_wrapper(arguments): ''' fortran_compiler = os.getenv("PSYCLONE_COMPILER", default=None) psyclone_options = os.getenv("PSYCLONE_OPTS", default="").split(' ') - psyclone_exclude_files = os.getenv("PSYCLONEFC_EXCLUDE_FILES", 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: @@ -122,7 +125,10 @@ def compiler_wrapper(arguments): # ... but for each fortran file: filename = Path(argument).name - if argument.endswith(FORTRAN_EXTENSIONS) and (filename not in psyclone_exclude_files): + 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 @@ -131,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. diff --git a/src/psyclone/tests/psyclonefc_cli_test.py b/src/psyclone/tests/psyclonefc_cli_test.py index 8568b3a3c3..a30bf99007 100644 --- a/src/psyclone/tests/psyclonefc_cli_test.py +++ b/src/psyclone/tests/psyclonefc_cli_test.py @@ -87,7 +87,7 @@ 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 @@ -95,13 +95,15 @@ def test_psyclonefc(monkeypatch, capsys): 'PSYCLONEFC_EXCLUDE_FILES': 'source3.f90', }) with pytest.raises(SystemExit) as err: - compiler_wrapper(['source1.f90', 'source2.f90', 'source3.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 + # 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) + assert ("true source1.psycloned.f90 source2.psycloned.f90 source3.f90 " + "-c -o app.exe" in stdout) From 6d57f790f47423f615397de6e8e571a21522e485 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Wed, 22 Apr 2026 13:57:05 +0100 Subject: [PATCH 5/5] #3012 Update changelog --- changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog b/changelog index 3a69f580dc..f6483e56d1 100644 --- a/changelog +++ b/changelog @@ -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