From 4bd1d73170ef3e1003d45d9a80373f902c33c92e Mon Sep 17 00:00:00 2001 From: harsha-mangena Date: Sat, 18 Nov 2023 01:09:49 -0500 Subject: [PATCH 01/10] - refer https://github.com/pyccel/pyccel/issues/1554 - added a check for epression if it is `LiteralInteger` or not - no type specifier is added for NativeInteger --- pyccel/codegen/printing/fcode.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pyccel/codegen/printing/fcode.py b/pyccel/codegen/printing/fcode.py index 85fe6f2fe5..819c77a6be 100644 --- a/pyccel/codegen/printing/fcode.py +++ b/pyccel/codegen/printing/fcode.py @@ -2640,15 +2640,17 @@ def _print_Header(self, expr): def _print_SysExit(self, expr): code = "" + if isinstance(expr.status, LiteralInteger): + arg = str(expr.status) if expr.status.dtype is not NativeInteger() or expr.status.rank > 0: print_arg = FunctionCallArgument(expr.status) code = self._print(PythonPrint((print_arg, ), file="stderr")) arg = "1" else: - arg = expr.status - if arg.precision != 4: - arg = NumpyInt32(arg) - arg = self._print(arg) + # Ensure no type specifier is added for NativeInteger + arg = self._print(expr.status) + # Remove any type specifier from the argument + arg = arg.split('_')[0] return f'{code}stop {arg}\n' def _print_NumpyUfuncBase(self, expr): From 411a630861c1aaacf7001a8231f691d34d292a7e Mon Sep 17 00:00:00 2001 From: harsha-mangena Date: Sat, 18 Nov 2023 21:07:57 -0500 Subject: [PATCH 02/10] - sirectly changing the `expr` to `string` --- pyccel/codegen/printing/fcode.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pyccel/codegen/printing/fcode.py b/pyccel/codegen/printing/fcode.py index 819c77a6be..9f673adc93 100644 --- a/pyccel/codegen/printing/fcode.py +++ b/pyccel/codegen/printing/fcode.py @@ -2642,16 +2642,12 @@ def _print_SysExit(self, expr): code = "" if isinstance(expr.status, LiteralInteger): arg = str(expr.status) - if expr.status.dtype is not NativeInteger() or expr.status.rank > 0: + elif expr.status.dtype is not NativeInteger() or expr.status.rank > 0: print_arg = FunctionCallArgument(expr.status) code = self._print(PythonPrint((print_arg, ), file="stderr")) arg = "1" else: - # Ensure no type specifier is added for NativeInteger - arg = self._print(expr.status) - # Remove any type specifier from the argument - arg = arg.split('_')[0] - return f'{code}stop {arg}\n' + arg = str(expr.status) def _print_NumpyUfuncBase(self, expr): type_name = type(expr).__name__ From e7b32f5dcb73e27a935c23d79d52f81fe3ec55a8 Mon Sep 17 00:00:00 2001 From: harsha-mangena Date: Sat, 18 Nov 2023 21:09:47 -0500 Subject: [PATCH 03/10] - fixed typo --- pyccel/codegen/printing/fcode.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyccel/codegen/printing/fcode.py b/pyccel/codegen/printing/fcode.py index 9f673adc93..3f42a351f5 100644 --- a/pyccel/codegen/printing/fcode.py +++ b/pyccel/codegen/printing/fcode.py @@ -2648,6 +2648,7 @@ def _print_SysExit(self, expr): arg = "1" else: arg = str(expr.status) + return f'{code}stop {arg}\n' def _print_NumpyUfuncBase(self, expr): type_name = type(expr).__name__ From 17d1d1f07a3ee404dc420d900651a607da93eea8 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Wed, 3 Jan 2024 09:25:41 +0100 Subject: [PATCH 04/10] Fix bugs --- pyccel/codegen/printing/fcode.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pyccel/codegen/printing/fcode.py b/pyccel/codegen/printing/fcode.py index f2cd32fd0d..ff62b60426 100644 --- a/pyccel/codegen/printing/fcode.py +++ b/pyccel/codegen/printing/fcode.py @@ -2626,14 +2626,17 @@ def _print_Header(self, expr): def _print_SysExit(self, expr): code = "" - if isinstance(expr.status, LiteralInteger): - arg = str(expr.status) - elif expr.status.dtype is not NativeInteger() or expr.status.rank > 0: - print_arg = FunctionCallArgument(expr.status) + exit_code = expr.status + if isinstance(exit_code, LiteralInteger): + arg = exit_code.python_value + elif exit_code.dtype is not NativeInteger() or exit_code.rank > 0: + print_arg = FunctionCallArgument(exit_code) code = self._print(PythonPrint((print_arg, ), file="stderr")) arg = "1" else: - arg = str(expr.status) + if exit_code.precision != 4: + exit_code = NumpyInt32(exit_code) + arg = self._print(exit_code) return f'{code}stop {arg}\n' def _print_NumpyUfuncBase(self, expr): From f2cbba13e50261634f417dfe888dfb0fc5925c9c Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Wed, 3 Jan 2024 11:01:06 +0100 Subject: [PATCH 05/10] Fix local intel setup --- .github/actions/intel_install/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/intel_install/action.yml b/.github/actions/intel_install/action.yml index 17d90f4617..56672ee9f6 100644 --- a/.github/actions/intel_install/action.yml +++ b/.github/actions/intel_install/action.yml @@ -28,7 +28,7 @@ runs: shell: bash - name: Save Intel environment variables run: | - source /opt/intel/oneapi/setvars.sh + source /opt/intel/oneapi/compiler/2024.0/env/vars.sh echo "$PATH" > $GITHUB_PATH echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV echo "LIBRARY_PATH=$LIBRARY_PATH" >> $GITHUB_ENV From 0a3974482c4915f30f49cd4d5eb21e13c0c680c1 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Wed, 3 Jan 2024 11:13:30 +0100 Subject: [PATCH 06/10] Use intel oneapi compilers --- pyccel/compilers/default_compilers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyccel/compilers/default_compilers.py b/pyccel/compilers/default_compilers.py index c729d74195..005dd429d4 100644 --- a/pyccel/compilers/default_compilers.py +++ b/pyccel/compilers/default_compilers.py @@ -37,8 +37,8 @@ gfort_info['mpi']['libdirs'] = (os.environ["MSMPI_LIB64"].rstrip('\\'),) #------------------------------------------------------------ -ifort_info = {'exec' : 'ifort', - 'mpi_exec' : 'mpiifort', +ifort_info = {'exec' : 'ifx', + 'mpi_exec' : 'mpiifx', 'language': 'fortran', 'module_output_flag': '-module', 'debug_flags': ("-check=bounds","-g","-O0"), @@ -124,7 +124,7 @@ #------------------------------------------------------------ icc_info = {'exec' : 'icx', - 'mpi_exec' : 'mpicc', + 'mpi_exec' : 'mpiicx', 'language': 'c', 'debug_flags': ("-g","-O0"), 'release_flags': ("-O3","-funroll-loops",), From 4ff2546322cd3a0f26e741b4fabe9b6093a337d2 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Wed, 3 Jan 2024 11:14:43 +0100 Subject: [PATCH 07/10] Keep other implicit imports --- .github/actions/intel_install/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/intel_install/action.yml b/.github/actions/intel_install/action.yml index 56672ee9f6..54175be8ea 100644 --- a/.github/actions/intel_install/action.yml +++ b/.github/actions/intel_install/action.yml @@ -28,7 +28,8 @@ runs: shell: bash - name: Save Intel environment variables run: | - source /opt/intel/oneapi/compiler/2024.0/env/vars.sh + source /opt/intel/oneapi/setvars.sh + source /opt/intel/oneapi/compiler/2024.0/env/vars.sh echo "$PATH" > $GITHUB_PATH echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV echo "LIBRARY_PATH=$LIBRARY_PATH" >> $GITHUB_ENV From d862a428f9780b55c994c12031a2c2a1bc0abd52 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Wed, 3 Jan 2024 11:30:45 +0100 Subject: [PATCH 08/10] Revert intel changes for testing --- .github/actions/intel_install/action.yml | 1 - pyccel/compilers/default_compilers.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/actions/intel_install/action.yml b/.github/actions/intel_install/action.yml index 54175be8ea..17d90f4617 100644 --- a/.github/actions/intel_install/action.yml +++ b/.github/actions/intel_install/action.yml @@ -29,7 +29,6 @@ runs: - name: Save Intel environment variables run: | source /opt/intel/oneapi/setvars.sh - source /opt/intel/oneapi/compiler/2024.0/env/vars.sh echo "$PATH" > $GITHUB_PATH echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV echo "LIBRARY_PATH=$LIBRARY_PATH" >> $GITHUB_ENV diff --git a/pyccel/compilers/default_compilers.py b/pyccel/compilers/default_compilers.py index 005dd429d4..c729d74195 100644 --- a/pyccel/compilers/default_compilers.py +++ b/pyccel/compilers/default_compilers.py @@ -37,8 +37,8 @@ gfort_info['mpi']['libdirs'] = (os.environ["MSMPI_LIB64"].rstrip('\\'),) #------------------------------------------------------------ -ifort_info = {'exec' : 'ifx', - 'mpi_exec' : 'mpiifx', +ifort_info = {'exec' : 'ifort', + 'mpi_exec' : 'mpiifort', 'language': 'fortran', 'module_output_flag': '-module', 'debug_flags': ("-check=bounds","-g","-O0"), @@ -124,7 +124,7 @@ #------------------------------------------------------------ icc_info = {'exec' : 'icx', - 'mpi_exec' : 'mpiicx', + 'mpi_exec' : 'mpicc', 'language': 'c', 'debug_flags': ("-g","-O0"), 'release_flags': ("-O3","-funroll-loops",), From ec959060c14c4f3c7cb8ac9373268e947bbe6f0c Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Wed, 3 Jan 2024 11:34:33 +0100 Subject: [PATCH 09/10] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 450049cfee..69da20ee14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file. - #1614 : Allow relative paths for custom compilation file. - #1615 : Fixed infinite loop when passing slices while copying arrays. - #1628 : Fixed segmentation fault when writing to optional scalars. +- #1554 : Fix exit statement in Fortran with Intel compiler. ### Changed From ac93af6ff246416c6c75a414fdd28f246b5d2a75 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Thu, 4 Jan 2024 17:45:46 +0100 Subject: [PATCH 10/10] Fix coverage --- tests/pyccel/scripts/exits/error_message_exit.py | 7 +++++++ tests/pyccel/test_pyccel.py | 1 + 2 files changed, 8 insertions(+) create mode 100644 tests/pyccel/scripts/exits/error_message_exit.py diff --git a/tests/pyccel/scripts/exits/error_message_exit.py b/tests/pyccel/scripts/exits/error_message_exit.py new file mode 100644 index 0000000000..32025c7226 --- /dev/null +++ b/tests/pyccel/scripts/exits/error_message_exit.py @@ -0,0 +1,7 @@ +# pylint: disable=missing-function-docstring, missing-module-docstring + +import sys + +if __name__ == "__main__": + sys.exit("Exiting program") + diff --git a/tests/pyccel/test_pyccel.py b/tests/pyccel/test_pyccel.py index f125864ed7..9f7e4d0199 100644 --- a/tests/pyccel/test_pyccel.py +++ b/tests/pyccel/test_pyccel.py @@ -959,6 +959,7 @@ def test_assert(language, test_file): "scripts/exits/positive_exit2.py", "scripts/exits/positive_exit3.py", "scripts/exits/zero_exit.py", + "scripts/exits/error_message_exit.py", ] ) def test_exit(language, test_file):