particle_soa_t Derived Type

type, public :: particle_soa_t

6 parallel field arrays plus size/capacity bookkeeping.


Inherits

type~~particle_soa_t~~InheritsGraph type~particle_soa_t particle_soa_t type~soa_extent_t soa_extent_t type~particle_soa_t->type~soa_extent_t extent

Components

Type Visibility Attributes Name Initial
logical, public, allocatable :: active(:)

Whether the particle takes part in the simulation.

type(soa_extent_t), public :: extent

Live element count and allocated capacity.

integer(kind=int32), public, allocatable :: id(:)

Particle identifier.

real(kind=dp), public, allocatable :: mass(:)

Particle mass.

real(kind=dp), public, allocatable :: x(:)

Cartesian x coordinate.

real(kind=dp), public, allocatable :: y(:)

Cartesian y coordinate.

real(kind=dp), public, allocatable :: z(:)

Cartesian z coordinate.


Type-Bound Procedures

procedure, public :: allocate => particle_soa_allocate

  • private subroutine particle_soa_allocate(this, n, err)

    Give the container n live elements, discarding any it already had.

    Read more…

    Arguments

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

    Container to (re)allocate.

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

    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 the field arrays cannot be allocated.

procedure, public :: capacity => particle_soa_capacity

  • private pure function particle_soa_capacity(this) result(n)

    Allocated length of every field array. Always at least size().

    Arguments

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

    Container to query.

    Return Value integer(kind=default_int)

procedure, public :: clear => particle_soa_clear

  • private subroutine particle_soa_clear(this)

    Drop every live element but keep the allocated capacity.

    Read more…

    Arguments

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

    Container to empty.

procedure, public :: deallocate => particle_soa_deallocate

  • private subroutine particle_soa_deallocate(this)

    Release every field array and reset both counters to zero.

    Arguments

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

    Container to empty.

procedure, public :: deserialize => particle_soa_deserialize

  • private subroutine particle_soa_deserialize(this, unit, err)

    Read a container back from an open stream unit.

    Read more…

    Arguments

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

    Container to fill. Any previous contents are discarded.

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

    Stream unit opened for unformatted stream reading.

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

    Error state, ERROR_VALIDATION on a layout or length mismatch and ERROR_IO on a truncated stream.

procedure, public :: resize => particle_soa_resize

  • private subroutine particle_soa_resize(this, n, err)

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

    Read more…

    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.

procedure, public :: serialize => particle_soa_serialize

  • private subroutine particle_soa_serialize(this, unit, err)

    Write the container to an open stream unit.

    Read more…

    Arguments

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

    Container to write.

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

    Stream unit opened for unformatted stream writing.

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

    Error state, ERROR_IO if the stream cannot be written.

procedure, public :: serialized_bytes => particle_soa_serialized_bytes

  • private pure function particle_soa_serialized_bytes(this) result(nbytes)

    Exact size in bytes of the stream serialize would write now.

    Arguments

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

    Container to measure.

    Return Value integer(kind=int64)

procedure, public :: size => particle_soa_size

  • private pure function particle_soa_size(this) result(n)

    Number of live elements.

    Arguments

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

    Container to query.

    Return Value integer(kind=default_int)

procedure, public :: state_hash => particle_soa_state_hash

  • private function particle_soa_state_hash(this) result(digest)

    32-bit FNV-1a digest of the container’s live state.

    Read more…

    Arguments

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

    Container to fingerprint.

    Return Value integer(kind=int32)

procedure, public :: state_hash64 => particle_soa_state_hash64

  • private function particle_soa_state_hash64(this) result(digest)

    64-bit FNV-1a digest of the container’s live state.

    Read more…

    Arguments

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

    Container to fingerprint.

    Return Value integer(kind=int64)

Source Code

   type :: particle_soa_t
      !! 6 parallel field arrays plus size/capacity bookkeeping.
      type(soa_extent_t) :: extent
         !! Live element count and allocated capacity.
      integer(int32), allocatable :: id(:)
         !! Particle identifier.
      real(dp), allocatable :: x(:)
         !! Cartesian x coordinate.
      real(dp), allocatable :: y(:)
         !! Cartesian y coordinate.
      real(dp), allocatable :: z(:)
         !! Cartesian z coordinate.
      real(dp), allocatable :: mass(:)
         !! Particle mass.
      logical, allocatable :: active(:)
         !! Whether the particle takes part in the simulation.
   contains
      procedure :: allocate => particle_soa_allocate
      procedure :: resize => particle_soa_resize
      procedure :: deallocate => particle_soa_deallocate
      procedure :: clear => particle_soa_clear
      procedure :: size => particle_soa_size
      procedure :: capacity => particle_soa_capacity
      procedure :: serialized_bytes => particle_soa_serialized_bytes
      procedure :: serialize => particle_soa_serialize
      procedure :: deserialize => particle_soa_deserialize
      procedure :: state_hash => particle_soa_state_hash
      procedure :: state_hash64 => particle_soa_state_hash64
   end type particle_soa_t