10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-07-05 19:05:59 +02:00

Corrected mysterious openmp bug

This commit is contained in:
Anthony Scemama 2015-11-13 13:38:42 +01:00
parent 66e1ef316d
commit b7e20b3493

View File

@ -1250,17 +1250,15 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint)
ASSERT (n>0) ASSERT (n>0)
PROVIDE ref_bitmask_energy davidson_criterion PROVIDE ref_bitmask_energy davidson_criterion
v_0 = 0.d0 v_0 = 0.d0
call sort_dets_ab_v(keys_tmp, sorted, sort_idx, shortcut, version, n, Nint)
!$OMP PARALLEL DEFAULT(NONE) & !$OMP PARALLEL DEFAULT(NONE) &
!$OMP PRIVATE(i,hij,j,k,idx,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi) & !$OMP PRIVATE(i,hij,j,k,idx,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi) &
!$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold,sorted,shortcut,sort_idx,version) !$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold,sorted,shortcut,sort_idx,version)
allocate(idx(0:n), vt(n)) allocate(idx(0:n), vt(n))
Vt = 0.d0 Vt = 0.d0
!$OMP SINGLE
call sort_dets_ab_v(keys_tmp, sorted, sort_idx, shortcut, version, n, Nint)
!$OMP END SINGLE
!$OMP BARRIER
!$OMP DO SCHEDULE(dynamic) !$OMP DO SCHEDULE(dynamic)
do sh=1,shortcut(0) do sh=1,shortcut(0)
do sh2=1,sh do sh2=1,sh
@ -1299,11 +1297,22 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint)
enddo enddo
!$OMP END DO !$OMP END DO
integer :: omp_get_num_threads , omp_get_thread_num !$OMP CRITICAL
!$OMP SINGLE do i=1,n
v_0(i) = v_0(i) + vt(i)
enddo
!$OMP END CRITICAL
deallocate(idx,vt)
!$OMP END PARALLEL
call sort_dets_ba_v(keys_tmp, sorted, sort_idx, shortcut, version, n, Nint) call sort_dets_ba_v(keys_tmp, sorted, sort_idx, shortcut, version, n, Nint)
!$OMP END SINGLE
!$OMP BARRIER !$OMP PARALLEL DEFAULT(NONE) &
!$OMP PRIVATE(i,hij,j,k,idx,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi) &
!$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold,sorted,shortcut,sort_idx,version)
allocate(idx(0:n), vt(n))
Vt = 0.d0
!$OMP DO SCHEDULE(dynamic) !$OMP DO SCHEDULE(dynamic)
do sh=1,shortcut(0) do sh=1,shortcut(0)
@ -1334,6 +1343,7 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint)
!$OMP END CRITICAL !$OMP END CRITICAL
deallocate(idx,vt) deallocate(idx,vt)
!$OMP END PARALLEL !$OMP END PARALLEL
do i=1,n do i=1,n
v_0(i) += H_jj(i) * u_0(i) v_0(i) += H_jj(i) * u_0(i)
enddo enddo