Skip to content

Commit

Permalink
fix of NL using nvfortran + openmp (+cudaF, possibly irrelevant here)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-ferretti committed Jan 18, 2025
1 parent 9f0c310 commit 8a51017
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/nloptics/el_density_vbands.F
Original file line number Diff line number Diff line change
Expand Up @@ -47,42 +47,45 @@ subroutine el_density_vbands(en,Xk,rho,VAL_BANDS)
integer :: i1,ik,is,rho_syms,ir,ik_mem
real(SP) :: rho_no_sym(fft_size)
!
!$OMP WORKSHARE
rho=rZERO
rho_no_sym=rZERO
!$OMP END WORKSHARE
!
do ik=1,Xk%nibz
!
if (.not.PAR_IND_Xk_ibz%element_1D(ik)) cycle
ik_mem=PAR_Xk_ibz_index(ik)
!
!$omp parallel do, default(shared), private(is,ir), &
!$omp reduction(+:rho_no_sym), collapse(2)
do is=1,n_sp_pol
!$OMP WORKSHARE
forall(ir=1:fft_size)
rho_no_sym(ir)=rho_no_sym(ir)+real(spin_occ,SP)*Xk%weights(ik)*sum(abs(VAL_BANDS(ir,:en%nbf(is),ik_mem,is))**2._SP)
end forall
!$OMP END WORKSHARE
do ir=1,fft_size
rho_no_sym(ir)=rho_no_sym(ir)+real(spin_occ,SP)*Xk%weights(ik)*&
& sum(abs(VAL_BANDS(ir,:en%nbf(is),ik_mem,is))**2._SP)
enddo
enddo
!$omp end parallel do
!
enddo
!
call PP_redux_wait(rho_no_sym,COMM=PAR_COM_Xk_ibz_INDEX%COMM)
!
! Simmetrization
!
!$OMP WORKSHARE
rho_syms=nsym/(i_time_rev+1)
!$OMP END WORKSHARE
!
!$OMP WORKSHARE
forall(ir=1:fft_size)
rho(:)=rZERO
!
!$omp parallel default(shared), private(ir)
!$omp do, reduction(+:rho)
do ir=1,fft_size
rho(ir)=rho(ir)+sum(rho_no_sym(fft_rot_r(ir,1:rho_syms)))/real(nsym,SP)
end forall
!$OMP END WORKSHARE
enddo
!$omp end do
!
!$OMP WORKSHARE
rho=real(1._SP+i_time_rev,SP)*rho
!$OMP END WORKSHARE
!$omp do
do ir=1,fft_size
rho(ir)=real(1._SP+i_time_rev,SP)*rho(ir)
enddo
!$omp end do
!$omp end parallel
!
end subroutine

0 comments on commit 8a51017

Please sign in to comment.