mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-25 05:43:47 +01:00
Merge github.com:scemama/quantum_package into thesis
Conflicts: plugins/Full_CI_ZMQ/pt2_stoch_routines.irp.f plugins/Full_CI_ZMQ/run_pt2_slave.irp.f plugins/Full_CI_ZMQ/run_selection_slave.irp.f plugins/Full_CI_ZMQ/selection.irp.f plugins/Generators_full/generators.irp.f plugins/dress_zmq/dress_stoch_routines.irp.f plugins/dress_zmq/dressing.irp.f plugins/dress_zmq/run_dress_slave.irp.f plugins/shiftedbk/shifted_bk_routines.irp.f src/Determinants/slater_rules.irp.f
This commit is contained in:
commit
cfc37ea57c
@ -63,9 +63,6 @@ END_PROVIDER
|
||||
call davidson_diag_HS2(psi_det,CI_eigenvectors_dressed, CI_eigenvectors_s2_dressed,&
|
||||
size(CI_eigenvectors_dressed,1), CI_electronic_energy_dressed,&
|
||||
N_det,min(N_det,N_states),min(N_det,N_states_diag),N_int,1)
|
||||
! call u_0_S2_u_0(CI_eigenvectors_s2_dressed,CI_eigenvectors_dressed,N_det,psi_det,N_int,&
|
||||
! N_states_diag,size(CI_eigenvectors_dressed,1))
|
||||
|
||||
|
||||
else if (diag_algorithm == "Lapack") then
|
||||
|
||||
@ -159,6 +156,7 @@ subroutine diagonalize_CI_dressed
|
||||
! eigenstates of the CI matrix
|
||||
END_DOC
|
||||
integer :: i,j
|
||||
PROVIDE delta_ij
|
||||
do j=1,N_states
|
||||
do i=1,N_det
|
||||
psi_coef(i,j) = CI_eigenvectors_dressed(i,j)
|
||||
|
@ -10,20 +10,19 @@ program fci_zmq
|
||||
|
||||
double precision :: hf_energy_ref
|
||||
logical :: has
|
||||
double precision :: relative_error, absolute_error
|
||||
double precision :: relative_error
|
||||
integer :: N_states_p
|
||||
character*(512) :: fmt
|
||||
|
||||
relative_error=PT2_relative_error
|
||||
absolute_error=PT2_absolute_error
|
||||
|
||||
pt2 = -huge(1.e0)
|
||||
threshold_davidson_in = threshold_davidson
|
||||
threshold_davidson = threshold_davidson_in * 100.d0
|
||||
SOFT_TOUCH threshold_davidson
|
||||
|
||||
! call diagonalize_CI
|
||||
! call save_wavefunction
|
||||
call diagonalize_CI
|
||||
call save_wavefunction
|
||||
|
||||
call ezfio_has_hartree_fock_energy(has)
|
||||
if (has) then
|
||||
@ -72,7 +71,7 @@ program fci_zmq
|
||||
threshold_selectors = 1.d0
|
||||
threshold_generators = 1.d0
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
call ZMQ_pt2(CI_energy, pt2,relative_error,absolute_error,error) ! Stochastic PT2
|
||||
call ZMQ_pt2(CI_energy, pt2,relative_error,error) ! Stochastic PT2
|
||||
threshold_selectors = threshold_selectors_save
|
||||
threshold_generators = threshold_generators_save
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
@ -184,7 +183,7 @@ program fci_zmq
|
||||
threshold_selectors = 1.d0
|
||||
threshold_generators = 1d0
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
call ZMQ_pt2(CI_energy, pt2,relative_error,absolute_error,error) ! Stochastic PT2
|
||||
call ZMQ_pt2(CI_energy, pt2,relative_error,error) ! Stochastic PT2
|
||||
threshold_selectors = threshold_selectors_save
|
||||
threshold_generators = threshold_generators_save
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
|
@ -1,246 +0,0 @@
|
||||
program fci_zmq
|
||||
implicit none
|
||||
integer :: i,j,k
|
||||
double precision, allocatable :: pt2(:)
|
||||
integer :: degree
|
||||
integer :: n_det_before, to_select
|
||||
double precision :: threshold_davidson_in
|
||||
|
||||
allocate (pt2(N_states))
|
||||
|
||||
double precision :: hf_energy_ref
|
||||
logical :: has
|
||||
double precision :: relative_error, absolute_error
|
||||
integer :: N_states_p
|
||||
character*(512) :: fmt
|
||||
|
||||
relative_error=PT2_relative_error
|
||||
absolute_error=PT2_absolute_error
|
||||
|
||||
pt2 = -huge(1.e0)
|
||||
threshold_davidson_in = threshold_davidson
|
||||
threshold_davidson = threshold_davidson_in * 100.d0
|
||||
SOFT_TOUCH threshold_davidson
|
||||
|
||||
call diagonalize_CI
|
||||
call save_wavefunction
|
||||
|
||||
call ezfio_has_hartree_fock_energy(has)
|
||||
if (has) then
|
||||
call ezfio_get_hartree_fock_energy(hf_energy_ref)
|
||||
else
|
||||
hf_energy_ref = ref_bitmask_energy
|
||||
endif
|
||||
|
||||
if (N_det > N_det_max) then
|
||||
psi_det = psi_det_sorted
|
||||
psi_coef = psi_coef_sorted
|
||||
N_det = N_det_max
|
||||
soft_touch N_det psi_det psi_coef
|
||||
call diagonalize_CI
|
||||
call save_wavefunction
|
||||
N_states_p = min(N_det,N_states)
|
||||
endif
|
||||
|
||||
n_det_before = 0
|
||||
|
||||
character*(8) :: pt2_string
|
||||
double precision :: correlation_energy_ratio
|
||||
double precision :: threshold_selectors_save, threshold_generators_save
|
||||
threshold_selectors_save = threshold_selectors
|
||||
threshold_generators_save = threshold_generators
|
||||
double precision :: error(N_states)
|
||||
|
||||
correlation_energy_ratio = 0.d0
|
||||
|
||||
if (.True.) then ! Avoid pre-calculation of CI_energy
|
||||
do while ( &
|
||||
(N_det < N_det_max) .and. &
|
||||
(maxval(abs(pt2(1:N_states))) > pt2_max) .and. &
|
||||
(correlation_energy_ratio <= correlation_energy_ratio_max) &
|
||||
)
|
||||
write(*,'(A)') '--------------------------------------------------------------------------------'
|
||||
|
||||
|
||||
if (do_pt2) then
|
||||
pt2_string = ' '
|
||||
pt2 = 0.d0
|
||||
threshold_selectors = 1.d0
|
||||
threshold_generators = 1d0
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
call ZMQ_pt2(CI_energy, pt2,relative_error,absolute_error,error) ! Stochastic PT2
|
||||
threshold_selectors = threshold_selectors_save
|
||||
threshold_generators = threshold_generators_save
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
else
|
||||
pt2_string = '(approx)'
|
||||
endif
|
||||
|
||||
|
||||
correlation_energy_ratio = (CI_energy(1) - hf_energy_ref) / &
|
||||
(CI_energy(1) + pt2(1) - hf_energy_ref)
|
||||
correlation_energy_ratio = min(1.d0,correlation_energy_ratio)
|
||||
|
||||
N_states_p = min(N_det,N_states)
|
||||
|
||||
print *, ''
|
||||
print '(A,I12)', 'Summary at N_det = ', N_det
|
||||
print '(A)', '-----------------------------------'
|
||||
print *, ''
|
||||
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
|
||||
print *, ''
|
||||
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
write(fmt,*) '(12X,', N_states_p, '(6X,A7,1X,I6,10X))'
|
||||
write(*,fmt) ('State',k, k=1,N_states_p)
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
write(fmt,*) '(A12,', N_states_p, '(1X,F14.8,15X))'
|
||||
write(*,fmt) '# E ', CI_energy(1:N_states_p)
|
||||
if (N_states_p > 1) then
|
||||
write(*,fmt) '# Excit. (au)', CI_energy(1:N_states_p)-CI_energy(1)
|
||||
write(*,fmt) '# Excit. (eV)', (CI_energy(1:N_states_p)-CI_energy(1))*27.211396641308d0
|
||||
endif
|
||||
write(fmt,*) '(A12,', 2*N_states_p, '(1X,F14.8))'
|
||||
write(*,fmt) '# PT2'//pt2_string, (pt2(k), error(k), k=1,N_states_p)
|
||||
write(*,'(A)') '#'
|
||||
write(*,fmt) '# E+PT2 ', (CI_energy(k)+pt2(k),error(k), k=1,N_states_p)
|
||||
if (N_states_p > 1) then
|
||||
write(*,fmt) '# Excit. (au)', ( (CI_energy(k)+pt2(k)-CI_energy(1)-pt2(1)), &
|
||||
dsqrt(error(k)*error(k)+error(1)*error(1)), k=1,N_states_p)
|
||||
write(*,fmt) '# Excit. (eV)', ( (CI_energy(k)+pt2(k)-CI_energy(1)-pt2(1))*27.211396641308d0, &
|
||||
dsqrt(error(k)*error(k)+error(1)*error(1))*27.211396641308d0, k=1,N_states_p)
|
||||
endif
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
print *, ''
|
||||
|
||||
print *, 'N_det = ', N_det
|
||||
print *, 'N_states = ', N_states
|
||||
print*, 'correlation_ratio = ', correlation_energy_ratio
|
||||
|
||||
do k=1, N_states_p
|
||||
print*,'State ',k
|
||||
print *, 'PT2 = ', pt2(k)
|
||||
print *, 'E = ', CI_energy(k)
|
||||
print *, 'E+PT2'//pt2_string//' = ', CI_energy(k)+pt2(k), ' +/- ', error(k)
|
||||
enddo
|
||||
|
||||
print *, '-----'
|
||||
if(N_states.gt.1)then
|
||||
print *, 'Variational Energy difference (au | eV)'
|
||||
do i=2, N_states_p
|
||||
print*,'Delta E = ', (CI_energy(i) - CI_energy(1)), &
|
||||
(CI_energy(i) - CI_energy(1)) * 27.211396641308d0
|
||||
enddo
|
||||
print *, '-----'
|
||||
print*, 'Variational + perturbative Energy difference (au | eV)'
|
||||
do i=2, N_states_p
|
||||
print*,'Delta E = ', (CI_energy(i)+ pt2(i) - (CI_energy(1) + pt2(1))), &
|
||||
(CI_energy(i)+ pt2(i) - (CI_energy(1) + pt2(1))) * 27.211396641308d0
|
||||
enddo
|
||||
endif
|
||||
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
|
||||
call dump_fci_iterations_value(N_det,CI_energy,pt2)
|
||||
|
||||
n_det_before = N_det
|
||||
if (s2_eig) then
|
||||
to_select = N_det/2+1
|
||||
to_select = max(N_det/2+1, to_select)
|
||||
to_select = min(to_select, N_det_max-n_det_before)
|
||||
else
|
||||
to_select = N_det
|
||||
to_select = max(N_det, to_select)
|
||||
to_select = min(to_select, N_det_max-n_det_before)
|
||||
endif
|
||||
call save_natural_mos
|
||||
call map_deinit(mo_integrals_map)
|
||||
FREE mo_integrals_map
|
||||
PROVIDE mo_integrals_map
|
||||
call four_index_transform_block(ao_integrals_map,mo_integrals_map, &
|
||||
mo_coef, size(mo_coef,1), &
|
||||
1, 1, 1, 1, ao_num, ao_num, ao_num, ao_num, &
|
||||
1, 1, 1, 1, mo_num, mo_num, mo_num, mo_num)
|
||||
|
||||
call ZMQ_selection(to_select, pt2)
|
||||
|
||||
PROVIDE psi_coef
|
||||
PROVIDE psi_det
|
||||
PROVIDE psi_det_sorted
|
||||
|
||||
if (N_det >= N_det_max) then
|
||||
threshold_davidson = threshold_davidson_in
|
||||
end if
|
||||
call diagonalize_CI
|
||||
call save_wavefunction
|
||||
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
|
||||
enddo
|
||||
endif
|
||||
|
||||
if (N_det < N_det_max) then
|
||||
threshold_davidson = threshold_davidson_in
|
||||
call diagonalize_CI
|
||||
call save_wavefunction
|
||||
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
|
||||
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
|
||||
endif
|
||||
|
||||
if (do_pt2) then
|
||||
pt2 = 0.d0
|
||||
threshold_selectors = 1.d0
|
||||
threshold_generators = 1d0
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
call ZMQ_pt2(CI_energy, pt2,relative_error,absolute_error,error) ! Stochastic PT2
|
||||
threshold_selectors = threshold_selectors_save
|
||||
threshold_generators = threshold_generators_save
|
||||
SOFT_TOUCH threshold_selectors threshold_generators
|
||||
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
|
||||
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
|
||||
endif
|
||||
print *, 'N_det = ', N_det
|
||||
print *, 'N_states = ', N_states
|
||||
print*, 'correlation_ratio = ', correlation_energy_ratio
|
||||
|
||||
|
||||
call dump_fci_iterations_value(N_det,CI_energy,pt2)
|
||||
|
||||
print *, ''
|
||||
print '(A,I12)', 'Summary at N_det = ', N_det
|
||||
print '(A)', '-----------------------------------'
|
||||
print *, ''
|
||||
call write_double(6,correlation_energy_ratio, 'Correlation ratio')
|
||||
print *, ''
|
||||
|
||||
|
||||
N_states_p = min(N_det,N_states)
|
||||
print *, ''
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
write(fmt,*) '(12X,', N_states_p, '(6X,A7,1X,I6,10X))'
|
||||
write(*,fmt) ('State',k, k=1,N_states_p)
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
write(fmt,*) '(A12,', N_states_p, '(1X,F14.8,15X))'
|
||||
write(*,fmt) '# E ', CI_energy(1:N_states_p)
|
||||
if (N_states_p > 1) then
|
||||
write(*,fmt) '# Excit. (au)', CI_energy(1:N_states_p)-CI_energy(1)
|
||||
write(*,fmt) '# Excit. (eV)', (CI_energy(1:N_states_p)-CI_energy(1))*27.211396641308d0
|
||||
endif
|
||||
write(fmt,*) '(A12,', 2*N_states_p, '(1X,F14.8))'
|
||||
write(*,fmt) '# PT2'//pt2_string, (pt2(k), error(k), k=1,N_states_p)
|
||||
write(*,'(A)') '#'
|
||||
write(*,fmt) '# E+PT2 ', (CI_energy(k)+pt2(k),error(k), k=1,N_states_p)
|
||||
if (N_states_p > 1) then
|
||||
write(*,fmt) '# Excit. (au)', ( (CI_energy(k)+pt2(k)-CI_energy(1)-pt2(1)), &
|
||||
dsqrt(error(k)*error(k)+error(1)*error(1)), k=1,N_states_p)
|
||||
write(*,fmt) '# Excit. (eV)', ( (CI_energy(k)+pt2(k)-CI_energy(1)-pt2(1))*27.211396641308d0, &
|
||||
dsqrt(error(k)*error(k)+error(1)*error(1))*27.211396641308d0, k=1,N_states_p)
|
||||
endif
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
print *, ''
|
||||
|
||||
|
||||
|
||||
end
|
@ -12,30 +12,30 @@ subroutine run
|
||||
integer :: i,j,k
|
||||
logical, external :: detEq
|
||||
|
||||
double precision, allocatable :: pt2(:)
|
||||
double precision :: pt2(N_states)
|
||||
integer :: degree
|
||||
integer :: n_det_before, to_select
|
||||
double precision :: threshold_davidson_in
|
||||
|
||||
double precision :: E_CI_before, relative_error, absolute_error, eqt
|
||||
double precision :: E_CI_before(N_states), relative_error, error(N_states)
|
||||
|
||||
allocate (pt2(N_states))
|
||||
pt2(:) = 0.d0
|
||||
|
||||
E_CI_before = psi_energy(1) + nuclear_repulsion
|
||||
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
|
||||
threshold_selectors = 1.d0
|
||||
threshold_generators = 1.d0
|
||||
relative_error=PT2_relative_error
|
||||
absolute_error=PT2_absolute_error
|
||||
|
||||
call ZMQ_pt2(E_CI_before, pt2, relative_error, absolute_error, eqt)
|
||||
print *, 'Final step'
|
||||
call ZMQ_pt2(E_CI_before, pt2, relative_error, error)
|
||||
do k=1,N_states
|
||||
print *, 'State ', k
|
||||
print *, 'N_det = ', N_det
|
||||
print *, 'PT2 = ', pt2
|
||||
print *, 'E = ', E_CI_before
|
||||
print *, 'E+PT2 = ', E_CI_before+pt2, ' +/- ', eqt
|
||||
print *, 'E = ', E_CI_before(k)
|
||||
print *, 'E+PT2 = ', E_CI_before(k)+pt2(k), ' +/- ', error(k)
|
||||
print *, '-----'
|
||||
call ezfio_set_full_ci_zmq_energy_pt2(E_CI_before+pt2(1))
|
||||
enddo
|
||||
call ezfio_set_full_ci_zmq_energy_pt2(E_CI_before(1)+pt2(1))
|
||||
end
|
||||
|
||||
|
||||
|
@ -6,27 +6,34 @@ BEGIN_PROVIDER [ integer, pt2_stoch_istate ]
|
||||
pt2_stoch_istate = 1
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ integer, pt2_N_teeth ]
|
||||
&BEGIN_PROVIDER [ integer, pt2_minDetInFirstTeeth ]
|
||||
&BEGIN_PROVIDER [ integer, pt2_n_tasks_max ]
|
||||
&BEGIN_PROVIDER [ integer, pt2_F, (N_det_generators) ]
|
||||
implicit none
|
||||
logical, external :: testTeethBuilding
|
||||
pt2_F(:) = 1
|
||||
!pt2_F(:N_det_generators/1000*0+50) = 1
|
||||
pt2_n_tasks_max = 16 ! N_det_generators/100 + 1
|
||||
integer :: i
|
||||
integer :: e
|
||||
e = elec_num - n_core_orb * 2
|
||||
pt2_n_tasks_max = 1+min((e*(e-1))/2, int(dsqrt(dble(N_det_selectors)))/10)
|
||||
do i=1,N_det_generators
|
||||
if (maxval(dabs(psi_coef_sorted_gen(i,1:N_states))) > 0.001d0) then
|
||||
pt2_F(i) = pt2_n_tasks_max
|
||||
else
|
||||
pt2_F(i) = 1
|
||||
endif
|
||||
enddo
|
||||
|
||||
if(N_det_generators < 1024) then
|
||||
pt2_minDetInFirstTeeth = 1
|
||||
pt2_N_teeth = 1
|
||||
else
|
||||
do pt2_N_teeth=32,1,-1
|
||||
pt2_minDetInFirstTeeth = min(5, N_det_generators)
|
||||
do pt2_N_teeth=100,2,-1
|
||||
if(testTeethBuilding(pt2_minDetInFirstTeeth, pt2_N_teeth)) exit
|
||||
end do
|
||||
end if
|
||||
print *, pt2_N_teeth
|
||||
call write_int(6,pt2_N_teeth,'Number of comb teeth')
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
@ -41,25 +48,39 @@ logical function testTeethBuilding(minF, N)
|
||||
|
||||
allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators))
|
||||
|
||||
tilde_cW(0) = 0d0
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = psi_coef_generators(i,pt2_stoch_istate)**2
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20
|
||||
enddo
|
||||
|
||||
double precision :: norm
|
||||
norm = 0.d0
|
||||
do i=N_det_generators,1,-1
|
||||
norm += tilde_w(i)
|
||||
enddo
|
||||
|
||||
tilde_w(:) = tilde_w(:) / norm
|
||||
|
||||
tilde_cW(0) = -1.d0
|
||||
do i=1,N_det_generators
|
||||
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
|
||||
enddo
|
||||
tilde_cW(N_det_generators) = 1d0
|
||||
tilde_cW(:) = tilde_cW(:) + 1.d0
|
||||
|
||||
n0 = 0
|
||||
testTeethBuilding = .false.
|
||||
do
|
||||
u0 = tilde_cW(n0)
|
||||
r = tilde_cW(n0 + minF)
|
||||
Wt = (1d0 - u0) / dble(N)
|
||||
if (dabs(Wt) <= 1.d-3) then
|
||||
return
|
||||
endif
|
||||
if(Wt >= r - u0) then
|
||||
testTeethBuilding = .true.
|
||||
return
|
||||
end if
|
||||
n0 += 1
|
||||
if(N_det_generators - n0 < minF * N) then
|
||||
testTeethBuilding = .false.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
@ -68,20 +89,19 @@ end function
|
||||
|
||||
|
||||
|
||||
subroutine ZMQ_pt2(E, pt2,relative_error, absolute_error, error)
|
||||
subroutine ZMQ_pt2(E, pt2,relative_error, error)
|
||||
use f77_zmq
|
||||
use selection_types
|
||||
|
||||
implicit none
|
||||
|
||||
character(len=64000) :: task
|
||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull
|
||||
integer, external :: omp_get_thread_num
|
||||
double precision, intent(in) :: relative_error, absolute_error, E(N_states)
|
||||
double precision, intent(in) :: relative_error, E(N_states)
|
||||
double precision, intent(out) :: pt2(N_states),error(N_states)
|
||||
|
||||
|
||||
integer :: i, j, k
|
||||
integer :: i
|
||||
|
||||
double precision, external :: omp_get_wtime
|
||||
double precision :: state_average_weight_save(N_states), w(N_states)
|
||||
@ -138,17 +158,39 @@ subroutine ZMQ_pt2(E, pt2,relative_error, absolute_error, error)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
integer, external :: add_task_to_taskserver
|
||||
character(100000) :: task
|
||||
|
||||
integer :: j,k,ipos
|
||||
|
||||
ipos=0
|
||||
do i=1,N_det_generators
|
||||
do j=1,pt2_F(i) !!!!!!!!!!!!
|
||||
write(task(1:20),'(I9,1X,I9''|'')') j, pt2_J(i)
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:20))) == -1) then
|
||||
if (pt2_F(i) > 1) then
|
||||
ipos += 1
|
||||
endif
|
||||
enddo
|
||||
call write_int(6,ipos,'Number of fragmented tasks')
|
||||
|
||||
ipos=1
|
||||
|
||||
do i= 1, N_det_generators
|
||||
do j=1,pt2_F(pt2_J(i))
|
||||
write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') j, pt2_J(i)
|
||||
ipos += 20
|
||||
if (ipos > 100000-20) then
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
stop 'Unable to add task to task server'
|
||||
endif
|
||||
ipos=1
|
||||
endif
|
||||
end do
|
||||
end do
|
||||
enddo
|
||||
if (ipos > 1) then
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
stop 'Unable to add task to task server'
|
||||
endif
|
||||
endif
|
||||
|
||||
integer, external :: zmq_set_running
|
||||
if (zmq_set_running(zmq_to_qp_run_socket) == -1) then
|
||||
@ -166,11 +208,13 @@ subroutine ZMQ_pt2(E, pt2,relative_error, absolute_error, error)
|
||||
nproc_target = min(nproc_target,nproc)
|
||||
endif
|
||||
|
||||
call omp_set_nested(.true.)
|
||||
|
||||
!$OMP PARALLEL DEFAULT(shared) NUM_THREADS(nproc_target+1) &
|
||||
!$OMP PRIVATE(i)
|
||||
i = omp_get_thread_num()
|
||||
if (i==0) then
|
||||
call pt2_collector(zmq_socket_pull, E(pt2_stoch_istate),relative_error, absolute_error, w, error)
|
||||
call pt2_collector(zmq_socket_pull, E(pt2_stoch_istate),relative_error, w, error)
|
||||
pt2(pt2_stoch_istate) = w(pt2_stoch_istate)
|
||||
else
|
||||
call pt2_slave_inproc(i)
|
||||
@ -181,6 +225,8 @@ subroutine ZMQ_pt2(E, pt2,relative_error, absolute_error, error)
|
||||
print *, '========== ================= ================= ================='
|
||||
|
||||
enddo
|
||||
! call omp_set_nested(.false.)
|
||||
|
||||
FREE pt2_stoch_istate
|
||||
state_average_weight(:) = state_average_weight_save(:)
|
||||
TOUCH state_average_weight
|
||||
@ -200,7 +246,7 @@ subroutine pt2_slave_inproc(i)
|
||||
end
|
||||
|
||||
|
||||
subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2, error)
|
||||
subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error)
|
||||
use f77_zmq
|
||||
use selection_types
|
||||
use bitmasks
|
||||
@ -208,7 +254,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2
|
||||
|
||||
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
|
||||
double precision, intent(in) :: relative_error, absolute_error, E
|
||||
double precision, intent(in) :: relative_error, E
|
||||
double precision, intent(out) :: pt2(N_states), error(N_states)
|
||||
|
||||
|
||||
@ -216,6 +262,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2
|
||||
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
||||
integer, external :: zmq_delete_tasks
|
||||
integer, external :: zmq_abort
|
||||
integer, external :: pt2_find_sample
|
||||
|
||||
integer :: more, n, i, p, c, t, n_tasks, U
|
||||
@ -235,6 +282,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2
|
||||
allocate(eI(N_states, N_det_generators), eI_task(N_states, pt2_n_tasks_max))
|
||||
allocate(S(pt2_N_teeth+1), S2(pt2_N_teeth+1))
|
||||
|
||||
pt2(:) = -huge(1.)
|
||||
S(:) = 0d0
|
||||
S2(:) = 0d0
|
||||
n = 1
|
||||
@ -254,10 +302,12 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2
|
||||
do while(d(U+1))
|
||||
U += 1
|
||||
end do
|
||||
|
||||
! Deterministic part
|
||||
do while(t <= pt2_N_teeth)
|
||||
if(U >= pt2_n_0(t+1)) then
|
||||
t=t+1
|
||||
E0 = E
|
||||
E0 = 0.d0
|
||||
do i=pt2_n_0(t),1,-1
|
||||
E0 += eI(pt2_stoch_istate, i)
|
||||
end do
|
||||
@ -266,8 +316,9 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2
|
||||
end if
|
||||
end do
|
||||
|
||||
! Add Stochastic part
|
||||
c = pt2_R(n)
|
||||
if(c /= 0) then
|
||||
if(c > 0) then
|
||||
x = 0d0
|
||||
do p=pt2_N_teeth, 1, -1
|
||||
v = pt2_u_0 + pt2_W_T * (pt2_u(c) + dble(p-1))
|
||||
@ -276,13 +327,26 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, absolute_error, pt2
|
||||
S(p) += x
|
||||
S2(p) += x**2
|
||||
end do
|
||||
avg = S(t) / dble(c)
|
||||
eqt = (S2(t) / c) - (S(t)/c)**2
|
||||
eqt = sqrt(eqt / dble(c-1+1))
|
||||
pt2(pt2_stoch_istate) = E0-E+avg
|
||||
avg = E0 + S(t) / dble(c)
|
||||
pt2(pt2_stoch_istate) = avg
|
||||
! 1/(N-1.5) : see Brugger, The American Statistician (23) 4 p. 32 (1969)
|
||||
if(c > 2) then
|
||||
eqt = dabs((S2(t) / c) - (S(t)/c)**2) ! dabs for numerical stability
|
||||
eqt = sqrt(eqt / (dble(c) - 1.5d0))
|
||||
error(pt2_stoch_istate) = eqt
|
||||
if(mod(c,10)==0 .or. n==N_det_generators) then
|
||||
print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', c, avg+E, eqt, time-time0, ''
|
||||
if( dabs(error(pt2_stoch_istate) / pt2(pt2_stoch_istate)) < relative_error) then
|
||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||
call sleep(10)
|
||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||
print *, irp_here, ': Error in sending abort signal (2)'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
time = omp_get_wtime()
|
||||
if(mod(c,10)==1 .or. n==N_det_generators) print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', c, avg+E0, eqt, time-time0, ''
|
||||
end if
|
||||
n += 1
|
||||
else if(more == 0) then
|
||||
@ -318,8 +382,13 @@ integer function pt2_find_sample(v, w)
|
||||
r = i
|
||||
end if
|
||||
end do
|
||||
|
||||
pt2_find_sample = r
|
||||
i = r
|
||||
do r=i+1,N_det_generators
|
||||
if (w(r) /= w(i)) then
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
pt2_find_sample = r-1
|
||||
end function
|
||||
|
||||
|
||||
@ -343,11 +412,18 @@ end function
|
||||
d(i) = .true.
|
||||
pt2_J(i) = i
|
||||
end do
|
||||
call random_seed(put=(/3211,64,6566,321,65,321,654,65,321,6321,654,65,321,621,654,65,321,65,654,65,321,65/))
|
||||
call RANDOM_NUMBER(pt2_u)
|
||||
call RANDOM_NUMBER(pt2_u)
|
||||
|
||||
integer :: m
|
||||
integer, allocatable :: seed(:)
|
||||
call random_seed(size=m)
|
||||
allocate(seed(m))
|
||||
do i=1,m
|
||||
seed(i) = i
|
||||
enddo
|
||||
call random_seed(put=seed)
|
||||
deallocate(seed)
|
||||
|
||||
call RANDOM_NUMBER(pt2_u)
|
||||
|
||||
U = 0
|
||||
|
||||
@ -400,9 +476,22 @@ END_PROVIDER
|
||||
tilde_cW(0) = 0d0
|
||||
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = psi_coef_generators(i,pt2_stoch_istate)**2
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20
|
||||
enddo
|
||||
|
||||
double precision :: norm
|
||||
norm = 0.d0
|
||||
do i=N_det_generators,1,-1
|
||||
norm += tilde_w(i)
|
||||
enddo
|
||||
|
||||
tilde_w(:) = tilde_w(:) / norm
|
||||
|
||||
tilde_cW(0) = -1.d0
|
||||
do i=1,N_det_generators
|
||||
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
|
||||
enddo
|
||||
tilde_cW(:) = tilde_cW(:) + 1.d0
|
||||
|
||||
pt2_n_0(1) = 0
|
||||
do
|
||||
@ -429,6 +518,10 @@ END_PROVIDER
|
||||
pt2_w(:pt2_n_0(1)) = tilde_w(:pt2_n_0(1))
|
||||
do t=1, pt2_N_teeth
|
||||
tooth_width = tilde_cW(pt2_n_0(t+1)) - tilde_cW(pt2_n_0(t))
|
||||
if (tooth_width == 0.d0) then
|
||||
tooth_width = sum(tilde_w(pt2_n_0(t):pt2_n_0(t+1)))
|
||||
endif
|
||||
ASSERT(tooth_width > 0.d0)
|
||||
do i=pt2_n_0(t)+1, pt2_n_0(t+1)
|
||||
pt2_w(i) = tilde_w(i) * pt2_W_T / tooth_width
|
||||
end do
|
||||
|
@ -43,10 +43,11 @@ subroutine run_pt2_slave(thread,iproc,energy)
|
||||
call create_selection_buffer(0, 0, buf)
|
||||
|
||||
done = .False.
|
||||
n_tasks = 1
|
||||
do while (.not.done)
|
||||
|
||||
n_tasks = max(1,n_tasks)
|
||||
n_tasks = min(n_tasks,pt2_n_tasks_max)
|
||||
! n_tasks = max(1,n_tasks)
|
||||
! n_tasks = min(pt2_n_tasks_max,n_tasks)
|
||||
|
||||
integer, external :: get_tasks_from_taskserver
|
||||
if (get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task, n_tasks) == -1) then
|
||||
@ -61,13 +62,17 @@ subroutine run_pt2_slave(thread,iproc,energy)
|
||||
enddo
|
||||
|
||||
double precision :: time0, time1
|
||||
call wall_time(time0)
|
||||
! call wall_time(time0)
|
||||
do k=1,n_tasks
|
||||
pt2(:,k) = 0.d0
|
||||
buf%cur = 0
|
||||
!double precision :: time2
|
||||
!call wall_time(time2)
|
||||
call select_connected(i_generator(k),energy,pt2(1,k),buf,subset(k),pt2_F(i_generator(k)))
|
||||
!call wall_time(time1)
|
||||
!print *, i_generator(1), time1-time2, n_tasks, pt2_F(i_generator(1))
|
||||
enddo
|
||||
call wall_time(time1)
|
||||
! call wall_time(time1)
|
||||
|
||||
integer, external :: tasks_done_to_taskserver
|
||||
if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then
|
||||
@ -75,9 +80,8 @@ subroutine run_pt2_slave(thread,iproc,energy)
|
||||
endif
|
||||
call push_pt2_results(zmq_socket_push, i_generator, pt2, task_id, n_tasks)
|
||||
|
||||
! Try to adjust n_tasks around 1 second per job
|
||||
n_tasks = min(n_tasks,int( 1.d0*dble(n_tasks) / (time1 - time0 + 1.d-9)))+1
|
||||
! n_tasks = n_tasks+1
|
||||
! Try to adjust n_tasks around nproc seconds per job
|
||||
! n_tasks = min(2*n_tasks,int( dble(n_tasks * nproc) / (time1 - time0 + 1.d0)))
|
||||
end do
|
||||
|
||||
integer, external :: disconnect_from_taskserver
|
||||
|
@ -1,122 +1,4 @@
|
||||
subroutine run_selection_slave(thread,iproc,energy)
|
||||
implicit none
|
||||
integer, intent(in) :: thread, iproc
|
||||
double precision, intent(in) :: energy(N_states_diag)
|
||||
call run_selection_slave_new(thread,iproc,energy)
|
||||
end
|
||||
|
||||
subroutine run_selection_slave_new(thread,iproc,energy)
|
||||
use f77_zmq
|
||||
use selection_types
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: thread, iproc
|
||||
double precision, intent(in) :: energy(N_states_diag)
|
||||
integer :: rc, i, N
|
||||
logical :: buffer_ready
|
||||
|
||||
integer :: worker_id, ltask
|
||||
character*(512), allocatable :: task(:)
|
||||
integer, allocatable :: task_id(:)
|
||||
|
||||
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
||||
|
||||
integer(ZMQ_PTR), external :: new_zmq_push_socket
|
||||
integer(ZMQ_PTR) :: zmq_socket_push
|
||||
|
||||
type(selection_buffer) :: buf, buf2
|
||||
logical :: done
|
||||
|
||||
double precision,allocatable :: pt2(:,:)
|
||||
integer :: n_tasks, k, n_tasks_max
|
||||
integer, allocatable :: i_generator(:), subset(:)
|
||||
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
PROVIDE psi_bilinear_matrix_transp_order
|
||||
|
||||
buffer_ready = .False.
|
||||
n_tasks_max = N_det_generators/100+1
|
||||
allocate(task_id(n_tasks_max), task(n_tasks_max))
|
||||
allocate(pt2(N_states,n_tasks_max), i_generator(n_tasks_max), subset(n_tasks_max))
|
||||
|
||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||
|
||||
integer, external :: connect_to_taskserver
|
||||
if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then
|
||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
return
|
||||
endif
|
||||
|
||||
zmq_socket_push = new_zmq_push_socket(thread)
|
||||
|
||||
buf%N = 0
|
||||
n_tasks = 1
|
||||
call create_selection_buffer(0, 0, buf)
|
||||
done = .False.
|
||||
do while (.not.done)
|
||||
|
||||
n_tasks = max(1,n_tasks)
|
||||
n_tasks = min(n_tasks,n_tasks_max)
|
||||
|
||||
integer, external :: get_tasks_from_taskserver
|
||||
if (get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task, n_tasks) == -1) then
|
||||
exit
|
||||
endif
|
||||
done = task_id(n_tasks) == 0
|
||||
if (done) n_tasks = n_tasks-1
|
||||
if (n_tasks == 0) exit
|
||||
|
||||
do k=1,n_tasks
|
||||
read (task(k),*) subset(k), i_generator(k), N
|
||||
enddo
|
||||
|
||||
if(buf%N == 0) then
|
||||
! Only first time
|
||||
call create_selection_buffer(N, N*2, buf)
|
||||
call create_selection_buffer(N, N*2, buf2)
|
||||
buffer_ready = .True.
|
||||
endif
|
||||
|
||||
double precision :: time0, time1
|
||||
call wall_time(time0)
|
||||
do k=1,n_tasks
|
||||
pt2(:,k) = 0.d0
|
||||
buf%cur = 0
|
||||
call select_connected(i_generator(k),energy,pt2(1,k),buf,subset(k))
|
||||
enddo
|
||||
call wall_time(time1)
|
||||
|
||||
integer, external :: tasks_done_to_taskserver
|
||||
if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then
|
||||
done = .true.
|
||||
endif
|
||||
call sort_selection_buffer(buf)
|
||||
call merge_selection_buffers(buf,buf2)
|
||||
call push_selection_results(zmq_socket_push, pt2, buf, task_id, n_tasks)
|
||||
buf%mini = buf2%mini
|
||||
pt2(:,:) = 0d0
|
||||
buf%cur = 0
|
||||
|
||||
! ! Try to adjust n_tasks around 5 second per job
|
||||
! n_tasks = min(n_tasks,int( 5.d0 * dble(n_tasks) / (time1 - time0 + 1.d-9)))+1
|
||||
n_tasks = n_tasks+1
|
||||
end do
|
||||
|
||||
integer, external :: disconnect_from_taskserver
|
||||
if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) == -1) then
|
||||
continue
|
||||
endif
|
||||
|
||||
call end_zmq_push_socket(zmq_socket_push,thread)
|
||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
call delete_selection_buffer(buf)
|
||||
|
||||
end
|
||||
|
||||
subroutine run_selection_slave_old(thread,iproc,energy)
|
||||
use f77_zmq
|
||||
use selection_types
|
||||
implicit none
|
||||
@ -177,7 +59,7 @@ subroutine run_selection_slave_old(thread,iproc,energy)
|
||||
else
|
||||
ASSERT (N == buf%N)
|
||||
end if
|
||||
call select_connected(i_generator,energy,pt2,buf,subset,fragment_count)
|
||||
call select_connected(i_generator,energy,pt2,buf,subset,pt2_F(i_generator))
|
||||
endif
|
||||
|
||||
integer, external :: task_done_to_taskserver
|
||||
|
@ -1,14 +1,5 @@
|
||||
use bitmasks
|
||||
|
||||
BEGIN_PROVIDER [ integer, fragment_count ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Number of fragments for the deterministic part
|
||||
END_DOC
|
||||
fragment_count = (elec_alpha_num-n_core_orb)**2
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
subroutine assert(cond, msg)
|
||||
character(*), intent(in) :: msg
|
||||
logical, intent(in) :: cond
|
||||
@ -298,8 +289,6 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
integer(bit_kind), allocatable:: preinteresting_det(:,:,:)
|
||||
allocate (preinteresting_det(N_int,2,N_det))
|
||||
|
||||
!PROVIDE fragment_count
|
||||
|
||||
monoAdo = .true.
|
||||
monoBdo = .true.
|
||||
|
||||
@ -319,7 +308,7 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
call bitstring_to_list_ab(hole , hole_list , N_holes , N_int)
|
||||
call bitstring_to_list_ab(particle, particle_list, N_particles, N_int)
|
||||
|
||||
integer :: l_a, nmax
|
||||
integer :: l_a, nmax, idx
|
||||
integer, allocatable :: indices(:), exc_degree(:), iorder(:)
|
||||
allocate (indices(N_det), &
|
||||
exc_degree(max(N_det_alpha_unique,N_det_beta_unique)))
|
||||
@ -342,7 +331,9 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
do l_a=psi_bilinear_matrix_columns_loc(j), psi_bilinear_matrix_columns_loc(j+1)-1
|
||||
i = psi_bilinear_matrix_rows(l_a)
|
||||
if (nt + exc_degree(i) <= 4) then
|
||||
indices(k) = psi_det_sorted_order(psi_bilinear_matrix_order(l_a))
|
||||
idx = psi_det_sorted_order(psi_bilinear_matrix_order(l_a))
|
||||
if (psi_average_norm_contrib_sorted(idx) < 1.d-12) cycle
|
||||
indices(k) = idx
|
||||
k=k+1
|
||||
endif
|
||||
enddo
|
||||
@ -361,13 +352,16 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
i = psi_bilinear_matrix_transp_columns(l_a)
|
||||
if (exc_degree(i) < 3) cycle
|
||||
if (nt + exc_degree(i) <= 4) then
|
||||
indices(k) = psi_det_sorted_order( &
|
||||
idx = psi_det_sorted_order( &
|
||||
psi_bilinear_matrix_order( &
|
||||
psi_bilinear_matrix_transp_order(l_a)))
|
||||
if (psi_average_norm_contrib_sorted(idx) < 1.d-12) cycle
|
||||
indices(k) = idx
|
||||
k=k+1
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
|
||||
deallocate(exc_degree)
|
||||
nmax=k-1
|
||||
|
||||
@ -378,8 +372,8 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
call isort(indices,iorder,nmax)
|
||||
deallocate(iorder)
|
||||
|
||||
allocate(preinteresting(0:N_det_selectors), prefullinteresting(0:N_det), &
|
||||
interesting(0:N_det_selectors), fullinteresting(0:N_det))
|
||||
allocate(preinteresting(0:N_det), prefullinteresting(0:N_det), &
|
||||
interesting(0:N_det), fullinteresting(0:N_det))
|
||||
preinteresting(0) = 0
|
||||
prefullinteresting(0) = 0
|
||||
|
||||
@ -415,14 +409,36 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
end do
|
||||
deallocate(indices)
|
||||
|
||||
|
||||
allocate(minilist(N_int, 2, N_det_selectors), fullminilist(N_int, 2, N_det))
|
||||
allocate(banned(mo_tot_num, mo_tot_num,2), bannedOrb(mo_tot_num, 2))
|
||||
allocate (mat(N_states, mo_tot_num, mo_tot_num))
|
||||
maskInd = -1
|
||||
integer :: nb_count
|
||||
|
||||
integer :: nb_count, maskInd_save
|
||||
logical :: monoBdo_save
|
||||
logical :: found
|
||||
do s1=1,2
|
||||
do i1=N_holes(s1),1,-1 ! Generate low excitations first
|
||||
|
||||
found = .False.
|
||||
monoBdo_save = monoBdo
|
||||
maskInd_save = maskInd
|
||||
do s2=s1,2
|
||||
ib = 1
|
||||
if(s1 == s2) ib = i1+1
|
||||
do i2=N_holes(s2),ib,-1
|
||||
maskInd += 1
|
||||
if(mod(maskInd, csubset) == (subset-1)) then
|
||||
found = .True.
|
||||
end if
|
||||
enddo
|
||||
if(s1 /= s2) monoBdo = .false.
|
||||
enddo
|
||||
|
||||
if (.not.found) cycle
|
||||
monoBdo = monoBdo_save
|
||||
maskInd = maskInd_save
|
||||
|
||||
h1 = hole_list(i1,s1)
|
||||
call apply_hole(psi_det_generators(1,1,i_generator), s1,h1, pmask, ok, N_int)
|
||||
|
||||
@ -536,8 +552,6 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
|
||||
end if
|
||||
end do
|
||||
|
||||
|
||||
|
||||
do s2=s1,2
|
||||
sp = s1
|
||||
|
||||
|
@ -13,9 +13,10 @@ program selection_slave
|
||||
end
|
||||
|
||||
subroutine provide_everything
|
||||
PROVIDE H_apply_buffer_allocated mo_bielec_integrals_in_map psi_det_generators psi_coef_generators psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context n_states_diag
|
||||
PROVIDE pt2_e0_denominator mo_tot_num N_int fragment_count ci_energy mpi_master zmq_state zmq_context
|
||||
PROVIDE psi_det psi_coef
|
||||
PROVIDE H_apply_buffer_allocated mo_bielec_integrals_in_map psi_det_generators psi_coef_generators psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context N_states_diag
|
||||
PROVIDE pt2_e0_denominator mo_tot_num N_int ci_energy mpi_master zmq_state zmq_context
|
||||
PROVIDE psi_det psi_coef threshold_generators threshold_selectors state_average_weight
|
||||
PROVIDE N_det_selectors pt2_stoch_istate N_det
|
||||
end
|
||||
|
||||
subroutine run_wf
|
||||
@ -35,12 +36,11 @@ subroutine run_wf
|
||||
double precision :: t0, t1
|
||||
|
||||
integer, external :: zmq_get_dvector, zmq_get_N_det_generators
|
||||
integer, external :: zmq_get8_dvector
|
||||
integer, external :: zmq_get_ivector
|
||||
integer, external :: zmq_get_psi, zmq_get_N_det_selectors
|
||||
integer, external :: zmq_get_N_states_diag
|
||||
|
||||
call provide_everything
|
||||
|
||||
zmq_context = f77_zmq_ctx_new ()
|
||||
states(1) = 'selection'
|
||||
states(2) = 'davidson'
|
||||
@ -49,6 +49,13 @@ subroutine run_wf
|
||||
|
||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||
|
||||
PROVIDE psi_det psi_coef threshold_generators threshold_selectors state_average_weight mpi_master
|
||||
PROVIDE zmq_state N_det_selectors pt2_stoch_istate N_det pt2_e0_denominator
|
||||
PROVIDE N_det_generators N_states N_states_diag psi_energy
|
||||
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
do
|
||||
|
||||
if (mpi_master) then
|
||||
@ -62,6 +69,10 @@ subroutine run_wf
|
||||
print *, trim(zmq_state)
|
||||
endif
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
call MPI_BCAST (zmq_state, 128, MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
@ -146,6 +157,12 @@ subroutine run_wf
|
||||
! PT2
|
||||
! ---
|
||||
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here, 'error in barrier'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
call wall_time(t0)
|
||||
if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle
|
||||
if (zmq_get_N_det_generators (zmq_to_qp_run_socket, 1) == -1) cycle
|
||||
@ -168,13 +185,19 @@ subroutine run_wf
|
||||
|
||||
call wall_time(t1)
|
||||
call write_double(6,(t1-t0),'Broadcast time')
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here, 'error in barrier'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
|
||||
logical :: lstop
|
||||
lstop = .False.
|
||||
if (.true.) then
|
||||
!$OMP PARALLEL PRIVATE(i)
|
||||
i = omp_get_thread_num()
|
||||
call run_pt2_slave(0,i,pt2_e0_denominator)
|
||||
!$OMP END PARALLEL
|
||||
endif
|
||||
print *, 'PT2 done'
|
||||
FREE state_average_weight
|
||||
|
||||
|
@ -14,7 +14,7 @@ end
|
||||
|
||||
subroutine provide_everything
|
||||
PROVIDE H_apply_buffer_allocated mo_bielec_integrals_in_map psi_det_generators psi_coef_generators psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context n_states_diag
|
||||
PROVIDE pt2_e0_denominator mo_tot_num N_int fragment_count ci_energy mpi_master zmq_state zmq_context
|
||||
PROVIDE pt2_e0_denominator mo_tot_num N_int ci_energy mpi_master zmq_state zmq_context
|
||||
PROVIDE psi_det psi_coef
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
program fci_zmq
|
||||
program target_pt2_ratio
|
||||
implicit none
|
||||
integer :: i,j,k
|
||||
logical, external :: detEq
|
||||
|
@ -1,4 +1,4 @@
|
||||
program fci_zmq
|
||||
program target_pt2
|
||||
implicit none
|
||||
integer :: i,j,k
|
||||
logical, external :: detEq
|
||||
|
@ -12,15 +12,13 @@ subroutine ZMQ_selection(N_in, pt2)
|
||||
double precision, intent(out) :: pt2(N_states)
|
||||
|
||||
|
||||
PROVIDE fragment_count
|
||||
|
||||
N = max(N_in,1)
|
||||
if (.True.) then
|
||||
PROVIDE pt2_e0_denominator nproc
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
PROVIDE psi_bilinear_matrix_transp_order fragment_count
|
||||
PROVIDE psi_bilinear_matrix_transp_order
|
||||
|
||||
call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,'selection')
|
||||
|
||||
@ -54,34 +52,22 @@ subroutine ZMQ_selection(N_in, pt2)
|
||||
endif
|
||||
|
||||
integer, external :: add_task_to_taskserver
|
||||
character(len=64000) :: task
|
||||
character(len=100000) :: task
|
||||
integer :: j,k,ipos
|
||||
ipos=1
|
||||
task = ' '
|
||||
|
||||
do i= 1, N_det_generators
|
||||
! /!\ Fragments don't work
|
||||
! if (i>-ishft(N_det_generators,-2)) then
|
||||
write(task(ipos:ipos+30),'(I9,1X,I9,1X,I9,''|'')') 0, i, N
|
||||
do j=1,pt2_F(pt2_J(i))
|
||||
write(task(ipos:ipos+30),'(I9,1X,I9,1X,I9,''|'')') j, pt2_J(i), N
|
||||
ipos += 30
|
||||
if (ipos > 63970) then
|
||||
if (ipos > 100000-30) then
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
stop 'Unable to add task to task server'
|
||||
endif
|
||||
ipos=1
|
||||
endif
|
||||
! else
|
||||
! do j=1,fragment_count
|
||||
! write(task(ipos:ipos+30),'(I9,1X,I9,1X,I9,''|'')') j, i, N
|
||||
! ipos += 30
|
||||
! if (ipos > 63970) then
|
||||
! if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
! stop 'Unable to add task to task server'
|
||||
! endif
|
||||
! ipos=1
|
||||
! endif
|
||||
! end do
|
||||
! endif
|
||||
end do
|
||||
enddo
|
||||
if (ipos > 1) then
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
|
@ -9,11 +9,11 @@ BEGIN_PROVIDER [ integer, N_det_generators ]
|
||||
integer :: i
|
||||
double precision :: norm
|
||||
call write_time(6)
|
||||
norm = 0.d0
|
||||
norm = 1.d0
|
||||
N_det_generators = N_det
|
||||
do i=1,N_det
|
||||
norm = norm + psi_average_norm_contrib_sorted(i)
|
||||
if (norm > threshold_generators+1d-10) then
|
||||
norm = norm - psi_average_norm_contrib_sorted(i)
|
||||
if (norm - 1.d-10 < 1.d0 - threshold_generators) then
|
||||
N_det_generators = i
|
||||
exit
|
||||
endif
|
||||
|
@ -16,8 +16,8 @@ program print_mos
|
||||
call write_Mo_basis(i_unit_output)
|
||||
|
||||
|
||||
write(i_unit_output,*),''
|
||||
write(i_unit_output,*),''
|
||||
write(i_unit_output,*)''
|
||||
write(i_unit_output,*)''
|
||||
write(i_unit_output,*)' ------------------------'
|
||||
|
||||
close(i_unit_output)
|
||||
|
5
plugins/NOFT/.gitignore
vendored
Normal file
5
plugins/NOFT/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
IRPF90_temp/
|
||||
IRPF90_man/
|
||||
irpf90.make
|
||||
irpf90_entities
|
||||
tags
|
19
plugins/NOFT/EZFIO.cfg
Normal file
19
plugins/NOFT/EZFIO.cfg
Normal file
@ -0,0 +1,19 @@
|
||||
[do_JK_functionals]
|
||||
type: logical
|
||||
doc: Compute energies for JK-only functionals
|
||||
interface: ezfio,provider,ocaml
|
||||
default: True
|
||||
|
||||
[do_JKL_functionals]
|
||||
type: logical
|
||||
doc: Compute energies for JKL-only functionals (PNOFs)
|
||||
interface: ezfio,provider,ocaml
|
||||
default: True
|
||||
|
||||
[do_PT2_NOFT]
|
||||
type: logical
|
||||
doc: Compute PT2 correction for NOFT
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
|
1
plugins/NOFT/NEEDED_CHILDREN_MODULES
Normal file
1
plugins/NOFT/NEEDED_CHILDREN_MODULES
Normal file
@ -0,0 +1 @@
|
||||
Hartree_Fock Determinants
|
72
plugins/NOFT/NOFT.irp.f
Normal file
72
plugins/NOFT/NOFT.irp.f
Normal file
@ -0,0 +1,72 @@
|
||||
program NOFT
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Natural orbital functional theory module
|
||||
END_DOC
|
||||
|
||||
PROVIDE mo_bielec_integrals_in_map
|
||||
|
||||
integer :: i,j
|
||||
integer :: nMO,FL
|
||||
double precision :: ET,EV
|
||||
double precision :: integral,get_mo_bielec_integral
|
||||
double precision,allocatable :: n(:)
|
||||
|
||||
print*, ''
|
||||
print*, '*******************************'
|
||||
print*, '*** NOFT functionals ***'
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
print*, 'SD = single determinant'
|
||||
print*, 'MBB = Muller, Buijse and Baerends'
|
||||
print*, 'POWER = Cioslowski and Pernal'
|
||||
print*, 'BCC2 = Gritsenko and coworkers'
|
||||
print*, 'CA = Csanyi and Arias'
|
||||
print*, 'CGA = Csanyi, Goedecker and Arias'
|
||||
print*, 'GU = Goedecker and Umrigar'
|
||||
print*, 'ML = Marques and Lathiotakis'
|
||||
print*, 'MLSIC = ML with self-interaction correction'
|
||||
print*, 'PNOF2 = Piris natural orbital functional 2 (bug)'
|
||||
print*, 'PNOF3 = Piris natural orbital functional 3'
|
||||
print*, 'PNOF4 = Piris natural orbital functional 4'
|
||||
print*, 'PNOF5 = Piris natural orbital functional 5 (NYI)'
|
||||
print*, 'PNOF6x = Piris natural orbital functional 6 (x = d, u, h)'
|
||||
print*, 'PNOF7 = Piris natural orbital functional 7 (NYI)'
|
||||
print*, ''
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
print*, '*******************************'
|
||||
print*, '*** NOFT energies ***'
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
|
||||
! Occupation numbers
|
||||
|
||||
nMO = mo_tot_num
|
||||
FL = elec_num/2
|
||||
allocate(n(nMO))
|
||||
n(1:nMO) = 0.5d0*mo_occ(1:mo_tot_num)
|
||||
|
||||
! Compute core energies
|
||||
|
||||
call NOFT_core(nMO,ET,EV,n)
|
||||
|
||||
! JK-only functionals
|
||||
|
||||
if(do_JK_functionals) call NOFT_JKfunc(nMO,FL,ET,EV,n)
|
||||
|
||||
! JKL-only functionals
|
||||
|
||||
if(do_JKL_functionals) call NOFT_JKLfunc(nMO,FL,ET,EV,n)
|
||||
|
||||
! PT2-NOFT correction
|
||||
|
||||
if(do_PT2_NOFT) call NOFT_JKLfunc(nMO,FL,n)
|
||||
|
||||
! End
|
||||
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
|
||||
end
|
||||
|
484
plugins/NOFT/NOFT_JKLfunc.irp.f
Normal file
484
plugins/NOFT/NOFT_JKLfunc.irp.f
Normal file
@ -0,0 +1,484 @@
|
||||
subroutine NOFT_JKLfunc(nMO,FL,ET,EV,n)
|
||||
! JKL-only functionals for NOFT
|
||||
END_DOC
|
||||
|
||||
PROVIDE mo_bielec_integrals_in_map
|
||||
|
||||
! Input variables
|
||||
|
||||
integer,intent(in) :: nMO,FL
|
||||
double precision,intent(in) :: ET,EV
|
||||
double precision,intent(in) :: n(nMO)
|
||||
|
||||
! Local variables
|
||||
|
||||
integer :: i,j
|
||||
double precision :: EJ_SD,EK_SD
|
||||
double precision :: EJ_PNOF2,EJ_PNOF3,EJ_PNOF4,EJ_PNOF5,EJ_PNOF6d,EJ_PNOF6u,EJ_PNOF6h,EJ_PNOF7
|
||||
double precision :: EK_PNOF2,EK_PNOF3,EK_PNOF4,EK_PNOF5,EK_PNOF6d,EK_PNOF6u,EK_PNOF6h,EK_PNOF7
|
||||
double precision :: EL_PNOF2,EL_PNOF3,EL_PNOF4,EL_PNOF5,EL_PNOF6d,EL_PNOF6u,EL_PNOF6h,EL_PNOF7
|
||||
double precision :: E_PNOF2,E_PNOF3,E_PNOF4,E_PNOF5,E_PNOF6d,E_PNOF6u,E_PNOF6h,E_PNOF7
|
||||
double precision :: get_mo_bielec_integral
|
||||
|
||||
double precision :: SF,Sd,Su,Sh,Delta_ij,T_ij,Pi_ij
|
||||
|
||||
double precision,allocatable :: h(:),kappa(:),gam(:),Jint(:,:),Kint(:,:),Lint(:,:)
|
||||
|
||||
! memory allocation
|
||||
|
||||
allocate(h(nMO),kappa(nMO),gam(nMO),Jint(nMO,nMO),Kint(nMO,nMO),Lint(nMO,nMO))
|
||||
|
||||
! Useful quantities
|
||||
|
||||
h(1:nMO) = 1d0 - n(1:nMO)
|
||||
|
||||
SF = 0d0
|
||||
do i=1,FL
|
||||
SF = SF + h(i)
|
||||
enddo
|
||||
|
||||
! Useful quantities for PNOF6
|
||||
|
||||
do i=1,FL
|
||||
kappa(i) = h(i)*exp(-SF)
|
||||
enddo
|
||||
do i=FL+1,nMO
|
||||
kappa(i) = n(i)*exp(-SF)
|
||||
enddo
|
||||
|
||||
gam(:) = 0d0
|
||||
do i=1,nMO
|
||||
do j=i,FL
|
||||
gam(i) = gam(i) + kappa(j)
|
||||
enddo
|
||||
gam(i) = n(i)*h(i) + kappa(i)*kappa(i) - kappa(i)*gam(i)
|
||||
enddo
|
||||
|
||||
Sd = 0d0
|
||||
do i=1,FL
|
||||
Sd = Sd + gam(i)
|
||||
enddo
|
||||
|
||||
Su = 0d0
|
||||
do i=FL+1,nMO
|
||||
Su = Su + gam(i)
|
||||
enddo
|
||||
|
||||
Sh = 0.5d0*(Sd + Su)
|
||||
|
||||
! Coulomb, exchange and time-inversion integrals
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
Jint(i,j) = get_mo_bielec_integral(i,j,i,j,mo_integrals_map)
|
||||
Kint(i,j) = get_mo_bielec_integral(i,j,j,i,mo_integrals_map)
|
||||
Lint(i,j) = get_mo_bielec_integral(i,i,j,j,mo_integrals_map)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
!****************************************
|
||||
!*** Coulomb and exchange parts of SD ***
|
||||
!****************************************
|
||||
|
||||
EJ_SD = +2d0*dot_product(n,matmul(Jint,n))
|
||||
EK_SD = -1d0*dot_product(n,matmul(Kint,n))
|
||||
|
||||
! *************
|
||||
! *** PNOF2 ***
|
||||
! *************
|
||||
|
||||
EJ_PNOF2 = 0d0
|
||||
EK_PNOF2 = 0d0
|
||||
EL_PNOF2 = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i == j) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
T_ij = 0d0
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = h(i)*h(j)
|
||||
T_ij = n(i)*n(j) - Delta_ij
|
||||
Pi_ij = sqrt(n(i)*n(j)) + sqrt(h(i)*h(j)) + T_ij
|
||||
|
||||
elseif(i <= FL .and. j > FL) then
|
||||
|
||||
Delta_ij = n(j)*h(i)*(1d0 - SF)/SF
|
||||
T_ij = n(i)*n(j) - Delta_ij
|
||||
Pi_ij = sqrt(n(i)*n(j)) - sqrt(n(j)*h(i)) + T_ij
|
||||
|
||||
elseif(i > FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = n(i)*h(j)*(1d0 - SF)/SF
|
||||
T_ij = n(i)*n(j) - Delta_ij
|
||||
Pi_ij = sqrt(n(i)*n(j)) - sqrt(n(i)*h(j)) + T_ij
|
||||
|
||||
elseif(i > FL .and. j > FL) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
T_ij = n(i)*n(j) - Delta_ij
|
||||
Pi_ij = T_ij
|
||||
|
||||
else
|
||||
|
||||
Delta_ij = 0d0
|
||||
T_ij = 0d0
|
||||
Pi_ij = 0d0
|
||||
|
||||
endif
|
||||
|
||||
EJ_PNOF2 = EJ_PNOF2 - 2d0*Delta_ij*Jint(i,j)
|
||||
EK_PNOF2 = EK_PNOF2 + Delta_ij*Kint(i,j)
|
||||
EL_PNOF2 = EL_PNOF2 + Pi_ij*Lint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! *************
|
||||
! *** PNOF3 ***
|
||||
! *************
|
||||
|
||||
EJ_PNOF3 = 0d0
|
||||
EK_PNOF3 = 0d0
|
||||
EL_PNOF3 = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i == j) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = h(i)*h(j)
|
||||
Pi_ij = n(i)*n(j) - sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j > FL) then
|
||||
|
||||
Delta_ij = n(j)*h(i)*(1d0 - SF)/SF
|
||||
Pi_ij = n(i)*n(j) - sqrt(n(i)*n(j)) - sqrt(n(j)*h(i))
|
||||
|
||||
elseif(i > FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = n(i)*h(j)*(1d0 - SF)/SF
|
||||
Pi_ij = n(i)*n(j) - sqrt(n(i)*n(j)) - sqrt(n(i)*h(j))
|
||||
|
||||
elseif(i > FL .and. j > FL) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = n(i)*n(j) + sqrt(n(i)*n(j))
|
||||
|
||||
else
|
||||
|
||||
Delta_ij = 0d0
|
||||
Pi_ij = 0d0
|
||||
|
||||
endif
|
||||
|
||||
EJ_PNOF3 = EJ_PNOF3 - Delta_ij*Jint(i,j)
|
||||
EK_PNOF3 = EK_PNOF3
|
||||
EL_PNOF3 = EL_PNOF3 + Pi_ij*Lint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! *************
|
||||
! *** PNOF4 ***
|
||||
! *************
|
||||
|
||||
EJ_PNOF4 = 0d0
|
||||
EK_PNOF4 = 0d0
|
||||
EL_PNOF4 = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i == j) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = h(i)*h(j)
|
||||
Pi_ij = - sqrt(h(i)*h(j))
|
||||
|
||||
elseif(i <= FL .and. j > FL) then
|
||||
|
||||
Delta_ij = n(j)*h(i)*(1d0 - SF)/SF
|
||||
Pi_ij = - sqrt( (h(i)*n(j)/SF) * (n(i)-n(j)+h(i)*n(j)/SF))
|
||||
|
||||
elseif(i > FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = n(i)*h(j)*(1d0 - SF)/SF
|
||||
Pi_ij = - sqrt( (h(j)*n(i)/SF) * (n(j)-n(i)+h(j)*n(i)/SF))
|
||||
|
||||
elseif(i > FL .and. j >= FL) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
else
|
||||
|
||||
Delta_ij = 0d0
|
||||
Pi_ij = 0d0
|
||||
|
||||
endif
|
||||
|
||||
EJ_PNOF4 = EJ_PNOF4 - 2d0*Delta_ij*Jint(i,j)
|
||||
EK_PNOF4 = EK_PNOF4 + Delta_ij*Kint(i,j)
|
||||
EL_PNOF4 = EL_PNOF4 + Pi_ij*Lint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
||||
! **************
|
||||
! *** PNOF6d ***
|
||||
! **************
|
||||
|
||||
EJ_PNOF6d = 0d0
|
||||
EK_PNOF6d = 0d0
|
||||
EL_PNOF6d = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i == j) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = h(i)*h(j)*exp(-2d0*SF)
|
||||
Pi_ij = - sqrt(h(i)*h(j))*exp(-SF)
|
||||
|
||||
elseif(i <= FL .and. j > FL) then
|
||||
|
||||
Delta_ij = gam(i)*gam(j)/Sd
|
||||
Pi_ij = - sqrt( (n(i)*h(j) + gam(i)*gam(j)/Sd) * (n(j)*h(i) + gam(i)*gam(j)/Sd))
|
||||
|
||||
elseif(i > FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = gam(i)*gam(j)/Sd
|
||||
Pi_ij = - sqrt( (n(i)*h(j) + gam(i)*gam(j)/Sd) * (n(j)*h(i) + gam(i)*gam(j)/Sd))
|
||||
|
||||
elseif(i > FL .and. j >= FL) then
|
||||
|
||||
Delta_ij = n(i)*n(j)*exp(-2d0*SF)
|
||||
Pi_ij = sqrt(n(i)*n(j))*exp(-SF)
|
||||
|
||||
else
|
||||
|
||||
Delta_ij = 0d0
|
||||
Pi_ij = 0d0
|
||||
|
||||
endif
|
||||
|
||||
EJ_PNOF6d = EJ_PNOF6d - 2d0*Delta_ij*Jint(i,j)
|
||||
EK_PNOF6d = EK_PNOF6d + Delta_ij*Kint(i,j)
|
||||
EL_PNOF6d = EL_PNOF6d + Pi_ij*Lint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! **************
|
||||
! *** PNOF6u ***
|
||||
! **************
|
||||
|
||||
EJ_PNOF6u = 0d0
|
||||
EK_PNOF6u = 0d0
|
||||
EL_PNOF6u = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i == j) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = h(i)*h(j)*exp(-2d0*SF)
|
||||
Pi_ij = - sqrt(h(i)*h(j))*exp(-SF)
|
||||
|
||||
elseif(i <= FL .and. j > FL) then
|
||||
|
||||
Delta_ij = gam(i)*gam(j)/Su
|
||||
Pi_ij = - sqrt( (n(i)*h(j) + gam(i)*gam(j)/Su) * (n(j)*h(i) + gam(i)*gam(j)/Su))
|
||||
|
||||
elseif(i > FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = gam(i)*gam(j)/Su
|
||||
Pi_ij = - sqrt( (n(i)*h(j) + gam(i)*gam(j)/Su) * (n(j)*h(i) + gam(i)*gam(j)/Su))
|
||||
|
||||
elseif(i > FL .and. j >= FL) then
|
||||
|
||||
Delta_ij = n(i)*n(j)*exp(-2d0*SF)
|
||||
Pi_ij = sqrt(n(i)*n(j))*exp(-SF)
|
||||
|
||||
else
|
||||
|
||||
Delta_ij = 0d0
|
||||
Pi_ij = 0d0
|
||||
|
||||
endif
|
||||
|
||||
EJ_PNOF6u = EJ_PNOF6u - 2d0*Delta_ij*Jint(i,j)
|
||||
EK_PNOF6u = EK_PNOF6u + Delta_ij*Kint(i,j)
|
||||
EL_PNOF6u = EL_PNOF6u + Pi_ij*Lint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! **************
|
||||
! *** PNOF6h ***
|
||||
! **************
|
||||
|
||||
EJ_PNOF6h = 0d0
|
||||
EK_PNOF6h = 0d0
|
||||
EL_PNOF6h = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i == j) then
|
||||
|
||||
Delta_ij = n(i)*n(j)
|
||||
Pi_ij = sqrt(n(i)*n(j))
|
||||
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = h(i)*h(j)*exp(-2d0*SF)
|
||||
Pi_ij = - sqrt(h(i)*h(j))*exp(-SF)
|
||||
|
||||
elseif(i <= FL .and. j > FL) then
|
||||
|
||||
Delta_ij = gam(i)*gam(j)/Sh
|
||||
Pi_ij = - sqrt( (n(i)*h(j) + gam(i)*gam(j)/Sh) * (n(j)*h(i) + gam(i)*gam(j)/Sh))
|
||||
|
||||
elseif(i > FL .and. j <= FL) then
|
||||
|
||||
Delta_ij = gam(i)*gam(j)/Sh
|
||||
Pi_ij = - sqrt( (n(i)*h(j) + gam(i)*gam(j)/Sh) * (n(j)*h(i) + gam(i)*gam(j)/Sh))
|
||||
|
||||
elseif(i > FL .and. j >= FL) then
|
||||
|
||||
Delta_ij = n(i)*n(j)*exp(-2d0*SF)
|
||||
Pi_ij = sqrt(n(i)*n(j))*exp(-SF)
|
||||
|
||||
else
|
||||
|
||||
Delta_ij = 0d0
|
||||
Pi_ij = 0d0
|
||||
|
||||
endif
|
||||
|
||||
EJ_PNOF6h = EJ_PNOF6h - 2d0*Delta_ij*Jint(i,j)
|
||||
EK_PNOF6h = EK_PNOF6h + Delta_ij*Kint(i,j)
|
||||
EL_PNOF6h = EL_PNOF6h + Pi_ij*Lint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Add the SD part
|
||||
|
||||
EJ_PNOF2 = EJ_SD + EJ_PNOF2
|
||||
EJ_PNOF3 = EJ_SD + EJ_PNOF3
|
||||
EJ_PNOF4 = EJ_SD + EJ_PNOF4
|
||||
! EJ_PNOF5 = EJ_SD + EJ_PNOF5
|
||||
EJ_PNOF6d = EJ_SD + EJ_PNOF6d
|
||||
EJ_PNOF6u = EJ_SD + EJ_PNOF6u
|
||||
EJ_PNOF6h = EJ_SD + EJ_PNOF6h
|
||||
! EJ_PNOF7 = EJ_SD + EJ_PNOF7
|
||||
|
||||
EK_PNOF2 = EK_SD + EK_PNOF2
|
||||
EK_PNOF3 = EK_SD + EK_PNOF3
|
||||
EK_PNOF4 = EK_SD + EK_PNOF4
|
||||
! EK_PNOF5 = EK_SD + EK_PNOF5
|
||||
EK_PNOF6d = EK_SD + EK_PNOF6d
|
||||
EK_PNOF6u = EK_SD + EK_PNOF6u
|
||||
EK_PNOF6h = EK_SD + EK_PNOF6h
|
||||
! EK_PNOF7 = EK_SD + EK_PNOF7
|
||||
|
||||
! Compute total energies
|
||||
|
||||
E_PNOF2 = ET + EV + EJ_PNOF2 + EK_PNOF2 + EL_PNOF2
|
||||
E_PNOF3 = ET + EV + EJ_PNOF3 + EK_PNOF3 + EL_PNOF3
|
||||
E_PNOF4 = ET + EV + EJ_PNOF4 + EK_PNOF4 + EL_PNOF4
|
||||
! E_PNOF5 = ET + EV + EJ_PNOF5 + EK_PNOF5 + EL_PNOF5
|
||||
E_PNOF6d = ET + EV + EJ_PNOF6d + EK_PNOF6d + EL_PNOF6d
|
||||
E_PNOF6u = ET + EV + EJ_PNOF6u + EK_PNOF6u + EL_PNOF6u
|
||||
E_PNOF6h = ET + EV + EJ_PNOF6h + EK_PNOF6h + EL_PNOF6h
|
||||
! E_PNOF7 = ET + EV + EJ_PNOF7 + EK_PNOF7 + EL_PNOF7
|
||||
|
||||
! Dump energies
|
||||
|
||||
print*, '*******************************'
|
||||
print*, '*** JKL NOFT functionals ***'
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
print*, '*** Coulomb energies ***'
|
||||
print*, 'Coulomb PNOF2 energy = ',EJ_PNOF2
|
||||
print*, 'Coulomb PNOF3 energy = ',EJ_PNOF3
|
||||
print*, 'Coulomb PNOF4 energy = ',EJ_PNOF4
|
||||
! print*, 'Coulomb PNOF5 energy = ',EJ_PNOF5
|
||||
print*, 'Coulomb PNOF6d energy = ',EJ_PNOF6d
|
||||
print*, 'Coulomb PNOF6u energy = ',EJ_PNOF6u
|
||||
print*, 'Coulomb PNOF6h energy = ',EJ_PNOF6h
|
||||
! print*, 'Coulomb PNOF7 energy = ',EJ_PNOF7
|
||||
print*, ''
|
||||
print*, '*** Exchange energies ***'
|
||||
print*, 'Exchange PNOF2 energy = ',EK_PNOF2
|
||||
print*, 'Exchange PNOF3 energy = ',EK_PNOF3
|
||||
print*, 'Exchange PNOF4 energy = ',EK_PNOF4
|
||||
! print*, 'Exchange PNOF5 energy = ',EK_PNOF5
|
||||
print*, 'Exchange PNOF6d energy = ',EK_PNOF6d
|
||||
print*, 'Exchange PNOF6u energy = ',EK_PNOF6u
|
||||
print*, 'Exchange PNOF6h energy = ',EK_PNOF6h
|
||||
! print*, 'Exchange PNOF7 energy = ',EK_PNOF7
|
||||
print*, ''
|
||||
print*, '*** Time-inversion energies ***'
|
||||
print*, 'Time-inversion PNOF2 energy = ',EL_PNOF2
|
||||
print*, 'Time-inversion PNOF3 energy = ',EL_PNOF3
|
||||
print*, 'Time-inversion PNOF4 energy = ',EL_PNOF4
|
||||
! print*, 'Time-inversion PNOF5 energy = ',EL_PNOF5
|
||||
print*, 'Time-inversion PNOF6d energy = ',EL_PNOF6d
|
||||
print*, 'Time-inversion PNOF6u energy = ',EL_PNOF6u
|
||||
print*, 'Time-inversion PNOF6h energy = ',EL_PNOF6h
|
||||
! print*, 'Time-inversion PNOF7 energy = ',EL_PNOF7
|
||||
print*, ''
|
||||
print*, '*** Two-electron energies ***'
|
||||
print*, 'J+K+L PNOF2 energy = ',EJ_PNOF2 + EK_PNOF2 + EL_PNOF2
|
||||
print*, 'J+K+L PNOF3 energy = ',EJ_PNOF3 + EK_PNOF3 + EL_PNOF3
|
||||
print*, 'J+K+L PNOF4 energy = ',EJ_PNOF4 + EK_PNOF4 + EL_PNOF4
|
||||
! print*, 'J+K+L PNOF5 energy = ',EJ_PNOF5 + EK_PNOF5 + EL_PNOF5
|
||||
print*, 'J+K+L PNOF6d energy = ',EJ_PNOF6d + EK_PNOF6d + EL_PNOF6d
|
||||
print*, 'J+K+L PNOF6u energy = ',EJ_PNOF6u + EK_PNOF6u + EL_PNOF6u
|
||||
print*, 'J+K+L PNOF6h energy = ',EJ_PNOF6h + EK_PNOF6h + EL_PNOF6h
|
||||
! print*, 'J+K+L PNOF7 energy = ',EJ_PNOF7 + EK_PNOF7 + EL_PNOF7
|
||||
print*, ''
|
||||
print*, '*** Total energies ***'
|
||||
print*, 'Total PNOF2 energy = ',E_PNOF2
|
||||
print*, 'Total PNOF3 energy = ',E_PNOF3
|
||||
print*, 'Total PNOF4 energy = ',E_PNOF4
|
||||
! print*, 'Total PNOF5 energy = ',E_PNOF5
|
||||
print*, 'Total PNOF6d energy = ',E_PNOF6d
|
||||
print*, 'Total PNOF6u energy = ',E_PNOF6u
|
||||
print*, 'Total PNOF6h energy = ',E_PNOF6h
|
||||
! print*, 'Total PNOF7 energy = ',E_PNOF7
|
||||
print*, ''
|
||||
|
||||
end subroutine NOFT_JKLfunc
|
||||
|
260
plugins/NOFT/NOFT_JKfunc.irp.f
Normal file
260
plugins/NOFT/NOFT_JKfunc.irp.f
Normal file
@ -0,0 +1,260 @@
|
||||
subroutine NOFT_JKfunc(nMO,FL,ET,EV,n)
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! JK-only functionals for NOFT
|
||||
END_DOC
|
||||
|
||||
PROVIDE mo_bielec_integrals_in_map
|
||||
|
||||
! Input variables
|
||||
|
||||
integer,intent(in) :: nMO,FL
|
||||
double precision,intent(in) :: ET,EV
|
||||
double precision,intent(in) :: n(nMO)
|
||||
|
||||
! Local variables
|
||||
|
||||
integer :: i,j
|
||||
double precision :: EJ_SD
|
||||
double precision :: EK_SD,EK_MBB,EK_POWER,EK_BBC1,EK_BBC2,EK_CA,EK_CGA,EK_GU,EK_ML,EK_MLSIC
|
||||
double precision :: E_SD,E_MBB,E_POWER,E_BBC1,E_BBC2,E_CA,E_CGA,E_GU,E_ML,E_MLSIC
|
||||
double precision :: alpha,a0,a1,b1
|
||||
double precision :: f_ij,get_mo_bielec_integral
|
||||
double precision,allocatable :: Jint(:,:),Kint(:,:)
|
||||
|
||||
! Memory allocation
|
||||
|
||||
allocate(Jint(nMO,nMO),Kint(nMO,nMO))
|
||||
|
||||
! Coulomb, exchange and time-inversion integrals
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
Jint(i,j) = get_mo_bielec_integral(i,j,i,j,mo_integrals_map)
|
||||
Kint(i,j) = get_mo_bielec_integral(i,j,j,i,mo_integrals_map)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute SD Coulomb energy
|
||||
|
||||
EJ_SD = 2d0*dot_product(n,matmul(Jint,n))
|
||||
|
||||
! Compute SD exchange energy
|
||||
|
||||
EK_SD = dot_product(n,matmul(Kint,n))
|
||||
|
||||
! Compute MBB exchange energy
|
||||
|
||||
EK_MBB = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
EK_MBB = EK_MBB + sqrt(n(i)*n(j))*Kint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute BBC1 exchange energy
|
||||
|
||||
EK_BBC1 = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
|
||||
if(i /= j .and. i > FL .and. j > FL) then
|
||||
f_ij = - sqrt(n(i)*n(j))
|
||||
else
|
||||
f_ij = sqrt(n(i)*n(j))
|
||||
endif
|
||||
|
||||
EK_BBC1 = EK_BBC1 + f_ij*Kint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute BBC2 exchange energy
|
||||
|
||||
EK_BBC2 = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,i-1
|
||||
|
||||
if(i > FL .and. j > FL) then
|
||||
f_ij = - sqrt(n(i)*n(j))
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
f_ij = n(i)*n(j)
|
||||
else
|
||||
f_ij = sqrt(n(i)*n(j))
|
||||
endif
|
||||
|
||||
EK_BBC2 = EK_BBC2 + f_ij*Kint(i,j)
|
||||
|
||||
enddo
|
||||
|
||||
EK_BBC2 = EK_BBC2 + n(i)*Kint(i,i)
|
||||
|
||||
do j=i+1,nMO
|
||||
|
||||
if(i > FL .and. j > FL) then
|
||||
f_ij = - sqrt(n(i)*n(j))
|
||||
elseif(i <= FL .and. j <= FL) then
|
||||
f_ij = n(i)*n(j)
|
||||
else
|
||||
f_ij = sqrt(n(i)*n(j))
|
||||
endif
|
||||
|
||||
EK_BBC2 = EK_BBC2 + f_ij*Kint(i,j)
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute CA exchange energy
|
||||
|
||||
EK_CA = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
EK_CA = EK_CA + (sqrt(n(i)*n(j)*(1d0 - n(i))*(1d0 - n(j))) + n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute CGA exchange energy
|
||||
|
||||
EK_CGA = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
EK_CGA = EK_CGA + 0.5d0*(sqrt(n(i)*n(j)*(2d0 - n(i))*(2d0 - n(j))) + n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute ML exchange energy
|
||||
|
||||
EK_ML = 0d0
|
||||
|
||||
a0 = 126.3101d0
|
||||
a1 = 2213.33d0
|
||||
b1 = 2338.64d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
EK_ML = EK_ML + n(i)*n(j)*(a0 + a1*n(i)*n(j))/(1d0 + b1*n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute MLSIC exchange energy
|
||||
|
||||
EK_MLSIC = 0d0
|
||||
|
||||
a0 = 1298.78d0
|
||||
a1 = 35114.4d0
|
||||
b1 = 36412.2d0
|
||||
|
||||
do i=1,nMO
|
||||
|
||||
do j=1,i-1
|
||||
EK_MLSIC = EK_MLSIC + n(i)*n(j)*(a0 + a1*n(i)*n(j))/(1d0 + b1*n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
|
||||
EK_MLSIC = EK_MLSIC + n(i)*n(i)*Kint(i,i)
|
||||
|
||||
do j=i+1,nMO
|
||||
EK_MLSIC = EK_MLSIC + n(i)*n(j)*(a0 + a1*n(i)*n(j))/(1d0 + b1*n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
|
||||
enddo
|
||||
|
||||
! Compute GU exchange energy
|
||||
|
||||
EK_GU = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
|
||||
do j=1,i-1
|
||||
EK_GU = EK_GU + sqrt(n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
|
||||
EK_GU = EK_GU + n(i)*n(i)*Kint(i,j)
|
||||
|
||||
do j=i+1,nMO
|
||||
EK_GU = EK_GU + sqrt(n(i)*n(j))*Kint(i,j)
|
||||
enddo
|
||||
|
||||
enddo
|
||||
|
||||
! Compute POWER exchange energy
|
||||
|
||||
EK_POWER = 0d0
|
||||
alpha = 1d0/3d0
|
||||
|
||||
do i=1,nMO
|
||||
do j=1,nMO
|
||||
EK_POWER = EK_POWER + (n(i)*n(j))**alpha*Kint(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute total energies
|
||||
|
||||
E_SD = ET + EV + EJ_SD - EK_SD
|
||||
E_MBB = ET + EV + EJ_SD - EK_MBB
|
||||
E_BBC1 = ET + EV + EJ_SD - EK_BBC1
|
||||
E_BBC2 = ET + EV + EJ_SD - EK_BBC2
|
||||
E_CA = ET + EV + EJ_SD - EK_CA
|
||||
E_CGA = ET + EV + EJ_SD - EK_CGA
|
||||
E_ML = ET + EV + EJ_SD - EK_ML
|
||||
E_MLSIC = ET + EV + EJ_SD - EK_MLSIC
|
||||
E_GU = ET + EV + EJ_SD - EK_GU
|
||||
E_POWER = ET + EV + EJ_SD - EK_POWER
|
||||
|
||||
! Dump energies
|
||||
|
||||
print*, '*******************************'
|
||||
print*, '*** JK NOFT functionals ***'
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
print*, '*** Coulomb energies ***'
|
||||
print*, 'Coulomb SD energy = ',EJ_SD
|
||||
print*, ''
|
||||
print*, '*** Exchange energies ***'
|
||||
print*, 'Exchange SD energy = ',-EK_SD
|
||||
print*, 'Exchange MBB energy = ',-EK_MBB
|
||||
print*, 'Exchange BBC1 energy = ',-EK_BBC1
|
||||
print*, 'Exchange BBC2 energy = ',-EK_BBC2
|
||||
print*, 'Exchange CA energy = ',-EK_CA
|
||||
print*, 'Exchange CGA energy = ',-EK_CGA
|
||||
print*, 'Exchange ML energy = ',-EK_ML
|
||||
print*, 'Exchange MLSIC energy = ',-EK_MLSIC
|
||||
print*, 'Exchange GU energy = ',-EK_GU
|
||||
print*, 'Exchange POWER energy = ',-EK_POWER
|
||||
print*, ''
|
||||
print*, ''
|
||||
print*, '*** Two-electron energies ***'
|
||||
print*, 'J+K SD energy = ',EJ_SD - EK_SD
|
||||
print*, 'J+K MBB energy = ',EJ_SD - EK_MBB
|
||||
print*, 'J+K BBC1 energy = ',EJ_SD - EK_BBC1
|
||||
print*, 'J+K BBC2 energy = ',EJ_SD - EK_BBC2
|
||||
print*, 'J+K CA energy = ',EJ_SD - EK_CA
|
||||
print*, 'J+K CGA energy = ',EJ_SD - EK_CGA
|
||||
print*, 'J+K ML energy = ',EJ_SD - EK_ML
|
||||
print*, 'J+K MLSIC energy = ',EJ_SD - EK_MLSIC
|
||||
print*, 'J+K GU energy = ',EJ_SD - EK_GU
|
||||
print*, 'J+K POWER energy = ',EJ_SD - EK_POWER
|
||||
print*, ''
|
||||
print*, '*** Total energies ***'
|
||||
print*, 'Total SD energy = ',E_SD
|
||||
print*, 'Total MBB energy = ',E_MBB
|
||||
print*, 'Total BBC1 energy = ',E_BBC1
|
||||
print*, 'Total BBC2 energy = ',E_BBC2
|
||||
print*, 'Total CA energy = ',E_CA
|
||||
print*, 'Total CGA energy = ',E_CGA
|
||||
print*, 'Total ML energy = ',E_ML
|
||||
print*, 'Total MLSIC energy = ',E_MLSIC
|
||||
print*, 'Total GU energy = ',E_GU
|
||||
print*, 'Total POWER energy = ',E_POWER
|
||||
print*, ''
|
||||
|
||||
end subroutine NOFT_JKfunc
|
||||
|
46
plugins/NOFT/NOFT_PT2.irp.f
Normal file
46
plugins/NOFT/NOFT_PT2.irp.f
Normal file
@ -0,0 +1,46 @@
|
||||
subroutine NOFT_PT2(nMO,FL,n)
|
||||
! Compute the PT2 correction from NOFT
|
||||
END_DOC
|
||||
|
||||
PROVIDE mo_bielec_integrals_in_map
|
||||
|
||||
! Input variables
|
||||
|
||||
integer,intent(in) :: nMO,FL
|
||||
double precision,intent(in) :: n(nMO)
|
||||
|
||||
! Local variables
|
||||
|
||||
integer :: i,j,a,b
|
||||
double precision :: EPT1,EPT2
|
||||
double precision :: get_mo_bielec_integral
|
||||
|
||||
! memory allocation
|
||||
|
||||
! Useful quantities
|
||||
|
||||
EPT2 = 0d0
|
||||
|
||||
! do i=1,FL
|
||||
! do j=1,FL
|
||||
! do a=FL+1,nMO
|
||||
! do b=FL+1,nMO
|
||||
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
|
||||
! Dump energies
|
||||
|
||||
print*, '*******************************'
|
||||
print*, '*** PT2 NOFT corrections ***'
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
print*, 'Total PT1 energy = ',E_PT1
|
||||
print*, 'Total PT2 energy = ',E_PT2
|
||||
print*, 'Total PT1+PT2 energy = ',E_PT1 + E_PT2
|
||||
print*, ''
|
||||
|
||||
end subroutine NOFT_PT2
|
||||
|
51
plugins/NOFT/NOFT_core.irp.f
Normal file
51
plugins/NOFT/NOFT_core.irp.f
Normal file
@ -0,0 +1,51 @@
|
||||
subroutine NOFT_core(nMO,ET,EV,n)
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Core energy for NOFT
|
||||
END_DOC
|
||||
|
||||
! Input variables
|
||||
|
||||
integer,intent(in) :: nMO
|
||||
double precision,intent(in) :: n(nMO)
|
||||
|
||||
! Local variables
|
||||
|
||||
integer :: i
|
||||
|
||||
! Output variables
|
||||
|
||||
double precision,intent(out) :: ET,EV
|
||||
|
||||
! Compute kinetic energy
|
||||
|
||||
ET = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
ET = ET + n(i)*mo_kinetic_integral(i,i)
|
||||
enddo
|
||||
|
||||
ET = 2d0*ET
|
||||
|
||||
! Compute nuclear attraction energy
|
||||
|
||||
EV = 0d0
|
||||
|
||||
do i=1,nMO
|
||||
EV = EV + n(i)*mo_nucl_elec_integral(i,i)
|
||||
enddo
|
||||
|
||||
EV = 2d0*EV
|
||||
|
||||
! Dump energies
|
||||
|
||||
print*, '*******************************'
|
||||
print*, '*** Core energies ***'
|
||||
print*, '*******************************'
|
||||
print*, ''
|
||||
print*, 'Kinetic energy = ',ET
|
||||
print*, 'Nuclear attraction energy = ',EV
|
||||
print*, ''
|
||||
|
||||
end subroutine NOFT_core
|
||||
|
12
plugins/NOFT/README.rst
Normal file
12
plugins/NOFT/README.rst
Normal file
@ -0,0 +1,12 @@
|
||||
====
|
||||
NOFT
|
||||
====
|
||||
|
||||
Needed Modules
|
||||
==============
|
||||
.. Do not edit this section It was auto-generated
|
||||
.. by the `update_README.py` script.
|
||||
Documentation
|
||||
=============
|
||||
.. Do not edit this section It was auto-generated
|
||||
.. by the `update_README.py` script.
|
106
plugins/NOFT/ezfio_interface.irp.f
Normal file
106
plugins/NOFT/ezfio_interface.irp.f
Normal file
@ -0,0 +1,106 @@
|
||||
! DO NOT MODIFY BY HAND
|
||||
! Created by $QP_ROOT/scripts/ezfio_interface/ei_handler.py
|
||||
! from file /home/loos/quantum_package/src/NOFT/EZFIO.cfg
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ logical, do_jk_functionals ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Compute energies for JK-only functionals
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
if (mpi_master) then
|
||||
|
||||
call ezfio_has_noft_do_jk_functionals(has)
|
||||
if (has) then
|
||||
call ezfio_get_noft_do_jk_functionals(do_jk_functionals)
|
||||
else
|
||||
print *, 'noft/do_jk_functionals not found in EZFIO file'
|
||||
stop 1
|
||||
endif
|
||||
endif
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
call MPI_BCAST( do_jk_functionals, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
stop 'Unable to read do_jk_functionals with MPI'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
|
||||
call write_time(6)
|
||||
if (mpi_master) then
|
||||
write(6, *) 'Read do_jk_functionals'
|
||||
endif
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ logical, do_jkl_functionals ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Compute energies for JKL-only functionals (PNOFs)
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
if (mpi_master) then
|
||||
|
||||
call ezfio_has_noft_do_jkl_functionals(has)
|
||||
if (has) then
|
||||
call ezfio_get_noft_do_jkl_functionals(do_jkl_functionals)
|
||||
else
|
||||
print *, 'noft/do_jkl_functionals not found in EZFIO file'
|
||||
stop 1
|
||||
endif
|
||||
endif
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
call MPI_BCAST( do_jkl_functionals, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
stop 'Unable to read do_jkl_functionals with MPI'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
|
||||
call write_time(6)
|
||||
if (mpi_master) then
|
||||
write(6, *) 'Read do_jkl_functionals'
|
||||
endif
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ logical, do_pt2_noft ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Compute PT2 correction for NOFT
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
if (mpi_master) then
|
||||
|
||||
call ezfio_has_noft_do_pt2_noft(has)
|
||||
if (has) then
|
||||
call ezfio_get_noft_do_pt2_noft(do_pt2_noft)
|
||||
else
|
||||
print *, 'noft/do_pt2_noft not found in EZFIO file'
|
||||
stop 1
|
||||
endif
|
||||
endif
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
call MPI_BCAST( do_pt2_noft, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
stop 'Unable to read do_pt2_noft with MPI'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
|
||||
call write_time(6)
|
||||
if (mpi_master) then
|
||||
write(6, *) 'Read do_pt2_noft'
|
||||
endif
|
||||
|
||||
END_PROVIDER
|
@ -15,13 +15,7 @@ default: 0.0001
|
||||
type: Normalized_float
|
||||
doc: Stop stochastic PT2 when the relative error is smaller than PT2_relative_error
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 0.001
|
||||
|
||||
[PT2_absolute_error]
|
||||
type: Threshold
|
||||
doc: Stop stochastic PT2 when the statistical error is smaller than PT2_absolute_error
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 0.00001
|
||||
default: 0.01
|
||||
|
||||
[correlation_energy_ratio_max]
|
||||
type: Normalized_float
|
||||
|
@ -72,6 +72,10 @@ integer function zmq_get_$X(zmq_to_qp_run_socket, worker_id)
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
@ -10,17 +10,15 @@ BEGIN_PROVIDER [ integer, N_det_selectors]
|
||||
double precision :: norm, norm_max
|
||||
call write_time(6)
|
||||
N_det_selectors = N_det
|
||||
if (threshold_generators < 1.d0) then
|
||||
norm = 0.d0
|
||||
norm = 1.d0
|
||||
do i=1,N_det
|
||||
norm = norm + psi_average_norm_contrib_sorted(i)
|
||||
if (norm > threshold_selectors) then
|
||||
norm = norm - psi_average_norm_contrib_sorted(i)
|
||||
if (norm - 1.d-10 < 1.d0 - threshold_selectors) then
|
||||
N_det_selectors = i
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
N_det_selectors = max(N_det_selectors,N_det_generators)
|
||||
endif
|
||||
call write_int(6,N_det_selectors,'Number of selectors')
|
||||
END_PROVIDER
|
||||
|
||||
|
@ -10,3 +10,9 @@ doc: Maximum number of dressed CI iterations
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 10
|
||||
|
||||
[dress_relative_error]
|
||||
type: Normalized_float
|
||||
doc: Stop stochastic PT2 when the relative error is smaller than PT2_relative_error
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 0.001
|
||||
|
||||
|
@ -81,10 +81,6 @@ subroutine generate_singles_and_doubles(delta_ij_loc, i_generator, bitmask_index
|
||||
hole (k,2) = iand(psi_det_generators(k,2,i_generator), generators_bitmask(k,2,s_hole,bitmask_index))
|
||||
particle(k,1) = iand(not(psi_det_generators(k,1,i_generator)), generators_bitmask(k,1,s_part,bitmask_index))
|
||||
particle(k,2) = iand(not(psi_det_generators(k,2,i_generator)), generators_bitmask(k,2,s_part,bitmask_index))
|
||||
!hole (k,1) = iand(psi_det_generators(k,1,i_generator), full_ijkl_bitmask(k))
|
||||
!hole (k,2) = iand(psi_det_generators(k,2,i_generator), full_ijkl_bitmask(k))
|
||||
!particle(k,1) = iand(not(psi_det_generators(k,1,i_generator)), full_ijkl_bitmask(k))
|
||||
!particle(k,2) = iand(not(psi_det_generators(k,2,i_generator)), full_ijkl_bitmask(k))
|
||||
enddo
|
||||
|
||||
integer :: N_holes(2), N_particles(2)
|
||||
|
@ -42,6 +42,7 @@ subroutine run_dressing(N_st,energy)
|
||||
do i=1,N_st
|
||||
print *, i, ci_energy_dressed(i)
|
||||
enddo
|
||||
energy(1:N_st) = ci_energy_dressed(1:N_st)
|
||||
call diagonalize_ci_dressed
|
||||
E_new = sum(psi_energy(:))
|
||||
|
||||
@ -61,10 +62,9 @@ subroutine run_dressing(N_st,energy)
|
||||
enddo
|
||||
print *, 'Dressed energy <Psi|H+Delta|Psi>'
|
||||
do i=1,N_st
|
||||
print *, i, ci_energy_dressed(i)+nuclear_repulsion
|
||||
print *, i, ci_energy_dressed(i)
|
||||
enddo
|
||||
endif
|
||||
|
||||
if(.true.) energy(1:N_st) = 0d0 ! ci_energy_dressed(1:N_st)
|
||||
end
|
||||
|
||||
|
@ -64,11 +64,7 @@ subroutine run_wf
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_gen_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
PROVIDE psi_bilinear_matrix_transp_order
|
||||
!!$OMP PARALLEL PRIVATE(i)
|
||||
!i = omp_get_thread_num()
|
||||
! call dress_slave_tcp(i+1, energy)
|
||||
call dress_slave_tcp(0, energy)
|
||||
!!$OMP END PARALLEL
|
||||
endif
|
||||
end do
|
||||
end
|
||||
@ -77,8 +73,6 @@ subroutine dress_slave_tcp(i,energy)
|
||||
implicit none
|
||||
double precision, intent(in) :: energy(N_states_diag)
|
||||
integer, intent(in) :: i
|
||||
logical :: lstop
|
||||
lstop = .False.
|
||||
call run_dress_slave(0,i,energy)
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
BEGIN_PROVIDER [ integer, dress_stoch_istate ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! State for stochatsic dressing
|
||||
END_DOC
|
||||
dress_stoch_istate = 1
|
||||
END_PROVIDER
|
||||
|
||||
@ -9,19 +12,29 @@ END_PROVIDER
|
||||
&BEGIN_PROVIDER [ integer, pt2_F, (N_det_generators) ]
|
||||
implicit none
|
||||
logical, external :: testTeethBuilding
|
||||
pt2_F(:) = 1
|
||||
!pt2_F(:N_det_generators/1000*0+50) = 1
|
||||
pt2_n_tasks_max = 16 ! N_det_generators/100 + 1
|
||||
integer :: i
|
||||
integer :: e
|
||||
e = elec_num - n_core_orb * 2
|
||||
pt2_n_tasks_max = 1 + min((e*(e-1))/2, int(dsqrt(dble(N_det_generators)))/10)
|
||||
do i=1,N_det_generators
|
||||
if (maxval(dabs(psi_coef_sorted_gen(i,1:N_states))) > 0.001d0) then
|
||||
pt2_F(i) = pt2_n_tasks_max
|
||||
else
|
||||
pt2_F(i) = 1
|
||||
endif
|
||||
enddo
|
||||
|
||||
|
||||
if(N_det_generators < 1024) then
|
||||
pt2_minDetInFirstTeeth = 1
|
||||
pt2_N_teeth = 1
|
||||
else
|
||||
do pt2_N_teeth=32,1,-1
|
||||
pt2_minDetInFirstTeeth = min(5, N_det_generators)
|
||||
do pt2_N_teeth=100,2,-1
|
||||
if(testTeethBuilding(pt2_minDetInFirstTeeth, pt2_N_teeth)) exit
|
||||
end do
|
||||
end if
|
||||
call write_int(6,pt2_N_teeth,'Number of comb teeth')
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
@ -36,25 +49,39 @@ logical function testTeethBuilding(minF, N)
|
||||
|
||||
allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators))
|
||||
|
||||
tilde_cW(0) = 0d0
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = psi_coef_generators(i,dress_stoch_istate)**2
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,dress_stoch_istate)**2 + 1.d-20
|
||||
enddo
|
||||
|
||||
double precision :: norm
|
||||
norm = 0.d0
|
||||
do i=N_det_generators,1,-1
|
||||
norm += tilde_w(i)
|
||||
enddo
|
||||
|
||||
tilde_w(:) = tilde_w(:) / norm
|
||||
|
||||
tilde_cW(0) = -1.d0
|
||||
do i=1,N_det_generators
|
||||
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
|
||||
enddo
|
||||
tilde_cW(N_det_generators) = 1d0
|
||||
tilde_cW(:) = tilde_cW(:) + 1.d0
|
||||
|
||||
n0 = 0
|
||||
testTeethBuilding = .false.
|
||||
do
|
||||
u0 = tilde_cW(n0)
|
||||
r = tilde_cW(n0 + minF)
|
||||
Wt = (1d0 - u0) / dble(N)
|
||||
if (dabs(Wt) <= 1.d-3) then
|
||||
return
|
||||
endif
|
||||
if(Wt >= r - u0) then
|
||||
testTeethBuilding = .true.
|
||||
return
|
||||
end if
|
||||
n0 += 1
|
||||
if(N_det_generators - n0 < minF * N) then
|
||||
testTeethBuilding = .false.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
@ -62,7 +89,7 @@ logical function testTeethBuilding(minF, N)
|
||||
end function
|
||||
|
||||
BEGIN_PROVIDER[ integer, dress_N_cp_max ]
|
||||
dress_N_cp_max = 64
|
||||
dress_N_cp_max = 28
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER[integer, pt2_J, (N_det_generators)]
|
||||
@ -75,6 +102,7 @@ END_PROVIDER
|
||||
|
||||
pt2_J = pt2_J_
|
||||
dress_R1 = dress_R1_
|
||||
!return
|
||||
|
||||
do m=1,dress_N_cp
|
||||
nmov = 0
|
||||
@ -118,26 +146,31 @@ END_PROVIDER
|
||||
N_j = pt2_n_0(1)
|
||||
d(:) = .false.
|
||||
|
||||
U = min(1, N_det_generators/(dress_N_cp_max**2/2))
|
||||
do i=1,dress_N_cp_max-1
|
||||
dress_M_m(i) = U * ((i**2-i)/2)! / (dress_N_cp_max+1)
|
||||
! Set here the positions of the checkpoints
|
||||
! U = N_det_generators/((dress_N_cp_max**2+dress_N_cp_max)/2)+1
|
||||
! do i=1, dress_N_cp_max-1
|
||||
! dress_M_m(i) = U * (((i*i)+i)/2) + 10
|
||||
! end do
|
||||
! dress_M_m(dress_N_cp_max) = N_det_generators+1
|
||||
do i=1, dress_N_cp_max-1
|
||||
dress_M_m(i) = ishft(1,i+3)
|
||||
end do
|
||||
|
||||
|
||||
|
||||
U = N_det_generators/((dress_N_cp_max**2+dress_N_cp_max)/2)+1
|
||||
do i=1, dress_N_cp_max
|
||||
dress_M_m(i) = U * (((i*i)+i)/2)
|
||||
end do
|
||||
|
||||
dress_M_m(1) = min(dress_M_m(1), 2)
|
||||
dress_M_m(dress_N_cp_max) = N_det_generators+1
|
||||
|
||||
do i=1,N_j
|
||||
d(i) = .true.
|
||||
pt2_J_(i) = i
|
||||
end do
|
||||
call random_seed(put=(/3211,64,6566,321,65,321,654,65,321,6321,654,65,321,621,654,65,321,65,654,65,321,65/))
|
||||
|
||||
integer, allocatable :: seed(:)
|
||||
call random_seed(size=m)
|
||||
allocate(seed(m))
|
||||
do i=1,m
|
||||
seed(i) = i
|
||||
enddo
|
||||
call random_seed(put=seed)
|
||||
deallocate(seed)
|
||||
|
||||
call RANDOM_NUMBER(pt2_u)
|
||||
call RANDOM_NUMBER(pt2_u)
|
||||
|
||||
@ -177,6 +210,10 @@ END_PROVIDER
|
||||
enddo
|
||||
|
||||
dress_N_cp = m-1
|
||||
if (dress_N_cp == 0) then
|
||||
dress_N_cp = 1
|
||||
endif
|
||||
|
||||
dress_R1_(dress_N_cp) = N_j
|
||||
dress_M_m(dress_N_cp) = N_c
|
||||
!!!!!!!!!!!!!!
|
||||
@ -196,10 +233,10 @@ END_PROVIDER
|
||||
|
||||
subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
||||
use f77_zmq
|
||||
use selection_types
|
||||
|
||||
implicit none
|
||||
|
||||
character(len=64000) :: task
|
||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket, zmq_socket_pull
|
||||
integer, external :: omp_get_thread_num
|
||||
double precision, intent(in) :: E(N_states), relative_error
|
||||
@ -212,20 +249,18 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
||||
|
||||
integer :: i, j, k, Ncp
|
||||
|
||||
integer, external :: add_task_to_taskserver
|
||||
double precision :: state_average_weight_save(N_states)
|
||||
character(100000) :: task
|
||||
PROVIDE Nproc
|
||||
task(:) = CHAR(0)
|
||||
allocate(delta(N_states,N_det), delta_s2(N_states, N_det))
|
||||
state_average_weight_save(:) = state_average_weight(:)
|
||||
do dress_stoch_istate=1,N_states
|
||||
SOFT_TOUCH dress_stoch_istate
|
||||
state_average_weight(:) = 0.d0
|
||||
state_average_weight(dress_stoch_istate) = 1.d0
|
||||
TOUCH state_average_weight
|
||||
TOUCH state_average_weight dress_stoch_istate
|
||||
|
||||
!provide psi_coef_generators
|
||||
provide nproc mo_bielec_integrals_in_map mo_mono_elec_integral psi_selectors
|
||||
!print *, dress_e0_denominator
|
||||
provide nproc mo_bielec_integrals_in_map mo_mono_elec_integral psi_selectors pt2_F
|
||||
|
||||
print *, '========== ================= ================= ================='
|
||||
print *, ' Samples Energy Stat. Error Seconds '
|
||||
@ -237,7 +272,7 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
||||
integer, external :: zmq_put_N_det_generators
|
||||
integer, external :: zmq_put_N_det_selectors
|
||||
integer, external :: zmq_put_dvector
|
||||
integer, external :: zmq_set_running
|
||||
integer, external :: zmq_put_int
|
||||
|
||||
if (zmq_put_psi(zmq_to_qp_run_socket,1) == -1) then
|
||||
stop 'Unable to put psi on ZMQ server'
|
||||
@ -254,29 +289,71 @@ subroutine ZMQ_dress(E, dress, delta_out, delta_s2_out, relative_error)
|
||||
if (zmq_put_dvector(zmq_to_qp_run_socket,1,"state_average_weight",state_average_weight,N_states) == -1) then
|
||||
stop 'Unable to put state_average_weight on ZMQ server'
|
||||
endif
|
||||
if (zmq_put_dvector(zmq_to_qp_run_socket,1,"dress_stoch_istate",real(dress_stoch_istate,8),1) == -1) then
|
||||
if (zmq_put_int(zmq_to_qp_run_socket,1,'dress_stoch_istate',dress_stoch_istate) == -1) then
|
||||
stop 'Unable to put dress_stoch_istate on ZMQ server'
|
||||
endif
|
||||
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_selectors',threshold_selectors,1) == -1) then
|
||||
stop 'Unable to put threshold_selectors on ZMQ server'
|
||||
endif
|
||||
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) then
|
||||
stop 'Unable to put threshold_generators on ZMQ server'
|
||||
endif
|
||||
|
||||
|
||||
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
|
||||
|
||||
call write_int(6,pt2_n_tasks_max,'Max number of task fragments')
|
||||
|
||||
|
||||
integer, external :: add_task_to_taskserver
|
||||
integer :: ipos
|
||||
ipos=0
|
||||
do i=1,N_det_generators
|
||||
if (pt2_F(i) > 1) then
|
||||
ipos += 1
|
||||
endif
|
||||
enddo
|
||||
call write_int(6,ipos,'Number of fragmented tasks')
|
||||
|
||||
|
||||
ipos=1
|
||||
|
||||
do i= 1, N_det_generators
|
||||
do j=1,pt2_F(pt2_J(i))
|
||||
write(task(1:20),'(I9,1X,I9''|'')') j, pt2_J(i)
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:20))) == -1) then
|
||||
write(task(ipos:ipos+20),'(I9,1X,I9,''|'')') j, pt2_J(i)
|
||||
ipos += 20
|
||||
if (ipos > len(task)-20) then
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
stop 'Unable to add task to task server'
|
||||
endif
|
||||
ipos=1
|
||||
endif
|
||||
end do
|
||||
end do
|
||||
enddo
|
||||
if (ipos > 1) then
|
||||
if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then
|
||||
stop 'Unable to add task to task server'
|
||||
endif
|
||||
endif
|
||||
|
||||
integer, external :: zmq_set_running
|
||||
if (zmq_set_running(zmq_to_qp_run_socket) == -1) then
|
||||
print *, irp_here, ': Failed in zmq_set_running'
|
||||
endif
|
||||
|
||||
|
||||
|
||||
integer :: nproc_target
|
||||
nproc_target = nproc
|
||||
double precision :: mem
|
||||
mem = 8.d0 * N_det * (N_int * 2.d0 * 3.d0 + 3.d0 + 5.d0) / (1024.d0**3)
|
||||
call write_double(6,mem,'Estimated memory/thread (Gb)')
|
||||
if (qp_max_mem > 0) then
|
||||
nproc_target = max(1,int(dble(qp_max_mem)/mem))
|
||||
nproc_target = min(nproc_target,nproc)
|
||||
endif
|
||||
|
||||
call omp_set_nested(.true.)
|
||||
|
||||
if (.true.) then !! TODO
|
||||
!$OMP PARALLEL DEFAULT(shared) NUM_THREADS(2) &
|
||||
!$OMP PRIVATE(i)
|
||||
i = omp_get_thread_num()
|
||||
@ -288,13 +365,6 @@ if (.true.) then !! TODO
|
||||
endif
|
||||
!$OMP END PARALLEL
|
||||
|
||||
else
|
||||
|
||||
call dress_collector(zmq_socket_pull,E, relative_error, delta, delta_s2, dress,&
|
||||
dress_stoch_istate)
|
||||
endif
|
||||
|
||||
call omp_set_nested(.false.)
|
||||
delta_out(dress_stoch_istate,1:N_det) = delta(dress_stoch_istate,1:N_det)
|
||||
delta_s2_out(dress_stoch_istate,1:N_det) = delta_s2(dress_stoch_istate,1:N_det)
|
||||
|
||||
@ -304,6 +374,7 @@ endif
|
||||
enddo
|
||||
FREE dress_stoch_istate
|
||||
state_average_weight(:) = state_average_weight_save(:)
|
||||
! call omp_set_nested(.false.)
|
||||
TOUCH state_average_weight
|
||||
deallocate(delta,delta_s2)
|
||||
|
||||
@ -401,7 +472,7 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
||||
double precision, intent(out) :: delta(N_states, N_det)
|
||||
double precision, intent(out) :: delta_s2(N_states, N_det)
|
||||
double precision, allocatable :: breve_delta_m(:,:,:), S(:), S2(:)
|
||||
double precision, allocatable :: edI(:,:), edI_task(:,:)
|
||||
double precision, allocatable :: edI(:), edI_task(:)
|
||||
integer, allocatable :: edI_index(:)
|
||||
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
||||
@ -417,16 +488,16 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
||||
integer, external :: zmq_delete_tasks, dress_find_sample
|
||||
logical :: found
|
||||
integer :: worker_id
|
||||
worker_id=1
|
||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||
|
||||
call connect_to_taskserver(zmq_to_qp_run_socket,worker_id,1)
|
||||
|
||||
found = .false.
|
||||
delta = 0d0
|
||||
delta_s2 = 0d0
|
||||
allocate(task_id(pt2_n_tasks_max))
|
||||
allocate(edI(N_states, N_det))
|
||||
allocate(edI_task(N_states, N_det), edI_index(N_det))
|
||||
allocate(edI(N_det_generators))
|
||||
allocate(edI_task(N_det_generators), edI_index(N_det_generators))
|
||||
allocate(breve_delta_m(N_states, N_det, 2))
|
||||
allocate(dot_f(dress_N_cp+1))
|
||||
allocate(S(pt2_N_teeth+1), S2(pt2_N_teeth+1))
|
||||
@ -447,7 +518,7 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
||||
if(dot_f(m) == 0) then
|
||||
E0 = 0
|
||||
do i=dress_dot_n_0(m),1,-1
|
||||
E0 += edI(dress_stoch_istate, i)
|
||||
E0 += edI(i)
|
||||
end do
|
||||
do while(c < dress_M_m(m))
|
||||
c = c+1
|
||||
@ -455,34 +526,34 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
||||
do p=pt2_N_teeth, 1, -1
|
||||
v = pt2_u_0 + pt2_W_T * (pt2_u(c) + dble(p-1))
|
||||
i = dress_find_sample(v, pt2_cW)
|
||||
x += edI(dress_stoch_istate, i) * pt2_W_T / pt2_w(i)
|
||||
x += edI(i) * pt2_W_T / pt2_w(i)
|
||||
S(p) += x
|
||||
S2(p) += x**2
|
||||
end do
|
||||
end do
|
||||
t = dress_dot_t(m)
|
||||
avg = S(t) / dble(c)
|
||||
if (c > 1) then
|
||||
eqt = (S2(t) / c) - (S(t)/c)**2
|
||||
eqt = sqrt(eqt / dble(c-1))
|
||||
error = eqt
|
||||
avg = E0 + S(t) / dble(c)
|
||||
if (c > 2) then
|
||||
eqt = dabs((S2(t) / c) - (S(t)/c)**2)
|
||||
error = sqrt(eqt / (dble(c)-1.5d0))
|
||||
time = omp_get_wtime()
|
||||
print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', c, avg+E0+E(dress_stoch_istate), eqt, time-time0, ''
|
||||
print '(G10.3, 2X, F16.10, 2X, G16.3, 2X, F16.4, A20)', c, avg+E(istate), error, time-time0, ''
|
||||
else if ( m==dress_N_cp ) then
|
||||
error = 0.d0
|
||||
else
|
||||
eqt = 1.d0
|
||||
error = eqt
|
||||
error =1.d0
|
||||
endif
|
||||
m += 1
|
||||
if(eqt <= relative_error) then
|
||||
if(dabs(error / avg) <= relative_error) then
|
||||
integer, external :: zmq_put_dvector
|
||||
i= zmq_put_dvector(zmq_to_qp_run_socket, worker_id, "ending", dble(m-1), 1)
|
||||
integer, external :: zmq_put_int
|
||||
i= zmq_put_int(zmq_to_qp_run_socket, worker_id, 'ending', (m-1))
|
||||
found = .true.
|
||||
end if
|
||||
else
|
||||
do
|
||||
call pull_dress_results(zmq_socket_pull, m_task, f, edI_task, edI_index, breve_delta_m, task_id, n_tasks)
|
||||
if(time0 == -1d0) then
|
||||
print *, "first pull", omp_get_wtime()-time
|
||||
time0 = omp_get_wtime()
|
||||
end if
|
||||
if(m_task == 0) then
|
||||
@ -496,14 +567,13 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
||||
end if
|
||||
end do
|
||||
do i=1,n_tasks
|
||||
if(edI(1, edI_index(i)) /= 0d0) stop "NIN M"
|
||||
edI(:, edI_index(i)) += edI_task(:, i)
|
||||
edI(edI_index(i)) += edI_task(i)
|
||||
end do
|
||||
dot_f(m_task) -= f
|
||||
end if
|
||||
end do
|
||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||
call sleep(1)
|
||||
call sleep(10)
|
||||
if (zmq_abort(zmq_to_qp_run_socket) == -1) then
|
||||
print *, irp_here, ': Error in sending abort signal (2)'
|
||||
endif
|
||||
@ -537,12 +607,11 @@ subroutine dress_collector(zmq_socket_pull, E, relative_error, delta, delta_s2,
|
||||
!tmp = 0d0
|
||||
|
||||
!do i=1,N_det
|
||||
! if(edi(1,i) == 0d0) stop "EMPTY"
|
||||
! if(edi(i) == 0d0) stop "EMPTY"
|
||||
! tmp += psi_coef(i, 1) * delta(1, i)
|
||||
!end do
|
||||
!print *, "SUM", E(1)+sum(edi(1,:))
|
||||
!print *, "SUM", E(1)+sum(edi(:))
|
||||
!print *, "DOT", E(1)+tmp
|
||||
call disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id)
|
||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
end subroutine
|
||||
|
||||
@ -563,8 +632,13 @@ integer function dress_find_sample(v, w)
|
||||
r = i
|
||||
end if
|
||||
end do
|
||||
|
||||
dress_find_sample = r
|
||||
i = r
|
||||
do r=i+1,N_det_generators
|
||||
if (w(r) /= w(i)) then
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
dress_find_sample = r-1
|
||||
end function
|
||||
|
||||
|
||||
@ -582,13 +656,24 @@ end function
|
||||
|
||||
allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators))
|
||||
|
||||
tilde_cW(0) = 0d0
|
||||
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = psi_coef_generators(i,dress_stoch_istate)**2
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,dress_stoch_istate)**2 + 1.d-20
|
||||
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
|
||||
enddo
|
||||
tilde_cW(N_det_generators) = 1d0
|
||||
|
||||
double precision :: norm
|
||||
norm = 0.d0
|
||||
do i=N_det_generators,1,-1
|
||||
norm += tilde_w(i)
|
||||
enddo
|
||||
|
||||
tilde_w(:) = tilde_w(:) / norm
|
||||
|
||||
tilde_cW(0) = -1.d0
|
||||
do i=1,N_det_generators
|
||||
tilde_cW(i) = tilde_cW(i-1) + tilde_w(i)
|
||||
enddo
|
||||
tilde_cW(:) = tilde_cW(:) + 1.d0
|
||||
|
||||
pt2_n_0(1) = 0
|
||||
do
|
||||
@ -615,6 +700,10 @@ end function
|
||||
pt2_w(:pt2_n_0(1)) = tilde_w(:pt2_n_0(1))
|
||||
do t=1, pt2_N_teeth
|
||||
tooth_width = tilde_cW(pt2_n_0(t+1)) - tilde_cW(pt2_n_0(t))
|
||||
if (tooth_width == 0.d0) then
|
||||
tooth_width = sum(tilde_w(pt2_n_0(t):pt2_n_0(t+1)))
|
||||
endif
|
||||
ASSERT(tooth_width > 0.d0)
|
||||
do i=pt2_n_0(t)+1, pt2_n_0(t+1)
|
||||
pt2_w(i) = tilde_w(i) * pt2_W_T / tooth_width
|
||||
end do
|
||||
@ -628,3 +717,6 @@ end function
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,68 +1,6 @@
|
||||
use bitmasks
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ integer, N_dress_teeth ]
|
||||
N_dress_teeth = 10
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ double precision, dress_norm_acc, (0:N_det, N_states) ]
|
||||
&BEGIN_PROVIDER [ double precision, dress_norm, (0:N_det, N_states) ]
|
||||
&BEGIN_PROVIDER [ double precision, dress_teeth_size, (0:N_det, N_states) ]
|
||||
&BEGIN_PROVIDER [ integer, dress_teeth, (0:N_dress_teeth+1, N_states) ]
|
||||
implicit none
|
||||
integer :: i, j, st, nt
|
||||
double precision :: norm_sto, jump, norm_mwen, norm_loc
|
||||
|
||||
if(N_states /= 1) stop "dress_sto may not work with N_states /= 1"
|
||||
|
||||
do st=1,N_states
|
||||
dress_teeth(0,st) = 1
|
||||
norm_sto = 1d0
|
||||
do i=1,N_det
|
||||
dress_teeth(1,st) = i
|
||||
jump = (1d0 / dfloat(N_dress_teeth)) * norm_sto
|
||||
if(psi_coef_generators(i,1)**2 < jump / 2d0) exit
|
||||
norm_sto -= psi_coef_generators(i,1)**2
|
||||
end do
|
||||
|
||||
norm_loc = 0d0
|
||||
dress_norm_acc(0,st) = 0d0
|
||||
nt = 1
|
||||
|
||||
do i=1,dress_teeth(1,st)-1
|
||||
dress_norm_acc(i,st) = dress_norm_acc(i-1,st) + psi_coef_generators(i,st)**2
|
||||
end do
|
||||
|
||||
do i=dress_teeth(1,st), N_det_generators!-dress_teeth(1,st)+1
|
||||
norm_mwen = psi_coef_generators(i,st)**2!-1+dress_teeth(1,st),st)**2
|
||||
dress_norm_acc(i,st) = dress_norm_acc(i-1,st) + norm_mwen
|
||||
norm_loc += norm_mwen
|
||||
if(norm_loc > (jump*dfloat(nt))) then
|
||||
nt = nt + 1
|
||||
dress_teeth(nt,st) = i
|
||||
end if
|
||||
end do
|
||||
if(nt > N_dress_teeth+1) then
|
||||
print *, "foireouse dress_teeth", nt, dress_teeth(nt,st), N_det
|
||||
stop
|
||||
end if
|
||||
|
||||
dress_teeth(N_dress_teeth+1,st) = N_det+1
|
||||
norm_loc = 0d0
|
||||
do i=N_dress_teeth, 0, -1
|
||||
dress_teeth_size(i,st) = dress_norm_acc(dress_teeth(i+1,st)-1,st) - dress_norm_acc(dress_teeth(i,st)-1, st)
|
||||
dress_norm_acc(dress_teeth(i,st):dress_teeth(i+1,st)-1,st) -= dress_norm_acc(dress_teeth(i,st)-1, st)
|
||||
dress_norm_acc(dress_teeth(i,st):dress_teeth(i+1,st)-1,st) = &
|
||||
dress_norm_acc(dress_teeth(i,st):dress_teeth(i+1,st)-1,st) / dress_teeth_size(i,st)
|
||||
dress_norm(dress_teeth(i,st), st) = dress_norm_acc(dress_teeth(i,st), st)
|
||||
do j=dress_teeth(i,st)+1, dress_teeth(i+1,1)-1
|
||||
dress_norm(j,1) = dress_norm_acc(j, st) - dress_norm_acc(j-1, st)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ integer , N_det_delta_ij ]
|
||||
implicit none
|
||||
N_det_delta_ij = N_det
|
||||
@ -83,21 +21,20 @@ BEGIN_PROVIDER [ double precision, delta_ij_tmp, (N_states,N_det_delta_ij,2) ]
|
||||
integer :: i,j,k
|
||||
|
||||
double precision, allocatable :: dress(:), del(:,:), del_s2(:,:)
|
||||
double precision :: E_CI_before(N_states), relative_error
|
||||
double precision :: E_CI_before(N_states)
|
||||
integer :: cnt = 0
|
||||
|
||||
allocate(dress(N_states), del(N_states, N_det_delta_ij), del_s2(N_states, N_det_delta_ij))
|
||||
allocate(dress(N_states), del(N_states, N_det), del_s2(N_states, N_det))
|
||||
|
||||
delta_ij_tmp = 0d0
|
||||
|
||||
E_CI_before(:) = dress_E0_denominator(:) + nuclear_repulsion
|
||||
relative_error = 1.d-5
|
||||
|
||||
call write_double(6,relative_error,"Convergence of the stochastic algorithm")
|
||||
call write_double(6,dress_relative_error,"Convergence of the stochastic algorithm")
|
||||
|
||||
call ZMQ_dress(E_CI_before, dress, del, del_s2, abs(relative_error), N_det_delta_ij)
|
||||
delta_ij_tmp(:,:,1) = del(:,:)
|
||||
delta_ij_tmp(:,:,2) = del_s2(:,:)
|
||||
call ZMQ_dress(E_CI_before, dress, del, del_s2, abs(dress_relative_error))
|
||||
delta_ij_tmp(:,1:N_det_delta_ij,1) = del(:,1:N_det_delta_ij)
|
||||
delta_ij_tmp(:,1:N_det_delta_ij,2) = del_s2(:,1:N_det_delta_ij)
|
||||
|
||||
|
||||
deallocate(dress, del, del_s2)
|
||||
|
@ -8,7 +8,7 @@ subroutine run_dress_slave(thread,iproce,energy)
|
||||
|
||||
double precision, intent(in) :: energy(N_states_diag)
|
||||
integer, intent(in) :: thread, iproce
|
||||
integer :: rc, i, subset, i_generator
|
||||
integer :: rc, i, j, subset, i_generator
|
||||
|
||||
integer :: worker_id, ctask, ltask
|
||||
character*(512) :: task(Nproc)
|
||||
@ -33,15 +33,14 @@ subroutine run_dress_slave(thread,iproce,energy)
|
||||
integer :: cp_max(Nproc)
|
||||
integer :: will_send, task_id, purge_task_id, ntask_buf
|
||||
integer, allocatable :: task_buf(:)
|
||||
integer(kind=OMP_LOCK_KIND) :: lck_det(0:pt2_N_teeth+1)
|
||||
integer(kind=OMP_LOCK_KIND) :: lck_sto(0:dress_N_cp+1), sending, getting_task
|
||||
! integer(kind=OMP_LOCK_KIND) :: lck_det(0:pt2_N_teeth+1)
|
||||
! integer(kind=OMP_LOCK_KIND) :: lck_sto(dress_N_cp)
|
||||
double precision :: fac
|
||||
double precision :: ending(1)
|
||||
integer, external :: zmq_get_dvector
|
||||
integer :: ending, ending_tmp
|
||||
integer, external :: zmq_get_dvector, zmq_get_int
|
||||
! double precision, external :: omp_get_wtime
|
||||
double precision :: time, time0
|
||||
double precision :: time, time0
|
||||
integer :: ntask_tbd, task_tbd(Nproc), i_gen_tbd(Nproc), subset_tbd(Nproc)
|
||||
! if(iproce /= 0) stop "RUN DRESS SLAVE is OMP"
|
||||
|
||||
allocate(delta_det(N_states, N_det, 0:pt2_N_teeth+1, 2))
|
||||
allocate(cp(N_states, N_det, dress_N_cp, 2))
|
||||
@ -53,23 +52,22 @@ double precision :: time, time0
|
||||
cp = 0d0
|
||||
task = CHAR(0)
|
||||
|
||||
call omp_init_lock(sending)
|
||||
call omp_init_lock(getting_task)
|
||||
do i=0,dress_N_cp+1
|
||||
call omp_init_lock(lck_sto(i))
|
||||
end do
|
||||
do i=0,pt2_N_teeth+1
|
||||
call omp_init_lock(lck_det(i))
|
||||
end do
|
||||
! do i=1,dress_N_cp
|
||||
! call omp_init_lock(lck_sto(i))
|
||||
! end do
|
||||
! do i=0,pt2_N_teeth+1
|
||||
! call omp_init_lock(lck_det(i))
|
||||
! end do
|
||||
|
||||
cp_done = 0
|
||||
cp_sent = 0
|
||||
will_send = 0
|
||||
cp_max(:) = 0
|
||||
|
||||
double precision :: hij, sij, tmp
|
||||
purge_task_id = 0
|
||||
provide psi_energy
|
||||
ending(1) = dble(dress_N_cp+1)
|
||||
ending = dress_N_cp+1
|
||||
ntask_tbd = 0
|
||||
!$OMP PARALLEL DEFAULT(SHARED) &
|
||||
!$OMP PRIVATE(breve_delta_m, task_id) &
|
||||
@ -79,7 +77,11 @@ double precision :: time, time0
|
||||
!$OMP PRIVATE(task_buf, ntask_buf,time, time0)
|
||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||
zmq_socket_push = new_zmq_push_socket(thread)
|
||||
call connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread)
|
||||
integer, external :: connect_to_taskserver
|
||||
if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then
|
||||
print *, irp_here, ': Unable to connect to task server'
|
||||
stop -1
|
||||
endif
|
||||
if(worker_id == -1) then
|
||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
call end_zmq_push_socket(zmq_socket_push,thread)
|
||||
@ -94,8 +96,10 @@ double precision :: time, time0
|
||||
call push_dress_results(zmq_socket_push, 0, 0, edI_task, edI_index, breve_delta_m, task_buf, ntask_buf)
|
||||
end if
|
||||
|
||||
do while(cp_done > cp_sent .or. m /= dress_N_cp+1)
|
||||
call omp_set_lock(getting_task)
|
||||
m=0
|
||||
!$OMP BARRIER
|
||||
do while( (cp_done > cp_sent) .or. (m /= dress_N_cp+1) )
|
||||
!$OMP CRITICAL (send)
|
||||
if(ntask_tbd == 0) then
|
||||
ntask_tbd = size(task_tbd)
|
||||
call get_tasks_from_taskserver(zmq_to_qp_run_socket,worker_id, task_tbd, task, ntask_tbd)
|
||||
@ -113,12 +117,12 @@ double precision :: time, time0
|
||||
ntask_tbd -= 1
|
||||
else
|
||||
m = dress_N_cp + 1
|
||||
i= zmq_get_dvector(zmq_to_qp_run_socket, worker_id, "ending", ending, 1)
|
||||
if (zmq_get_int(zmq_to_qp_run_socket, worker_id, "ending", ending_tmp) /= -1) then
|
||||
ending = ending_tmp
|
||||
endif
|
||||
end if
|
||||
call omp_unset_lock(getting_task)
|
||||
will_send = 0
|
||||
|
||||
!$OMP CRITICAL
|
||||
cp_max(iproc) = m
|
||||
cp_done = minval(cp_max)-1
|
||||
if(cp_done > cp_sent) then
|
||||
@ -132,10 +136,8 @@ double precision :: time, time0
|
||||
ntask_buf += 1
|
||||
task_buf(ntask_buf) = task_id
|
||||
end if
|
||||
!$OMP END CRITICAL
|
||||
|
||||
if(will_send /= 0 .and. will_send <= int(ending(1))) then
|
||||
call omp_set_lock(sending)
|
||||
if(will_send /= 0 .and. will_send <= ending) then
|
||||
n_tasks = 0
|
||||
sum_f = 0
|
||||
do i=1,N_det_generators
|
||||
@ -146,9 +148,10 @@ double precision :: time, time0
|
||||
edI_index(n_tasks) = i
|
||||
end if
|
||||
end do
|
||||
call push_dress_results(zmq_socket_push, will_send, sum_f, edI_task, edI_index, breve_delta_m, 0, n_tasks)
|
||||
call omp_unset_lock(sending)
|
||||
call push_dress_results(zmq_socket_push, will_send, sum_f, edI_task, edI_index, &
|
||||
breve_delta_m, task_buf, n_tasks)
|
||||
end if
|
||||
!$OMP END CRITICAL (send)
|
||||
|
||||
if(m /= dress_N_cp+1) then
|
||||
!UPDATE i_generator
|
||||
@ -158,21 +161,28 @@ double precision :: time, time0
|
||||
time0 = omp_get_wtime()
|
||||
call alpha_callback(breve_delta_m, i_generator, subset, pt2_F(i_generator), iproc)
|
||||
time = omp_get_wtime()
|
||||
!print '(I0.11, I4, A12, F12.3)', i_generator, subset, "GREPMETIME", time-time0
|
||||
t = dress_T(i_generator)
|
||||
|
||||
call omp_set_lock(lck_det(t))
|
||||
delta_det(:,:,t, 1) += breve_delta_m(:,:,1)
|
||||
delta_det(:,:,t, 2) += breve_delta_m(:,:,2)
|
||||
call omp_unset_lock(lck_det(t))
|
||||
!$OMP CRITICAL(t_crit)
|
||||
do j=1,N_det
|
||||
do i=1,N_states
|
||||
delta_det(i,j,t, 1) = delta_det(i,j,t, 1) + breve_delta_m(i,j,1)
|
||||
delta_det(i,j,t, 2) = delta_det(i,j,t, 2) + breve_delta_m(i,j,2)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END CRITICAL(t_crit)
|
||||
|
||||
do p=1,dress_N_cp
|
||||
if(dress_e(i_generator, p) /= 0d0) then
|
||||
fac = dress_e(i_generator, p)
|
||||
call omp_set_lock(lck_sto(p))
|
||||
cp(:,:,p,1) += breve_delta_m(:,:,1) * fac
|
||||
cp(:,:,p,2) += breve_delta_m(:,:,2) * fac
|
||||
call omp_unset_lock(lck_sto(p))
|
||||
!$OMP CRITICAL(p_crit)
|
||||
do j=1,N_det
|
||||
do i=1,N_states
|
||||
cp(i,j,p,1) = cp(i,j,p,1) + breve_delta_m(i,j,1) * fac
|
||||
cp(i,j,p,2) = cp(i,j,p,2) + breve_delta_m(i,j,2) * fac
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END CRITICAL(p_crit)
|
||||
end if
|
||||
end do
|
||||
|
||||
@ -191,19 +201,20 @@ double precision :: time, time0
|
||||
end if
|
||||
end if
|
||||
end do
|
||||
|
||||
!$OMP BARRIER
|
||||
if(ntask_buf /= 0) then
|
||||
call push_dress_results(zmq_socket_push, 0, 0, edI_task, edI_index, breve_delta_m, task_buf, ntask_buf)
|
||||
ntask_buf = 0
|
||||
end if
|
||||
|
||||
!$OMP SINGLE
|
||||
if(purge_task_id /= 0) then
|
||||
do while(int(ending(1)) == dress_N_cp+1)
|
||||
do while (zmq_get_int(zmq_to_qp_run_socket, worker_id, "ending", ending) == -1)
|
||||
call sleep(1)
|
||||
i= zmq_get_dvector(zmq_to_qp_run_socket, worker_id, "ending", ending, 1)
|
||||
end do
|
||||
|
||||
will_send = int(ending(1))
|
||||
will_send = ending
|
||||
breve_delta_m = 0d0
|
||||
|
||||
do l=will_send, 1,-1
|
||||
@ -222,20 +233,26 @@ double precision :: time, time0
|
||||
do i=1,N_det_generators
|
||||
if(dress_P(i) <= will_send) sum_f = sum_f + f(i)
|
||||
end do
|
||||
call push_dress_results(zmq_socket_push, -will_send, sum_f, edI_task, edI_index, breve_delta_m, purge_task_id, 1)
|
||||
task_buf(1) = purge_task_id
|
||||
call push_dress_results(zmq_socket_push, -will_send, sum_f, edI_task, edI_index, breve_delta_m, task_buf, 1)
|
||||
end if
|
||||
|
||||
!$OMP END SINGLE
|
||||
call disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id)
|
||||
|
||||
integer, external :: disconnect_from_taskserver
|
||||
if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) == -1) then
|
||||
print *, irp_here, ': Unable to disconnect from task server'
|
||||
stop -1
|
||||
endif
|
||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
call end_zmq_push_socket(zmq_socket_push,thread)
|
||||
!$OMP END PARALLEL
|
||||
do i=0,dress_N_cp+1
|
||||
call omp_destroy_lock(lck_sto(i))
|
||||
end do
|
||||
do i=0,pt2_N_teeth+1
|
||||
call omp_destroy_lock(lck_det(i))
|
||||
end do
|
||||
! do i=0,dress_N_cp+1
|
||||
! call omp_destroy_lock(lck_sto(i))
|
||||
! end do
|
||||
! do i=0,pt2_N_teeth+1
|
||||
! call omp_destroy_lock(lck_det(i))
|
||||
! end do
|
||||
end subroutine
|
||||
|
||||
|
||||
|
@ -26,3 +26,9 @@ doc: Type of zeroth-order Hamiltonian [ EN | Barycentric ]
|
||||
interface: ezfio,provider,ocaml
|
||||
default: EN
|
||||
|
||||
[dress_relative_error]
|
||||
type: Normalized_float
|
||||
doc: Stop stochastic dressing when the relative error is smaller than PT2_relative_error
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 0.01
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
module selection_types
|
||||
type selection_buffer
|
||||
integer :: N, cur
|
||||
integer(8) , pointer :: det(:,:,:)
|
||||
double precision, pointer :: val(:)
|
||||
double precision :: mini
|
||||
endtype
|
||||
end module
|
||||
|
@ -1,159 +0,0 @@
|
||||
program shifted_bk
|
||||
implicit none
|
||||
integer :: i,j,k
|
||||
double precision, allocatable :: pt2(:)
|
||||
integer :: degree
|
||||
integer :: n_det_before
|
||||
double precision :: threshold_davidson_in
|
||||
|
||||
allocate (pt2(N_states))
|
||||
|
||||
double precision :: hf_energy_ref
|
||||
logical :: has
|
||||
double precision :: relative_error, absolute_error
|
||||
integer :: N_states_p
|
||||
character*(512) :: fmt
|
||||
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
PROVIDE psi_bilinear_matrix_transp_order
|
||||
|
||||
|
||||
pt2 = -huge(1.e0)
|
||||
threshold_davidson_in = threshold_davidson
|
||||
threshold_davidson = threshold_davidson_in * 100.d0
|
||||
SOFT_TOUCH threshold_davidson
|
||||
|
||||
call diagonalize_CI_dressed
|
||||
call save_wavefunction
|
||||
|
||||
call ezfio_has_hartree_fock_energy(has)
|
||||
if (has) then
|
||||
call ezfio_get_hartree_fock_energy(hf_energy_ref)
|
||||
else
|
||||
hf_energy_ref = ref_bitmask_energy
|
||||
endif
|
||||
|
||||
if (N_det > N_det_max) then
|
||||
psi_det = psi_det_sorted
|
||||
psi_coef = psi_coef_sorted
|
||||
N_det = N_det_max
|
||||
soft_touch N_det psi_det psi_coef
|
||||
call diagonalize_CI_dressed
|
||||
call save_wavefunction
|
||||
N_states_p = min(N_det,N_states)
|
||||
endif
|
||||
|
||||
n_det_before = 0
|
||||
|
||||
character*(8) :: pt2_string
|
||||
double precision :: threshold_selectors_save, threshold_generators_save
|
||||
threshold_selectors_save = threshold_selectors
|
||||
threshold_generators_save = threshold_generators
|
||||
double precision :: error(N_states), energy(N_states)
|
||||
error = 0.d0
|
||||
|
||||
threshold_selectors = 1.d0
|
||||
threshold_generators = 1d0
|
||||
|
||||
if (.True.) then
|
||||
pt2_string = '(sh-Bk) '
|
||||
do while ( (N_det < N_det_max) )
|
||||
write(*,'(A)') '--------------------------------------------------------------------------------'
|
||||
|
||||
N_det_delta_ij = N_det
|
||||
|
||||
do i=1,N_states
|
||||
energy(i) = psi_energy(i)+nuclear_repulsion
|
||||
enddo
|
||||
|
||||
PROVIDE delta_ij_tmp
|
||||
call delta_ij_done()
|
||||
|
||||
call diagonalize_ci_dressed
|
||||
do i=1,N_states
|
||||
pt2(i) = ci_energy_dressed(i) - energy(i)
|
||||
enddo
|
||||
|
||||
N_states_p = min(N_det,N_states)
|
||||
|
||||
print *, ''
|
||||
print '(A,I12)', 'Summary at N_det = ', N_det
|
||||
print '(A)', '-----------------------------------'
|
||||
print *, ''
|
||||
print *, ''
|
||||
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
write(fmt,*) '(12X,', N_states_p, '(6X,A7,1X,I6,10X))'
|
||||
write(*,fmt) ('State',k, k=1,N_states_p)
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
write(fmt,*) '(A12,', N_states_p, '(1X,F14.8,15X))'
|
||||
write(*,fmt) '# E ', energy(1:N_states_p)
|
||||
if (N_states_p > 1) then
|
||||
write(*,fmt) '# Excit. (au)', energy(1:N_states_p)-energy(1)
|
||||
write(*,fmt) '# Excit. (eV)', (energy(1:N_states_p)-energy(1))*27.211396641308d0
|
||||
endif
|
||||
write(fmt,*) '(A12,', 2*N_states_p, '(1X,F14.8))'
|
||||
write(*,fmt) '# PT2'//pt2_string, (pt2(k), error(k), k=1,N_states_p)
|
||||
write(*,'(A)') '#'
|
||||
write(*,fmt) '# E+PT2 ', (energy(k)+pt2(k),error(k), k=1,N_states_p)
|
||||
if (N_states_p > 1) then
|
||||
write(*,fmt) '# Excit. (au)', ( (energy(k)+pt2(k)-energy(1)-pt2(1)), &
|
||||
dsqrt(error(k)*error(k)+error(1)*error(1)), k=1,N_states_p)
|
||||
write(*,fmt) '# Excit. (eV)', ( (energy(k)+pt2(k)-energy(1)-pt2(1))*27.211396641308d0, &
|
||||
dsqrt(error(k)*error(k)+error(1)*error(1))*27.211396641308d0, k=1,N_states_p)
|
||||
endif
|
||||
write(fmt,*) '(''# ============'',', N_states_p, '(1X,''=============================''))'
|
||||
write(*,fmt)
|
||||
print *, ''
|
||||
|
||||
print *, 'N_det = ', N_det
|
||||
print *, 'N_states = ', N_states
|
||||
|
||||
do k=1, N_states_p
|
||||
print*,'State ',k
|
||||
print *, 'PT2 = ', pt2(k)
|
||||
print *, 'E = ', energy(k)
|
||||
print *, 'E+PT2'//pt2_string//' = ', energy(k)+pt2(k)
|
||||
enddo
|
||||
|
||||
print *, '-----'
|
||||
if(N_states.gt.1)then
|
||||
print *, 'Variational Energy difference (au | eV)'
|
||||
do i=2, N_states_p
|
||||
print*,'Delta E = ', (energy(i) - energy(1)), &
|
||||
(energy(i) - energy(1)) * 27.211396641308d0
|
||||
enddo
|
||||
print *, '-----'
|
||||
print*, 'Variational + perturbative Energy difference (au | eV)'
|
||||
do i=2, N_states_p
|
||||
print*,'Delta E = ', (energy(i)+ pt2(i) - (energy(1) + pt2(1))), &
|
||||
(energy(i)+ pt2(i) - (energy(1) + pt2(1))) * 27.211396641308d0
|
||||
enddo
|
||||
endif
|
||||
call ezfio_set_shiftedbk_energy_pt2(energy(1)+pt2(1))
|
||||
! call dump_fci_iterations_value(N_det,energy,pt2)
|
||||
|
||||
n_det_before = N_det
|
||||
|
||||
PROVIDE psi_coef
|
||||
PROVIDE psi_det
|
||||
PROVIDE psi_det_sorted
|
||||
|
||||
if (N_det >= N_det_max) then
|
||||
threshold_davidson = threshold_davidson_in
|
||||
end if
|
||||
call save_wavefunction
|
||||
call ezfio_set_shiftedbk_energy(energy(1))
|
||||
call ezfio_set_shiftedbk_energy_pt2(ci_energy_dressed(1))
|
||||
enddo
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
@ -1,85 +1,15 @@
|
||||
use selection_types
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ double precision, global_sum_alpha2, (N_states) ]
|
||||
&BEGIN_PROVIDER [ double precision, slave_sum_alpha2, (N_states, Nproc) ]
|
||||
global_sum_alpha2 = 0d0
|
||||
slave_sum_alpha2 = 0d0
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ double precision, fock_diag_tmp_, (2,mo_tot_num+1,Nproc) ]
|
||||
&BEGIN_PROVIDER [ integer, n_det_add ]
|
||||
&BEGIN_PROVIDER [ double precision, a_h_i, (N_det, Nproc) ]
|
||||
&BEGIN_PROVIDER [ double precision, a_s2_i, (N_det, Nproc) ]
|
||||
&BEGIN_PROVIDER [ type(selection_buffer), sb, (Nproc) ]
|
||||
&BEGIN_PROVIDER [ type(selection_buffer), global_sb ]
|
||||
&BEGIN_PROVIDER [ type(selection_buffer), mini_sb ]
|
||||
&BEGIN_PROVIDER [ double precision, N_det_increase_factor ]
|
||||
implicit none
|
||||
fock_diag_tmp_(:,:,:) = 0.d0
|
||||
integer :: i
|
||||
|
||||
N_det_increase_factor = dble(N_states)
|
||||
|
||||
|
||||
n_det_add = max(1, int(float(N_det) * N_det_increase_factor))
|
||||
call create_selection_buffer(n_det_add, n_det_add*2, global_sb)
|
||||
call create_selection_buffer(n_det_add, n_det_add*2, mini_sb)
|
||||
do i=1,Nproc
|
||||
call create_selection_buffer(n_det_add, n_det_add*2, sb(i))
|
||||
end do
|
||||
fock_diag_tmp_(:,:,:) = 0.d0
|
||||
a_h_i = 0d0
|
||||
a_s2_i = 0d0
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ integer, N_dress_int_buffer ]
|
||||
&BEGIN_PROVIDER [ integer, N_dress_double_buffer ]
|
||||
&BEGIN_PROVIDER [ integer, N_dress_det_buffer ]
|
||||
implicit none
|
||||
N_dress_int_buffer = 1
|
||||
N_dress_double_buffer = n_det_add+N_states
|
||||
N_dress_det_buffer = n_det_add
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
subroutine generator_done(i_gen, int_buf, double_buf, det_buf, N_buf, iproc)
|
||||
implicit none
|
||||
integer, intent(in) :: i_gen, iproc
|
||||
integer, intent(out) :: int_buf(N_dress_int_buffer), N_buf(3)
|
||||
double precision, intent(out) :: double_buf(N_dress_double_buffer)
|
||||
integer(bit_kind), intent(out) :: det_buf(N_int, 2, N_dress_det_buffer)
|
||||
integer :: i
|
||||
int_buf(:) = 0
|
||||
|
||||
call sort_selection_buffer(sb(iproc))
|
||||
|
||||
if(sb(iproc)%cur > 0) then
|
||||
!$OMP CRITICAL
|
||||
call merge_selection_buffers(sb(iproc), mini_sb)
|
||||
!call sort_selection_buffer(mini_sb)
|
||||
do i=1,Nproc
|
||||
mini_sb%mini = min(sb(i)%mini, mini_sb%mini)
|
||||
end do
|
||||
do i=1,Nproc
|
||||
sb(i)%mini = mini_sb%mini
|
||||
end do
|
||||
!$OMP END CRITICAL
|
||||
end if
|
||||
call truncate_to_mini(sb(iproc))
|
||||
det_buf(:,:,:sb(iproc)%cur) = sb(iproc)%det(:,:,:sb(iproc)%cur)
|
||||
double_buf(:sb(iproc)%cur) = sb(iproc)%val(:sb(iproc)%cur)
|
||||
double_buf(sb(iproc)%cur+1:sb(iproc)%cur+N_states) = slave_sum_alpha2(:,iproc)
|
||||
N_buf(1) = 1
|
||||
N_buf(2) = sb(iproc)%cur+N_states
|
||||
N_buf(3) = sb(iproc)%cur
|
||||
|
||||
sb(iproc)%cur = 0
|
||||
slave_sum_alpha2(:,iproc) = 0d0
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine generator_start(i_gen, iproc)
|
||||
implicit none
|
||||
integer, intent(in) :: i_gen, iproc
|
||||
@ -89,159 +19,31 @@ subroutine generator_start(i_gen, iproc)
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine dress_pulled(ind, int_buf, double_buf, det_buf, N_buf)
|
||||
use bitmasks
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: ind, N_buf(3)
|
||||
integer, intent(in) :: int_buf(*)
|
||||
double precision, intent(in) :: double_buf(*)
|
||||
integer(bit_kind), intent(in) :: det_buf(N_int,2,*)
|
||||
integer :: i
|
||||
|
||||
do i=1,N_buf(3)
|
||||
call add_to_selection_buffer(global_sb, det_buf(1,1,i), double_buf(i))
|
||||
end do
|
||||
if(N_buf(3) + N_states /= N_buf(2)) stop "buf size"
|
||||
!$OMP CRITICAL
|
||||
global_sum_alpha2(:) += double_buf(N_buf(3)+1:N_buf(2))
|
||||
!$OMP END CRITICAL
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine delta_ij_done()
|
||||
use bitmasks
|
||||
implicit none
|
||||
integer :: i, old_det_gen
|
||||
integer(bit_kind), allocatable :: old_generators(:,:,:)
|
||||
|
||||
allocate(old_generators(N_int, 2, N_det_generators))
|
||||
old_generators(:,:,:) = psi_det_generators(:,:,:N_det_generators)
|
||||
old_det_gen = N_det_generators
|
||||
|
||||
|
||||
! Add buffer only when the last state is computed
|
||||
call unique_selection_buffer(global_sb)
|
||||
call sort_selection_buffer(global_sb)
|
||||
call fill_H_apply_buffer_no_selection(global_sb%cur,global_sb%det,N_int,0)
|
||||
call copy_H_apply_buffer_to_wf()
|
||||
if (s2_eig.or.(N_states > 1) ) then
|
||||
call make_s2_eigenfunction
|
||||
endif
|
||||
call undress_with_alpha(old_generators, old_det_gen, psi_det(1,1,N_det_delta_ij+1), N_det-N_det_delta_ij)
|
||||
call save_wavefunction
|
||||
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine undress_with_alpha(old_generators, old_det_gen, alpha, n_alpha)
|
||||
use bitmasks
|
||||
implicit none
|
||||
|
||||
integer(bit_kind), intent(in) :: alpha(N_int,2,n_alpha)
|
||||
integer, intent(in) :: n_alpha
|
||||
integer, allocatable :: minilist(:)
|
||||
integer(bit_kind), allocatable :: det_minilist(:,:,:)
|
||||
double precision, allocatable :: delta_ij_loc(:,:,:,:)
|
||||
integer :: exc(0:2,2,2), h1, h2, p1, p2, s1, s2
|
||||
integer :: i, j, k, ex, n_minilist, iproc, degree
|
||||
double precision :: haa, contrib, phase, c_alpha(N_states,Nproc), s_c_alpha(N_states)
|
||||
logical :: ok
|
||||
integer, external :: omp_get_thread_num
|
||||
|
||||
integer,intent(in) :: old_det_gen
|
||||
integer(bit_kind), intent(in) :: old_generators(N_int, 2, old_det_gen)
|
||||
|
||||
allocate(minilist(N_det_delta_ij), det_minilist(N_int, 2, N_det_delta_ij), delta_ij_loc(N_states, N_det_delta_ij, 2, Nproc))
|
||||
|
||||
c_alpha = 0d0
|
||||
delta_ij_loc = 0d0
|
||||
|
||||
!$OMP PARALLEL DO DEFAULT(SHARED) SCHEDULE(STATIC) PRIVATE(i, j, iproc, n_minilist, ex) &
|
||||
!$OMP PRIVATE(det_minilist, minilist, haa, contrib, s_c_alpha) &
|
||||
!$OMP PRIVATE(exc, h1, h2, p1, p2, s1, s2, phase, degree, ok)
|
||||
do i=n_alpha,1,-1
|
||||
iproc = omp_get_thread_num()+1
|
||||
if(mod(i,10000) == 0) print *, "UNDRESSING", i, "/", n_alpha, iproc
|
||||
n_minilist = 0
|
||||
ok = .false.
|
||||
|
||||
do j=1, old_det_gen
|
||||
call get_excitation_degree(alpha(1,1,i), old_generators(1,1,j), ex, N_int)
|
||||
if(ex <= 2) then
|
||||
call get_excitation(old_generators(1,1,j), alpha(1,1,i), exc,degree,phase,N_int)
|
||||
call decode_exc(exc,degree,h1,p1,h2,p2,s1,s2)
|
||||
ok = (mo_class(h1)(1:1) == 'A' .or. mo_class(h1)(1:1) == 'I') .and. &
|
||||
(mo_class(p1)(1:1) == 'A' .or. mo_class(p1)(1:1) == 'V')
|
||||
if(ok .and. degree == 2) then
|
||||
ok = (mo_class(h2)(1:1) == 'A' .or. mo_class(h2)(1:1) == 'I') .and. &
|
||||
(mo_class(p2)(1:1) == 'A' .or. mo_class(p2)(1:1) == 'V')
|
||||
end if
|
||||
if(ok) exit
|
||||
end if
|
||||
end do
|
||||
|
||||
if(.not. ok) cycle
|
||||
|
||||
do j=1, N_det_delta_ij
|
||||
call get_excitation_degree(alpha(1,1,i), psi_det(1,1,j), ex, N_int)
|
||||
if(ex <= 2) then
|
||||
n_minilist += 1
|
||||
det_minilist(:,:,n_minilist) = psi_det(:,:,j)
|
||||
minilist(n_minilist) = j
|
||||
end if
|
||||
end do
|
||||
call i_h_j(alpha(1,1,i), alpha(1,1,i), N_int, haa)
|
||||
call dress_with_alpha_(N_states, N_det_delta_ij, N_int, delta_ij_loc(1,1,1,iproc), &
|
||||
minilist, det_minilist, n_minilist, alpha(1,1,i), haa, contrib, s_c_alpha, iproc)
|
||||
|
||||
c_alpha(:,iproc) += s_c_alpha(:)**2
|
||||
end do
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
do i=2,Nproc
|
||||
delta_ij_loc(:,:,:,1) += delta_ij_loc(:,:,:,i)
|
||||
c_alpha(:,1) += c_alpha(:,i)
|
||||
end do
|
||||
|
||||
|
||||
delta_ij_tmp(:,:,1) -= delta_ij_loc(:,:,1,1)
|
||||
delta_ij_tmp(:,:,2) -= delta_ij_loc(:,:,2,1)
|
||||
|
||||
!print *, "SUM ALPHA2 PRE", global_sum_alpha2
|
||||
!global_sum_alpha2(:) -= c_alpha(:,1)
|
||||
print *, "SUM C_ALPHA^2 =", global_sum_alpha2(:)
|
||||
!print *, "*** DRESSINS DIVIDED BY 1+SUM C_ALPHA^2 ***"
|
||||
!do i=1,N_states
|
||||
! delta_ij_tmp(i,:,:) = delta_ij_tmp(i,:,:) / (1d0 + global_sum_alpha2(i))
|
||||
!end do
|
||||
global_sum_alpha2 = 0d0
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine dress_with_alpha_(Nstates,Ndet,Nint,delta_ij_loc,minilist, det_minilist, n_minilist, alpha, haa, contrib, c_alpha, iproc)
|
||||
subroutine dress_with_alpha_buffer(Nstates,Ndet,Nint,delta_ij_loc, i_gen, minilist, det_minilist, n_minilist, alpha, iproc)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
!delta_ij_loc(:,:,1) : dressing column for H
|
||||
!delta_ij_loc(:,:,2) : dressing column for S2
|
||||
!i_gen : generator index in psi_det_generators
|
||||
!minilist : indices of determinants connected to alpha ( in psi_det )
|
||||
!n_minilist : size of minilist
|
||||
!alpha : alpha determinant
|
||||
END_DOC
|
||||
integer, intent(in) :: Nint, Ndet, Nstates, n_minilist, iproc
|
||||
integer, intent(in) :: Nint, Ndet, Nstates, n_minilist, iproc, i_gen
|
||||
integer(bit_kind), intent(in) :: alpha(Nint,2), det_minilist(Nint, 2, n_minilist)
|
||||
integer,intent(in) :: minilist(n_minilist)
|
||||
double precision, intent(inout) :: delta_ij_loc(Nstates,N_det,2)
|
||||
double precision, intent(out) :: contrib, c_alpha(N_states)
|
||||
double precision,intent(in) :: haa
|
||||
double precision :: hij, sij
|
||||
double precision, external :: diag_H_mat_elem_fock
|
||||
integer :: i,j,k,l,m, l_sd
|
||||
double precision :: haa, contrib, c_alpha(N_states)
|
||||
double precision :: de, a_h_psi(N_states)
|
||||
double precision :: hdress, sdress
|
||||
double precision :: de, a_h_psi(Nstates)
|
||||
integer :: i, l_sd
|
||||
|
||||
|
||||
haa = diag_H_mat_elem_fock(psi_det_generators(1,1,i_gen),alpha,fock_diag_tmp_(1,1,iproc),N_int)
|
||||
|
||||
a_h_psi = 0d0
|
||||
|
||||
|
||||
@ -266,44 +68,11 @@ subroutine dress_with_alpha_(Nstates,Ndet,Nint,delta_ij_loc,minilist, det_minili
|
||||
do l_sd=1,n_minilist
|
||||
hdress = c_alpha(i) * a_h_i(l_sd, iproc)
|
||||
sdress = c_alpha(i) * a_s2_i(l_sd, iproc)
|
||||
!if(c_alpha(i) * a_s2_i(l_sd, iproc) > 1d-1) then
|
||||
! call debug_det(det_minilist(1,1,l_sd), N_int)
|
||||
! call debug_det(alpha,N_int)
|
||||
!end if
|
||||
delta_ij_loc(i, minilist(l_sd), 1) += hdress
|
||||
delta_ij_loc(i, minilist(l_sd), 2) += sdress
|
||||
end do
|
||||
end do
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine dress_with_alpha_buffer(Nstates,Ndet,Nint,delta_ij_loc, i_gen, minilist, det_minilist, n_minilist, alpha, iproc)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
!delta_ij_loc(:,:,1) : dressing column for H
|
||||
!delta_ij_loc(:,:,2) : dressing column for S2
|
||||
!i_gen : generator index in psi_det_generators
|
||||
!minilist : indices of determinants connected to alpha ( in psi_det )
|
||||
!n_minilist : size of minilist
|
||||
!alpha : alpha determinant
|
||||
END_DOC
|
||||
integer, intent(in) :: Nint, Ndet, Nstates, n_minilist, iproc, i_gen
|
||||
integer(bit_kind), intent(in) :: alpha(Nint,2), det_minilist(Nint, 2, n_minilist)
|
||||
integer,intent(in) :: minilist(n_minilist)
|
||||
double precision, intent(inout) :: delta_ij_loc(Nstates,N_det,2)
|
||||
double precision, external :: diag_H_mat_elem_fock
|
||||
double precision :: haa, contrib, c_alpha(N_states)
|
||||
|
||||
|
||||
|
||||
haa = diag_H_mat_elem_fock(psi_det_generators(1,1,i_gen),alpha,fock_diag_tmp_(1,1,iproc),N_int)
|
||||
|
||||
call dress_with_alpha_(Nstates, Ndet, Nint, delta_ij_loc, minilist, det_minilist, n_minilist, alpha, haa, contrib, c_alpha, iproc)
|
||||
slave_sum_alpha2(:,iproc) += c_alpha(:)**2
|
||||
if(contrib < sb(iproc)%mini) then
|
||||
call add_to_selection_buffer(sb(iproc), alpha, contrib)
|
||||
end if
|
||||
end subroutine
|
||||
|
||||
|
||||
@ -316,4 +85,3 @@ BEGIN_PROVIDER [ logical, initialize_E0_denominator ]
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
|
||||
|
@ -1,15 +1,170 @@
|
||||
program shifted_bk
|
||||
program shifted_bk_slave
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Helper subroutine to compute the dress in distributed mode.
|
||||
! Helper program to compute the dress in distributed mode.
|
||||
END_DOC
|
||||
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_gen_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
PROVIDE psi_bilinear_matrix_transp_order
|
||||
|
||||
!call diagonalize_CI()
|
||||
call dress_slave()
|
||||
read_wf = .False.
|
||||
distributed_davidson = .False.
|
||||
SOFT_TOUCH read_wf distributed_davidson
|
||||
call provide_all
|
||||
call switch_qp_run_to_master
|
||||
call run_w
|
||||
end
|
||||
|
||||
subroutine provide_all
|
||||
PROVIDE H_apply_buffer_allocated mo_bielec_integrals_in_map psi_det_generators psi_coef_generators psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context N_states_diag
|
||||
PROVIDE dress_e0_denominator mo_tot_num N_int ci_energy mpi_master zmq_state zmq_context
|
||||
PROVIDE psi_det psi_coef threshold_generators threshold_selectors state_average_weight
|
||||
PROVIDE N_det_selectors dress_stoch_istate N_det
|
||||
end
|
||||
|
||||
subroutine run_w
|
||||
use f77_zmq
|
||||
|
||||
implicit none
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
IRP_ENDIF
|
||||
|
||||
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
|
||||
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
||||
double precision :: energy(N_states)
|
||||
character*(64) :: states(3)
|
||||
character*(64) :: old_state
|
||||
integer :: rc, i, ierr
|
||||
double precision :: t0, t1
|
||||
|
||||
integer, external :: zmq_get_dvector, zmq_get_N_det_generators
|
||||
integer, external :: zmq_get_ivector
|
||||
integer, external :: zmq_get_psi, zmq_get_N_det_selectors, zmq_get_int
|
||||
integer, external :: zmq_get_N_states_diag
|
||||
|
||||
zmq_context = f77_zmq_ctx_new ()
|
||||
states(1) = 'selection'
|
||||
states(2) = 'davidson'
|
||||
states(3) = 'dress'
|
||||
old_state = 'Waiting'
|
||||
|
||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||
|
||||
PROVIDE psi_det psi_coef threshold_generators threshold_selectors state_average_weight mpi_master
|
||||
PROVIDE zmq_state N_det_selectors dress_stoch_istate N_det dress_e0_denominator
|
||||
PROVIDE N_det_generators N_states N_states_diag
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
do
|
||||
|
||||
if (mpi_master) then
|
||||
call wait_for_states(states,zmq_state,size(states))
|
||||
if (zmq_state(1:64) == old_state(1:64)) then
|
||||
call sleep(1)
|
||||
cycle
|
||||
else
|
||||
old_state(1:64) = zmq_state(1:64)
|
||||
endif
|
||||
print *, trim(zmq_state)
|
||||
endif
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
call MPI_BCAST (zmq_state, 128, MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here, 'error in broadcast of zmq_state'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
|
||||
if(zmq_state(1:7) == 'Stopped') then
|
||||
exit
|
||||
endif
|
||||
|
||||
|
||||
if (zmq_state(1:8) == 'davidson') then
|
||||
|
||||
! Davidson
|
||||
! --------
|
||||
|
||||
call wall_time(t0)
|
||||
if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle
|
||||
if (zmq_get_N_states_diag(zmq_to_qp_run_socket,1) == -1) cycle
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states_diag) == -1) cycle
|
||||
|
||||
call wall_time(t1)
|
||||
if (mpi_master) then
|
||||
call write_double(6,(t1-t0),'Broadcast time')
|
||||
endif
|
||||
|
||||
call omp_set_nested(.True.)
|
||||
call davidson_slave_tcp(0)
|
||||
call omp_set_nested(.False.)
|
||||
print *, 'Davidson done'
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here, 'error in barrier'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
print *, 'All Davidson done'
|
||||
|
||||
else if (zmq_state(1:5) == 'dress') then
|
||||
|
||||
! Dress
|
||||
! ---
|
||||
|
||||
call wall_time(t0)
|
||||
if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle
|
||||
|
||||
if (zmq_get_N_det_generators (zmq_to_qp_run_socket, 1) == -1) cycle
|
||||
|
||||
if (zmq_get_N_det_selectors(zmq_to_qp_run_socket, 1) == -1) cycle
|
||||
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_generators',threshold_generators,1) == -1) cycle
|
||||
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'threshold_selectors',threshold_selectors,1) == -1) cycle
|
||||
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states) == -1) cycle
|
||||
|
||||
if (zmq_get_int(zmq_to_qp_run_socket,1,'dress_stoch_istate',dress_stoch_istate) == -1) cycle
|
||||
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'state_average_weight',state_average_weight,N_states) == -1) cycle
|
||||
|
||||
psi_energy(1:N_states) = energy(1:N_states)
|
||||
TOUCH psi_energy state_average_weight dress_stoch_istate threshold_selectors threshold_generators
|
||||
if (mpi_master) then
|
||||
print *, 'N_det', N_det
|
||||
print *, 'N_det_generators', N_det_generators
|
||||
print *, 'N_det_selectors', N_det_selectors
|
||||
print *, 'psi_energy', psi_energy
|
||||
print *, 'dress_stoch_istate', dress_stoch_istate
|
||||
print *, 'state_average_weight', state_average_weight
|
||||
endif
|
||||
|
||||
call wall_time(t1)
|
||||
call write_double(6,(t1-t0),'Broadcast time')
|
||||
|
||||
call dress_slave_tcp(0, energy)
|
||||
|
||||
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here, 'error in barrier'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
print *, 'All dress done'
|
||||
|
||||
endif
|
||||
|
||||
end do
|
||||
IRP_IF MPI
|
||||
call MPI_finalize(ierr)
|
||||
IRP_ENDIF
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -32,6 +32,10 @@ BEGIN_PROVIDER [ %(type)s, %(name)s %(size)s ]
|
||||
stop 1
|
||||
endif
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
@ -127,6 +127,10 @@ BEGIN_PROVIDER [ integer, N_generators_bitmask ]
|
||||
ASSERT (N_generators_bitmask > 0)
|
||||
call write_int(6,N_generators_bitmask,'N_generators_bitmask')
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -170,6 +174,10 @@ BEGIN_PROVIDER [ integer, N_generators_bitmask_restart ]
|
||||
ASSERT (N_generators_bitmask_restart > 0)
|
||||
call write_int(6,N_generators_bitmask_restart,'N_generators_bitmask_restart')
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -244,6 +252,10 @@ BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask_restart, (N_int,2,6,N_gen
|
||||
enddo
|
||||
enddo
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -313,6 +325,10 @@ if (mpi_master) then
|
||||
enddo
|
||||
enddo
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -354,6 +370,10 @@ BEGIN_PROVIDER [ integer, N_cas_bitmask ]
|
||||
call write_int(6,N_cas_bitmask,'N_cas_bitmask')
|
||||
endif
|
||||
ASSERT (N_cas_bitmask > 0)
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -407,6 +427,10 @@ BEGIN_PROVIDER [ integer(bit_kind), cas_bitmask, (N_int,2,N_cas_bitmask) ]
|
||||
enddo
|
||||
write(*,*) 'Read CAS bitmask'
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
@ -21,11 +21,15 @@ END_PROVIDER
|
||||
subroutine broadcast_chunks_bit_kind(A, LDA)
|
||||
use bitmasks
|
||||
implicit none
|
||||
integer, intent(in) :: LDA
|
||||
integer*8, intent(in) :: LDA
|
||||
integer(bit_kind), intent(inout) :: A(LDA)
|
||||
BEGIN_DOC
|
||||
! Broadcast with chunks of ~2GB
|
||||
END_DOC
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: i, sze, ierr
|
||||
|
@ -8,7 +8,7 @@ default: 1.e-12
|
||||
type: States_number
|
||||
doc: Number of states to consider during the Davdison diagonalization
|
||||
default: 4
|
||||
interface: ezfio,provider,ocaml
|
||||
interface: ezfio,ocaml
|
||||
|
||||
[davidson_sze_max]
|
||||
type: Strictly_positive_int
|
||||
|
@ -13,7 +13,6 @@ end
|
||||
subroutine davidson_slave_tcp(i)
|
||||
implicit none
|
||||
integer, intent(in) :: i
|
||||
|
||||
call davidson_run_slave(0,i)
|
||||
end
|
||||
|
||||
@ -36,6 +35,8 @@ subroutine davidson_run_slave(thread,iproc)
|
||||
|
||||
integer, external :: connect_to_taskserver
|
||||
|
||||
|
||||
|
||||
if (connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread) == -1) then
|
||||
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
endif
|
||||
@ -74,23 +75,35 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze,
|
||||
! Get wave function (u_t)
|
||||
! -----------------------
|
||||
|
||||
integer :: rc
|
||||
integer :: rc, ni, nj
|
||||
integer*8 :: rc8
|
||||
integer :: N_states_read, N_det_read, psi_det_size_read
|
||||
integer :: N_det_selectors_read, N_det_generators_read
|
||||
double precision, allocatable :: energy(:)
|
||||
|
||||
integer, external :: zmq_get_dvector
|
||||
integer, external :: zmq_get_dmatrix
|
||||
|
||||
allocate(u_t(N_st,N_det))
|
||||
allocate (energy(N_st))
|
||||
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket, worker_id, 'u_t', u_t, size(u_t)) == -1) then
|
||||
! Warning : dimensions are modified for efficiency, It is OK since we get the
|
||||
! full matrix
|
||||
if (size(u_t,kind=8) < 8388608_8) then
|
||||
ni = size(u_t)
|
||||
nj = 1
|
||||
else
|
||||
ni = 8388608
|
||||
nj = size(u_t,kind=8)/8388608_8 + 1
|
||||
endif
|
||||
if (zmq_get_dmatrix(zmq_to_qp_run_socket, worker_id, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1) then
|
||||
print *, irp_here, ': Unable to get u_t'
|
||||
deallocate(u_t,energy)
|
||||
return
|
||||
endif
|
||||
|
||||
if (zmq_get_dvector(zmq_to_qp_run_socket, worker_id, 'energy', energy, size(energy)) == -1) then
|
||||
print *, irp_here, ': Unable to get energy'
|
||||
deallocate(u_t,energy)
|
||||
return
|
||||
endif
|
||||
@ -99,7 +112,7 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze,
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
||||
call broadcast_chunks_double(u_t,size(u_t))
|
||||
call broadcast_chunks_double(u_t,size(u_t,kind=8))
|
||||
|
||||
IRP_ENDIF
|
||||
|
||||
@ -111,7 +124,6 @@ subroutine davidson_slave_work(zmq_to_qp_run_socket, zmq_socket_push, N_st, sze,
|
||||
do
|
||||
integer, external :: get_task_from_taskserver
|
||||
integer, external :: task_done_to_taskserver
|
||||
call sleep(1)
|
||||
if (get_task_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, msg) == -1) then
|
||||
exit
|
||||
endif
|
||||
@ -305,11 +317,12 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze)
|
||||
call new_parallel_job(zmq_to_qp_run_socket,zmq_socket_pull,'davidson')
|
||||
|
||||
character*(512) :: task
|
||||
integer :: rc
|
||||
integer :: rc, ni, nj
|
||||
integer*8 :: rc8
|
||||
double precision :: energy(N_st)
|
||||
|
||||
integer, external :: zmq_put_dvector, zmq_put_psi, zmq_put_N_states_diag
|
||||
integer, external :: zmq_put_dmatrix
|
||||
|
||||
energy = 0.d0
|
||||
|
||||
@ -322,7 +335,16 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze)
|
||||
if (zmq_put_dvector(zmq_to_qp_run_socket,1,'energy',energy,size(energy)) == -1) then
|
||||
stop 'Unable to put energy on ZMQ server'
|
||||
endif
|
||||
if (zmq_put_dvector(zmq_to_qp_run_socket, 1, 'u_t', u_t, size(u_t)) == -1) then
|
||||
if (size(u_t) < 8388608) then
|
||||
ni = size(u_t)
|
||||
nj = 1
|
||||
else
|
||||
ni = 8388608
|
||||
nj = size(u_t)/8388608 + 1
|
||||
endif
|
||||
! Warning : dimensions are modified for efficiency, It is OK since we get the
|
||||
! full matrix
|
||||
if (zmq_put_dmatrix(zmq_to_qp_run_socket, 1, 'u_t', u_t, ni, nj, size(u_t,kind=8)) == -1) then
|
||||
stop 'Unable to put u_t on ZMQ server'
|
||||
endif
|
||||
|
||||
@ -333,14 +355,13 @@ subroutine H_S2_u_0_nstates_zmq(v_0,s_0,u_0,N_st,sze)
|
||||
! ============
|
||||
|
||||
integer :: istep, imin, imax, ishift
|
||||
double precision :: w, max_workload, N_det_inv, di
|
||||
double precision :: w, max_workload, N_det_inv
|
||||
integer, external :: add_task_to_taskserver
|
||||
w = 0.d0
|
||||
istep=1
|
||||
ishift=0
|
||||
imin=1
|
||||
N_det_inv = 1.d0/dble(N_det)
|
||||
di = dble(N_det)
|
||||
max_workload = 50000.d0
|
||||
do imax=1,N_det
|
||||
w = w + 1.d0
|
||||
@ -467,10 +488,13 @@ integer function zmq_get_N_states_diag(zmq_to_qp_run_socket, worker_id)
|
||||
if (rc /= 4) go to 10
|
||||
endif
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
||||
call MPI_BCAST (zmq_get_N_states_diag, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here//': Unable to broadcast N_states'
|
||||
@ -484,6 +508,7 @@ integer function zmq_get_N_states_diag(zmq_to_qp_run_socket, worker_id)
|
||||
endif
|
||||
endif
|
||||
IRP_ENDIF
|
||||
TOUCH N_states_diag
|
||||
|
||||
return
|
||||
|
||||
|
39
src/Davidson/input.irp.f
Normal file
39
src/Davidson/input.irp.f
Normal file
@ -0,0 +1,39 @@
|
||||
BEGIN_PROVIDER [ integer, n_states_diag ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Number of states to consider during the Davdison diagonalization
|
||||
END_DOC
|
||||
|
||||
logical :: has
|
||||
PROVIDE ezfio_filename
|
||||
if (mpi_master) then
|
||||
|
||||
call ezfio_has_davidson_n_states_diag(has)
|
||||
if (has) then
|
||||
call ezfio_get_davidson_n_states_diag(n_states_diag)
|
||||
else
|
||||
print *, 'davidson/n_states_diag not found in EZFIO file'
|
||||
stop 1
|
||||
endif
|
||||
n_states_diag = max(N_states, N_states_diag)
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
call MPI_BCAST( n_states_diag, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
stop 'Unable to read n_states_diag with MPI'
|
||||
endif
|
||||
IRP_ENDIF
|
||||
|
||||
call write_time(6)
|
||||
if (mpi_master) then
|
||||
write(6, *) 'Read n_states_diag'
|
||||
endif
|
||||
|
||||
END_PROVIDER
|
||||
|
@ -9,8 +9,6 @@ subroutine routine
|
||||
implicit none
|
||||
call diagonalize_CI
|
||||
print*,'N_det = ',N_det
|
||||
call save_wavefunction_general(N_det,N_states_diag,psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted)
|
||||
|
||||
|
||||
call save_wavefunction_general(N_det,N_states,psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted)
|
||||
|
||||
end
|
||||
|
@ -2,7 +2,12 @@ program print_energy
|
||||
implicit none
|
||||
read_wf = .true.
|
||||
touch read_wf
|
||||
provide mo_bielec_integrals_in_map
|
||||
double precision :: time1, time0
|
||||
call wall_time(time0)
|
||||
call routine
|
||||
call wall_time(time1)
|
||||
print *, 'Wall time :' , time1 - time0
|
||||
end
|
||||
|
||||
subroutine routine
|
||||
|
@ -398,7 +398,7 @@ BEGIN_PROVIDER [ double precision, c0_weight, (N_states) ]
|
||||
do i=1,N_states
|
||||
c0_weight(i) = 1.d-31
|
||||
c = maxval(psi_coef(:,i) * psi_coef(:,i))
|
||||
c0_weight(i) = 1.d0/c
|
||||
c0_weight(i) = 1.d0/(c+1.d-20)
|
||||
c0_weight(i) = min(c0_weight(i), 100.d0)
|
||||
enddo
|
||||
if (mpi_master) then
|
||||
|
@ -45,6 +45,10 @@ BEGIN_PROVIDER [ integer, N_det ]
|
||||
endif
|
||||
call write_int(6,N_det,'Number of determinants')
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -89,6 +93,10 @@ BEGIN_PROVIDER [ integer, psi_det_size ]
|
||||
psi_det_size = max(psi_det_size,100000)
|
||||
call write_int(6,psi_det_size,'Dimension of the psi arrays')
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -154,6 +162,10 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ]
|
||||
enddo
|
||||
endif
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -212,6 +224,10 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ]
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -520,7 +536,7 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
|
||||
call ezfio_set_determinants_mo_label(mo_label)
|
||||
|
||||
allocate (psi_det_save(N_int,2,ndet))
|
||||
!$OMP PARALLEL DO DEFAULT(NONE) PRIVATE(i,j,k) SHARED(psi_det_save,psidet,ndet,N_int)
|
||||
!$OMP PARALLEL DO DEFAULT(NONE) PRIVATE(i,j,k) SHARED(psi_det_save,psidet,ndet,N_int,accu_norm)
|
||||
do i=1,ndet
|
||||
do j=1,2
|
||||
do k=1,N_int
|
||||
@ -533,23 +549,18 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
|
||||
deallocate (psi_det_save)
|
||||
|
||||
allocate (psi_coef_save(ndet,nstates))
|
||||
double precision :: accu_norm(nstates)
|
||||
double precision :: accu_norm
|
||||
do k=1,nstates
|
||||
accu_norm = 0.d0
|
||||
do k=1,nstates
|
||||
do i=1,ndet
|
||||
accu_norm(k) = accu_norm(k) + psicoef(i,k) * psicoef(i,k)
|
||||
psi_coef_save(i,k) = psicoef(i,k)
|
||||
accu_norm = accu_norm + psicoef(i,k) * psicoef(i,k)
|
||||
enddo
|
||||
if (accu_norm(k) == 0.d0) then
|
||||
accu_norm(k) = 1.e-12
|
||||
if (accu_norm == 0.d0) then
|
||||
accu_norm = 1.e-12
|
||||
endif
|
||||
enddo
|
||||
do k = 1, nstates
|
||||
accu_norm(k) = 1.d0/dsqrt(accu_norm(k))
|
||||
enddo
|
||||
do k=1,nstates
|
||||
accu_norm = 1.d0/dsqrt(accu_norm)
|
||||
do i=1,ndet
|
||||
psi_coef_save(i,k) = psi_coef_save(i,k) * accu_norm(k)
|
||||
psi_coef_save(i,k) = psicoef(i,k) * accu_norm
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
@ -51,9 +51,10 @@ subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint)
|
||||
integer(bit_kind),intent(in) :: o(Nint,2)
|
||||
integer(bit_kind),intent(out) :: d(Nint,2,sze)
|
||||
|
||||
integer :: i, k, nt, na, nd, amax
|
||||
integer :: i, l, k, nt, na, nd, amax
|
||||
integer :: list_todo(2*n_alpha)
|
||||
integer :: list_a(2*n_alpha)
|
||||
integer :: ishift
|
||||
|
||||
amax = n_alpha
|
||||
do k=1,Nint
|
||||
@ -69,7 +70,7 @@ subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint)
|
||||
|
||||
sze = nd
|
||||
|
||||
integer :: ne(2), l
|
||||
integer :: ne(2)
|
||||
l=0
|
||||
do i=1,nd
|
||||
ne(1) = 0
|
||||
@ -90,6 +91,7 @@ subroutine occ_pattern_to_dets(o,d,sze,n_alpha,Nint)
|
||||
|
||||
end
|
||||
|
||||
|
||||
recursive subroutine rec_occ_pattern_to_dets(list_todo,nt,list_a,na,d,nd,sze,amax,Nint)
|
||||
use bitmasks
|
||||
implicit none
|
||||
@ -98,6 +100,7 @@ recursive subroutine rec_occ_pattern_to_dets(list_todo,nt,list_a,na,d,nd,sze,am
|
||||
integer,intent(inout) :: list_todo(nt)
|
||||
integer, intent(inout) :: list_a(na+1),nd
|
||||
integer(bit_kind),intent(inout) :: d(Nint,2,sze)
|
||||
integer :: iint, ipos, i,j,k
|
||||
|
||||
if (na == amax) then
|
||||
nd += 1
|
||||
@ -106,14 +109,17 @@ recursive subroutine rec_occ_pattern_to_dets(list_todo,nt,list_a,na,d,nd,sze,am
|
||||
print *, irp_here, ': sze = ', sze
|
||||
stop 'bug in rec_occ_pattern_to_dets'
|
||||
endif
|
||||
if (na > 0) then
|
||||
call list_to_bitstring( d(1,1,nd), list_a, na, Nint)
|
||||
endif
|
||||
if (nt > 0) then
|
||||
call list_to_bitstring( d(1,2,nd), list_todo, nt, Nint)
|
||||
endif
|
||||
do i=1,na
|
||||
iint = ishft(list_a(i)-1,-bit_kind_shift) + 1
|
||||
ipos = list_a(i)-ishft((iint-1),bit_kind_shift)-1
|
||||
d(iint,1,nd) = ibset( d(iint,1,nd), ipos )
|
||||
enddo
|
||||
do i=1,nt
|
||||
iint = ishft(list_todo(i)-1,-bit_kind_shift) + 1
|
||||
ipos = list_todo(i)-ishft((iint-1),bit_kind_shift)-1
|
||||
d(iint,2,nd) = ibset( d(iint,2,nd), ipos )
|
||||
enddo
|
||||
else
|
||||
integer :: i, j, k
|
||||
integer, allocatable :: list_todo_tmp(:)
|
||||
allocate (list_todo_tmp(nt))
|
||||
do i=1,nt
|
||||
@ -248,6 +254,55 @@ end
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ integer, det_to_occ_pattern, (N_det) ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Returns the index of the occupation pattern for each determinant
|
||||
END_DOC
|
||||
integer :: i,j,k
|
||||
integer(bit_kind) :: occ(N_int,2)
|
||||
logical :: found
|
||||
!$OMP PARALLEL DO DEFAULT(SHARED) &
|
||||
!$OMP PRIVATE(i,k,j,found,occ)
|
||||
do i=1,N_det
|
||||
do k = 1, N_int
|
||||
occ(k,1) = ieor(psi_det(k,1,i),psi_det(k,2,i))
|
||||
occ(k,2) = iand(psi_det(k,1,i),psi_det(k,2,i))
|
||||
enddo
|
||||
do j=1,N_occ_pattern
|
||||
found = .True.
|
||||
do k=1,N_int
|
||||
if ( (occ(k,1) /= psi_occ_pattern(k,1,j)) &
|
||||
.or. (occ(k,2) /= psi_occ_pattern(k,2,j)) ) then
|
||||
found = .False.
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
if (found) then
|
||||
det_to_occ_pattern(i) = j
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ double precision, weight_occ_pattern, (N_occ_pattern,N_states) ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Weight of the occupation patterns in the wave function
|
||||
END_DOC
|
||||
integer :: i,j,k
|
||||
weight_occ_pattern = 0.d0
|
||||
do i=1,N_det
|
||||
j = det_to_occ_pattern(i)
|
||||
do k=1,N_states
|
||||
weight_occ_pattern(j,k) += psi_coef(i,k) * psi_coef(i,k)
|
||||
enddo
|
||||
enddo
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
subroutine make_s2_eigenfunction
|
||||
implicit none
|
||||
integer :: i,j,k
|
||||
@ -268,7 +323,7 @@ subroutine make_s2_eigenfunction
|
||||
smax = s
|
||||
ithread=0
|
||||
!$ ithread = omp_get_thread_num()
|
||||
!$OMP DO
|
||||
!$OMP DO SCHEDULE (dynamic,1000)
|
||||
do i=1,N_occ_pattern
|
||||
call occ_pattern_to_dets_size(psi_occ_pattern(1,1,i),s,elec_alpha_num,N_int)
|
||||
s += 1
|
||||
@ -281,10 +336,7 @@ subroutine make_s2_eigenfunction
|
||||
do j=1,s
|
||||
if (.not. is_in_wavefunction(d(1,1,j), N_int) ) then
|
||||
N_det_new += 1
|
||||
do k=1,N_int
|
||||
det_buffer(k,1,N_det_new) = d(k,1,j)
|
||||
det_buffer(k,2,N_det_new) = d(k,2,j)
|
||||
enddo
|
||||
det_buffer(:,:,N_det_new) = d(:,:,j)
|
||||
if (N_det_new == bufsze) then
|
||||
call fill_H_apply_buffer_no_selection(bufsze,det_buffer,N_int,ithread)
|
||||
N_det_new = 0
|
||||
|
@ -167,7 +167,7 @@ subroutine decode_exc(exc,degree,h1,p1,h2,p2,s1,s2)
|
||||
end select
|
||||
end
|
||||
|
||||
subroutine get_double_excitation_ref(det1,det2,exc,phase,Nint)
|
||||
subroutine get_double_excitation(det1,det2,exc,phase,Nint)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
@ -335,112 +335,6 @@ subroutine get_phasemask_bit(det1, pm, Nint)
|
||||
end subroutine
|
||||
|
||||
|
||||
subroutine get_double_excitation(det1,det2,exc,phase,Nint)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Returns the two excitation operators between two doubly excited determinants and the phase
|
||||
END_DOC
|
||||
integer, intent(in) :: Nint
|
||||
integer(bit_kind), intent(in) :: det1(Nint,2)
|
||||
integer(bit_kind), intent(in) :: det2(Nint,2)
|
||||
integer, intent(out) :: exc(0:2,2,2)
|
||||
double precision, intent(out) :: phase
|
||||
integer :: tz
|
||||
integer :: l, ispin, idx_hole, idx_particle, ishift
|
||||
integer :: nperm
|
||||
integer :: i,j,k,m,n
|
||||
integer :: high, low
|
||||
integer :: a,b,c,d
|
||||
integer(bit_kind) :: hole, particle, tmp, pm(Nint,2)
|
||||
double precision, parameter :: phase_dble(0:1) = (/ 1.d0, -1.d0 /)
|
||||
double precision :: refaz
|
||||
logical :: ok
|
||||
|
||||
ASSERT (Nint > 0)
|
||||
|
||||
!do ispin=1,2
|
||||
!tmp = 0_8
|
||||
!do i=1,Nint
|
||||
! pm(i,ispin) = xor(det1(i,ispin), ishft(det1(i,ispin), 1))
|
||||
! pm(i,ispin) = xor(pm(i,ispin), ishft(pm(i,ispin), 2))
|
||||
! pm(i,ispin) = xor(pm(i,ispin), ishft(pm(i,ispin), 4))
|
||||
! pm(i,ispin) = xor(pm(i,ispin), ishft(pm(i,ispin), 8))
|
||||
! pm(i,ispin) = xor(pm(i,ispin), ishft(pm(i,ispin), 16))
|
||||
! pm(i,ispin) = xor(pm(i,ispin), ishft(pm(i,ispin), 32))
|
||||
! pm(i,ispin) = xor(pm(i,ispin), tmp)
|
||||
! if(iand(popcnt(det1(i,ispin)), 1) == 1) tmp = not(tmp)
|
||||
!end do
|
||||
!end do
|
||||
call get_phasemask_bit(det1, pm, Nint)
|
||||
nperm = 0
|
||||
exc(0,1,1) = 0
|
||||
exc(0,2,1) = 0
|
||||
exc(0,1,2) = 0
|
||||
exc(0,2,2) = 0
|
||||
do ispin = 1,2
|
||||
idx_particle = 0
|
||||
idx_hole = 0
|
||||
ishift = 1-bit_kind_size
|
||||
!par = 0
|
||||
do l=1,Nint
|
||||
ishift = ishift + bit_kind_size
|
||||
if (det1(l,ispin) == det2(l,ispin)) then
|
||||
cycle
|
||||
endif
|
||||
tmp = xor( det1(l,ispin), det2(l,ispin) )
|
||||
particle = iand(tmp, det2(l,ispin))
|
||||
hole = iand(tmp, det1(l,ispin))
|
||||
do while (particle /= 0_bit_kind)
|
||||
tz = trailz(particle)
|
||||
nperm = nperm + iand(ishft(pm(l,ispin), -tz), 1)
|
||||
idx_particle = idx_particle + 1
|
||||
exc(0,2,ispin) = exc(0,2,ispin) + 1
|
||||
exc(idx_particle,2,ispin) = tz+ishift
|
||||
particle = iand(particle,particle-1_bit_kind)
|
||||
enddo
|
||||
if (iand(exc(0,1,ispin),exc(0,2,ispin))==2) then ! exc(0,1,ispin)==2 or exc(0,2,ispin)==2
|
||||
exit
|
||||
endif
|
||||
do while (hole /= 0_bit_kind)
|
||||
tz = trailz(hole)
|
||||
nperm = nperm + iand(ishft(pm(l,ispin), -tz), 1)
|
||||
idx_hole = idx_hole + 1
|
||||
exc(0,1,ispin) = exc(0,1,ispin) + 1
|
||||
exc(idx_hole,1,ispin) = tz+ishift
|
||||
hole = iand(hole,hole-1_bit_kind)
|
||||
enddo
|
||||
if (iand(exc(0,1,ispin),exc(0,2,ispin))==2) then ! exc(0,1,ispin)==2 or exc(0,2,ispin)
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
|
||||
select case (exc(0,1,ispin))
|
||||
case(0)
|
||||
cycle
|
||||
|
||||
case(1)
|
||||
if(exc(1,1,ispin) < exc(1,2,ispin)) nperm = nperm+1
|
||||
|
||||
case (2)
|
||||
a = exc(1,1,ispin)
|
||||
b = exc(1,2,ispin)
|
||||
c = exc(2,1,ispin)
|
||||
d = exc(2,2,ispin)
|
||||
|
||||
if(min(a,c) > max(b,d) .or. min(b,d) > max(a,c) .or. (a-b)*(c-d)<0) then
|
||||
nperm = nperm + 1
|
||||
end if
|
||||
exit
|
||||
end select
|
||||
|
||||
enddo
|
||||
phase = phase_dble(iand(nperm,1))
|
||||
!call get_double_excitation_ref(det1,det2,exc,refaz,Nint)
|
||||
!if(phase == refaz) then
|
||||
! print *, "phase", phase, refaz, n, exc(0,1,1)
|
||||
!end if
|
||||
end
|
||||
|
||||
subroutine get_mono_excitation(det1,det2,exc,phase,Nint)
|
||||
use bitmasks
|
||||
|
@ -1,12 +1,17 @@
|
||||
program s2_eig_restart
|
||||
implicit none
|
||||
read_wf = .True.
|
||||
if (s2_eig) then
|
||||
call routine_s2
|
||||
else
|
||||
call routine
|
||||
endif
|
||||
end
|
||||
|
||||
subroutine routine
|
||||
implicit none
|
||||
integer :: ndet_max
|
||||
print*, 'How many determinants would you like ?'
|
||||
print*, 'Max number of determinants ?'
|
||||
read(5,*)ndet_max
|
||||
integer(bit_kind), allocatable :: psi_det_tmp(:,:,:)
|
||||
double precision, allocatable :: psi_coef_tmp(:,:)
|
||||
@ -34,6 +39,53 @@ subroutine routine
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call save_wavefunction_general(ndet_max,N_states,psi_det_tmp,N_det_max,psi_coef_tmp)
|
||||
call save_wavefunction_general(ndet_max,N_states,psi_det_tmp,size(psi_coef_tmp,1),psi_coef_tmp)
|
||||
|
||||
end
|
||||
|
||||
subroutine routine_s2
|
||||
implicit none
|
||||
integer :: ndet_max
|
||||
double precision :: wmin
|
||||
integer(bit_kind), allocatable :: psi_det_tmp(:,:,:)
|
||||
double precision, allocatable :: psi_coef_tmp(:,:)
|
||||
integer :: i,j,k
|
||||
double precision :: accu(N_states)
|
||||
|
||||
print*, 'Min weight of the occupation pattern ?'
|
||||
read(5,*) wmin
|
||||
|
||||
ndet_max = 0
|
||||
do i=1,N_det
|
||||
if (maxval(weight_occ_pattern( det_to_occ_pattern(i),:)) < wmin) cycle
|
||||
ndet_max = ndet_max+1
|
||||
enddo
|
||||
|
||||
allocate(psi_det_tmp(N_int,2,ndet_max),psi_coef_tmp(ndet_max, N_states))
|
||||
|
||||
accu = 0.d0
|
||||
k=0
|
||||
do i = 1, N_det
|
||||
if (maxval(weight_occ_pattern( det_to_occ_pattern(i),:)) < wmin) cycle
|
||||
k = k+1
|
||||
do j = 1, N_int
|
||||
psi_det_tmp(j,1,k) = psi_det(j,1,i)
|
||||
psi_det_tmp(j,2,k) = psi_det(j,2,i)
|
||||
enddo
|
||||
do j = 1, N_states
|
||||
psi_coef_tmp(k,j) = psi_coef(i,j)
|
||||
accu(j) += psi_coef_tmp(k,j) **2
|
||||
enddo
|
||||
enddo
|
||||
do j = 1, N_states
|
||||
accu(j) = 1.d0/dsqrt(accu(j))
|
||||
enddo
|
||||
do j = 1, N_states
|
||||
do i = 1, ndet_max
|
||||
psi_coef_tmp(i,j) = psi_coef_tmp(i,j) * accu(j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call save_wavefunction_general(ndet_max,N_states,psi_det_tmp,size(psi_coef_tmp,1),psi_coef_tmp)
|
||||
|
||||
end
|
||||
|
@ -11,8 +11,8 @@ integer function zmq_put_psi(zmq_to_qp_run_socket,worker_id)
|
||||
integer, external :: zmq_put_N_states
|
||||
integer, external :: zmq_put_N_det
|
||||
integer, external :: zmq_put_psi_det_size
|
||||
integer, external :: zmq_put_psi_det
|
||||
integer, external :: zmq_put_psi_coef
|
||||
integer*8, external :: zmq_put_psi_det
|
||||
integer*8, external :: zmq_put_psi_coef
|
||||
|
||||
zmq_put_psi = 0
|
||||
if (zmq_put_N_states(zmq_to_qp_run_socket, worker_id) == -1) then
|
||||
@ -112,6 +112,10 @@ integer function zmq_get_$X(zmq_to_qp_run_socket, worker_id)
|
||||
endif
|
||||
|
||||
10 continue
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -136,7 +140,7 @@ psi_det_size ;;
|
||||
|
||||
END_TEMPLATE
|
||||
|
||||
integer function zmq_put_psi_det(zmq_to_qp_run_socket,worker_id)
|
||||
integer*8 function zmq_put_psi_det(zmq_to_qp_run_socket,worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
@ -144,33 +148,24 @@ integer function zmq_put_psi_det(zmq_to_qp_run_socket,worker_id)
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer :: rc
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put_psi_det = 0
|
||||
integer*8 :: zmq_put_i8matrix
|
||||
integer :: ni, nj
|
||||
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'put_data '//trim(zmq_state), worker_id, 'psi_det'
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put_psi_det = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc8 = f77_zmq_send8(zmq_to_qp_run_socket,psi_det,int(N_int*2_8*N_det*bit_kind,8),0)
|
||||
if (rc8 /= N_int*2_8*N_det*bit_kind) then
|
||||
zmq_put_psi_det = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
zmq_put_psi_det = -1
|
||||
return
|
||||
if (size(psi_det,kind=8) <= 8388608_8) then
|
||||
ni = size(psi_det,kind=4)
|
||||
nj = 1
|
||||
else
|
||||
ni = 8388608_8
|
||||
nj = int(size(psi_det,kind=8)/8388608_8,4) + 1
|
||||
endif
|
||||
rc8 = zmq_put_i8matrix(zmq_to_qp_run_socket, 1, 'psi_det', psi_det, ni, nj, size(psi_det,kind=8))
|
||||
zmq_put_psi_det = rc8
|
||||
end
|
||||
|
||||
integer function zmq_put_psi_coef(zmq_to_qp_run_socket,worker_id)
|
||||
integer*8 function zmq_put_psi_coef(zmq_to_qp_run_socket,worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
@ -178,31 +173,75 @@ integer function zmq_put_psi_coef(zmq_to_qp_run_socket,worker_id)
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer :: rc
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put_psi_coef = 0
|
||||
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'put_data '//trim(zmq_state), worker_id, 'psi_coef'
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put_psi_coef = -1
|
||||
return
|
||||
endif
|
||||
integer*8 :: zmq_put_dmatrix
|
||||
integer :: ni, nj
|
||||
|
||||
rc8 = f77_zmq_send8(zmq_to_qp_run_socket,psi_coef,int(psi_det_size*N_states*8_8,8),0)
|
||||
if (rc8 /= psi_det_size*N_states*8_8) then
|
||||
zmq_put_psi_coef = -1
|
||||
return
|
||||
if (size(psi_coef,kind=8) <= 8388608_8) then
|
||||
ni = size(psi_coef,kind=4)
|
||||
nj = 1
|
||||
else
|
||||
ni = 8388608
|
||||
nj = int(size(psi_coef,kind=8)/8388608_8,4) + 1
|
||||
endif
|
||||
rc8 = zmq_put_dmatrix(zmq_to_qp_run_socket, 1, 'psi_coef', psi_coef, ni, nj, size(psi_coef,kind=8) )
|
||||
zmq_put_psi_coef = rc8
|
||||
end
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
zmq_put_psi_coef = -1
|
||||
return
|
||||
integer*8 function zmq_get_psi_det(zmq_to_qp_run_socket,worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get psi_det on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
integer*8 :: zmq_get_i8matrix
|
||||
integer :: ni, nj
|
||||
|
||||
if (size(psi_det,kind=8) <= 8388608_8) then
|
||||
ni = size(psi_det,kind=4)
|
||||
nj = 1
|
||||
else
|
||||
ni = 8388608
|
||||
nj = int(size(psi_det,kind=8)/8388608_8,4) + 1
|
||||
endif
|
||||
rc8 = zmq_get_i8matrix(zmq_to_qp_run_socket, 1, 'psi_det', psi_det, ni, nj, size(psi_det,kind=8))
|
||||
zmq_get_psi_det = rc8
|
||||
end
|
||||
|
||||
integer*8 function zmq_get_psi_coef(zmq_to_qp_run_socket,worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! get psi_coef on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_get_psi_coef = 0_8
|
||||
|
||||
integer*8 :: zmq_get_dmatrix
|
||||
integer :: ni, nj
|
||||
|
||||
if (size(psi_coef,kind=8) <= 8388608_8) then
|
||||
ni = size(psi_coef,kind=4)
|
||||
nj = 1
|
||||
else
|
||||
ni = 8388608
|
||||
nj = int(size(psi_coef,kind=8)/8388608_8,4) + 1
|
||||
endif
|
||||
rc8 = zmq_get_dmatrix(zmq_to_qp_run_socket, 1, 'psi_coef', psi_coef, ni, nj, size(psi_coef,kind=8) )
|
||||
zmq_get_psi_coef = rc8
|
||||
end
|
||||
|
||||
!---------------------------------------------------------------------------
|
||||
@ -220,8 +259,8 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id)
|
||||
integer, external :: zmq_get_N_states
|
||||
integer, external :: zmq_get_N_det
|
||||
integer, external :: zmq_get_psi_det_size
|
||||
integer, external :: zmq_get_psi_det
|
||||
integer, external :: zmq_get_psi_coef
|
||||
integer*8, external :: zmq_get_psi_det
|
||||
integer*8, external :: zmq_get_psi_coef
|
||||
|
||||
zmq_get_psi = 0
|
||||
|
||||
@ -238,21 +277,21 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id)
|
||||
return
|
||||
endif
|
||||
|
||||
if (size(psi_det) /= N_int*2_8*psi_det_size*bit_kind) then
|
||||
if (size(psi_det,kind=8) /= N_int*2_8*psi_det_size*bit_kind) then
|
||||
deallocate(psi_det)
|
||||
allocate(psi_det(N_int,2,psi_det_size))
|
||||
endif
|
||||
|
||||
if (size(psi_coef) /= psi_det_size*N_states) then
|
||||
if (size(psi_coef,kind=8) /= psi_det_size*N_states) then
|
||||
deallocate(psi_coef)
|
||||
allocate(psi_coef(psi_det_size,N_states))
|
||||
endif
|
||||
|
||||
if (zmq_get_psi_det(zmq_to_qp_run_socket, worker_id) == -1) then
|
||||
if (zmq_get_psi_det(zmq_to_qp_run_socket, worker_id) == -1_8) then
|
||||
zmq_get_psi = -1
|
||||
return
|
||||
endif
|
||||
if (zmq_get_psi_coef(zmq_to_qp_run_socket, worker_id) == -1) then
|
||||
if (zmq_get_psi_coef(zmq_to_qp_run_socket, worker_id) == -1_8) then
|
||||
zmq_get_psi = -1
|
||||
return
|
||||
endif
|
||||
@ -261,101 +300,5 @@ integer function zmq_get_psi(zmq_to_qp_run_socket, worker_id)
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_get_psi_det(zmq_to_qp_run_socket, worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get psi_det from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer :: rc
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
zmq_get_psi_det = 0
|
||||
if (mpi_master) then
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'get_data '//trim(zmq_state), worker_id, 'psi_det'
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get_psi_det = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
zmq_get_psi_det = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc8 = f77_zmq_recv8(zmq_to_qp_run_socket,psi_det,int(N_int*2_8*N_det*bit_kind,8),0)
|
||||
if (rc8 /= N_int*2_8*N_det*bit_kind) then
|
||||
zmq_get_psi_det = -1
|
||||
go to 10
|
||||
endif
|
||||
endif
|
||||
|
||||
10 continue
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
call MPI_BCAST (zmq_get_psi_det, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
stop 'Unable to broadcast zmq_get_psi_det'
|
||||
endif
|
||||
call broadcast_chunks_bit_kind(psi_det,size(psi_det))
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
integer function zmq_get_psi_coef(zmq_to_qp_run_socket, worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get psi_coef from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer :: rc
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state psi_det_size
|
||||
zmq_get_psi_coef = 0
|
||||
if (mpi_master) then
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'get_data '//trim(zmq_state), worker_id, 'psi_coef'
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get_psi_coef = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
zmq_get_psi_coef = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc8 = f77_zmq_recv8(zmq_to_qp_run_socket,psi_coef,int(psi_det_size*N_states*8_8,8),0)
|
||||
if (rc8 /= psi_det_size*N_states*8_8) then
|
||||
zmq_get_psi_coef = -1
|
||||
go to 10
|
||||
endif
|
||||
endif
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
call MPI_BCAST (zmq_get_psi_coef, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
stop 'Unable to broadcast zmq_get_psi_coef'
|
||||
endif
|
||||
call broadcast_chunks_double(psi_coef,size(psi_coef))
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -9,6 +9,10 @@ BEGIN_PROVIDER [ integer, mo_tot_num ]
|
||||
if (mpi_master) then
|
||||
call ezfio_has_mo_basis_mo_tot_num(has)
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -71,6 +75,10 @@ BEGIN_PROVIDER [ double precision, mo_coef, (ao_num,mo_tot_num) ]
|
||||
! Coefs
|
||||
call ezfio_has_mo_basis_mo_coef(exists)
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -136,6 +144,10 @@ BEGIN_PROVIDER [ character*(64), mo_label ]
|
||||
endif
|
||||
write(*,*) '* mo_label ', trim(mo_label)
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -198,6 +210,10 @@ BEGIN_PROVIDER [ double precision, mo_occ, (mo_tot_num) ]
|
||||
endif
|
||||
write(*,*) 'Read mo_occ'
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
@ -65,11 +65,15 @@ BEGIN_TEMPLATE
|
||||
|
||||
subroutine broadcast_chunks_$double(A, LDA)
|
||||
implicit none
|
||||
integer, intent(in) :: LDA
|
||||
integer*8, intent(in) :: LDA
|
||||
$type, intent(inout) :: A(LDA)
|
||||
BEGIN_DOC
|
||||
! Broadcast with chunks of ~2GB
|
||||
END_DOC
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: i, sze, ierr
|
||||
@ -80,6 +84,7 @@ subroutine broadcast_chunks_$double(A, LDA)
|
||||
print *, irp_here//': Unable to broadcast chunks $double ', i
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
enddo
|
||||
IRP_ENDIF
|
||||
end
|
||||
|
@ -54,6 +54,10 @@ BEGIN_PROVIDER [ double precision, nucl_coord, (nucl_num,3) ]
|
||||
|
||||
endif
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -159,6 +163,10 @@ BEGIN_PROVIDER [ double precision, nuclear_repulsion ]
|
||||
endif
|
||||
print*, 'Read nuclear_repulsion'
|
||||
endif
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
@ -228,6 +236,10 @@ END_PROVIDER
|
||||
close(10)
|
||||
endif
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
include 'mpif.h'
|
||||
integer :: ierr
|
||||
|
@ -8,7 +8,7 @@ integer function zmq_put_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer, intent(in) :: size_x
|
||||
double precision, intent(out) :: x(size_x)
|
||||
double precision, intent(in) :: x(size_x)
|
||||
integer :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
@ -48,7 +48,6 @@ integer function zmq_get_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
character*(*), intent(in) :: name
|
||||
double precision, intent(out) :: x(size_x)
|
||||
integer :: rc
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
@ -60,17 +59,20 @@ integer function zmq_get_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get_dvector = -1
|
||||
print *, irp_here, 'rc /= len(trim(msg))', rc, len(trim(msg))
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
print *, irp_here, 'msg(1:14) /= get_data_reply', msg(1:14)
|
||||
zmq_get_dvector = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,x,size_x*8,0)
|
||||
if (rc /= size_x*8) then
|
||||
print *, irp_here, 'rc /= size_x*8', rc, size_x*8
|
||||
zmq_get_dvector = -1
|
||||
go to 10
|
||||
endif
|
||||
@ -78,6 +80,10 @@ integer function zmq_get_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
integer :: ierr
|
||||
include 'mpif.h'
|
||||
@ -86,11 +92,8 @@ integer function zmq_get_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
print *, irp_here//': Unable to broadcast zmq_get_dvector'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BCAST (x, size_x, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here//': Unable to broadcast dvector'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
call broadcast_chunks_double(x, int(size_x,8))
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
@ -107,7 +110,7 @@ integer function zmq_put_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer, intent(in) :: size_x
|
||||
integer, intent(out) :: x(size_x)
|
||||
integer, intent(in) :: x(size_x)
|
||||
integer :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
@ -147,7 +150,6 @@ integer function zmq_get_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
character*(*), intent(in) :: name
|
||||
integer, intent(out) :: x(size_x)
|
||||
integer :: rc
|
||||
integer*8 :: rc8
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
@ -177,6 +179,10 @@ integer function zmq_get_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
integer :: ierr
|
||||
include 'mpif.h'
|
||||
@ -185,14 +191,537 @@ integer function zmq_get_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_
|
||||
print *, irp_here//': Unable to broadcast zmq_get_ivector'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BCAST (x, size_x, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
call broadcast_chunks_integer(x, int(size_x,8))
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_put8_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_x)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Put a float vector on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer*8, intent(in) :: size_x
|
||||
double precision, intent(in) :: x(size_x)
|
||||
integer*8 :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put8_dvector = 0
|
||||
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'put_data '//trim(zmq_state), worker_id, name
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put8_dvector = -1
|
||||
print *, 'Failed in put_data'
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_send8(zmq_to_qp_run_socket,x,size_x*8_8,0)
|
||||
if (rc /= size_x*8_8) then
|
||||
print *, 'Failed in send ', rc, size_x*8, size_x
|
||||
zmq_put8_dvector = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
print *, 'Failed in recv ', rc
|
||||
zmq_put8_dvector = -1
|
||||
return
|
||||
endif
|
||||
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_get8_dvector(zmq_to_qp_run_socket, worker_id, name, x, size_x)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get a float vector from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer*8, intent(in) :: size_x
|
||||
character*(*), intent(in) :: name
|
||||
double precision, intent(out) :: x(size_x)
|
||||
integer*8 :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
! Success
|
||||
zmq_get8_dvector = 0
|
||||
|
||||
if (mpi_master) then
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'get_data '//trim(zmq_state), worker_id, name
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get8_dvector = -1
|
||||
print *, irp_here, 'rc /= len(trim(msg))', rc, len(trim(msg))
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
print *, irp_here, 'msg(1:14) /= get_data_reply', msg(1:14)
|
||||
zmq_get8_dvector = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv8(zmq_to_qp_run_socket,x,size_x*8_8,0)
|
||||
if (rc /= size_x*8) then
|
||||
print *, irp_here, 'rc /= size_x*8', rc, size_x*8_8
|
||||
zmq_get8_dvector = -1
|
||||
go to 10
|
||||
endif
|
||||
endif
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
integer :: ierr
|
||||
include 'mpif.h'
|
||||
call MPI_BCAST (zmq_get8_dvector, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here//': Unable to broadcast ivector'
|
||||
print *, irp_here//': Unable to broadcast zmq_get8_dvector'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
call broadcast_chunks_double(x, size_x)
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
integer function zmq_put_dmatrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Put a float vector on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer, intent(in) :: size_x1, size_x2
|
||||
integer*8, intent(in) :: sze
|
||||
double precision, intent(in) :: x(size_x1, size_x2)
|
||||
integer*8 :: rc, ni
|
||||
integer :: j
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put_dmatrix = 0
|
||||
|
||||
ni = size_x1
|
||||
do j=1,size_x2
|
||||
if (j == size_x2) then
|
||||
ni = int(sze - int(j-1,8)*int(size_x1,8),8)
|
||||
endif
|
||||
write(msg,'(A,1X,I8,1X,A,I8.8)') 'put_data '//trim(zmq_state), worker_id, trim(name), j
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put_dmatrix = -1
|
||||
print *, 'Failed in put_data', rc, j
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_send8(zmq_to_qp_run_socket,x(1,j),ni*8_8,0)
|
||||
if (rc /= ni*8_8) then
|
||||
print *, 'Failed in send ', rc, j
|
||||
zmq_put_dmatrix = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
print *, 'Failed in recv ', rc, j
|
||||
zmq_put_dmatrix = -1
|
||||
return
|
||||
endif
|
||||
enddo
|
||||
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_get_dmatrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get a float vector from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer, intent(in) :: size_x1, size_x2
|
||||
integer*8, intent(in) :: sze
|
||||
character*(*), intent(in) :: name
|
||||
double precision, intent(out) :: x(size_x1,size_x2)
|
||||
integer*8 :: rc, ni
|
||||
integer*8 :: j
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
! Success
|
||||
zmq_get_dmatrix = 0
|
||||
|
||||
if (mpi_master) then
|
||||
ni = size_x1
|
||||
do j=1, size_x2
|
||||
if (j == size_x2) then
|
||||
ni = sze - (j-1)*size_x1
|
||||
endif
|
||||
write(msg,'(A,1X,I8,1X,A,I8.8)') 'get_data '//trim(zmq_state), worker_id, trim(name),j
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get_dmatrix = -1
|
||||
print *, irp_here, 'rc /= len(trim(msg))', rc, len(trim(msg))
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
print *, irp_here, 'msg(1:14) /= get_data_reply', msg(1:14)
|
||||
zmq_get_dmatrix = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv8(zmq_to_qp_run_socket,x(1,j),ni*8_8,0)
|
||||
if (rc /= ni*8_8) then
|
||||
print *, irp_here, 'rc /= size_x1*8', rc, ni*8_8
|
||||
zmq_get_dmatrix = -1
|
||||
go to 10
|
||||
endif
|
||||
enddo
|
||||
endif
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
integer :: ierr
|
||||
include 'mpif.h'
|
||||
call MPI_BCAST (zmq_get_dmatrix, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here//': Unable to broadcast zmq_get_dmatrix'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
call broadcast_chunks_double(x, sze)
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
integer function zmq_put8_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_x)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Put a vector of integers on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer*8, intent(in) :: size_x
|
||||
integer, intent(in) :: x(size_x)
|
||||
integer*8 :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put8_ivector = 0
|
||||
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'put_data '//trim(zmq_state), worker_id, name
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put8_ivector = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_send8(zmq_to_qp_run_socket,x,size_x*4_8,0)
|
||||
if (rc /= size_x*4_8) then
|
||||
zmq_put8_ivector = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
zmq_put8_ivector = -1
|
||||
return
|
||||
endif
|
||||
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_get8_ivector(zmq_to_qp_run_socket, worker_id, name, x, size_x)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get a vector of integers from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer*8, intent(in) :: size_x
|
||||
character*(*), intent(in) :: name
|
||||
integer, intent(out) :: x(size_x)
|
||||
integer*8 :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
! Success
|
||||
zmq_get8_ivector = 0
|
||||
|
||||
if (mpi_master) then
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'get_data '//trim(zmq_state), worker_id, name
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get8_ivector = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
zmq_get8_ivector = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv8(zmq_to_qp_run_socket,x,size_x*4_8,0)
|
||||
if (rc /= size_x*4) then
|
||||
zmq_get8_ivector = -1
|
||||
go to 10
|
||||
endif
|
||||
endif
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
integer :: ierr
|
||||
include 'mpif.h'
|
||||
call MPI_BCAST (zmq_get8_ivector, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here//': Unable to broadcast zmq_get8_ivector'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
call broadcast_chunks_integer(x, size_x)
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
integer function zmq_put_int(zmq_to_qp_run_socket, worker_id, name, x)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Put a vector of integers on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer, intent(in) :: x
|
||||
integer :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put_int = 0
|
||||
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'put_data '//trim(zmq_state), worker_id, name
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put_int = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,x,4,0)
|
||||
if (rc /= 4) then
|
||||
zmq_put_int = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
zmq_put_int = -1
|
||||
return
|
||||
endif
|
||||
|
||||
end
|
||||
|
||||
integer function zmq_get_int(zmq_to_qp_run_socket, worker_id, name, x)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get a vector of integers from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*), intent(in) :: name
|
||||
integer, intent(out) :: x
|
||||
integer :: rc
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
! Success
|
||||
zmq_get_int = 0
|
||||
|
||||
if (mpi_master) then
|
||||
write(msg,'(A,1X,I8,1X,A200)') 'get_data '//trim(zmq_state), worker_id, name
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get_int = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
zmq_get_int = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,x,4,0)
|
||||
if (rc /= 4) then
|
||||
zmq_get_int = -1
|
||||
go to 10
|
||||
endif
|
||||
endif
|
||||
|
||||
10 continue
|
||||
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_put_i8matrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Put a float vector on the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
character*(*) :: name
|
||||
integer, intent(in) :: size_x1, size_x2
|
||||
integer*8, intent(in) :: sze
|
||||
integer*8, intent(in) :: x(size_x1, size_x2)
|
||||
integer*8 :: rc, ni
|
||||
integer*8 :: j
|
||||
character*(256) :: msg
|
||||
|
||||
zmq_put_i8matrix = 0
|
||||
|
||||
ni = size_x1
|
||||
do j=1,size_x2
|
||||
if (j == size_x2) then
|
||||
ni = sze - (j-1_8)*int(size_x1,8)
|
||||
endif
|
||||
write(msg,'(A,1X,I8,1X,A,I8.8)') 'put_data '//trim(zmq_state), worker_id, trim(name), j
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),ZMQ_SNDMORE)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_put_i8matrix = -1
|
||||
print *, irp_here, 'Failed in put_data', rc, j
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_send8(zmq_to_qp_run_socket,x(1,j),ni*8_8,0)
|
||||
if (rc /= ni*8_8) then
|
||||
print *, irp_here, 'Failed in send ', rc, j
|
||||
zmq_put_i8matrix = -1
|
||||
return
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:rc) /= 'put_data_reply ok') then
|
||||
print *, irp_here, 'Failed in recv ', rc, j
|
||||
zmq_put_i8matrix = -1
|
||||
return
|
||||
endif
|
||||
enddo
|
||||
|
||||
end
|
||||
|
||||
|
||||
integer function zmq_get_i8matrix(zmq_to_qp_run_socket, worker_id, name, x, size_x1, size_x2, sze)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Get a float vector from the qp_run scheduler
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
integer, intent(in) :: worker_id
|
||||
integer, intent(in) :: size_x1, size_x2
|
||||
integer*8, intent(in) :: sze
|
||||
character*(*), intent(in) :: name
|
||||
double precision, intent(out) :: x(size_x1,size_x2)
|
||||
integer*8 :: rc, ni
|
||||
integer*8 :: j
|
||||
character*(256) :: msg
|
||||
|
||||
PROVIDE zmq_state
|
||||
! Success
|
||||
zmq_get_i8matrix = 0
|
||||
|
||||
if (mpi_master) then
|
||||
ni = size_x1
|
||||
do j=1, size_x2
|
||||
if (j == size_x2) then
|
||||
ni = sze - (j-1)*size_x1
|
||||
endif
|
||||
write(msg,'(A,1X,I8,1X,A,I8.8)') 'get_data '//trim(zmq_state), worker_id, trim(name),j
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
|
||||
if (rc /= len(trim(msg))) then
|
||||
zmq_get_i8matrix = -1
|
||||
print *, irp_here, 'rc /= len(trim(msg))', rc, len(trim(msg))
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv(zmq_to_qp_run_socket,msg,len(msg),0)
|
||||
if (msg(1:14) /= 'get_data_reply') then
|
||||
print *, irp_here, 'msg(1:14) /= get_data_reply', msg(1:14)
|
||||
zmq_get_i8matrix = -1
|
||||
go to 10
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv8(zmq_to_qp_run_socket,x(1,j),ni*8_8,0)
|
||||
if (rc /= ni*8_8) then
|
||||
print *, irp_here, 'rc /= ni*8', rc, ni*8_8
|
||||
zmq_get_i8matrix = -1
|
||||
go to 10
|
||||
endif
|
||||
enddo
|
||||
endif
|
||||
|
||||
10 continue
|
||||
|
||||
IRP_IF MPI_DEBUG
|
||||
print *, irp_here, mpi_rank
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
IRP_ENDIF
|
||||
IRP_IF MPI
|
||||
integer :: ierr
|
||||
include 'mpif.h'
|
||||
call MPI_BCAST (zmq_get_i8matrix, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
|
||||
if (ierr /= MPI_SUCCESS) then
|
||||
print *, irp_here//': Unable to broadcast zmq_get_i8matrix'
|
||||
stop -1
|
||||
endif
|
||||
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
|
||||
call broadcast_chunks_double(x, sze)
|
||||
IRP_ENDIF
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user