soa_check_live_count Subroutine

public subroutine soa_check_live_count(n, allocated_size, err)

Verify that n live elements really exist in a field array.

Pass allocated_size = -1 for a field that is not allocated at all, which is only consistent with n == 0; a container that has never been allocated is in exactly that state and must still be serializable.

Arguments

Type IntentOptional Attributes Name
integer(kind=default_int), intent(in) :: n

Number of live elements the container claims to have.

integer(kind=default_int), intent(in) :: allocated_size

Allocated length of the field array, or -1 if it is unallocated.

type(error_t), intent(inout) :: err

Error state, ERROR_VALIDATION when the claim cannot hold.


Calls

proc~~soa_check_live_count~~CallsGraph proc~soa_check_live_count soa_check_live_count interface~to_char to_char proc~soa_check_live_count->interface~to_char proc~error_set error_t%error_set proc~soa_check_live_count->proc~error_set proc~to_char_char to_char_char interface~to_char->proc~to_char_char proc~to_char_dp to_char_dp interface~to_char->proc~to_char_dp proc~to_char_int32 to_char_int32 interface~to_char->proc~to_char_int32 proc~to_char_int64 to_char_int64 interface~to_char->proc~to_char_int64 proc~to_char_logical to_char_logical interface~to_char->proc~to_char_logical proc~to_char_matrix_dp to_char_matrix_dp interface~to_char->proc~to_char_matrix_dp proc~to_char_matrix_int32 to_char_matrix_int32 interface~to_char->proc~to_char_matrix_int32 proc~to_char_matrix_int64 to_char_matrix_int64 interface~to_char->proc~to_char_matrix_int64 proc~to_char_matrix_sp to_char_matrix_sp interface~to_char->proc~to_char_matrix_sp proc~to_char_sp to_char_sp interface~to_char->proc~to_char_sp proc~to_char_vector_dp to_char_vector_dp interface~to_char->proc~to_char_vector_dp proc~to_char_vector_int32 to_char_vector_int32 interface~to_char->proc~to_char_vector_int32 proc~to_char_vector_int64 to_char_vector_int64 interface~to_char->proc~to_char_vector_int64 proc~to_char_vector_sp to_char_vector_sp interface~to_char->proc~to_char_vector_sp

Called by

proc~~soa_check_live_count~~CalledByGraph proc~soa_check_live_count soa_check_live_count proc~soa_write_int32_field soa_write_int32_field proc~soa_write_int32_field->proc~soa_check_live_count proc~soa_write_int64_field soa_write_int64_field proc~soa_write_int64_field->proc~soa_check_live_count proc~soa_write_logical_field soa_write_logical_field proc~soa_write_logical_field->proc~soa_check_live_count proc~soa_write_real_dp_field soa_write_real_dp_field proc~soa_write_real_dp_field->proc~soa_check_live_count proc~soa_write_real_sp_field soa_write_real_sp_field proc~soa_write_real_sp_field->proc~soa_check_live_count interface~soa_write_field soa_write_field interface~soa_write_field->proc~soa_write_int32_field interface~soa_write_field->proc~soa_write_int64_field interface~soa_write_field->proc~soa_write_logical_field interface~soa_write_field->proc~soa_write_real_dp_field interface~soa_write_field->proc~soa_write_real_sp_field proc~particle_soa_serialize particle_soa_t%particle_soa_serialize proc~particle_soa_serialize->interface~soa_write_field

Source Code

   subroutine soa_check_live_count(n, allocated_size, err)
      !! Verify that `n` live elements really exist in a field array.
      !!
      !! Pass `allocated_size = -1` for a field that is not allocated at all,
      !! which is only consistent with `n == 0`; a container that has never
      !! been allocated is in exactly that state and must still be
      !! serializable.
      integer(default_int), intent(in) :: n
         !! Number of live elements the container claims to have.
      integer(default_int), intent(in) :: allocated_size
         !! Allocated length of the field array, or -1 if it is unallocated.
      type(error_t), intent(inout) :: err
         !! Error state, `ERROR_VALIDATION` when the claim cannot hold.

      if (n < 0) then
         call err%set(ERROR_VALIDATION, "soa: live element count "//to_char(int(n, int64))// &
                      " is negative")
         return
      end if
      if (allocated_size < 0) then
         if (n > 0) then
            call err%set(ERROR_VALIDATION, "soa: "//to_char(int(n, int64))// &
                         " live elements requested from an unallocated field")
         end if
         return
      end if
      if (n > allocated_size) then
         call err%set(ERROR_VALIDATION, "soa: "//to_char(int(n, int64))// &
                      " live elements requested from a field holding "// &
                      to_char(int(allocated_size, int64)))
      end if
   end subroutine soa_check_live_count