1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-11-07 14:43:41 +01:00
qp_plugins_scemama/devel/trexio/import_trexio_integrals.irp.f

143 lines
3.7 KiB
FortranFixed
Raw Normal View History

2022-04-11 23:03:50 +02:00
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
2022-04-27 16:06:56 +02:00
integer(trexio_t) :: f ! TREXIO file handle
integer(trexio_exit_code) :: rc
2022-04-11 23:03:50 +02:00
2023-04-24 01:42:04 +02:00
integer ::i,j,k,l
integer(8) :: m, n_integrals
2022-04-11 23:03:50 +02:00
double precision :: integral
integer(key_kind), allocatable :: buffer_i(:)
real(integral_kind), allocatable :: buffer_values(:)
2022-04-11 23:05:24 +02:00
double precision, allocatable :: A(:,:)
double precision, allocatable :: V(:)
integer , allocatable :: Vi(:,:)
2022-12-05 17:44:07 +01:00
double precision :: s
PROVIDE ao_num
2022-04-11 23:05:24 +02:00
2022-04-11 23:03:50 +02:00
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
2022-05-25 15:24:19 +02:00
if (trexio_has_nucleus_repulsion(f) == TREXIO_SUCCESS) then
2022-04-11 23:03:50 +02:00
rc = trexio_read_nucleus_repulsion(f, s)
2022-12-05 17:44:07 +01:00
call trexio_assert(rc, TREXIO_SUCCESS)
2022-04-11 23:03:50 +02:00
if (rc /= TREXIO_SUCCESS) then
2022-12-05 17:44:07 +01:00
print *, irp_here, rc
2022-04-11 23:03:50 +02:00
print *, 'Error reading nuclear repulsion'
stop -1
endif
call ezfio_set_nuclei_nuclear_repulsion(s)
call ezfio_set_nuclei_io_nuclear_repulsion('Read')
endif
2022-04-11 23:05:24 +02:00
! AO integrals
! ------------
allocate(A(ao_num, ao_num))
2022-04-11 23:03:50 +02:00
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
2022-04-11 23:05:24 +02:00
! 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
2022-04-11 23:03:50 +02:00
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
2022-04-11 23:05:24 +02:00
deallocate(A)
! AO 2e integrals
! ---------------
2022-12-05 17:44:07 +01:00
PROVIDE ao_integrals_map
2022-04-11 23:03:50 +02:00
2022-12-07 09:53:26 +01:00
integer*4 :: BUFSIZE
BUFSIZE=ao_num**2
allocate(buffer_i(BUFSIZE), buffer_values(BUFSIZE))
allocate(Vi(4,BUFSIZE), V(BUFSIZE))
2022-04-11 23:03:50 +02:00
2022-04-11 23:05:24 +02:00
integer*8 :: offset, icount
offset = 0_8
2022-12-07 09:53:26 +01:00
icount = BUFSIZE
2022-04-11 23:05:24 +02:00
rc = TREXIO_SUCCESS
do while (icount == size(V))
rc = trexio_read_ao_2e_int_eri(f, offset, icount, Vi, V)
do m=1,icount
i = Vi(1,m)
j = Vi(2,m)
k = Vi(3,m)
l = Vi(4,m)
integral = V(m)
call two_e_integrals_index(i, j, k, l, buffer_i(m) )
buffer_values(m) = integral
enddo
call insert_into_ao_integrals_map(int(icount,4),buffer_i,buffer_values)
offset = offset + icount
2022-12-07 09:53:26 +01:00
if (rc /= TREXIO_SUCCESS) then
exit
endif
2022-04-11 23:05:24 +02:00
end do
n_integrals = offset
2022-04-11 23:03:50 +02:00
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