- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Following example should use Fortran 2018 error stop feature:
integer :: return_code
return_code = 77
error stop return_code
end
Using ifort 2021.1 Beta 20200827 on a Manjaro Linux, the program compiles without error but the return code is not propagated to the shell:
> gfortran-10 mwe.f90 && ./a.out
ERROR STOP 77
Error termination. Backtrace:
#0 0x562d2fa17176 in ???
#1 0x562d2fa171ac in ???
#2 0x7fa6e2a48151 in ???
#3 0x562d2fa1708d in ???
#4 0xffffffffffffffff in ???
> echo $?
77
> ifort mwe.f90 && ./a.out
77
> echo $?
128
Is the Fortran 2018 error stop opt-in for ifort and I'm missing a flag or is this an issue with the beta version of ifort?
Note: same issue is observed with the ifx compiler.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The standard says, "If the stop-code is an integer, it is recommended that the value be used as the process exit status, if the processor supports that concept." It's not a requirement. That said, I would expect it to be implemented and would recommend you submit a request that this be done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the clarification. If I understood correctly this means that even if the integer variable I'm passing is zero it is implementation dependent whether or not actually a zero exit status is actually reported?
I also created a service request for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Right. The standard requires only that the value of the stop code be "made available in a processor-dependent manner". The traditional method was to print a message with the code (which can now be suppressed with the optional QUIET specifier.)
Interestingly, the code is used for the process exit status on Windows:
:\Projects>type t.f90
error stop 42
end
D:\Projects>ifort t.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.3.311 Build 20201010_000000
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.28.29334.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:t.exe
-subsystem:console
t.obj
D:\Projects>t.exe
42
D:\Projects>echo %errorlevel%
42
I have a vague memory of this being an issue on Linux from years ago. Creating the service request was the right thing to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are some scenarios were this is working as expected and than there is this odd inconsistency between the printout and the return code on Linux:
> cat <<EOF > error_stop_std08.f90
error stop 0
end
> ifort error_stop_std08.f90 && ./a.out
0
> echo $?
0
> cat <<EOF > error_stop_std18.f90
i = 0
error stop i
end
> ifort error_stop_std18.f90 && ./a.out
0
> echo $?
128
Which I would almost consider a bug in ifort.
Also, my support request has been rejected, because I don't own a serial number for working with Intel compilers at https://github.com/fortran-lang/stdlib.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After the misunderstanding has been cleared this seems to be successfully reported with Service Request #:04894932. Note that this issue is still present in the just released version of the oneAPI Fortran compilers.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page