Abort Subroutine

public subroutine Abort(SourceFile, SourceLine, CompDate, CompTime, ErrorMessage, IntInfo, RealInfo, ErrorCode)

Terminate program correctly if an error has occurred (important in MPI mode!). Uses a MPI_ABORT which terminates FLUXO if a single proc calls this routine.

Arguments

Type IntentOptional Attributes Name
character(len=*) :: SourceFile

Source file where error has occurred

integer :: SourceLine

Line in source file

character(len=*) :: CompDate

Compilation date

character(len=*) :: CompTime

Compilation time

character(len=*) :: ErrorMessage

Error message

integer, optional :: IntInfo

Error info (integer)

real(kind=wp), optional :: RealInfo

Error info (real)

integer, optional :: ErrorCode

Error info (integer)


Calls

proc~~abort~~CallsGraph proc~abort Abort mpi_abort mpi_abort proc~abort->mpi_abort

Source Code

SUBROUTINE Abort(SourceFile,SourceLine,CompDate,CompTime,ErrorMessage,IntInfo,RealInfo,ErrorCode)
! MODULES
IMPLICIT NONE
!----------------------------------------------------------------------------------------------------------------------------------
! INPUT/OUTPUT VARIABLES
CHARACTER(LEN=*)                  :: SourceFile      !! Source file where error has occurred
INTEGER                           :: SourceLine      !! Line in source file
CHARACTER(LEN=*)                  :: CompDate        !! Compilation date
CHARACTER(LEN=*)                  :: CompTime        !! Compilation time
CHARACTER(LEN=*)                  :: ErrorMessage    !! Error message
INTEGER,OPTIONAL                  :: IntInfo         !! Error info (integer)
REAL(wp),OPTIONAL                 :: RealInfo        !! Error info (real)
INTEGER,OPTIONAL                  :: ErrorCode       !! Error info (integer)
!----------------------------------------------------------------------------------------------------------------------------------
! LOCAL VARIABLES
CHARACTER(LEN=50)                 :: IntString,RealString
#if MPI
INTEGER                           :: errOut          ! Output of MPI_ABORT
INTEGER                           :: signalout       ! Output errorcode
#endif
!==================================================================================================================================
IntString = ""
RealString = ""

IF (PRESENT(IntInfo))  WRITE(IntString,"(A,I0)")  "\nIntInfo:  ", IntInfo
IF (PRESENT(RealInfo)) WRITE(RealString,"(A,F24.19)") "\nRealInfo: ", RealInfo

WRITE(UNIT_stdOut,*) '_____________________________________________________________________________\n', &
                     'Program abort caused on Proc ',myRank, '\n', &
                     '  in File : ',TRIM(SourceFile),' Line ',SourceLine, '\n', &
                     '  This file was compiled at ',TRIM(CompDate),'  ',TRIM(CompTime), '\n', &
                     'Message: ',TRIM(ErrorMessage), &
                     TRIM(IntString), TRIM(RealString)

CALL FLUSH(UNIT_stdOut)
#if MPI
signalout=2 ! MPI_ABORT requires an output error-code /=0
IF(PRESENT(ErrorCode)) signalout=ErrorCode
CALL MPI_ABORT(MPI_COMM_WORLD,signalout,errOut)
#endif
#if GNU
CALL BACKTRACE
#endif
IF (ASSOCIATED(RaiseExceptionPtr)) THEN
  CALL RaiseExceptionPtr(ErrorMessage)
END IF
ERROR STOP 2
END SUBROUTINE Abort