get_error_api Subroutine

public subroutine get_error_api(verror, charptr, buffersize) bind(C, name=namespace//"get_error")

Get error message from error handle

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: verror
character(kind=c_char, len=1), intent(inout) :: charptr(*)
integer(kind=c_int), intent(in), optional :: buffersize

Source Code

subroutine get_error_api(verror, charptr, buffersize) &
      & bind(C, name=namespace//"get_error")
   !DEC$ ATTRIBUTES DLLEXPORT :: get_error_api
   type(c_ptr), value :: verror
   type(vp_error), pointer :: error
   character(kind=c_char), intent(inout) :: charptr(*)
   integer(c_int), intent(in), optional :: buffersize
   integer :: max_length

   if (debug) print'("[Info]",1x, a)', "get_error"

   if (c_associated(verror)) then
      call c_f_pointer(verror, error)

      if (present(buffersize)) then
         max_length = buffersize
      else
         max_length = huge(max_length) - 2
      end if

      if (allocated(error%ptr)) then
         call f_c_character(error%ptr%message, charptr, max_length)
      end if
   end if

end subroutine get_error_api