mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-08-29 20:23:40 +02:00
Merge pull request #50 from QuantumPackage/bugfix
Fix bug with deterministic PT2
This commit is contained in:
commit
a6c95879de
@ -148,7 +148,7 @@ subroutine run_pt2_slave_small(thread,iproc,energy)
|
|||||||
integer, external :: disconnect_from_taskserver
|
integer, external :: disconnect_from_taskserver
|
||||||
do i=1,300
|
do i=1,300
|
||||||
if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) /= -2) exit
|
if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) /= -2) exit
|
||||||
call sleep(1)
|
call usleep(500)
|
||||||
print *, 'Retry disconnect...'
|
print *, 'Retry disconnect...'
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ subroutine run_selection_slave(thread,iproc,energy)
|
|||||||
if(done .or. ctask == size(task_id)) then
|
if(done .or. ctask == size(task_id)) then
|
||||||
do i=1, ctask
|
do i=1, ctask
|
||||||
if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id(i)) == -1) then
|
if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id(i)) == -1) then
|
||||||
call sleep(1)
|
call usleep(100)
|
||||||
if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id(i)) == -1) then
|
if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id(i)) == -1) then
|
||||||
ctask = 0
|
ctask = 0
|
||||||
done = .true.
|
done = .true.
|
||||||
@ -85,6 +85,7 @@ subroutine run_selection_slave(thread,iproc,energy)
|
|||||||
if(ctask > 0) then
|
if(ctask > 0) then
|
||||||
call sort_selection_buffer(buf)
|
call sort_selection_buffer(buf)
|
||||||
! call merge_selection_buffers(buf,buf2)
|
! call merge_selection_buffers(buf,buf2)
|
||||||
|
print *, task_id(1), pt2(1), buf%cur, ctask
|
||||||
call push_selection_results(zmq_socket_push, pt2, variance, norm, buf, task_id(1), ctask)
|
call push_selection_results(zmq_socket_push, pt2, variance, norm, buf, task_id(1), ctask)
|
||||||
! buf%mini = buf2%mini
|
! buf%mini = buf2%mini
|
||||||
pt2(:) = 0d0
|
pt2(:) = 0d0
|
||||||
@ -132,7 +133,6 @@ subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_
|
|||||||
print *, 'f77_zmq_send( zmq_socket_push, b%cur, 4, ZMQ_SNDMORE)'
|
print *, 'f77_zmq_send( zmq_socket_push, b%cur, 4, ZMQ_SNDMORE)'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (b%cur > 0) then
|
|
||||||
|
|
||||||
rc = f77_zmq_send( zmq_socket_push, pt2, 8*N_states, ZMQ_SNDMORE)
|
rc = f77_zmq_send( zmq_socket_push, pt2, 8*N_states, ZMQ_SNDMORE)
|
||||||
if(rc /= 8*N_states) then
|
if(rc /= 8*N_states) then
|
||||||
@ -149,6 +149,8 @@ subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_
|
|||||||
print *, 'f77_zmq_send( zmq_socket_push, norm, 8*N_states, ZMQ_SNDMORE)'
|
print *, 'f77_zmq_send( zmq_socket_push, norm, 8*N_states, ZMQ_SNDMORE)'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if (b%cur > 0) then
|
||||||
|
|
||||||
rc = f77_zmq_send( zmq_socket_push, b%val(1), 8*b%cur, ZMQ_SNDMORE)
|
rc = f77_zmq_send( zmq_socket_push, b%val(1), 8*b%cur, ZMQ_SNDMORE)
|
||||||
if(rc /= 8*b%cur) then
|
if(rc /= 8*b%cur) then
|
||||||
print *, 'f77_zmq_send( zmq_socket_push, b%val(1), 8*b%cur, ZMQ_SNDMORE)'
|
print *, 'f77_zmq_send( zmq_socket_push, b%val(1), 8*b%cur, ZMQ_SNDMORE)'
|
||||||
@ -203,7 +205,10 @@ subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det
|
|||||||
print *, 'f77_zmq_recv( zmq_socket_pull, N, 4, 0)'
|
print *, 'f77_zmq_recv( zmq_socket_pull, N, 4, 0)'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (N>0) then
|
pt2(:) = 0.d0
|
||||||
|
variance(:) = 0.d0
|
||||||
|
norm(:) = 0.d0
|
||||||
|
|
||||||
rc = f77_zmq_recv( zmq_socket_pull, pt2, N_states*8, 0)
|
rc = f77_zmq_recv( zmq_socket_pull, pt2, N_states*8, 0)
|
||||||
if(rc /= 8*N_states) then
|
if(rc /= 8*N_states) then
|
||||||
print *, 'f77_zmq_recv( zmq_socket_pull, pt2, N_states*8, 0)'
|
print *, 'f77_zmq_recv( zmq_socket_pull, pt2, N_states*8, 0)'
|
||||||
@ -219,6 +224,7 @@ subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det
|
|||||||
print *, 'f77_zmq_recv( zmq_socket_pull, norm, N_states*8, 0)'
|
print *, 'f77_zmq_recv( zmq_socket_pull, norm, N_states*8, 0)'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if (N>0) then
|
||||||
rc = f77_zmq_recv( zmq_socket_pull, val(1), 8*N, 0)
|
rc = f77_zmq_recv( zmq_socket_pull, val(1), 8*N, 0)
|
||||||
if(rc /= 8*N) then
|
if(rc /= 8*N) then
|
||||||
print *, 'f77_zmq_recv( zmq_socket_pull, val(1), 8*N, 0)'
|
print *, 'f77_zmq_recv( zmq_socket_pull, val(1), 8*N, 0)'
|
||||||
@ -228,10 +234,6 @@ subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det
|
|||||||
if(rc /= bit_kind*N_int*2*N) then
|
if(rc /= bit_kind*N_int*2*N) then
|
||||||
print *, 'f77_zmq_recv( zmq_socket_pull, det(1,1,1), bit_kind*N_int*2*N, 0)'
|
print *, 'f77_zmq_recv( zmq_socket_pull, det(1,1,1), bit_kind*N_int*2*N, 0)'
|
||||||
endif
|
endif
|
||||||
else
|
|
||||||
pt2(:) = 0.d0
|
|
||||||
variance(:) = 0.d0
|
|
||||||
norm(:) = 0.d0
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
rc = f77_zmq_recv( zmq_socket_pull, ntask, 4, 0)
|
rc = f77_zmq_recv( zmq_socket_pull, ntask, 4, 0)
|
||||||
|
@ -63,7 +63,7 @@ subroutine run_slave_main
|
|||||||
if (mpi_master) then
|
if (mpi_master) then
|
||||||
call wait_for_states(states,zmq_state,size(states))
|
call wait_for_states(states,zmq_state,size(states))
|
||||||
if (zmq_state(1:64) == old_state(1:64)) then
|
if (zmq_state(1:64) == old_state(1:64)) then
|
||||||
call sleep(1)
|
call usleep(200)
|
||||||
cycle
|
cycle
|
||||||
else
|
else
|
||||||
old_state(1:64) = zmq_state(1:64)
|
old_state(1:64) = zmq_state(1:64)
|
||||||
|
@ -39,6 +39,8 @@ BEGIN_PROVIDER [ character*(128), ezfio_filename ]
|
|||||||
write(command,*) 'echo 15 > /proc//'//trim(adjustl(pidc))//'/oom_adj'
|
write(command,*) 'echo 15 > /proc//'//trim(adjustl(pidc))//'/oom_adj'
|
||||||
call system(command)
|
call system(command)
|
||||||
|
|
||||||
|
PROVIDE file_lock
|
||||||
|
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
BEGIN_PROVIDER [ character*(128), ezfio_work_dir ]
|
BEGIN_PROVIDER [ character*(128), ezfio_work_dir ]
|
||||||
|
@ -43,8 +43,13 @@ subroutine run
|
|||||||
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
|
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
|
||||||
relative_error=PT2_relative_error
|
relative_error=PT2_relative_error
|
||||||
|
|
||||||
|
if (do_pt2) then
|
||||||
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||||
norm,0) ! Stochastic PT2
|
norm,0) ! Stochastic PT2
|
||||||
|
else
|
||||||
|
call ZMQ_selection(0, pt2, variance, norm)
|
||||||
|
endif
|
||||||
|
|
||||||
do k=1,N_states
|
do k=1,N_states
|
||||||
rpt2(k) = pt2(k)/(1.d0 + norm(k))
|
rpt2(k) = pt2(k)/(1.d0 + norm(k))
|
||||||
enddo
|
enddo
|
||||||
|
19
src/utils/c_functions.f90
Normal file
19
src/utils/c_functions.f90
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module c_functions
|
||||||
|
use iso_c_binding
|
||||||
|
|
||||||
|
interface
|
||||||
|
subroutine usleep_c(us) bind (C,name="usleep")
|
||||||
|
use iso_c_binding
|
||||||
|
integer(c_int), value :: us
|
||||||
|
end subroutine usleep_c
|
||||||
|
end interface
|
||||||
|
|
||||||
|
end module
|
||||||
|
|
||||||
|
subroutine usleep(us)
|
||||||
|
use c_functions
|
||||||
|
use iso_c_binding
|
||||||
|
implicit none
|
||||||
|
integer, intent(in) :: us
|
||||||
|
call usleep_c(int(us,c_int))
|
||||||
|
end
|
@ -15,6 +15,7 @@ BEGIN_PROVIDER [ integer, qp_max_mem ]
|
|||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
subroutine resident_memory(value)
|
subroutine resident_memory(value)
|
||||||
|
use c_functions
|
||||||
implicit none
|
implicit none
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Returns the current used memory in gigabytes used by the current process.
|
! Returns the current used memory in gigabytes used by the current process.
|
||||||
@ -25,6 +26,8 @@ subroutine resident_memory(value)
|
|||||||
double precision, intent(out) :: value
|
double precision, intent(out) :: value
|
||||||
|
|
||||||
call omp_set_lock(file_lock)
|
call omp_set_lock(file_lock)
|
||||||
|
call usleep(10)
|
||||||
|
|
||||||
value = 0.d0
|
value = 0.d0
|
||||||
iunit = getUnitAndOpen('/proc/self/status','r')
|
iunit = getUnitAndOpen('/proc/self/status','r')
|
||||||
do
|
do
|
||||||
|
@ -275,7 +275,6 @@ IRP_ENDIF
|
|||||||
rc = f77_zmq_bind(new_zmq_pull_socket, zmq_socket_pull_tcp_address)
|
rc = f77_zmq_bind(new_zmq_pull_socket, zmq_socket_pull_tcp_address)
|
||||||
if (rc /= 0) then
|
if (rc /= 0) then
|
||||||
icount = icount-1
|
icount = icount-1
|
||||||
! call sleep(3)
|
|
||||||
zmq_socket_pull_tcp_address = 'tcp://*:'//zmq_port(2+icount*100)//' '
|
zmq_socket_pull_tcp_address = 'tcp://*:'//zmq_port(2+icount*100)//' '
|
||||||
zmq_socket_push_tcp_address = trim(qp_run_address)//':'//zmq_port(2+icount*100)//' '
|
zmq_socket_push_tcp_address = trim(qp_run_address)//':'//zmq_port(2+icount*100)//' '
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user