mirror of
https://gitlab.com/scemama/qp_plugins_scemama.git
synced 2024-07-26 04:37:31 +02:00
142 lines
3.8 KiB
Fortran
142 lines
3.8 KiB
Fortran
program import_integrals_ao
|
|
call run
|
|
end
|
|
|
|
subroutine run
|
|
use trexio
|
|
use map_module
|
|
implicit none
|
|
BEGIN_DOC
|
|
! Program to import integrals from TREXIO
|
|
END_DOC
|
|
|
|
integer(8) :: f ! TREXIO file handle
|
|
integer :: rc
|
|
|
|
integer ::i,j,k,l
|
|
double precision :: integral
|
|
double precision, allocatable :: A(:,:)
|
|
|
|
integer :: n_integrals
|
|
integer(key_kind), allocatable :: buffer_i(:)
|
|
real(integral_kind), allocatable :: buffer_values(:)
|
|
|
|
f = trexio_open(trexio_filename, 'r', TREXIO_AUTO, rc)
|
|
if (f == 0_8) then
|
|
print *, 'Unable to open TREXIO file for reading'
|
|
print *, 'rc = ', rc
|
|
stop -1
|
|
endif
|
|
|
|
|
|
double precision, allocatable :: A(:,:)
|
|
double precision, allocatable :: V(:)
|
|
double precision, allocatable :: s
|
|
allocate(A(ao_num, ao_num))
|
|
|
|
if (trexio_has_nucleus_repulsion(f)) then
|
|
rc = trexio_read_nucleus_repulsion(f, s)
|
|
if (rc /= TREXIO_SUCCESS) then
|
|
print *, irp_here
|
|
print *, 'Error reading nuclear repulsion'
|
|
stop -1
|
|
endif
|
|
call ezfio_set_nuclei_nuclear_repulsion(s)
|
|
call ezfio_set_nuclei_io_nuclear_repulsion('Read')
|
|
endif
|
|
|
|
|
|
if (trexio_has_ao_1e_int_overlap(f) == TREXIO_SUCCESS) then
|
|
rc = trexio_read_ao_1e_int_overlap(f, A)
|
|
if (rc /= TREXIO_SUCCESS) then
|
|
print *, irp_here
|
|
print *, 'Error reading AO overlap'
|
|
stop -1
|
|
endif
|
|
call ezfio_set_ao_one_e_ints_ao_integrals_overlap(A)
|
|
call ezfio_set_ao_one_e_ints_io_ao_integrals_overlap('Read')
|
|
endif
|
|
|
|
if (trexio_has_ao_1e_int_kinetic(f) == TREXIO_SUCCESS) then
|
|
rc = trexio_read_ao_1e_int_kinetic(f, A)
|
|
if (rc /= TREXIO_SUCCESS) then
|
|
print *, irp_here
|
|
print *, 'Error reading AO kinetic integrals'
|
|
stop -1
|
|
endif
|
|
call ezfio_set_ao_one_e_ints_ao_integrals_kinetic(A)
|
|
call ezfio_set_ao_one_e_ints_io_ao_integrals_kinetic('Read')
|
|
endif
|
|
|
|
if (trexio_has_ao_1e_int_ecp(f) == TREXIO_SUCCESS) then
|
|
rc = trexio_read_ao_1e_int_ecp(f, A)
|
|
if (rc /= TREXIO_SUCCESS) then
|
|
print *, irp_here
|
|
print *, 'Error reading AO ECP local integrals'
|
|
stop -1
|
|
endif
|
|
call ezfio_set_ao_one_e_ints_ao_integrals_pseudo(A)
|
|
call ezfio_set_ao_one_e_ints_io_ao_integrals_pseudo('Read')
|
|
endif
|
|
|
|
if (trexio_has_ao_1e_int_potential_n_e(f) == TREXIO_SUCCESS) then
|
|
rc = trexio_read_ao_1e_int_potential_n_e(f, A)
|
|
if (rc /= TREXIO_SUCCESS) then
|
|
print *, irp_here
|
|
print *, 'Error reading AO potential N-e integrals'
|
|
stop -1
|
|
endif
|
|
call ezfio_set_ao_one_e_ints_ao_integrals_n_e(A)
|
|
call ezfio_set_ao_one_e_ints_io_ao_integrals_n_e('Read')
|
|
endif
|
|
|
|
|
|
allocate(buffer_i(ao_num**3), buffer_values(ao_num**3))
|
|
iunit = getunitandopen('W.qp','r')
|
|
n_integrals=0
|
|
i = 1
|
|
j = 1
|
|
k = 1
|
|
l = 1
|
|
buffer_values = 0.d0
|
|
do
|
|
read (iunit,*,end=13) i,j,k,l, integral
|
|
if (i<0 .or. i>ao_num) then
|
|
print *, i
|
|
stop 'i out of bounds in W.qp'
|
|
endif
|
|
if (j<0 .or. j>ao_num) then
|
|
print *, j
|
|
stop 'j out of bounds in W.qp'
|
|
endif
|
|
if (k<0 .or. k>ao_num) then
|
|
print *, k
|
|
stop 'k out of bounds in W.qp'
|
|
endif
|
|
if (l<0 .or. l>ao_num) then
|
|
print *, l
|
|
stop 'l out of bounds in W.qp'
|
|
endif
|
|
n_integrals += 1
|
|
call two_e_integrals_index(i, j, k, l, buffer_i(n_integrals) )
|
|
buffer_values(n_integrals) = integral
|
|
if (n_integrals == size(buffer_i)) then
|
|
call insert_into_ao_integrals_map(n_integrals,buffer_i,buffer_values)
|
|
n_integrals = 0
|
|
endif
|
|
enddo
|
|
13 continue
|
|
close(iunit)
|
|
|
|
if (n_integrals > 0) then
|
|
call insert_into_ao_integrals_map(n_integrals,buffer_i,buffer_values)
|
|
endif
|
|
|
|
call map_sort(ao_integrals_map)
|
|
call map_unique(ao_integrals_map)
|
|
|
|
call map_save_to_disk(trim(ezfio_filename)//'/work/ao_ints',ao_integrals_map)
|
|
call ezfio_set_ao_two_e_ints_io_ao_two_e_integrals('Read')
|
|
|
|
end
|