anchor.diff:         ! Check for normal or problematic termination
          if (task(1:4) == 'CONV') then
             ! Converged.  Normal termination.  Leave error (task) message
  -          ! as may be informative.
  -          error_code_c = 0
  +          ! as it may be informative.
  +          error_code_c = LBFGSB_OK
          else if (task(1:4) == 'ABNO') then
             ! Could not satisfy termination conditions.  Result is best
             ! approximation.
  -          error_code_c = 1
  +          error_code_c = LBFGSB_APPROXIMATE
          else if (task(1:5) == 'ERROR') then
             ! Runtime or user error
  -          error_code_c = 2
  +          error_code_c = LBFGSB_RUNTIME_ERROR
          else
             ! Unrecognized task
  -          error_code_c = 3
  +          error_code_c = LBFGSB_TASK_ERROR
          end if
       else
          ! There was a problem computing the objective or the gradient.
  -       ! Fill C types with zeros so callers do not act unwittingly on
  -       ! garbage.
  +       ! The error message and code were already properly set by the
  +       ! call to function/gradient.  Fill C types with zeros so callers
  +       ! do not act unwittingly on garbage.
          min_x_c = 0d0
          min_f_c = 0d0
          min_g_c = 0d0
  
positive.code:     end do
  
      ! Analyze task and error state to see how to return
      if (error_code_c == 0) then
         ! Objective and gradient evaluations were OK but L-BFGS-B may not
         ! be.  Regardless, take what we can from the outputs.
         min_x_c = point
  
negative.code:      !   Arbitrary data to be used by the callback
       !
       ! error_code:
       !   Returned error code as defined in enumeration above
       function objective_function_c(dim, point, objective_function_value, &
            callback_data, error_message_length, error_message) &
            result(error_code) bind(c)
  