Test if a status variable is 0 or not
FT 17.09.2020
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | io_stat |
Status variable |
||
character(len=100), | intent(in) | :: | io_msg |
Status message |
||
character(len=*), | intent(in), | optional | :: | opt_msg |
Optional status message |
SUBROUTINE test_status( io_stat, io_msg, opt_msg )
!***********************************************
!
!# Test if a status variable is 0 or not
!
! FT 17.09.2020
!
!***********************************************
IMPLICIT NONE
INTEGER, INTENT(IN) :: io_stat
!! Status variable
CHARACTER(LEN=100), INTENT(IN) :: io_msg
!! Status message
CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: opt_msg
!! Optional status message
IF( io_stat > 0 )THEN
PRINT *
PRINT *, "***** ERROR! IOSTAT > 0. ", &
"The error message is: ", io_msg
IF( PRESENT( opt_msg ) )THEN
PRINT *, opt_msg
ENDIF
PRINT *
STOP
ENDIF
END SUBROUTINE test_status