Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29267 Discussions

exit codes to shell from main? exit()?

jkwi
Beginner
548 Views

What is the correct way to pass exit codes from a FORTRAN main to the calling shell?
In the past we've used:
call exit(icode) where icode is an integer byte.

call exit() seems to work fine but there is no function I could find in the documentation.
Seems to be a supported extension?
What library is this function in?

EXIT is a reserved word for exiting out of DO loops.

Thanks for any info.

0 Kudos
2 Replies
Kevin_D_Intel
Employee
548 Views

Look for "EXIT Subroutine" in the Intel Fortran documentation.

EXIT Subroutine
Intrinsic Subroutine (Generic): Terminates program execution, closes all files, and returns control to the operating system. Intrinsic subroutines cannot be passed as actual arguments.

Syntax

CALL EXIT [( [status] )]

status (Output; optional) Is an integer argument you can use to specify the image exit-status value.

The exit-status value may not be accessible after program termination in some application environments.

0 Kudos
mecej4
Honored Contributor III
548 Views
EXIT is a reserved word for exiting out of DO loops

Fortran does not have reserved keywords. Thus, the following code, while reprehensible, is legal:
[fortran]logical :: then, if, else, exit
integer :: i
..
do i=1,5
..
  if = then.or.else.and.exit
..
  if(if)then
    then=if
    exit
  else
    else=if
    call exit(3)
  endif
..
end do
..[/fortran]
0 Kudos
Reply