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 1ead53a commit ba79d66
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/commutator_rpnl.F
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ END SUBROUTINE build_com_rpnl
SUBROUTINE build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_set, matrix_rv, matrix_rxrv, &
matrix_rrv, ref_point, cell)

TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
TYPE(qs_kind_type), DIMENSION(:), INTENT(IN), &
POINTER :: qs_kind_set
TYPE(neighbor_list_set_p_type), DIMENSION(:), &
INTENT(IN), POINTER :: sab_all, sap_ppnl
REAL(KIND=dp), INTENT(IN) :: eps_ppnl
Expand All @@ -447,8 +448,9 @@ SUBROUTINE build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_s
REAL(KIND=dp), DIMENSION(3) :: rab, rf
REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: achint, acint, bchint, bcint
TYPE(alist_type), POINTER :: alist_ac, alist_bc
TYPE(block_p_type), DIMENSION(:), POINTER :: blocks_rrv, blocks_rv, blocks_rxrv
TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set
TYPE(block_p_type), ALLOCATABLE, DIMENSION(:) :: blocks_rrv, blocks_rv, blocks_rxrv
TYPE(gto_basis_set_p_type), ALLOCATABLE, &
DIMENSION(:) :: basis_set
TYPE(gto_basis_set_type), POINTER :: orb_basis_set
TYPE(sap_int_type), DIMENSION(:), POINTER :: sap_int

Expand Down Expand Up @@ -491,6 +493,7 @@ SUBROUTINE build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_s
nkind = SIZE(qs_kind_set)

!sap_int needs to be shared as multiple threads need to access this
NULLIFY (sap_int)
ALLOCATE (sap_int(nkind*nkind))
DO i = 1, nkind*nkind
NULLIFY (sap_int(i)%alist, sap_int(i)%asort, sap_int(i)%aindex)
Expand Down Expand Up @@ -568,7 +571,6 @@ SUBROUTINE build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_s
END IF

! allocate blocks
NULLIFY (blocks_rv, blocks_rxrv, blocks_rrv)
IF (my_rv) THEN
ALLOCATE (blocks_rv(3))
ENDIF
Expand Down
10 changes: 5 additions & 5 deletions src/qs_moments.F
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ SUBROUTINE qs_moment_locop(qs_env, magnetic, nmoments, reference, ref_point, uni
TYPE(qs_environment_type), POINTER :: qs_env
LOGICAL, INTENT(IN) :: magnetic
INTEGER, INTENT(IN) :: nmoments, reference
REAL(dp), DIMENSION(:), POINTER :: ref_point
REAL(dp), DIMENSION(:), INTENT(IN), POINTER :: ref_point
INTEGER, INTENT(IN) :: unit_number
LOGICAL, INTENT(IN), OPTIONAL :: vel_reprs, com_nl
Expand Down Expand Up @@ -2237,7 +2237,7 @@ SUBROUTINE print_moments(unit_number, nmom, rmom, rlab, rcc, cell, periodic, mmo
IF (PRESENT(mmom)) THEN
IF (nmom >= 1) THEN
dd = SQRT(SUM(mmom(1:3)**2))
WRITE (unit_number, "(T3,A)") "Magnetic Dipole Moment (only orbital contrib.) [a.u.]"
WRITE (unit_number, "(T3,A)") "Orbital angular momentum [a. u.]"
WRITE (unit_number, "(T5,3(A,A,F14.8,1X),T60,A,T67,F14.8)") &
(TRIM(rlab(i + 1)), "=", mmom(i), i=1, 3), "Total=", dd
END IF
Expand Down Expand Up @@ -2284,7 +2284,7 @@ SUBROUTINE print_moments_nl(unit_number, nmom, rlab, mmom, rmom_vel)
IF (PRESENT(mmom)) THEN
IF (nmom >= 1) THEN
dd = SQRT(SUM(mmom(1:3)**2))
WRITE (unit_number, "(T3,A)") "Orbital angular momentum [a.u.] incl. com_nl"
WRITE (unit_number, "(T3,A)") "Orbital angular momentum incl. com_nl [a. u.]"
WRITE (unit_number, "(T5,3(A,A,D14.8,1X),T60,A,T67,F14.8)") &
(TRIM(rlab(i + 1)), "=", mmom(i), i=1, 3), "Total=", dd
END IF
Expand All @@ -2294,11 +2294,11 @@ SUBROUTINE print_moments_nl(unit_number, nmom, rlab, mmom, rmom_vel)
SELECT CASE (l)
CASE (1)
dd = SQRT(SUM(rmom_vel(1:3)**2))
WRITE (unit_number, "(T3,A)") "Expectation value of momentum operator [a. u.] incl. com_nl"
WRITE (unit_number, "(T3,A)") "Expectation value of momentum operator incl. com_nl [a. u.]"
WRITE (unit_number, "(T5,3(A,A,D14.8,1X),T60,A,T67,F14.8)") &
(TRIM(rlab(i + 1)), "=", rmom_vel(i), i=1, 3), "Total=", dd
CASE (2)
WRITE (unit_number, "(T3,A)") "Expectation value of quadrupole operator in vel. repr. [a. u.] incl. com_nl"
WRITE (unit_number, "(T3,A)") "Expectation value of quadrupole operator in vel. repr. incl. com_nl [a. u.]"
WRITE (unit_number, "(T17,3(A,A,D14.8,9X))") &
(TRIM(rlab(i + 1)), "=", rmom_vel(i), i=4, 6)
WRITE (unit_number, "(T17,3(A,A,D14.8,9X))") &
Expand Down
6 changes: 5 additions & 1 deletion src/sap_kind_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ SUBROUTINE build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, ref
TYPE(clist_type), POINTER :: clist
TYPE(gth_potential_p_type), DIMENSION(:), POINTER :: gpotential
TYPE(gth_potential_type), POINTER :: gth_potential
TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set
TYPE(gto_basis_set_p_type), ALLOCATABLE, &
DIMENSION(:) :: basis_set
TYPE(gto_basis_set_type), POINTER :: orb_basis_set
TYPE(sgp_potential_p_type), DIMENSION(:), POINTER :: spotential
TYPE(sgp_potential_type), POINTER :: sgp_potential
Expand Down Expand Up @@ -345,6 +346,7 @@ SUBROUTINE build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, ref
ldai = ncoset(maxl + nder + 1)

!set up direct access to basis and potential
NULLIFY (gpotential, spotential)
ALLOCATE (basis_set(nkind), gpotential(nkind), spotential(nkind))
DO ikind = 1, nkind
CALL get_qs_kind(qs_kind_set(ikind), basis_set=orb_basis_set)
Expand Down Expand Up @@ -615,6 +617,8 @@ SUBROUTINE build_sap_ints(sap_int, sap_ppnl, qs_kind_set, nder, moment_mode, ref

!$OMP END PARALLEL

DEALLOCATE (basis_set)

CALL timestop(handle)

END SUBROUTINE build_sap_ints
Expand Down

0 comments on commit ba79d66

Please sign in to comment.