LCOV - code coverage report
Current view: top level - src/pw - pw_copy_all.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:262480d) Lines: 34 34 100.0 %
Date: 2024-11-22 07:00:40 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------------------------!
       2             : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3             : !   Copyright 2000-2024 CP2K developers group <https://cp2k.org>                                   !
       4             : !                                                                                                  !
       5             : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6             : !--------------------------------------------------------------------------------------------------!
       7             : 
       8             : ! **************************************************************************************************
       9             : !> \note
      10             : !>      Copy of pw types using an optimal match strategy
      11             : !> \par History
      12             : !>      JGH (06-May-2021) : pw_copy routine for complex match
      13             : !> \author JGH
      14             : ! **************************************************************************************************
      15             : MODULE pw_copy_all
      16             :    USE kinds,                           ONLY: dp
      17             :    USE message_passing,                 ONLY: mp_comm_type
      18             :    USE pw_grid_types,                   ONLY: pw_grid_type
      19             :    USE pw_types,                        ONLY: pw_c1d_gs_type
      20             : #include "../base/base_uses.f90"
      21             : 
      22             :    IMPLICIT NONE
      23             : 
      24             :    PRIVATE
      25             : 
      26             :    PUBLIC :: pw_copy_match
      27             : 
      28             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'pw_copy_all'
      29             :    LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .FALSE.
      30             : 
      31             : ! **************************************************************************************************
      32             : 
      33             : CONTAINS
      34             : 
      35             : ! **************************************************************************************************
      36             : !> \brief copy a pw type variable
      37             : !> \param pw1 ...
      38             : !> \param pw2 ...
      39             : !> \author JGH
      40             : ! **************************************************************************************************
      41           2 :    SUBROUTINE pw_copy_match(pw1, pw2)
      42             :       TYPE(pw_c1d_gs_type), INTENT(IN)                   :: pw1
      43             :       TYPE(pw_c1d_gs_type), INTENT(INOUT)                :: pw2
      44             : 
      45             :       COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:)        :: cc
      46             :       INTEGER                                            :: group_size, ig1, ig2, ip, jg2, me, ng1, &
      47             :                                                             ng2, ngm, penow
      48             :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: ngr
      49             :       INTEGER, ALLOCATABLE, DIMENSION(:, :)              :: g_hat
      50             :       INTEGER, DIMENSION(3)                              :: k1, k2
      51             :       TYPE(mp_comm_type)                                 :: group
      52             :       TYPE(pw_grid_type), POINTER                        :: pg1, pg2
      53             : 
      54           2 :       ng1 = SIZE(pw1%array)
      55           2 :       ng2 = SIZE(pw2%array)
      56             : 
      57           2 :       pg1 => pw1%pw_grid
      58           2 :       pg2 => pw2%pw_grid
      59             : 
      60           2 :       group = pg1%para%group
      61           2 :       group_size = pg1%para%group%num_pe
      62           2 :       me = pg1%para%group%mepos
      63           6 :       ALLOCATE (ngr(group_size))
      64           6 :       ngr = 0
      65           2 :       ngr(me + 1) = pg1%ngpts_cut_local
      66           2 :       CALL group%sum(ngr)
      67           6 :       ngm = MAXVAL(ngr)
      68           6 :       ALLOCATE (cc(ngm))
      69       13826 :       cc(1:ng1) = pw1%array(1:ng1)
      70           2 :       cc(ng1 + 1:ngm) = CMPLX(0.0_dp, 0.0_dp, KIND=dp)
      71             : 
      72           6 :       ALLOCATE (g_hat(3, ngm))
      73       55298 :       g_hat = 0
      74       55298 :       g_hat(1:3, 1:ng1) = pg1%g_hat(1:3, 1:ng1)
      75             : 
      76           6 :       DO ip = 1, group_size
      77           4 :          penow = me - ip + 1
      78           4 :          IF (penow < 0) penow = penow + group_size
      79             : 
      80       27652 :          DO ig1 = 1, ngr(penow + 1)
      81      110592 :             k1(1:3) = g_hat(1:3, ig1)
      82   143347968 :             jg2 = 0
      83   143347968 :             DO ig2 = 1, ng2
      84   573336576 :                k2(1:3) = pg2%g_hat(1:3, ig2)
      85   573350400 :                IF (SUM(ABS(k1 - k2)) == 0) THEN
      86             :                   jg2 = ig2
      87             :                   EXIT
      88             :                END IF
      89             :             END DO
      90       27652 :             IF (jg2 /= 0) pw2%array(jg2) = cc(ig1)
      91             :          END DO
      92           6 :          IF (ip /= group_size) THEN
      93           2 :             CALL group%shift(cc)
      94           2 :             CALL group%shift(g_hat)
      95             :          END IF
      96             : 
      97             :       END DO
      98             : 
      99           2 :       DEALLOCATE (ngr, cc, g_hat)
     100             : 
     101           2 :    END SUBROUTINE pw_copy_match
     102             : 
     103             : END MODULE pw_copy_all
     104             : 

Generated by: LCOV version 1.15