particle_soa_resize Subroutine

private subroutine particle_soa_resize(this, n, err)

Change the number of live elements, preserving the elements that survive.

min(size(), n) leading elements of every field keep their values. Growing sets the newly exposed elements to the zero value of their type; shrinking only lowers the live count. Capacity grows geometrically and never shrinks – see pic_soa.

On failure the container is left exactly as it was.

Type Bound

particle_soa_t

Arguments

Type IntentOptional Attributes Name
class(particle_soa_t), intent(inout) :: this

Container to resize.

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

New number of live elements. Must not be negative.

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

Error state, ERROR_VALIDATION on a negative n and ERROR_ALLOC if a field array cannot be allocated.


Calls

proc~~particle_soa_resize~~CallsGraph proc~particle_soa_resize particle_soa_t%particle_soa_resize interface~soa_resize_field soa_resize_field proc~particle_soa_resize->interface~soa_resize_field proc~error_has_error error_t%error_has_error proc~particle_soa_resize->proc~error_has_error proc~soa_plan_resize soa_plan_resize proc~particle_soa_resize->proc~soa_plan_resize proc~soa_resize_int32_field soa_resize_int32_field interface~soa_resize_field->proc~soa_resize_int32_field proc~soa_resize_int64_field soa_resize_int64_field interface~soa_resize_field->proc~soa_resize_int64_field proc~soa_resize_logical_field soa_resize_logical_field interface~soa_resize_field->proc~soa_resize_logical_field proc~soa_resize_real_dp_field soa_resize_real_dp_field interface~soa_resize_field->proc~soa_resize_real_dp_field proc~soa_resize_real_sp_field soa_resize_real_sp_field interface~soa_resize_field->proc~soa_resize_real_sp_field interface~to_char to_char proc~soa_plan_resize->interface~to_char proc~error_set error_t%error_set proc~soa_plan_resize->proc~error_set proc~soa_grow_capacity soa_grow_capacity proc~soa_plan_resize->proc~soa_grow_capacity 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 proc~soa_resize_int32_field->proc~error_has_error proc~soa_check_alloc soa_check_alloc proc~soa_resize_int32_field->proc~soa_check_alloc proc~soa_check_resize_args soa_check_resize_args proc~soa_resize_int32_field->proc~soa_check_resize_args proc~soa_resize_int64_field->proc~error_has_error proc~soa_resize_int64_field->proc~soa_check_alloc proc~soa_resize_int64_field->proc~soa_check_resize_args proc~soa_resize_logical_field->proc~error_has_error proc~soa_resize_logical_field->proc~soa_check_alloc proc~soa_resize_logical_field->proc~soa_check_resize_args proc~soa_resize_real_dp_field->proc~error_has_error proc~soa_resize_real_dp_field->proc~soa_check_alloc proc~soa_resize_real_dp_field->proc~soa_check_resize_args proc~soa_resize_real_sp_field->proc~error_has_error proc~soa_resize_real_sp_field->proc~soa_check_alloc proc~soa_resize_real_sp_field->proc~soa_check_resize_args proc~soa_check_alloc->interface~to_char proc~soa_check_alloc->proc~error_set proc~soa_check_resize_args->interface~to_char proc~soa_check_resize_args->proc~error_set

Called by

proc~~particle_soa_resize~~CalledByGraph proc~particle_soa_resize particle_soa_t%particle_soa_resize proc~particle_soa_allocate particle_soa_t%particle_soa_allocate proc~particle_soa_allocate->proc~particle_soa_resize

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: keep
integer(kind=default_int), private :: new_capacity

Source Code

   subroutine particle_soa_resize(this, n, err)
      !! Change the number of live elements, preserving the elements that
      !! survive.
      !!
      !! `min(size(), n)` leading elements of every field keep their values.
      !! Growing sets the newly exposed elements to the zero value of their
      !! type; shrinking only lowers the live count. Capacity grows
      !! geometrically and never shrinks -- see `pic_soa`.
      !!
      !! On failure the container is left exactly as it was.
      class(particle_soa_t), intent(inout) :: this
         !! Container to resize.
      integer(default_int), intent(in) :: n
         !! New number of live elements. Must not be negative.
      type(error_t), intent(inout) :: err
         !! Error state, `ERROR_VALIDATION` on a negative `n` and
         !! `ERROR_ALLOC` if a field array cannot be allocated.

      integer(default_int) :: new_capacity, keep

      call soa_plan_resize(this%extent, n, new_capacity, keep, err)
      if (err%has_error()) return

      call soa_resize_field(this%id, new_capacity, keep, n, err)
      if (err%has_error()) return
      call soa_resize_field(this%x, new_capacity, keep, n, err)
      if (err%has_error()) return
      call soa_resize_field(this%y, new_capacity, keep, n, err)
      if (err%has_error()) return
      call soa_resize_field(this%z, new_capacity, keep, n, err)
      if (err%has_error()) return
      call soa_resize_field(this%mass, new_capacity, keep, n, err)
      if (err%has_error()) return
      call soa_resize_field(this%active, new_capacity, keep, n, err)
      if (err%has_error()) return

      this%extent%used = n
      this%extent%capacity = new_capacity
   end subroutine particle_soa_resize