1
0
mirror of https://github.com/TREX-CoE/irpjast.git synced 2024-11-04 05:04:00 +01:00
irpjast/el_nuc_el_blas.irp.f

156 lines
4.9 KiB
FortranFixed
Raw Normal View History

2021-03-10 21:26:25 +01:00
BEGIN_PROVIDER [ double precision, tmp_c, (nelec_8,nnuc,0:ncord,0:ncord-1) ]
&BEGIN_PROVIDER [ double precision, dtmp_c, (nelec_8,4,nnuc,0:ncord,0:ncord-1) ]
2021-04-23 14:18:59 +02:00
use qmckl_blas
2021-01-18 23:51:00 +01:00
implicit none
BEGIN_DOC
2021-03-08 22:01:33 +01:00
! Calculate the intermediate buffers
! tmp_c:
! r_{ij}^k . R_{ja}^l -> tmp_c_{ia}^{kl}
!
! dtmp_c:
! dr_{ij}^k . R_{ja}^l -> dtmp_c_{ia}^{kl}
2021-01-18 23:51:00 +01:00
END_DOC
2021-04-26 10:40:43 +02:00
integer :: k, l, m
integer*8 :: tasks(100000), ntasks
2021-01-18 23:51:00 +01:00
2021-04-26 10:40:43 +02:00
ntasks = 0_8
2021-04-28 03:10:42 +02:00
! type(c_ptr) :: ptr_a, ptr_b, ptr_c, ptr_d, ptr_e
! double precision, pointer :: A(:,:,:), B(:,:,:), C(:,:,:,:), D(:,:,:,:), E(:,:,:,:,:)
! call alloc(ptr_a, int(size(rescale_een_e),8))
! call c_f_pointer(ptr_a, A, shape(rescale_een_e))
! A(:,:,:) = rescale_een_e(:,:,:)
!
! call alloc(ptr_b, int(size(rescale_een_n),8))
! call c_f_pointer(ptr_b, B, shape(rescale_een_n))
! B(:,:,:) = rescale_een_n(:,:,:)
!
! call alloc(ptr_c, int(size(tmp_c),8))
! call c_f_pointer(ptr_c, C, shape(tmp_c))
2021-01-23 15:34:36 +01:00
! r_{ij}^k . R_{ja}^l -> tmp_c_{ia}^{kl}
do k=0,ncord-1
2021-04-24 03:32:53 +02:00
do l=0,ncord
call qmckl_dgemm('N','N', nelec, nnuc, nelec, 1.d0, &
2021-01-23 15:34:36 +01:00
rescale_een_e(1,1,k), size(rescale_een_e,1), &
2021-04-24 03:32:53 +02:00
rescale_een_n(1,1,l), size(rescale_een_n,1), 0.d0, &
2021-04-26 10:40:43 +02:00
tmp_c(1,1,l,k), size(tmp_c,1), tasks, ntasks)
2021-04-28 03:10:42 +02:00
! call qmckl_dgemm('N','N', nelec, nnuc, nelec, 1.d0, &
! A(:,:,k), size(rescale_een_e,1), &
! B(:,:,l), size(rescale_een_n,1), 0.d0, &
! C(:,:,l,k), size(tmp_c,1), tasks, ntasks)
2021-04-24 03:32:53 +02:00
enddo
2021-01-23 15:34:36 +01:00
enddo
2021-04-28 03:10:42 +02:00
!call alloc(ptr_d, int(size(rescale_een_e_deriv_e),8))
!call c_f_pointer(ptr_d, D, shape(rescale_een_e_deriv_e))
!D(:,:,:,:) = rescale_een_e_deriv_e(:,:,:,:)
!call alloc(ptr_e, int(size(dtmp_c),8))
!call c_f_pointer(ptr_e, E, shape(dtmp_c))
2021-01-23 15:34:36 +01:00
! dr_{ij}^k . R_{ja}^l -> dtmp_c_{ia}^{kl}
do k=0,ncord-1
2021-04-24 03:32:53 +02:00
do l=0,ncord
call qmckl_dgemm('N','N', nelec_8*4, nnuc, nelec, 1.d0, &
2021-03-18 10:48:23 +01:00
rescale_een_e_deriv_e(1,1,1,k), &
size(rescale_een_e_deriv_e,1)*size(rescale_een_e_deriv_e,2), &
2021-04-24 03:32:53 +02:00
rescale_een_n(1,1,l), &
2021-03-18 10:48:23 +01:00
size(rescale_een_n,1), 0.d0, &
2021-04-24 03:32:53 +02:00
dtmp_c(1,1,1,l,k), size(dtmp_c,1)*size(dtmp_c,2), &
2021-04-26 10:40:43 +02:00
tasks, ntasks)
2021-04-28 03:10:42 +02:00
! call qmckl_dgemm('N','N', nelec_8*4, nnuc, nelec, 1.d0, &
! D(:,:,:,k), &
! size(rescale_een_e_deriv_e,1)*size(rescale_een_e_deriv_e,2), &
! B(:,:,l), &
! size(rescale_een_n,1), 0.d0, &
! E(:,:,:,l,k), size(dtmp_c,1)*size(dtmp_c,2), &
! tasks, ntasks)
2021-04-24 03:32:53 +02:00
enddo
2021-01-23 15:34:36 +01:00
enddo
2021-04-26 10:40:43 +02:00
print *, ntasks, ' tasks'
call qmckl_tasks_run(tasks, ntasks)
2021-04-28 03:10:42 +02:00
! tmp_c(:,:,:,:) = C(:,:,:,:)
! dtmp_c(:,:,:,:,:) = E(:,:,:,:,:)
! call free(ptr_a)
! call free(ptr_b)
! call free(ptr_c)
! call free(ptr_d)
! call free(ptr_e)
2021-01-23 19:49:01 +01:00
2021-03-08 22:16:50 +01:00
END_PROVIDER
2021-03-08 22:01:33 +01:00
BEGIN_PROVIDER [ double precision, factor_een_blas ]
2021-03-10 21:26:25 +01:00
&BEGIN_PROVIDER [ double precision, factor_een_deriv_e_blas, (nelec_8,4) ]
2021-03-08 22:01:33 +01:00
implicit none
BEGIN_DOC
! Dimensions 1-3 : dx, dy, dz
! Dimension 4 : d2x + d2y + d2z
END_DOC
integer :: i, j, a, p, k, l, lmax, m, n, ii
2021-03-18 10:08:47 +01:00
double precision :: accu, cn, cn2
2021-03-09 00:59:49 +01:00
! double precision,dimension(:),allocatable :: cn
2021-03-08 22:01:33 +01:00
factor_een_blas = 0.0d0
2021-03-10 21:26:25 +01:00
factor_een_deriv_e_blas(:,:) = 0.0d0
2021-01-25 00:16:09 +01:00
do n = 1, dim_cord_vect
2021-01-23 15:34:36 +01:00
2021-01-25 00:16:09 +01:00
l = lkpm_of_cindex(1,n)
k = lkpm_of_cindex(2,n)
p = lkpm_of_cindex(3,n)
m = lkpm_of_cindex(4,n)
2021-01-23 15:34:36 +01:00
2021-01-25 00:16:09 +01:00
do a = 1, nnuc
2021-03-09 00:59:49 +01:00
cn = cord_vect_full(n, a)
if (cn == 0.d0) cycle
2021-01-23 19:49:01 +01:00
2021-01-25 00:16:09 +01:00
accu = 0.d0
do j=1,nelec
2021-03-09 00:59:49 +01:00
accu = accu + rescale_een_n(j,a,m) * tmp_c(j,a,m+l,k)
enddo
2021-03-09 00:59:49 +01:00
factor_een_blas = factor_een_blas + accu * cn
2021-03-18 10:08:47 +01:00
cn2 = cn+cn
2021-03-09 00:59:49 +01:00
do ii=1,4
do j=1,nelec
factor_een_deriv_e_blas(j,ii) = factor_een_deriv_e_blas(j,ii) + (&
2021-03-18 10:08:47 +01:00
tmp_c (j,a,m+l,k) *rescale_een_n_deriv_e(j,ii,a,m) + &
dtmp_c(j,ii,a,m+l,k) * rescale_een_n(j,a,m) ) * cn
2021-03-09 00:59:49 +01:00
enddo
enddo
do j=1,nelec
factor_een_deriv_e_blas(j,4) = factor_een_deriv_e_blas(j,4) + (&
2021-03-08 22:49:30 +01:00
dtmp_c(j,1,a,m+l,k) * rescale_een_n_deriv_e(j,1,a,m ) + &
dtmp_c(j,2,a,m+l,k) * rescale_een_n_deriv_e(j,2,a,m ) + &
dtmp_c(j,3,a,m+l,k) * rescale_een_n_deriv_e(j,3,a,m ) &
2021-03-18 10:08:47 +01:00
)*cn2
enddo
do ii=1,4
do j=1,nelec
factor_een_deriv_e_blas(j,ii) = factor_een_deriv_e_blas(j,ii) + (&
tmp_c(j,a,m,k) * rescale_een_n_deriv_e(j,ii,a,m+l) + &
dtmp_c(j,ii,a,m,k) * rescale_een_n(j,a,m+l) ) * cn
enddo
enddo
do j=1,nelec
factor_een_deriv_e_blas(j,4) = factor_een_deriv_e_blas(j,4) + (&
dtmp_c(j,1,a,m ,k) * rescale_een_n_deriv_e(j,1,a,m+l) + &
dtmp_c(j,2,a,m ,k) * rescale_een_n_deriv_e(j,2,a,m+l) + &
dtmp_c(j,3,a,m ,k) * rescale_een_n_deriv_e(j,3,a,m+l) &
)*cn2
2021-01-23 15:34:36 +01:00
enddo
2021-01-25 00:16:09 +01:00
2021-01-23 15:34:36 +01:00
enddo
enddo
2021-01-25 00:16:09 +01:00
2021-01-18 23:51:00 +01:00
END_PROVIDER