handle_error Subroutine

subroutine handle_error(error)

Arguments

Type IntentOptional Attributes Name
type(error_type), intent(inout), allocatable :: error

Source Code

subroutine handle_error(error)
   type(error_type), allocatable, intent(inout) :: error

   interface
      subroutine sys_exit(stat) bind(c, name="exit")
         use, intrinsic :: iso_c_binding, only : c_int
         integer(c_int), value :: stat
      end subroutine sys_exit
   end interface

   if (allocated(error)) then
      if (error%stat == 0) then
         write(output_unit, '(a)') error%message
         call sys_exit(0)
      else
         write(error_unit, '("[Error]", 1x, a)') error%message
         call sys_exit(1)
      end if
   end if
end subroutine handle_error