SUBROUTINE SETUPUMAT2D(G1, HarInt)
! Set up UMat2D for storing the <ij|u|ij> and <ij|u|ji> integrals,
! and pre-calculate the common integrals (<ij|u|ij>, <ij|u|ji>,
! <i|v_har|j>) for CPMD calculations.
! In:
! G1: symmetry and momentum information on the basis functions.
! Out:
! HarInt(i,j)=<i|v_har|j>, where v_har is the Hartree potential.
TYPE(BasisFN) G1(*)
INTEGER ierr
complex(dp) HarInt(nStates, nStates)
character(len=*), parameter :: thisroutine = 'SETUPUMAT2D'
IF ((NSLOTSINIT < 0)) THEN
TUMAT2D = .FALSE.
write(stdout, *) "Not using UMAT2D."
ELSE
TUMAT2D = .TRUE.
allocate(UMat2D(nStates, nStates), STAT=ierr)
UMat2D = 0.0_dp
call LogMemAlloc('UMat2D', nStates**2, 8 * HElement_t_size, thisroutine, tagUMat2D, ierr)
CALL CPMDANTISYMINTEL(G1, UMAT2D, HarInt, NSTATES)
end if
END SUBROUTINE SetupUMat2D