pic_soa_particle Module

A struct-of-arrays container holding 6 parallel field arrays.

Each field is a separate contiguous rank-1 array, which is the point of the layout: this%id is contiguous, and so is the live slice this%id(1:this%size()), so either can be handed straight to BLAS or to a vectorised loop without a copy.

Growth, the serialized record layout, the schema check on deserialize and the state-hash fold order are all documented in pic_soa. This type’s schema string is

particle;id:i32,x:r64,y:r64,z:r64,mass:r64,active:bool

prefixed by SOA_SCHEMA_PREFIX. Fields are serialized and folded into the hash in exactly the order they are declared below.


Uses

  • module~~pic_soa_particle~~UsesGraph module~pic_soa_particle pic_soa_particle module~pic_array_hash pic_array_hash module~pic_soa_particle->module~pic_array_hash module~pic_error pic_error module~pic_soa_particle->module~pic_error module~pic_soa pic_soa module~pic_soa_particle->module~pic_soa module~pic_types pic_types module~pic_soa_particle->module~pic_types module~pic_array_hash->module~pic_types module~pic_uint64 pic_uint64 module~pic_array_hash->module~pic_uint64 module~pic_error->module~pic_types module~pic_global_definitions pic_global_definitions module~pic_error->module~pic_global_definitions module~pic_soa->module~pic_array_hash module~pic_soa->module~pic_error module~pic_soa->module~pic_types module~pic_io pic_io module~pic_soa->module~pic_io module~pic_serialize pic_serialize module~pic_soa->module~pic_serialize iso_c_binding iso_c_binding module~pic_types->iso_c_binding iso_fortran_env iso_fortran_env module~pic_types->iso_fortran_env module~pic_global_definitions->module~pic_types module~pic_io->module~pic_types module~pic_ascii pic_ascii module~pic_io->module~pic_ascii module~pic_serialize->module~pic_error module~pic_serialize->module~pic_types module~pic_serialize->module~pic_io module~pic_uint64->module~pic_types module~pic_ascii->module~pic_types

Variables

Type Visibility Attributes Name Initial
integer(kind=int32), public, parameter :: PARTICLE_SOA_FIELD_KINDS(PARTICLE_SOA_N_FIELDS) = [SOA_FIELD_INT32, SOA_FIELD_REAL_DP, SOA_FIELD_REAL_DP, SOA_FIELD_REAL_DP, SOA_FIELD_REAL_DP, SOA_FIELD_LOGICAL]

Field kind codes in declaration order. Fixed-width int32 because these describe on-disk record tags. Pass to soa_stream_bytes.

integer(kind=default_int), public, parameter :: PARTICLE_SOA_N_FIELDS = 6

Number of fields, which is also the number of field records a stream carries after the prologue.

character(len=*), public, parameter :: PARTICLE_SOA_SCHEMA = SOA_SCHEMA_PREFIX//"particle;id:i32,x:r64,y:r64,z:r64,mass:r64,active:bool"

Layout identity written into every stream and folded into every digest. Any change to the field list changes it, which is what makes a stale checkpoint fail loudly instead of decoding as garbage.


Derived Types

type, public ::  particle_soa_t

6 parallel field arrays plus size/capacity bookkeeping.

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
procedure, public :: capacity => particle_soa_capacity
procedure, public :: clear => particle_soa_clear
procedure, public :: deallocate => particle_soa_deallocate
procedure, public :: deserialize => particle_soa_deserialize
procedure, public :: resize => particle_soa_resize
procedure, public :: serialize => particle_soa_serialize
procedure, public :: serialized_bytes => particle_soa_serialized_bytes
procedure, public :: size => particle_soa_size
procedure, public :: state_hash => particle_soa_state_hash
procedure, public :: state_hash64 => particle_soa_state_hash64

Functions

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)

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)

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)

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)

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)


Subroutines

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.

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.

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.

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.

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.

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.