function checkValidSpawnedList(proc) result(list_full)
! Check that the position described by ValidSpawnedList is acceptable.
! If we have filled up the memory that would be acceptable, then
! end the calculation, i.e. throw an error
logical :: list_full
integer, intent(in) :: proc
logical, save :: new_warning = .true.
list_full = .false.
if (proc == nNodes - 1) then
list_full = ValidSpawnedList(proc) > MaxSpawned
else
list_full = ValidSpawnedList(proc) >= InitialSpawnedSlots(proc + 1)
end if
if (list_full .and. new_warning) then
! Only ever print this warning once
new_warning = .false.
write(stderr, *) "Attempting to spawn particle onto processor: ", proc
write(stderr, *) "No memory slots available for this spawn."
write(stderr, *) "Please increase MEMORYFACSPAWN"
write(stderr, *) ValidSpawnedList
write(stderr, *) InitialSpawnedSlots
! give a note on the counter-intuitive scaling behaviour
if (MaxSpawned / nProcessors < 0.1_dp * TotWalkers) then
write(stderr, *) "Memory available for spawns is too low, number of processes might be too high for the given walker number"
end if
end if
end function checkValidSpawnedList