Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exit statement in Fortran with Intel compiler #1624

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions pyccel/codegen/printing/fcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2626,15 +2626,17 @@ def _print_Header(self, expr):

def _print_SysExit(self, expr):
code = ""
if 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)
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
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)
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):
Expand Down
Loading