Skip to content

Commit

Permalink
clean-up: ALLOCATABLE instead of POINTER, descriptions for output fil…
Browse files Browse the repository at this point in the history
…es, deallocations
  • Loading branch information
mattiatj authored and dev-zero committed Feb 24, 2020
1 parent ba79d66 commit 61790e2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 46 deletions.
5 changes: 1 addition & 4 deletions src/commutator_rpnl.F
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ SUBROUTINE build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_s
INTEGER :: handle, i, iab, iac, iatom, ibc, icol, &
ikind, ind, irow, jatom, jkind, kac, &
kbc, kkind, na, natom, nb, nkind, np, &
nthread, order, slot
order, slot
INTEGER, DIMENSION(3) :: cell_b
LOGICAL :: asso_rrv, asso_rv, asso_rxrv, found, go, &
my_ref, my_rrv, my_rv, my_rxrv, &
Expand Down Expand Up @@ -521,9 +521,6 @@ SUBROUTINE build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_s
END IF
ENDDO

nthread = 1
!$ nthread = omp_get_max_threads()

! *** All integrals needed have been calculated and stored in sap_int
! *** We now calculate the commutator matrix elements

Expand Down
73 changes: 32 additions & 41 deletions src/qs_moments.F
Original file line number Diff line number Diff line change
Expand Up @@ -2354,21 +2354,37 @@ SUBROUTINE calculate_commutator_nl_terms(qs_env, nlcom_rv, nlcom_rxrv, nlcom_rrv
IF (.NOT. (calc_rv .OR. calc_rrv .OR. calc_rxrv)) RETURN
NULLIFY (cell, matrix_s, particle_set, qs_kind_set, rho, sab_orb, sap_ppnl)
CALL get_qs_env(qs_env, &
cell=cell, &
dft_control=dft_control, &
matrix_s=matrix_s, &
particle_set=particle_set, &
qs_kind_set=qs_kind_set, &
rho=rho, &
sab_orb=sab_orb, &
sap_ppnl=sap_ppnl)
! calculate expectation values
! real part
! This evaluates to zero, because all commutator matrices are anti-symmetric while
! the real part of the density matrix rho_ao is symmetric. Tr[A*S] = 0
IF (calc_rv) THEN
nlcom_rv(:) = 0._dp
ENDIF
eps_ppnl = dft_control%qs_control%eps_ppnl
IF (calc_rrv) THEN
nlcom_rrv(:) = 0._dp
ENDIF
! Calculate commutators, only needed of there is an imaginary part of the density matrix
IF (calc_rxrv) THEN
nlcom_rxrv(:) = 0._dp
ENDIF
! imagninary part of the density matrix
IF (qs_env%run_rtp) THEN
NULLIFY (cell, matrix_s, particle_set, qs_kind_set, rho, sab_orb, sap_ppnl)
CALL get_qs_env(qs_env, &
cell=cell, &
dft_control=dft_control, &
matrix_s=matrix_s, &
particle_set=particle_set, &
qs_kind_set=qs_kind_set, &
rho=rho, &
sab_orb=sab_orb, &
sap_ppnl=sap_ppnl)
eps_ppnl = dft_control%qs_control%eps_ppnl
! Calculate commutators, only needed of there is an imaginary part of the density matrix
! Allocate storage
NULLIFY (matrix_rv, matrix_rrv, matrix_rxrv)
IF (calc_rv) THEN
Expand Down Expand Up @@ -2427,36 +2443,14 @@ SUBROUTINE calculate_commutator_nl_terms(qs_env, nlcom_rv, nlcom_rxrv, nlcom_rrv
CALL build_com_mom_nl(qs_kind_set, sab_orb, sap_ppnl, eps_ppnl, particle_set, matrix_rxrv=matrix_rxrv, &
ref_point=ref_point, cell=cell)
ENDIF
ENDIF
! calculate expectation values
! real part
! This evaluates to zero, because all commutator matrices are anti-symmetric while
! the real part of the density matrix rho_ao is symmetric. Tr[A*S] = 0
NULLIFY (rho_ao)
CALL qs_rho_get(rho, rho_ao=rho_ao)
NULLIFY (tmp_ao)
ALLOCATE (tmp_ao)
CALL dbcsr_desymmetrize(matrix_s(1)%matrix, tmp_ao)
IF (calc_rv) THEN
nlcom_rv(:) = 0._dp
ENDIF
IF (calc_rrv) THEN
nlcom_rrv(:) = 0._dp
ENDIF
IF (calc_rxrv) THEN
nlcom_rxrv(:) = 0._dp
ENDIF
! imaginary part
IF (qs_env%run_rtp) THEN
NULLIFY (rho_ao)
CALL qs_rho_get(rho, rho_ao_im=rho_ao)
NULLIFY (tmp_ao)
ALLOCATE (tmp_ao)
CALL dbcsr_desymmetrize(matrix_s(1)%matrix, tmp_ao)
IF (calc_rv) THEN
trace = 0._dp
DO ind = 1, SIZE(matrix_rv)
Expand All @@ -2470,7 +2464,6 @@ SUBROUTINE calculate_commutator_nl_terms(qs_env, nlcom_rv, nlcom_rxrv, nlcom_rrv
END DO
nlcom_rv(ind) = nlcom_rv(ind) + strace
ENDDO
! WRITE (*, *) nlcom_rv
ENDIF
IF (calc_rrv) THEN
Expand All @@ -2486,7 +2479,6 @@ SUBROUTINE calculate_commutator_nl_terms(qs_env, nlcom_rv, nlcom_rxrv, nlcom_rrv
END DO
nlcom_rrv(ind) = nlcom_rrv(ind) + strace
ENDDO
! WRITE (*, *) nlcom_rrv
ENDIF
IF (calc_rxrv) THEN
Expand All @@ -2502,7 +2494,6 @@ SUBROUTINE calculate_commutator_nl_terms(qs_env, nlcom_rv, nlcom_rxrv, nlcom_rrv
END DO
nlcom_rxrv(ind) = nlcom_rxrv(ind) + strace
ENDDO
! WRITE (*, *) nlcom_rxrv
ENDIF
CALL dbcsr_deallocate_matrix(tmp_ao)
IF (calc_rv) CALL dbcsr_deallocate_matrix_set(matrix_rv)
Expand Down
2 changes: 1 addition & 1 deletion src/sap_kind_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ SUBROUTINE build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, ref

!$OMP END PARALLEL

DEALLOCATE (basis_set)
DEALLOCATE (basis_set, gpotential, spotential)

CALL timestop(handle)

Expand Down

0 comments on commit 61790e2

Please sign in to comment.