Cross-rank int64 sum for the decomposition-invariant chksum
bitcount (rdb_ocean_chksum). pic_mpi_lib exposes no
integer(int64) allreduce overload (MPI_INTEGER8 reaches only
send/recv), so the value rides the EXACT real64 allreduce: a
per-field POPCNT sum is bounded by (#elements x 64), which stays
FAR below the double-mantissa bound 253 for any realistic grid
(253/64 ~ 1.4e14 cells), so both the local->double cast and
every partial MPI_SUM are exact — the invariant survives.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | local_val | |||
| integer(kind=int64), | intent(out) | :: | global_val |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=real64), | private | :: | acc_global | ||||
| real(kind=real64), | private | :: | acc_local | ||||
| type(comm_t), | private | :: | comm |
subroutine halo_allreduce_sum_i8(local_val, global_val) !! Cross-rank int64 sum for the decomposition-invariant chksum !! bitcount (`rdb_ocean_chksum`). `pic_mpi_lib` exposes no !! `integer(int64)` allreduce overload (MPI_INTEGER8 reaches only !! send/recv), so the value rides the EXACT `real64` allreduce: a !! per-field POPCNT sum is bounded by (#elements x 64), which stays !! FAR below the double-mantissa bound 2**53 for any realistic grid !! (2**53/64 ~ 1.4e14 cells), so both the local->double cast and !! every partial MPI_SUM are exact — the invariant survives. integer(int64), intent(in) :: local_val integer(int64), intent(out) :: global_val type(comm_t) :: comm real(real64) :: acc_local, acc_global comm = comm_env_compute_comm() ! Single rank: the reduction is the identity, so return this rank's ! own contribution without entering a collective. Not just an ! optimisation -- pic-mpi's serial backend (PIC_ENABLE_MPI=OFF) ! deliberately `error stop`s in `allreduce`, pushing the size()==1 ! case onto the caller. This IS that case. if (comm%size() == 1) then global_val = local_val return end if acc_local = real(local_val, real64) call allreduce(comm, acc_local, acc_global, op=MPI_SUM) global_val = int(acc_global, int64) end subroutine halo_allreduce_sum_i8