Optimize X(hamiltonian_elec_base_nlocal_force routine)
In case of an applied phase, the following code is going twice over the full mesh: -once for copying from the mesh to the submesh -once for applying the phase. This should be optmized.
! collect all the points we need in a continuous array
if(batch_is_packed(psi1b)) then
forall(ip = 1:npoints)
forall(ist = 1:nst)
psi(0, ist, ip) = psi1b%pack%X(psi)(ist, pmat%map(ip))
forall(idir = 1:ndim) psi(idir, ist, ip) = psi2b(idir)%pack%X(psi)(ist, pmat%map(ip))
end forall
end forall
else
forall(ip = 1:npoints)
forall(ist = 1:nst)
psi(0, ist, ip) = psi1b%states_linear(ist)%X(psi)(pmat%map(ip))
forall(idir = 1:ndim) psi(idir, ist, ip) = psi2b(idir)%states_linear(ist)%X(psi)(pmat%map(ip))
end forall
end forall
end if
!
if(allocated(this%projector_phases)) then
forall(ip = 1:npoints)
forall(ist = 1:nst)
forall(idir = 0:ndim)
psi(idir, ist, ip) = this%projector_phases(ip, imat, iqn)*psi(idir, ist, ip)
end forall
end forall
end forall
end if
Edited by Nicolas Tancogne-Dejean