10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-27 06:43:48 +01:00
quantum_package/plugins/Full_CI_ZMQ/selection_slave.irp.f

117 lines
3.0 KiB
Fortran
Raw Normal View History

2016-08-01 16:05:40 +02:00
program selection_slave
implicit none
BEGIN_DOC
! Helper program to compute the PT2 in distributed mode.
END_DOC
read_wf = .False.
2017-05-24 15:24:20 +02:00
distributed_davidson = .False.
SOFT_TOUCH read_wf distributed_davidson
2016-08-01 16:05:40 +02:00
call provide_everything
call switch_qp_run_to_master
call run_wf
end
subroutine provide_everything
2018-05-18 23:12:19 +02:00
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
2016-08-01 16:05:40 +02:00
end
subroutine run_wf
use f77_zmq
2018-05-18 23:12:19 +02:00
2016-08-01 16:05:40 +02:00
implicit none
2018-05-18 23:12:19 +02:00
IRP_IF MPI
include 'mpif.h'
IRP_ENDIF
2016-08-01 16:05:40 +02:00
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
2016-11-16 15:18:24 +01:00
double precision :: energy(N_states)
2018-05-18 23:12:19 +02:00
character*(64) :: states(2)
2017-07-20 01:35:00 +02:00
integer :: rc, i, ierr
2018-05-18 23:12:19 +02:00
double precision :: t0, t1
2016-08-01 16:05:40 +02:00
2018-05-18 23:12:19 +02:00
integer, external :: zmq_get_dvector, zmq_get_N_det_generators
integer, external :: zmq_get_psi, zmq_get_N_det_selectors
integer, external :: zmq_get_N_states_diag
2016-08-01 16:05:40 +02:00
call provide_everything
zmq_context = f77_zmq_ctx_new ()
2016-10-06 16:39:34 +02:00
states(1) = 'selection'
2018-05-18 23:12:19 +02:00
states(2) = 'pt2'
2016-08-01 16:05:40 +02:00
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
do
2016-10-06 16:39:34 +02:00
2018-05-18 23:12:19 +02:00
call wait_for_states(states,zmq_state,size(states))
print *, trim(zmq_state)
2016-10-06 16:39:34 +02:00
2018-05-18 23:12:19 +02:00
if(zmq_state(1:7) == 'Stopped') then
2016-10-06 16:39:34 +02:00
exit
2018-05-18 23:12:19 +02:00
else if (zmq_state(1:9) == 'selection') then
2016-10-06 16:39:34 +02:00
! Selection
! ---------
2018-05-18 23:12:19 +02:00
call wall_time(t0)
2017-11-29 15:15:10 +01:00
if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle
2018-05-18 23:12:19 +02:00
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
2017-11-29 13:52:52 +01:00
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states) == -1) cycle
2018-05-18 23:12:19 +02:00
call wall_time(t1)
call write_double(6,(t1-t0),'Broadcast time')
2016-08-01 16:05:40 +02:00
2016-10-06 16:39:34 +02:00
!$OMP PARALLEL PRIVATE(i)
i = omp_get_thread_num()
2017-05-24 15:24:20 +02:00
call run_selection_slave(0,i,energy)
2016-10-06 16:39:34 +02:00
!$OMP END PARALLEL
print *, 'Selection done'
2018-05-18 23:12:19 +02:00
else if (zmq_state(1:3) == 'pt2') then
2017-05-24 15:24:20 +02:00
! PT2
! ---
print *, 'PT2'
2018-05-18 23:12:19 +02:00
call wall_time(t0)
2017-11-29 15:15:10 +01:00
if (zmq_get_psi(zmq_to_qp_run_socket,1) == -1) cycle
2017-11-29 13:52:52 +01:00
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'energy',energy,N_states) == -1) cycle
2018-05-18 23:12:19 +02:00
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
call wall_time(t1)
call write_double(6,(t1-t0),'Broadcast time')
2017-05-24 15:24:20 +02:00
logical :: lstop
lstop = .False.
!$OMP PARALLEL PRIVATE(i)
i = omp_get_thread_num()
call run_pt2_slave(0,i,energy,lstop)
!$OMP END PARALLEL
print *, 'PT2 done'
2016-10-06 16:39:34 +02:00
endif
2018-05-18 23:12:19 +02:00
IRP_IF MPI
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
print *, irp_here, 'error in barrier'
endif
IRP_ENDIF
2016-08-01 16:05:40 +02:00
end do
2018-05-18 23:12:19 +02:00
IRP_IF MPI
call MPI_finalize(i)
IRP_ENDIF
2016-08-01 16:05:40 +02:00
end