test_status Subroutine

public subroutine test_status(io_stat, io_msg, opt_msg)

Test if a status variable is 0 or not

FT 17.09.2020


Arguments

Type IntentOptional 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


Contents

Source Code


Source Code

  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