subroutine realloc_SpawnedParts() ! Routine called when RDM accumulation is turned on, usually midway ! through an FCIQMC simulation. ! When calculating the RDMs, we need to store the parent from which a ! child is spawned along with the children in the spawned array. This ! means a slightly larger array is communicated between processors, ! which there is no point in doing for the first part of the calculation. ! When we start calculating the RDMs this routine is called and the ! SpawnedParts array is made larger to accommodate the parents. use FciMCData, only: MaxSpawned, SpawnVec, SpawnVec2, SpawnVecTag, SpawnVec2Tag use FciMCData, only: SpawnedParts, SpawnedParts2 use MemoryManager, only: LogMemAlloc, LogMemDealloc integer :: ierr, nifbcast_old character(len=*), parameter :: this_routine = 'realloc_SpawnedParts' if (bit_rdm_init) & call stop_all(this_routine, 'RDM broadcast representation already initialised') deallocate(SpawnVec) call LogMemDealloc(this_routine, SpawnVecTag) deallocate(SpawnVec2) call LogMemDealloc(this_routine, SpawnVec2Tag) ! Resize the RDM arrays NIfBCast_old = IlutBits%len_bcast IlutBits%ind_parent = IlutBits%len_bcast + 1 IlutBits%ind_rdm_fac = IlutBits%ind_parent + IlutBits%len_orb + 1 IlutBits%ind_parent_flag = IlutBits%ind_rdm_fac + 1 IlutBits%len_bcast = IlutBits%ind_parent_flag ! IlutBits%len_bcast = IlutBits%len_bcast + nifd + 3 allocate(SpawnVec(0:IlutBits%len_bcast, MaxSpawned), stat=ierr) block use constants, only: int64 use util_mod, only: operator(.div.) if (ierr /= 0) then call stop_all(this_routine, 'Error in allocation of SpawnVec.') end if call LogMemAlloc("SpawnVec", size(SpawnVec, kind=int64), int(sizeof(SpawnVec), kind=int64) .div. size(SpawnVec, kind=int64),& & this_routine, SpawnVecTag, ierr) end block allocate(SpawnVec2(0:IlutBits%len_bcast, MaxSpawned), stat=ierr) block use constants, only: int64 use util_mod, only: operator(.div.) if (ierr /= 0) then call stop_all(this_routine, 'Error in allocation of SpawnVec2.') end if call LogMemAlloc("SpawnVec2", size(SpawnVec2, kind=int64), int(sizeof(SpawnVec2), kind=int64) .div. size(SpawnVec2, kind=int64),& & this_routine, SpawnVec2Tag, ierr) end block ! Point at correct spawning arrays SpawnedParts => SpawnVec SpawnedParts2 => SpawnVec2 write(stdout, '(A54,F10.4,A4,F10.4,A13)') & 'Memory requirement for spawned arrays increased from ', & real(((NIfBCast_old + 1) * MaxSpawned * 2 * size_n_int), dp) / 1048576.0_dp, & ' to ', & real(((IlutBits%len_bcast + 1) * MaxSpawned * 2 * size_n_int), dp) / 1048576.0_dp, & ' Mb/Processor' ! And we are done bit_rdm_init = .true. end subroutine realloc_SpawnedParts