10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-29 16:34:50 +02:00

Introduced MPI for EZFIO accesses

This commit is contained in:
Anthony Scemama 2017-11-28 00:54:22 +01:00
parent 6b0b988ee8
commit 1a5a4d5ff2
15 changed files with 427 additions and 205 deletions

View File

@ -42,7 +42,7 @@ subroutine zmq_get_$X(zmq_to_qp_run_socket, worker_id)
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
integer, intent(in) :: worker_id integer, intent(in) :: worker_id
integer :: rc integer :: rc
character*(64) :: msg character*(256) :: msg
write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, '$X' write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, '$X'
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0) rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)

View File

@ -22,14 +22,24 @@ BEGIN_PROVIDER [ %(type)s, %(name)s %(size)s ]
logical :: has logical :: has
PROVIDE ezfio_filename PROVIDE ezfio_filename
%(test_null_size)s if (mpi_master) then
call ezfio_has_%(ezfio_dir)s_%(ezfio_name)s(has) %(test_null_size)s
if (has) then call ezfio_has_%(ezfio_dir)s_%(ezfio_name)s(has)
call ezfio_get_%(ezfio_dir)s_%(ezfio_name)s(%(name)s) if (has) then
else call ezfio_get_%(ezfio_dir)s_%(ezfio_name)s(%(name)s)
print *, '%(ezfio_dir)s/%(ezfio_name)s not found in EZFIO file' else
stop 1 print *, '%(ezfio_dir)s/%(ezfio_name)s not found in EZFIO file'
stop 1
endif
endif endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( %(name)s, %(size_mpi)s, %(type_mpi)s, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read %(name)s with MPI'
endif
IRP_ENDIF
%(write)s %(write)s
END_PROVIDER END_PROVIDER
""".strip() """.strip()
@ -38,6 +48,12 @@ END_PROVIDER
"logical": "write_bool", "logical": "write_bool",
"double precision": "write_double"} "double precision": "write_double"}
mpi_correspondance = {"integer": "MPI_INTEGER",
"integer*8": "MPI_INTEGER8",
"character*(32)": "MPI_CHARACTER",
"logical": "MPI_LOGICAL",
"double precision": "MPI_DOUBLE_PRECISION"}
def __init__(self): def __init__(self):
self.values = "type doc name ezfio_dir ezfio_name write output".split() self.values = "type doc name ezfio_dir ezfio_name write output".split()
for v in self.values: for v in self.values:
@ -66,10 +82,11 @@ END_PROVIDER
def set_write(self): def set_write(self):
self.write = "" self.write = ""
self.type_mpi = self.mpi_correspondance[self.type]
if "size" in self.__dict__: if "size" in self.__dict__:
return return
else: else:
if self.type in self.write_correspondance: if self.type in self.mpi_correspondance:
write = self.write_correspondance[self.type] write = self.write_correspondance[self.type]
output = self.output output = self.output
name = self.name name = self.name
@ -101,7 +118,9 @@ END_PROVIDER
self.output = t self.output = t
def set_size(self, t): def set_size(self, t):
self.size_mpi = t.replace(',',')*(').replace('0:','1+')
if (self.type == "character*(32)"):
self.size_mpi += "*32"
if t != "1": if t != "1":
self.size = ", " + t self.size = ", " + t
else: else:

View File

@ -1,8 +1,9 @@
BEGIN_PROVIDER [ integer, ao_prim_num_max ] BEGIN_PROVIDER [ integer, ao_prim_num_max ]
implicit none implicit none
ao_prim_num_max = 0 BEGIN_DOC
PROVIDE ezfio_filename ! max number of primitives
call ezfio_get_ao_basis_ao_prim_num_max(ao_prim_num_max) END_DOC
ao_prim_num_max = maxval(ao_prim_num)
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, ao_coef_normalized, (ao_num,ao_prim_num_max) ] BEGIN_PROVIDER [ double precision, ao_coef_normalized, (ao_num,ao_prim_num_max) ]

View File

@ -102,25 +102,44 @@ BEGIN_PROVIDER [ integer, N_generators_bitmask ]
logical :: exists logical :: exists
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_has_bitmasks_N_mask_gen(exists) if (mpi_master) then
if (exists) then call ezfio_has_bitmasks_N_mask_gen(exists)
call ezfio_get_bitmasks_N_mask_gen(N_generators_bitmask) if (exists) then
integer :: N_int_check call ezfio_get_bitmasks_N_mask_gen(N_generators_bitmask)
integer :: bit_kind_check integer :: N_int_check
call ezfio_get_bitmasks_bit_kind(bit_kind_check) integer :: bit_kind_check
if (bit_kind_check /= bit_kind) then call ezfio_get_bitmasks_bit_kind(bit_kind_check)
print *, bit_kind_check, bit_kind if (bit_kind_check /= bit_kind) then
print *, 'Error: bit_kind is not correct in EZFIO file' print *, bit_kind_check, bit_kind
endif print *, 'Error: bit_kind is not correct in EZFIO file'
call ezfio_get_bitmasks_N_int(N_int_check) endif
if (N_int_check /= N_int) then call ezfio_get_bitmasks_N_int(N_int_check)
print *, N_int_check, N_int if (N_int_check /= N_int) then
print *, 'Error: N_int is not correct in EZFIO file' print *, N_int_check, N_int
endif print *, 'Error: N_int is not correct in EZFIO file'
else endif
N_generators_bitmask = 1 else
N_generators_bitmask = 1
endif
ASSERT (N_generators_bitmask > 0)
endif endif
ASSERT (N_generators_bitmask > 0) IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( N_generators_bitmask, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read N_generators_bitmask with MPI'
endif
call MPI_BCAST( bit_kind, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read bit_kind with MPI'
endif
call MPI_BCAST( N_int, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read N_int with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
@ -133,25 +152,40 @@ BEGIN_PROVIDER [ integer, N_generators_bitmask_restart ]
logical :: exists logical :: exists
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_has_bitmasks_N_mask_gen(exists) if (mpi_master) then
if (exists) then call ezfio_has_bitmasks_N_mask_gen(exists)
call ezfio_get_bitmasks_N_mask_gen(N_generators_bitmask_restart) if (exists) then
integer :: N_int_check call ezfio_get_bitmasks_N_mask_gen(N_generators_bitmask_restart)
integer :: bit_kind_check integer :: N_int_check
call ezfio_get_bitmasks_bit_kind(bit_kind_check) integer :: bit_kind_check
if (bit_kind_check /= bit_kind) then call ezfio_get_bitmasks_bit_kind(bit_kind_check)
print *, bit_kind_check, bit_kind if (bit_kind_check /= bit_kind) then
print *, 'Error: bit_kind is not correct in EZFIO file' print *, bit_kind_check, bit_kind
endif print *, 'Error: bit_kind is not correct in EZFIO file'
call ezfio_get_bitmasks_N_int(N_int_check) endif
if (N_int_check /= N_int) then call ezfio_get_bitmasks_N_int(N_int_check)
print *, N_int_check, N_int if (N_int_check /= N_int) then
print *, 'Error: N_int is not correct in EZFIO file' print *, N_int_check, N_int
endif print *, 'Error: N_int is not correct in EZFIO file'
else endif
N_generators_bitmask_restart = 1 else
N_generators_bitmask_restart = 1
endif
ASSERT (N_generators_bitmask_restart > 0)
endif endif
ASSERT (N_generators_bitmask_restart > 0) IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( bit_kind, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read bit_kind with MPI'
endif
call MPI_BCAST( N_generators_bitmask_restart, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read N_generators_bitmask_restart with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
@ -182,38 +216,49 @@ BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask_restart, (N_int,2,6,N_gen
logical :: exists logical :: exists
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_has_bitmasks_generators(exists) if (mpi_master) then
if (exists) then call ezfio_has_bitmasks_generators(exists)
call ezfio_get_bitmasks_generators(generators_bitmask_restart) if (exists) then
else call ezfio_get_bitmasks_generators(generators_bitmask_restart)
integer :: k, ispin else
do k=1,N_generators_bitmask integer :: k, ispin
do ispin=1,2 do k=1,N_generators_bitmask
do i=1,N_int do ispin=1,2
generators_bitmask_restart(i,ispin,s_hole ,k) = full_ijkl_bitmask(i) do i=1,N_int
generators_bitmask_restart(i,ispin,s_part ,k) = full_ijkl_bitmask(i) generators_bitmask_restart(i,ispin,s_hole ,k) = full_ijkl_bitmask(i)
generators_bitmask_restart(i,ispin,d_hole1,k) = full_ijkl_bitmask(i) generators_bitmask_restart(i,ispin,s_part ,k) = full_ijkl_bitmask(i)
generators_bitmask_restart(i,ispin,d_part1,k) = full_ijkl_bitmask(i) generators_bitmask_restart(i,ispin,d_hole1,k) = full_ijkl_bitmask(i)
generators_bitmask_restart(i,ispin,d_hole2,k) = full_ijkl_bitmask(i) generators_bitmask_restart(i,ispin,d_part1,k) = full_ijkl_bitmask(i)
generators_bitmask_restart(i,ispin,d_part2,k) = full_ijkl_bitmask(i) generators_bitmask_restart(i,ispin,d_hole2,k) = full_ijkl_bitmask(i)
generators_bitmask_restart(i,ispin,d_part2,k) = full_ijkl_bitmask(i)
enddo
enddo enddo
enddo enddo
enddo endif
endif
integer :: i
do k=1,N_generators_bitmask
do ispin=1,2
do i=1,N_int
generators_bitmask_restart(i,ispin,s_hole ,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,s_hole,k) )
generators_bitmask_restart(i,ispin,s_part ,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,s_part,k) )
generators_bitmask_restart(i,ispin,d_hole1,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_hole1,k) )
generators_bitmask_restart(i,ispin,d_part1,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_part1,k) )
generators_bitmask_restart(i,ispin,d_hole2,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_hole2,k) )
generators_bitmask_restart(i,ispin,d_part2,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_part2,k) )
enddo
enddo
enddo
endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( generators_bitmask_restart, N_int*2*6*N_generators_bitmask_restart, MPI_BIT_KIND, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read generators_bitmask_restart with MPI'
endif
IRP_ENDIF
integer :: i
do k=1,N_generators_bitmask
do ispin=1,2
do i=1,N_int
generators_bitmask_restart(i,ispin,s_hole ,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,s_hole,k) )
generators_bitmask_restart(i,ispin,s_part ,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,s_part,k) )
generators_bitmask_restart(i,ispin,d_hole1,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_hole1,k) )
generators_bitmask_restart(i,ispin,d_part1,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_part1,k) )
generators_bitmask_restart(i,ispin,d_hole2,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_hole2,k) )
generators_bitmask_restart(i,ispin,d_part2,k) = iand(full_ijkl_bitmask(i),generators_bitmask_restart(i,ispin,d_part2,k) )
enddo
enddo
enddo
END_PROVIDER END_PROVIDER
@ -241,6 +286,7 @@ BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask, (N_int,2,6,N_generators_
logical :: exists logical :: exists
PROVIDE ezfio_filename PROVIDE ezfio_filename
if (mpi_master) then
call ezfio_has_bitmasks_generators(exists) call ezfio_has_bitmasks_generators(exists)
if (exists) then if (exists) then
call ezfio_get_bitmasks_generators(generators_bitmask) call ezfio_get_bitmasks_generators(generators_bitmask)
@ -272,6 +318,16 @@ BEGIN_PROVIDER [ integer(bit_kind), generators_bitmask, (N_int,2,6,N_generators_
enddo enddo
enddo enddo
enddo enddo
endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( generators_bitmask, N_int*2*6*N_generators_bitmask, MPI_BIT_KIND, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read generators_bitmask with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ integer, N_cas_bitmask ] BEGIN_PROVIDER [ integer, N_cas_bitmask ]
@ -282,25 +338,35 @@ BEGIN_PROVIDER [ integer, N_cas_bitmask ]
logical :: exists logical :: exists
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_has_bitmasks_N_mask_cas(exists) if (mpi_master) then
if (exists) then call ezfio_has_bitmasks_N_mask_cas(exists)
call ezfio_get_bitmasks_N_mask_cas(N_cas_bitmask) if (exists) then
integer :: N_int_check call ezfio_get_bitmasks_N_mask_cas(N_cas_bitmask)
integer :: bit_kind_check integer :: N_int_check
call ezfio_get_bitmasks_bit_kind(bit_kind_check) integer :: bit_kind_check
if (bit_kind_check /= bit_kind) then call ezfio_get_bitmasks_bit_kind(bit_kind_check)
print *, bit_kind_check, bit_kind if (bit_kind_check /= bit_kind) then
print *, 'Error: bit_kind is not correct in EZFIO file' print *, bit_kind_check, bit_kind
endif print *, 'Error: bit_kind is not correct in EZFIO file'
call ezfio_get_bitmasks_N_int(N_int_check) endif
if (N_int_check /= N_int) then call ezfio_get_bitmasks_N_int(N_int_check)
print *, N_int_check, N_int if (N_int_check /= N_int) then
print *, 'Error: N_int is not correct in EZFIO file' print *, N_int_check, N_int
endif print *, 'Error: N_int is not correct in EZFIO file'
else endif
N_cas_bitmask = 1 else
N_cas_bitmask = 1
endif
endif endif
ASSERT (N_cas_bitmask > 0) ASSERT (N_cas_bitmask > 0)
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( N_cas_bitmask, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read N_cas_bitmask with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
@ -313,35 +379,46 @@ BEGIN_PROVIDER [ integer(bit_kind), cas_bitmask, (N_int,2,N_cas_bitmask) ]
integer :: i,i_part,i_gen,j,k integer :: i,i_part,i_gen,j,k
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_has_bitmasks_cas(exists) if (mpi_master) then
if (exists) then call ezfio_has_bitmasks_cas(exists)
call ezfio_get_bitmasks_cas(cas_bitmask) if (exists) then
else call ezfio_get_bitmasks_cas(cas_bitmask)
if(N_generators_bitmask == 1)then else
do j=1, N_cas_bitmask if(N_generators_bitmask == 1)then
do i=1, N_int do j=1, N_cas_bitmask
cas_bitmask(i,1,j) = iand(not(HF_bitmask(i,1)),full_ijkl_bitmask(i)) do i=1, N_int
cas_bitmask(i,2,j) = iand(not(HF_bitmask(i,2)),full_ijkl_bitmask(i)) cas_bitmask(i,1,j) = iand(not(HF_bitmask(i,1)),full_ijkl_bitmask(i))
cas_bitmask(i,2,j) = iand(not(HF_bitmask(i,2)),full_ijkl_bitmask(i))
enddo
enddo enddo
enddo else
else i_part = 2
i_part = 2 i_gen = 1
i_gen = 1 do j=1, N_cas_bitmask
do j=1, N_cas_bitmask do i=1, N_int
do i=1, N_int cas_bitmask(i,1,j) = generators_bitmask_restart(i,1,i_part,i_gen)
cas_bitmask(i,1,j) = generators_bitmask_restart(i,1,i_part,i_gen) cas_bitmask(i,2,j) = generators_bitmask_restart(i,2,i_part,i_gen)
cas_bitmask(i,2,j) = generators_bitmask_restart(i,2,i_part,i_gen) enddo
enddo enddo
enddo endif
endif endif
do i=1,N_cas_bitmask
do j = 1, N_cas_bitmask
do k=1,N_int
cas_bitmask(k,j,i) = iand(cas_bitmask(k,j,i),full_ijkl_bitmask(k))
enddo
enddo
enddo
endif endif
do i=1,N_cas_bitmask IRP_IF MPI
do j = 1, N_cas_bitmask include 'mpif.h'
do k=1,N_int integer :: ierr
cas_bitmask(k,j,i) = iand(cas_bitmask(k,j,i),full_ijkl_bitmask(k)) call MPI_BCAST( cas_bitmask, N_int*2*N_cas_bitmask, MPI_BIT_KIND, 0, MPI_COMM_WORLD, ierr)
enddo if (ierr /= MPI_SUCCESS) then
enddo stop 'Unable to read cas_bitmask with MPI'
enddo endif
IRP_ENDIF
END_PROVIDER END_PROVIDER

View File

@ -26,6 +26,7 @@ BEGIN_PROVIDER [ integer, N_det ]
character*(64) :: label character*(64) :: label
PROVIDE ezfio_filename PROVIDE ezfio_filename
PROVIDE nproc PROVIDE nproc
if (mpi_master) then
if (read_wf) then if (read_wf) then
call ezfio_has_determinants_n_det(exists) call ezfio_has_determinants_n_det(exists)
if (exists) then if (exists) then
@ -43,6 +44,16 @@ BEGIN_PROVIDER [ integer, N_det ]
else else
N_det = 1 N_det = 1
endif endif
endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( N_det, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read N_det with MPI'
endif
IRP_ENDIF
call write_int(output_determinants,N_det,'Number of determinants') call write_int(output_determinants,N_det,'Number of determinants')
ASSERT (N_det > 0) ASSERT (N_det > 0)
END_PROVIDER END_PROVIDER
@ -69,14 +80,25 @@ BEGIN_PROVIDER [ integer, psi_det_size ]
END_DOC END_DOC
PROVIDE ezfio_filename PROVIDE ezfio_filename
logical :: exists logical :: exists
call ezfio_has_determinants_n_det(exists) if (mpi_master) then
if (exists) then call ezfio_has_determinants_n_det(exists)
call ezfio_get_determinants_n_det(psi_det_size) if (exists) then
else call ezfio_get_determinants_n_det(psi_det_size)
psi_det_size = 1 else
psi_det_size = 1
endif
psi_det_size = max(psi_det_size,100000)
call write_int(output_determinants,psi_det_size,'Dimension of the psi arrays')
endif endif
psi_det_size = max(psi_det_size,100000) IRP_IF MPI
call write_int(output_determinants,psi_det_size,'Dimension of the psi arrays') include 'mpif.h'
integer :: ierr
call MPI_BCAST( psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read psi_det_size with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
@ -91,6 +113,7 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ]
character*(64) :: label character*(64) :: label
psi_det = 0_bit_kind psi_det = 0_bit_kind
if (mpi_master) then
if (read_wf) then if (read_wf) then
call ezfio_has_determinants_N_int(exists) call ezfio_has_determinants_N_int(exists)
if (exists) then if (exists) then
@ -129,6 +152,16 @@ BEGIN_PROVIDER [ integer(bit_kind), psi_det, (N_int,2,psi_det_size) ]
psi_det(i,2,1) = HF_bitmask(i,2) psi_det(i,2,1) = HF_bitmask(i,2)
enddo enddo
endif endif
endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( psi_det, N_int*2*N_det, MPI_BIT_KIND, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read psi_det with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
@ -146,6 +179,7 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ]
double precision, allocatable :: psi_coef_read(:,:) double precision, allocatable :: psi_coef_read(:,:)
character*(64) :: label character*(64) :: label
if (mpi_master) then
psi_coef = 0.d0 psi_coef = 0.d0
do i=1,min(N_states,psi_det_size) do i=1,min(N_states,psi_det_size)
psi_coef(i,i) = 1.d0 psi_coef(i,i) = 1.d0
@ -175,6 +209,16 @@ BEGIN_PROVIDER [ double precision, psi_coef, (psi_det_size,N_states) ]
endif endif
endif endif
endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( psi_coef, N_states*psi_det_size, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read psi_coef with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
@ -444,7 +488,9 @@ subroutine save_wavefunction
BEGIN_DOC BEGIN_DOC
! Save the wave function into the EZFIO file ! Save the wave function into the EZFIO file
END_DOC END_DOC
call save_wavefunction_general(N_det,min(N_states,N_det),psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted) if (mpi_master) then
call save_wavefunction_general(N_det,min(N_states,N_det),psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted)
endif
end end
@ -454,7 +500,9 @@ subroutine save_wavefunction_unsorted
BEGIN_DOC BEGIN_DOC
! Save the wave function into the EZFIO file ! Save the wave function into the EZFIO file
END_DOC END_DOC
call save_wavefunction_general(N_det,min(N_states,N_det),psi_det,size(psi_coef,1),psi_coef) if (mpi_master) then
call save_wavefunction_general(N_det,min(N_states,N_det),psi_det,size(psi_coef,1),psi_coef)
endif
end end
subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef) subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
@ -472,6 +520,7 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
integer :: i,j,k integer :: i,j,k
if (mpi_master) then
call ezfio_set_determinants_N_int(N_int) call ezfio_set_determinants_N_int(N_int)
call ezfio_set_determinants_bit_kind(bit_kind) call ezfio_set_determinants_bit_kind(bit_kind)
call ezfio_set_determinants_N_det(ndet) call ezfio_set_determinants_N_det(ndet)
@ -513,6 +562,7 @@ subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
call ezfio_set_determinants_psi_coef(psi_coef_save) call ezfio_set_determinants_psi_coef(psi_coef_save)
deallocate (psi_coef_save) deallocate (psi_coef_save)
call write_int(output_determinants,ndet,'Saved determinants') call write_int(output_determinants,ndet,'Saved determinants')
endif
end end

View File

@ -36,7 +36,7 @@ subroutine occ_pattern_to_dets_size(o,sze,n_alpha,Nint)
amax -= popcnt( o(k,2) ) amax -= popcnt( o(k,2) )
enddo enddo
sze = int( min(binom_func(bmax, amax), 1.d8) ) sze = int( min(binom_func(bmax, amax), 1.d8) )
sze = 2*sze*sze + 16 sze = 2*sze*sze + 64
end end
@ -264,7 +264,7 @@ subroutine make_s2_eigenfunction
!$OMP PRIVATE(s,ithread, d, det_buffer, smax, N_det_new,i,j,k) !$OMP PRIVATE(s,ithread, d, det_buffer, smax, N_det_new,i,j,k)
N_det_new = 0 N_det_new = 0
call occ_pattern_to_dets_size(psi_occ_pattern(1,1,1),s,elec_alpha_num,N_int) call occ_pattern_to_dets_size(psi_occ_pattern(1,1,1),s,elec_alpha_num,N_int)
allocate (d(N_int,2,s+16), det_buffer(N_int,2,bufsze) ) allocate (d(N_int,2,s+64), det_buffer(N_int,2,bufsze) )
smax = s smax = s
ithread=0 ithread=0
!$ ithread = omp_get_thread_num() !$ ithread = omp_get_thread_num()
@ -274,7 +274,7 @@ subroutine make_s2_eigenfunction
s += 1 s += 1
if (s > smax) then if (s > smax) then
deallocate(d) deallocate(d)
allocate ( d(N_int,2,s+16) ) allocate ( d(N_int,2,s+64) )
smax = s smax = s
endif endif
call occ_pattern_to_dets(psi_occ_pattern(1,1,i),d,s,elec_alpha_num,N_int) call occ_pattern_to_dets(psi_occ_pattern(1,1,i),d,s,elec_alpha_num,N_int)

View File

@ -62,7 +62,7 @@ subroutine zmq_get_$X(zmq_to_qp_run_socket, worker_id)
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
integer, intent(in) :: worker_id integer, intent(in) :: worker_id
integer :: rc integer :: rc
character*(64) :: msg character*(256) :: msg
write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, '$X' write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, '$X'
rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0) rc = f77_zmq_send(zmq_to_qp_run_socket,trim(msg),len(trim(msg)),0)
@ -171,7 +171,6 @@ subroutine zmq_get_psi(zmq_to_qp_run_socket, worker_id)
END_DOC END_DOC
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
integer, intent(in) :: worker_id integer, intent(in) :: worker_id
character*(64) :: msg
call zmq_get_N_states(zmq_to_qp_run_socket, worker_id) call zmq_get_N_states(zmq_to_qp_run_socket, worker_id)
call zmq_get_N_det(zmq_to_qp_run_socket, worker_id) call zmq_get_N_det(zmq_to_qp_run_socket, worker_id)
@ -195,7 +194,7 @@ subroutine zmq_get_psi_det(zmq_to_qp_run_socket, worker_id)
integer, intent(in) :: worker_id integer, intent(in) :: worker_id
integer :: rc integer :: rc
integer*8 :: rc8 integer*8 :: rc8
character*(64) :: msg character*(256) :: msg
write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, 'psi_det' write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, 'psi_det'
@ -230,7 +229,7 @@ subroutine zmq_get_psi_coef(zmq_to_qp_run_socket, worker_id)
integer, intent(in) :: worker_id integer, intent(in) :: worker_id
integer :: rc integer :: rc
integer*8 :: rc8 integer*8 :: rc8
character*(64) :: msg character*(256) :: msg
write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, 'psi_coef' write(msg,'(A8,1X,I8,1X,A230)') 'get_data', worker_id, 'psi_coef'

View File

@ -12,4 +12,4 @@ interface: ezfio, provider
type: Positive_int type: Positive_int
doc: Numbers total of electrons (alpha + beta) doc: Numbers total of electrons (alpha + beta)
default: = electrons.elec_alpha_num + electrons.elec_beta_num default: = electrons.elec_alpha_num + electrons.elec_beta_num
interface: ezfio interface: ezfio

View File

@ -1,4 +1,4 @@
BEGIN_PROVIDER [ integer, elec_num] BEGIN_PROVIDER [ integer, elec_num ]
&BEGIN_PROVIDER [ integer, elec_num_tab, (2)] &BEGIN_PROVIDER [ integer, elec_num_tab, (2)]
implicit none implicit none
@ -7,9 +7,9 @@
END_DOC END_DOC
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_get_electrons_elec_num(elec_num)
elec_num_tab(1) = elec_alpha_num elec_num_tab(1) = elec_alpha_num
elec_num_tab(2) = elec_beta_num elec_num_tab(2) = elec_beta_num
elec_num = elec_alpha_num+elec_beta_num
END_PROVIDER END_PROVIDER

View File

@ -407,7 +407,7 @@ BEGIN_PROVIDER [ logical, ao_bielec_integrals_in_map ]
ao_bielec_integrals_in_map = .True. ao_bielec_integrals_in_map = .True.
if (write_ao_integrals) then if (write_ao_integrals.and.mpi_master) then
call ezfio_set_work_empty(.False.) call ezfio_set_work_empty(.False.)
call map_save_to_disk(trim(ezfio_filename)//'/work/ao_ints',ao_integrals_map) call map_save_to_disk(trim(ezfio_filename)//'/work/ao_ints',ao_integrals_map)
call ezfio_set_integrals_bielec_disk_access_ao_integrals("Read") call ezfio_set_integrals_bielec_disk_access_ao_integrals("Read")

View File

@ -599,6 +599,9 @@ subroutine dump_$ao_integrals(filename)
integer(cache_key_kind), pointer :: key(:) integer(cache_key_kind), pointer :: key(:)
real(integral_kind), pointer :: val(:) real(integral_kind), pointer :: val(:)
integer*8 :: i,j, n integer*8 :: i,j, n
if (.not.mpi_master) then
return
endif
call ezfio_set_work_empty(.False.) call ezfio_set_work_empty(.False.)
open(unit=66,file=filename,FORM='unformatted') open(unit=66,file=filename,FORM='unformatted')
write(66) integral_kind, key_kind write(66) integral_kind, key_kind

View File

@ -134,7 +134,7 @@ BEGIN_PROVIDER [ logical, mo_bielec_integrals_in_map ]
print*,'Molecular integrals provided' print*,'Molecular integrals provided'
endif endif
if (write_mo_integrals) then if (write_mo_integrals.and.mpi_master) then
call ezfio_set_work_empty(.False.) call ezfio_set_work_empty(.False.)
call map_save_to_disk(trim(ezfio_filename)//'/work/mo_ints',mo_integrals_map) call map_save_to_disk(trim(ezfio_filename)//'/work/mo_ints',mo_integrals_map)
call ezfio_set_integrals_bielec_disk_access_mo_integrals("Read") call ezfio_set_integrals_bielec_disk_access_mo_integrals("Read")

View File

@ -1,18 +1,32 @@
BEGIN_PROVIDER [ integer, mo_tot_num ] BEGIN_PROVIDER [ integer, mo_tot_num ]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! Total number of molecular orbitals and the size of the keys corresponding ! Number of MOs
END_DOC END_DOC
logical :: has
PROVIDE ezfio_filename PROVIDE ezfio_filename
logical :: exists if (mpi_master) then
call ezfio_has_mo_basis_mo_tot_num(exists) call ezfio_has_mo_basis_mo_tot_num(has)
if (exists) then if (has) then
call ezfio_get_mo_basis_mo_tot_num(mo_tot_num) mo_tot_num = ao_ortho_canonical_num
else else
mo_tot_num = ao_ortho_canonical_num print *, 'mo_basis/mo_tot_num not found in EZFIO file'
stop 1
endif
endif endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( mo_tot_num, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_tot_num with MPI'
endif
IRP_ENDIF
call write_int(6,mo_tot_num,'mo_tot_num') call write_int(6,mo_tot_num,'mo_tot_num')
ASSERT (mo_tot_num > 0) ASSERT (mo_tot_num > 0)
END_PROVIDER END_PROVIDER
@ -29,18 +43,29 @@ BEGIN_PROVIDER [ double precision, mo_coef, (ao_num,mo_tot_num) ]
PROVIDE ezfio_filename PROVIDE ezfio_filename
! Coefs if (mpi_master) then
call ezfio_has_mo_basis_mo_coef(exists) ! Coefs
if (exists) then call ezfio_has_mo_basis_mo_coef(exists)
call ezfio_get_mo_basis_mo_coef(mo_coef) if (exists) then
else call ezfio_get_mo_basis_mo_coef(mo_coef)
! Orthonormalized AO basis else
do i=1,mo_tot_num ! Orthonormalized AO basis
do j=1,ao_num do i=1,mo_tot_num
mo_coef(j,i) = ao_ortho_canonical_coef(j,i) do j=1,ao_num
mo_coef(j,i) = ao_ortho_canonical_coef(j,i)
enddo
enddo enddo
enddo endif
endif endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( mo_coef, mo_tot_num*ao_num, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_coef with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, mo_coef_in_ao_ortho_basis, (ao_num, mo_tot_num) ] BEGIN_PROVIDER [ double precision, mo_coef_in_ao_ortho_basis, (ao_num, mo_tot_num) ]
@ -67,12 +92,23 @@ BEGIN_PROVIDER [ character*(64), mo_label ]
logical :: exists logical :: exists
PROVIDE ezfio_filename PROVIDE ezfio_filename
call ezfio_has_mo_basis_mo_label(exists) if (mpi_master) then
if (exists) then call ezfio_has_mo_basis_mo_label(exists)
call ezfio_get_mo_basis_mo_label(mo_label) if (exists) then
else call ezfio_get_mo_basis_mo_label(mo_label)
mo_label = 'no_label' else
mo_label = 'no_label'
endif
endif endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( mo_label, 64, MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_label with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, mo_coef_transp, (mo_tot_num,ao_num) ] BEGIN_PROVIDER [ double precision, mo_coef_transp, (mo_tot_num,ao_num) ]
@ -109,20 +145,31 @@ BEGIN_PROVIDER [ double precision, mo_occ, (mo_tot_num) ]
! MO occupation numbers ! MO occupation numbers
END_DOC END_DOC
PROVIDE ezfio_filename PROVIDE ezfio_filename
logical :: exists if (mpi_master) then
call ezfio_has_mo_basis_mo_occ(exists) logical :: exists
if (exists) then call ezfio_has_mo_basis_mo_occ(exists)
call ezfio_get_mo_basis_mo_occ(mo_occ) if (exists) then
else call ezfio_get_mo_basis_mo_occ(mo_occ)
mo_occ = 0.d0 else
integer :: i mo_occ = 0.d0
do i=1,elec_beta_num integer :: i
mo_occ(i) = 2.d0 do i=1,elec_beta_num
enddo mo_occ(i) = 2.d0
do i=elec_beta_num+1,elec_alpha_num enddo
mo_occ(i) = 1.d0 do i=elec_beta_num+1,elec_alpha_num
enddo mo_occ(i) = 1.d0
enddo
endif
endif endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( mo_occ, mo_tot_num, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read mo_occ with MPI'
endif
IRP_ENDIF
END_PROVIDER END_PROVIDER

View File

@ -1 +1 @@
Utils

View File

@ -6,29 +6,42 @@ BEGIN_PROVIDER [ double precision, nucl_coord, (nucl_num,3) ]
END_DOC END_DOC
PROVIDE ezfio_filename PROVIDE ezfio_filename
double precision, allocatable :: buffer(:,:) if (mpi_master) then
nucl_coord = 0.d0 double precision, allocatable :: buffer(:,:)
allocate (buffer(nucl_num,3)) nucl_coord = 0.d0
buffer = 0.d0 allocate (buffer(nucl_num,3))
logical :: has buffer = 0.d0
call ezfio_has_nuclei_nucl_coord(has) logical :: has
if (.not.has) then call ezfio_has_nuclei_nucl_coord(has)
print *, irp_here if (.not.has) then
stop 1 print *, irp_here
stop 1
endif
call ezfio_get_nuclei_nucl_coord(buffer)
integer :: i,j
do i=1,3
do j=1,nucl_num
nucl_coord(j,i) = buffer(j,i)
enddo
enddo
deallocate(buffer)
character*(64), parameter :: f = '(A16, 4(1X,F12.6))'
character*(64), parameter :: ft= '(A16, 4(1X,A12 ))'
double precision, parameter :: a0= 0.529177249d0
endif endif
call ezfio_get_nuclei_nucl_coord(buffer)
integer :: i,j
do i=1,3 IRP_IF MPI
do j=1,nucl_num include 'mpif.h'
nucl_coord(j,i) = buffer(j,i) integer :: ierr
enddo call MPI_BCAST( nucl_coord, 3*nucl_num, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
enddo if (ierr /= MPI_SUCCESS) then
deallocate(buffer) stop 'Unable to read nucl_coord with MPI'
endif
character*(64), parameter :: f = '(A16, 4(1X,F12.6))' IRP_ENDIF
character*(64), parameter :: ft= '(A16, 4(1X,A12 ))'
double precision, parameter :: a0= 0.529177249d0
call write_time(output_Nuclei) call write_time(output_Nuclei)
write(output_Nuclei,'(A)') '' write(output_Nuclei,'(A)') ''
write(output_Nuclei,'(A)') 'Nuclear Coordinates (Angstroms)' write(output_Nuclei,'(A)') 'Nuclear Coordinates (Angstroms)'
@ -135,13 +148,24 @@ BEGIN_PROVIDER [ double precision, nuclear_repulsion ]
IF (disk_access_nuclear_repulsion.EQ.'Read') THEN IF (disk_access_nuclear_repulsion.EQ.'Read') THEN
print*, 'nuclear_repulsion read from disk' print*, 'nuclear_repulsion read from disk'
LOGICAL :: has LOGICAL :: has
call ezfio_has_nuclei_nuclear_repulsion(has) if (mpi_master) then
if (has) then call ezfio_has_nuclei_nuclear_repulsion(has)
call ezfio_get_nuclei_nuclear_repulsion(nuclear_repulsion) if (has) then
else call ezfio_get_nuclei_nuclear_repulsion(nuclear_repulsion)
print *, 'nuclei/nuclear_repulsion not found in EZFIO file' else
stop 1 print *, 'nuclei/nuclear_repulsion not found in EZFIO file'
stop 1
endif
endif endif
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BCAST( nuclear_repulsion, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
if (ierr /= MPI_SUCCESS) then
stop 'Unable to read nuclear_repulsion with MPI'
endif
IRP_ENDIF
ELSE ELSE
@ -169,7 +193,9 @@ BEGIN_PROVIDER [ double precision, nuclear_repulsion ]
'Nuclear repulsion energy') 'Nuclear repulsion energy')
IF (disk_access_nuclear_repulsion.EQ.'Write') THEN IF (disk_access_nuclear_repulsion.EQ.'Write') THEN
if (mpi_master) then
call ezfio_set_nuclei_nuclear_repulsion(nuclear_repulsion) call ezfio_set_nuclei_nuclear_repulsion(nuclear_repulsion)
endif
END IF END IF
END_PROVIDER END_PROVIDER