stop_message_c Subroutine

public pure subroutine stop_message_c(info, message, message_size) bind(C)

Get a message corresponding to a given info code.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), intent(in), value :: info

Variable designating why the computations were stopped.

character(kind=c_char, len=1), intent(out) :: message(message_size)

C-string containing a message corresponding to info.

integer(kind=c_size_t), intent(in), value :: message_size

Length of array message.


Variables

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: msg
integer(kind=c_size_t), public :: i

Source Code

   pure subroutine stop_message_c(info, message, message_size) bind(C)
   !! Get a message corresponding to a given `info` code.
      integer(c_int), intent(in), value :: info
         !! Variable designating why the computations were stopped.
      character(kind=c_char), intent(out) :: message(message_size)
         !! C-string containing a message corresponding to `info`.
      integer(c_size_t), intent(in), value :: message_size
         !! Length of array `message`.

      character(len=:), allocatable :: msg
      integer(c_size_t) :: i

      select case (info)
      case (1)
         msg = "Sum of squares convergence."
      case (2)
         msg = "Parameter convergence."
      case (3)
         msg = "Sum of squares and parameter convergence."
      case (4)
         msg = "Iteration limit reached."
      case (5:)
         msg = "Questionable results or fatal errors detected. See report and error message."
      case default
         msg = "Unknown info code."
      end select
      msg = msg//c_null_char

      do i = 1, min(message_size, len(msg))
         message(i) = msg(i:i)
      end do

   end subroutine stop_message_c