LCOV - code coverage report
Current view: top level - src - smeagol_emtoptions.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:71c3ab0) Lines: 0.0 % 164 0
Test Date: 2026-07-25 06:35:44 Functions: 0.0 % 4 0

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief CP2K+SMEAGOL interface.
      10              : !> \author Sergey Chulkov
      11              : !> \author Christian Ahart
      12              : !> \author Clotilde Cucinotta
      13              : ! **************************************************************************************************
      14              : MODULE smeagol_emtoptions
      15              :    #:include 'input_cp2k_smeagol.fypp'
      16              :    USE cell_types, ONLY: cell_type, &
      17              :                          scaled_to_real
      18              :    USE cp_dbcsr_api, ONLY: dbcsr_get_info, &
      19              :                            dbcsr_type
      20              : #if defined(__SMEAGOL)
      21              :    USE global_meshvar, ONLY: smeagolglobal_orbital_BS => orbital_BS
      22              : #endif
      23              :    USE input_constants, ONLY: smeagol_gridmethod_adaptive, &
      24              :                               smeagol_gridmethod_traditional, &
      25              :                               smeagol_integraltype_gauss_chebyshev, &
      26              :                               smeagol_integraltype_gauss_legendre
      27              :    USE kinds, ONLY: default_string_length, &
      28              :                     dp
      29              : #if defined(__SMEAGOL)
      30              :    USE mbfield, ONLY: smeagolglobal_ZeemanBx => ZeemanBx, &
      31              :                       smeagolglobal_ZeemanBy => ZeemanBy, &
      32              :                       smeagolglobal_ZeemanBz => ZeemanBz
      33              : #endif
      34              :    USE message_passing, ONLY: mp_para_env_type
      35              : #if defined(__SMEAGOL)
      36              :    USE mselfenergies, ONLY: SetOptionsSelfEnergies
      37              :    USE negfcoop, ONLY: coopinfo
      38              :    USE negfmod, ONLY: &
      39              : #:for name1, keyword1, val1 in reademtr_negfmod_llist
      40              :       smeagolglobal_${name1}$ => ${name1}$, &
      41              : #:endfor
      42              : #:for name1, keyword1, val1 in reademtr_negfmod_ilist
      43              :       smeagolglobal_${name1}$ => ${name1}$, &
      44              : #:endfor
      45              : #:for name1, keyword1, val1 in reademtr_negfmod_rlist
      46              :       smeagolglobal_${name1}$ => ${name1}$, &
      47              : #:endfor
      48              : #:for name1, keyword1, val1, unit1 in reademtr_negfmod_rydberg_plist
      49              :       smeagolglobal_${name1}$ => ${name1}$, &
      50              : #:endfor
      51              : #:for name1, keyword1, val1, unit1 in reademtr_negfmod_plist
      52              :       smeagolglobal_${name1}$ => ${name1}$, &
      53              : #:endfor
      54              : #:for name1, keyword1, val1 in readoptsnegf_negfmod_llist
      55              :       smeagolglobal_${name1}$ => ${name1}$, &
      56              : #:endfor
      57              : #:for name1, keyword1, val1 in readoptsnegf_negfmod_ilist
      58              :       smeagolglobal_${name1}$ => ${name1}$, &
      59              : #:endfor
      60              : #:for name1, keyword1, val1 in readoptsnegf_negfmod_rlist
      61              :       smeagolglobal_${name1}$ => ${name1}$, &
      62              : #:endfor
      63              : #:for name1, keyword1, val1, unit1 in readoptsnegf_negfmod_explicit_plist
      64              :       smeagolglobal_${name1}$ => ${name1}$, &
      65              : #:endfor
      66              : #:for name1, keyword1, val1 in emtoptions_negfmod_llist
      67              :       smeagolglobal_${name1}$ => ${name1}$, &
      68              : #:endfor
      69              : #:for name1, keyword1, val1 in emtoptions_negfmod_ilist
      70              :       smeagolglobal_${name1}$ => ${name1}$, &
      71              : #:endfor
      72              : #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_ilist
      73              :       smeagolglobal_${name1}$ => ${name1}$, &
      74              : #:endfor
      75              : #:for name1, keyword1, val1 in emtoptions_negfmod_rlist
      76              :       smeagolglobal_${name1}$ => ${name1}$, &
      77              : #:endfor
      78              : #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_rlist
      79              :       smeagolglobal_${name1}$ => ${name1}$, &
      80              : #:endfor
      81              : #:for name1, keyword1, val1, unit1 in emtoptions_negfmod_rydberg_plist
      82              :       smeagolglobal_${name1}$ => ${name1}$, &
      83              : #:endfor
      84              :       smeagolglobal_deltabss_bs => deltabss_bs, &
      85              :       smeagolglobal_gamma_negf => gamma_negf, &
      86              :       smeagolglobal_emforces => emforces, &
      87              :       smeagolglobal_emSTT => emSTT, &
      88              :       smeagolglobal_emSTTLin => emSTTLin, &
      89              :       smeagolglobal_gridmethod => gridmethod, &
      90              :       smeagolglobal_integraltype => integraltype, &
      91              :       smeagolglobal_ndivxy => ndivxy, &
      92              :       smeagolglobal_ndivxyNL => ndivxyNL, &
      93              :       smeagolglobal_negf_base_comm => negf_base_comm, &
      94              :       smeagolglobal_nebss_bs => nebss_bs, &
      95              :       smeagolglobal_nprocs_hs => nprocs_hs
      96              :    USE sigma, ONLY: &
      97              : #:for name1, keyword1, val1 in emtoptions_sigma_ilist
      98              :       smeagolglobal_${name1}$ => ${name1}$
      99              :       #:endfor
     100              : #endif
     101              :       USE smeagol_control_types, ONLY: smeagol_control_type
     102              :       USE string_utilities, ONLY: integer_to_string
     103              : #include "./base/base_uses.f90"
     104              : 
     105              :       IMPLICIT NONE
     106              :       PRIVATE
     107              : 
     108              :       CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'smeagol_emtoptions'
     109              : 
     110              :       PUBLIC :: reademtr, ReadOptionsNEGF_DFT, emtrans_options, emtrans_deallocate_global_arrays
     111              : 
     112              :    CONTAINS
     113              : 
     114            0 :       SUBROUTINE reademtr(smeagol_control, natoms, gamma_negf)
     115              :          TYPE(smeagol_control_type), POINTER                :: smeagol_control
     116              :          INTEGER, INTENT(in)                                :: natoms
     117              :          LOGICAL, INTENT(in)                                :: gamma_negf
     118              : 
     119              :          CHARACTER(LEN=*), PARAMETER :: routineN = 'reademtr'
     120              : 
     121              :          INTEGER                                            :: handle
     122              : 
     123            0 :          CALL timeset(routineN, handle)
     124              : 
     125              : #if defined(__SMEAGOL)
     126            0 :          CPASSERT(ASSOCIATED(smeagol_control%aux))
     127              : 
     128            0 :          smeagolglobal_gamma_negf = gamma_negf
     129              : 
     130            0 :          IF (smeagol_control%aux%AtmRVCte <= 0) smeagol_control%aux%AtmRVCte = natoms
     131              : 
     132              :          #:for name1, keyword1, val1 in reademtr_negfmod_llist
     133            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     134              :          #:endfor
     135              : 
     136              :          #:for name1, keyword1, val1 in reademtr_negfmod_ilist
     137            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     138              :          #:endfor
     139              : 
     140              :          #:for name1, keyword1, val1 in reademtr_negfmod_rlist
     141            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     142              :          #:endfor
     143              : 
     144              :          #:for name1, keyword1, val1, unit1 in reademtr_negfmod_rydberg_plist
     145            0 :             smeagolglobal_${name1}$ = smeagol_control%to_smeagol_energy_units*smeagol_control%aux%${name1}$
     146              :          #:endfor
     147              :          #:for name1, keyword1, val1, unit1 in reademtr_negfmod_plist
     148            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     149              :          #:endfor
     150              : 
     151            0 :          coopinfo%ccoop = smeagol_control%aux%COOPCalculate
     152            0 :          coopinfo%nbond = smeagol_control%aux%COOPNumberOfBonds
     153              : #else
     154              :          CALL cp_abort(__LOCATION__, &
     155              :                        "CP2K was compiled with no SMEAGOL support.")
     156              :          MARK_USED(smeagol_control)
     157              :          MARK_USED(natoms)
     158              :          MARK_USED(gamma_negf)
     159              : #endif
     160              : 
     161            0 :          CALL timestop(handle)
     162            0 :       END SUBROUTINE reademtr
     163              : 
     164            0 :       SUBROUTINE ReadOptionsNEGF_DFT(smeagol_control, ucell, torqueflag, torquelin)
     165              :          TYPE(smeagol_control_type), POINTER                :: smeagol_control
     166              :          TYPE(cell_type), POINTER                           :: ucell
     167              :          LOGICAL, INTENT(in)                                :: torqueflag, torquelin
     168              : 
     169              :          CHARACTER(LEN=*), PARAMETER :: routineN = 'ReadOptionsNEGF_DFT'
     170              : 
     171              :          INTEGER                                            :: handle
     172              :          REAL(kind=dp), DIMENSION(3)                        :: coord_real, coord_scaled
     173              : 
     174            0 :          CALL timeset(routineN, handle)
     175              : 
     176              : #if defined(__SMEAGOL)
     177            0 :          CPASSERT(ASSOCIATED(smeagol_control%aux))
     178              : 
     179            0 :          smeagolglobal_emSTT = torqueflag
     180            0 :          smeagolglobal_emSTTLin = torquelin
     181              : 
     182              :          ! In case of the original SIESTA+SMEAGOL, 'TimeReversal' keyword is enabled by default,
     183              :          ! therefore 'EM.TimeReversal' is also enabled.
     184              :          ! In case of this CP2K+SMEAGOL interface, the default value of 'timereversal' variable is .FALSE.
     185            0 :          IF (smeagol_control%aux%timereversal) THEN
     186              :             CALL cp_warn(__LOCATION__, &
     187            0 :                          "The SMEAGOL keyword 'EM.TimeReversal' is not supported yet.")
     188              :          END IF
     189              : 
     190              :          #:for name1, keyword1, val1 in readoptsnegf_negfmod_llist
     191            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     192              :          #:endfor
     193              : 
     194              :          #:for name1, keyword1, val1 in readoptsnegf_negfmod_ilist
     195            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     196              :          #:endfor
     197              : 
     198              :          #:for name1, keyword1, val1 in readoptsnegf_negfmod_rlist
     199            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     200              :          #:endfor
     201              : 
     202              :          ! readoptsnegf_negfmod_plist
     203            0 :          IF (.NOT. smeagol_control%aux%isexplicit_RGlxmin) smeagol_control%aux%RGlxmin = 0.0_dp
     204            0 :          IF (.NOT. smeagol_control%aux%isexplicit_RGlymin) smeagol_control%aux%RGlymin = 0.0_dp
     205            0 :          IF (.NOT. smeagol_control%aux%isexplicit_RGlzmin) smeagol_control%aux%RGlzmin = 0.0_dp
     206            0 :          IF (.NOT. smeagol_control%aux%isexplicit_RGlxmax) THEN
     207            0 :             coord_scaled(:) = [1.0_dp, 0.0_dp, 0.0_dp]
     208            0 :             CALL scaled_to_real(coord_real, coord_scaled, ucell)
     209            0 :             smeagol_control%aux%RGlxmax = coord_real(1)
     210              :          END IF
     211            0 :          IF (.NOT. smeagol_control%aux%isexplicit_RGlymax) THEN
     212            0 :             coord_scaled(:) = [0.0_dp, 1.0_dp, 0.0_dp]
     213            0 :             CALL scaled_to_real(coord_real, coord_scaled, ucell)
     214            0 :             smeagol_control%aux%RGlymax = coord_real(2)
     215              :          END IF
     216            0 :          IF (.NOT. smeagol_control%aux%isexplicit_RGlzmax) THEN
     217            0 :             coord_scaled(:) = [0.0_dp, 0.0_dp, 1.0_dp]
     218            0 :             CALL scaled_to_real(coord_real, coord_scaled, ucell)
     219            0 :             smeagol_control%aux%RGlzmax = coord_real(3)
     220              :          END IF
     221              :          #:for name1, keyword1, val1, unit1 in readoptsnegf_negfmod_explicit_plist
     222            0 :             smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     223              :          #:endfor
     224              : 
     225              :          ! options to add a Zeeman term to the Hamiltonian
     226              :          #:for name1, keyword1, val1, unit1 in readoptsnegf_bfield_rydberg_plist
     227            0 :             smeagolglobal_${name1}$ = smeagol_control%to_smeagol_energy_units*smeagol_control%aux%${name1}$
     228              :          #:endfor
     229              : #else
     230              :          CALL cp_abort(__LOCATION__, &
     231              :                        "CP2K was compiled with no SMEAGOL support.")
     232              :          MARK_USED(smeagol_control)
     233              :          MARK_USED(ucell)
     234              :          MARK_USED(torqueflag)
     235              :          MARK_USED(torquelin)
     236              :          ! local variables
     237              :          MARK_USED(coord_real)
     238              :          MARK_USED(coord_scaled)
     239              : #endif
     240              : 
     241            0 :          CALL timestop(handle)
     242            0 :       END SUBROUTINE ReadOptionsNEGF_DFT
     243              : 
     244            0 :       SUBROUTINE emtrans_options(smeagol_control, matrix_s, para_env, iter, istep, inicoor, iv, delta, nk)
     245              :          TYPE(smeagol_control_type), POINTER                :: smeagol_control
     246              :          TYPE(dbcsr_type), INTENT(in), POINTER              :: matrix_s
     247              :          TYPE(mp_para_env_type), POINTER                    :: para_env
     248              :          INTEGER, INTENT(in)                                :: iter, istep, inicoor, iv
     249              :          REAL(kind=dp), INTENT(in)                          :: delta
     250              :          INTEGER, INTENT(in)                                :: nk
     251              : 
     252              :          CHARACTER(LEN=*), PARAMETER :: routineN = 'emtrans_options'
     253              : 
     254              :          CHARACTER(len=default_string_length)               :: actual_val_str, expected_val_str
     255              :          INTEGER                                            :: GetRhoSingleLeadDefault, handle, i, iatom, n1, nblkcols_total, &
     256              :                                                                NParallelK, NParallelKbuf
     257            0 :          INTEGER, DIMENSION(:), POINTER                     :: col_blk_offset, col_blk_size
     258              : 
     259            0 :          CALL timeset(routineN, handle)
     260              : 
     261              : #if defined(__SMEAGOL)
     262            0 :          CPASSERT(ASSOCIATED(smeagol_control%aux))
     263              : 
     264              :          CALL dbcsr_get_info(matrix=matrix_s, nblkcols_total=nblkcols_total, &
     265            0 :                              col_blk_size=col_blk_size, col_blk_offset=col_blk_offset)
     266              :          ! number of atomic orbitals.
     267              :          ! The name n1 is meaningless, but it is used in the original SIESTA's version of emtrans_options() subroutine
     268            0 :          n1 = SUM(col_blk_size(1:nblkcols_total))
     269              : 
     270            0 :          IF ((iter == 1) .AND. (istep == inicoor) .AND. (iv == 0)) THEN
     271              : 
     272            0 :             IF (smeagol_control%aux%gridmethod == smeagol_gridmethod_traditional) THEN
     273            0 :                smeagolglobal_gridmethod = 'Traditional'
     274            0 :             ELSE IF (smeagol_control%aux%gridmethod == smeagol_gridmethod_adaptive) THEN
     275            0 :                smeagolglobal_gridmethod = 'Adaptivegrid'
     276              :             ELSE
     277            0 :                smeagolglobal_gridmethod = 'UNKNOWN'
     278              :             END IF
     279              : 
     280            0 :             IF (smeagol_control%aux%integraltype == smeagol_integraltype_gauss_legendre) THEN
     281            0 :                smeagolglobal_integraltype = 'gauss-legendre'
     282            0 :             ELSE IF (smeagol_control%aux%integraltype == smeagol_integraltype_gauss_chebyshev) THEN
     283            0 :                smeagolglobal_integraltype = 'gauss-chebyshev'
     284              :             ELSE
     285            0 :                smeagolglobal_integraltype = 'UNKNOWN'
     286              :             END IF
     287              : 
     288            0 :             smeagolglobal_negf_base_comm = para_env%get_handle()
     289              : 
     290            0 :             IF (MOD(smeagol_control%aux%ndivisions, 2) == 0) THEN
     291              :                CALL cp_abort(__LOCATION__, &
     292            0 :                              "AM.NumberDivisions value must be odd.")
     293              :             END IF
     294              : 
     295              :             ! It seems that 'sigmatodisk' parameter is specific to the SIESTA interface.
     296              :             ! Consider setting smeagol_control%aux%sigmatodisk = .FALSE. and remove smeagol_control%aux%storesigma input keyword.
     297            0 :             IF (smeagol_control%aux%storesigma == 2) THEN
     298            0 :                smeagol_control%aux%sigmatodisk = .TRUE.
     299            0 :             ELSE IF (smeagol_control%aux%storesigma == 1) THEN
     300            0 :                smeagol_control%aux%sigmatodisk = .FALSE.
     301              :             END IF
     302              : 
     303              :             ! Bound states
     304              :             !     options:
     305              :             !       bs_add    : true => bound states are added
     306              :             !                   false=> normal smeagol
     307              :             !       bs_method : 0    => calculate bound states with effective Hamiltonian
     308              :             !                   1    => calculate bound states by adding a small
     309              :             !                           imaginary part to the selfenergies
     310            0 :             IF (smeagol_control%aux%bs_nmid == 0) smeagol_control%aux%bs_nmid = n1/2
     311              : 
     312              :             ! SC: Bad practice: real number comparison
     313            0 :             IF (smeagol_control%aux%SigmaWideBand /= 0.0_dp) smeagol_control%aux%m_svdtolzi = 0.0_dp
     314              : 
     315            0 :             IF (smeagol_control%aux%leadspdos) smeagol_control%aux%leadsdos = .TRUE.
     316            0 :             IF (smeagol_control%aux%curr_distKEne) smeagol_control%aux%curr_distK = .TRUE.
     317            0 :             IF (smeagol_control%aux%curr_distK) smeagol_control%aux%curr_dist = .TRUE.
     318              : 
     319            0 :             IF (smeagolglobal_emSTT .AND. smeagolglobal_emSTTLin .OR. smeagol_control%aux%curr_dist) THEN
     320            0 :                smeagol_control%aux%emldos2 = .TRUE.
     321            0 :                IF (smeagol_control%aux%curr_dist) THEN
     322              :                   GetRhoSingleLeadDefault = 3
     323              :                ELSE
     324            0 :                   GetRhoSingleLeadDefault = -3
     325              :                END IF
     326              :             ELSE
     327              :                GetRhoSingleLeadDefault = 0
     328              :             END IF
     329              : 
     330              :             ! current-induced forces
     331              :             ! The value of 'smeagol_control%emforces' is set in qs_energies().
     332              :             ! Calculation of forces is enabled automatically for certain run_types
     333              :             ! (energy_force, geo_opt, md) and disabled otherwise.
     334            0 :             IF (smeagol_control%aux%curr_dist) THEN
     335            0 :                smeagol_control%emforces = .TRUE.
     336              :             END IF
     337              : 
     338            0 :             IF (.NOT. smeagol_control%aux%isexplicit_nprocs_hs) smeagol_control%aux%nprocs_hs = smeagol_control%aux%nprocs_inverse
     339            0 :             smeagolglobal_nprocs_hs = smeagol_control%aux%nprocs_hs
     340            0 :            IF (.NOT. smeagol_control%aux%isexplicit_GetRhoSingleLead) smeagol_control%aux%GetRhoSingleLead = GetRhoSingleLeadDefault
     341              : 
     342            0 :             IF (smeagol_control%aux%MinChannelIndex < 1) smeagol_control%aux%MinChannelIndex = 1
     343            0 :             IF (smeagol_control%aux%MaxChannelIndex < 1) THEN
     344            0 :                smeagol_control%aux%MaxChannelIndex = smeagol_control%aux%MinChannelIndex + 4
     345              :             END IF
     346              : 
     347            0 :             IF (smeagolglobal_emSTT .AND. smeagolglobal_emSTTLin .AND. smeagol_control%aux%GetRhoSingleLead /= -3) THEN
     348              :                CALL cp_warn(__LOCATION__, &
     349              :                             "EM.LDOSLeadsProjection should be set to -3. "// &
     350              :                             "If SpinTorque and STLinResp are T, otherwise the output "// &
     351            0 :                             "results for the spin transfer torque are incorrect.")
     352              :             END IF
     353              : 
     354              :             ! NParallelK
     355            0 :             NParallelK = smeagol_control%aux%NParallelK
     356            0 :             IF (MOD(para_env%num_pe, NParallelK) /= 0) then
     357              :                CALL cp_warn(__LOCATION__, &
     358              :                             "EM.ParallelOverKNum must be a divisor of the total number of "// &
     359            0 :                             "MPI processes used in a run; resetting the value of NParallelK.")
     360            0 :                NParallelKbuf = NParallelK
     361            0 :                DO NParallelK = NParallelKbuf, 1, -1
     362            0 :                   IF (MOD(para_env%num_pe, NParallelK) == 0) EXIT
     363              :                END DO
     364              :             END IF
     365              : 
     366            0 :             IF (NParallelK > para_env%num_pe) THEN
     367              :                CALL cp_warn(__LOCATION__, &
     368              :                             "EM.ParallelOverKNum can not be larger than the total number of "// &
     369            0 :                             "MPI processes used in a run; resetting the value of NParallelK.")
     370            0 :                NParallelK = -1
     371              :             END IF
     372              : 
     373            0 :             IF (NParallelK > nk) THEN
     374              :                CALL cp_warn(__LOCATION__, &
     375              :                             "EM.ParallelOverKNum can not be larger than the total number of "// &
     376            0 :                             "k-points used in a run; resetting the value of NParallelK.")
     377              :                NParallelK = -1
     378              :             END IF
     379              : 
     380            0 :             IF (NParallelK == -1) THEN
     381            0 :                DO NParallelK = nk, 1, -1
     382            0 :                   IF (MOD(para_env%num_pe, NParallelK) == 0) EXIT
     383              :                END DO
     384              :             END IF
     385              : 
     386            0 :             smeagol_control%aux%NParallelK = NParallelK
     387              : 
     388            0 :             IF (smeagol_control%aux%empdosk) smeagol_control%aux%empdos = .TRUE.
     389            0 :             IF (smeagol_control%aux%emldos2) smeagol_control%aux%emdos = .TRUE.
     390            0 :             IF (smeagol_control%aux%TransmissionChannels) smeagol_control%aux%emdos = .TRUE.
     391            0 :             IF (smeagol_control%aux%TransmissionMatrix) smeagol_control%aux%emdos = .TRUE.
     392            0 :             IF (smeagol_control%aux%curr_dist) smeagol_control%aux%emdos = .TRUE.
     393            0 :             IF (smeagol_control%aux%empdos) smeagol_control%aux%emdos = .TRUE.
     394            0 :             IF (smeagol_control%aux%m_skipsvd < 2.0_dp) smeagol_control%aux%m_skipsvd = 10.0_dp
     395              : 
     396            0 :             IF (smeagol_control%aux%CallImpuritySolver) smeagol_control%aux%ComputeImpurityGfMatsubara = .TRUE.
     397              : 
     398              :             #:for name1, keyword1, val1 in emtoptions_negfmod_llist
     399            0 :                smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     400              :             #:endfor
     401            0 :             smeagolglobal_emforces = smeagol_control%emforces
     402              : 
     403              :             ! emtoptions_local_ilist, emtoptions_local_explicit_ilist
     404            0 :             IF (.NOT. smeagol_control%aux%isexplicit_Sigma_NxLeft) smeagol_control%aux%Sigma_NxLeft = smeagol_control%aux%Sigma_Nx
     405            0 :             IF (.NOT. smeagol_control%aux%isexplicit_Sigma_NyLeft) smeagol_control%aux%Sigma_NyLeft = smeagol_control%aux%Sigma_Ny
     406            0 :             IF (.NOT. smeagol_control%aux%isexplicit_Sigma_NxRight) smeagol_control%aux%Sigma_NxRight = smeagol_control%aux%Sigma_Nx
     407            0 :             IF (.NOT. smeagol_control%aux%isexplicit_Sigma_NyRight) smeagol_control%aux%Sigma_NyRight = smeagol_control%aux%Sigma_Ny
     408              : 
     409            0 :             smeagolglobal_ndivxy(1) = smeagol_control%aux%Sigma_Nx
     410            0 :             smeagolglobal_ndivxy(2) = smeagol_control%aux%Sigma_Ny
     411            0 :             smeagolglobal_ndivxyNL(1, 1) = smeagol_control%aux%Sigma_NxLeft
     412            0 :             smeagolglobal_ndivxyNL(1, 2) = smeagol_control%aux%Sigma_NyLeft
     413            0 :             smeagolglobal_ndivxyNL(2, 1) = smeagol_control%aux%Sigma_NxRight
     414            0 :             smeagolglobal_ndivxyNL(2, 2) = smeagol_control%aux%Sigma_NyRight
     415              : 
     416            0 :             CALL SetOptionsSelfEnergies(smeagolglobal_ndivxyNL, 2)
     417              : 
     418              :             #:for name1, keyword1, val1 in emtoptions_negfmod_ilist
     419            0 :                smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     420              :             #:endfor
     421              : 
     422              :             #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_ilist
     423            0 :                smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     424              :             #:endfor
     425              : 
     426              :             #:for name1, keyword1, val1 in emtoptions_sigma_ilist
     427            0 :                smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     428              :             #:endfor
     429              : 
     430              :             #:for name1, keyword1, val1 in emtoptions_negfmod_rlist
     431            0 :                smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     432              :             #:endfor
     433              : 
     434              :             ! +++ bound states
     435            0 :             IF (.NOT. smeagol_control%aux%isexplicit_deltamin) smeagol_control%aux%deltamin = delta
     436              : 
     437              :             #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_rlist
     438            0 :                smeagolglobal_${name1}$ = smeagol_control%aux%${name1}$
     439              :             #:endfor
     440              : 
     441              :             #:for name1, keyword1, val1 in emtoptions_negfmod_rydberg_plist
     442            0 :                smeagolglobal_${name1}$ = smeagol_control%to_smeagol_energy_units*smeagol_control%aux%${name1}$
     443              :             #:endfor
     444              : 
     445              :             ! At present read_options_ImpuritySolver() is a dummy libsmeagol.a subroutine,
     446              :             ! so we do not call it
     447              :             !IF (smeagol_control%ComputeImpurityGfMatsubara) THEN
     448              :             !   CALL read_options_ImpuritySolver(CallImpuritySolver,n1)
     449              :             !END IF
     450              :          END IF
     451              : 
     452              :          ! *** bound states (re-implemented ReadSpeciesBS() and ReadBSSubSystemBoundaries() subroutines)
     453              : 
     454              :          ! bound- state-related global allocatable arrays
     455            0 :          ALLOCATE (smeagolglobal_deltabss_bs(smeagol_control%aux%nbss))
     456            0 :          ALLOCATE (smeagolglobal_nebss_bs(smeagol_control%aux%nbss, 2))
     457            0 :          ALLOCATE (smeagolglobal_orbital_BS(n1))
     458              : 
     459              :          ! BS.SubSystemsDelta
     460            0 :          IF (ALLOCATED(smeagol_control%aux%deltabss_bs)) THEN
     461            0 :             smeagolglobal_deltabss_bs(:) = smeagol_control%aux%deltabss_bs(:)
     462              :          ELSE
     463            0 :             smeagolglobal_deltabss_bs(:) = smeagol_control%aux%deltamin
     464              :          END IF
     465              : 
     466              :          ! BS.SubSystemsBoundaries
     467            0 :          IF (ALLOCATED(smeagol_control%aux%nebss_bs)) THEN
     468            0 :             IF (MAXVAL(smeagol_control%aux%nebss_bs) > n1) THEN
     469            0 :                CALL integer_to_string(MAXVAL(smeagol_control%aux%nebss_bs), actual_val_str)
     470            0 :                CALL integer_to_string(n1, expected_val_str)
     471              :                CALL cp_abort(__LOCATION__, &
     472              :                              "The largest index in BS.SubSystemsBoundaries section ("//TRIM(actual_val_str)// &
     473            0 :                              ") exceeds the number of atomic orbitals ("//TRIM(expected_val_str)//").")
     474              :             END IF
     475            0 :             smeagolglobal_nebss_bs(:, :) = smeagol_control%aux%nebss_bs(:, :)
     476              :          ELSE
     477            0 :             smeagolglobal_nebss_bs(1, 1) = 1
     478            0 :             smeagolglobal_nebss_bs(1, 2) = n1/smeagol_control%aux%nbss
     479            0 :             DO i = 2, smeagol_control%aux%nbss
     480            0 :                smeagolglobal_nebss_bs(i, 1) = smeagolglobal_nebss_bs(i - 1, 2) + 1
     481            0 :                smeagolglobal_nebss_bs(i, 2) = i*n1/smeagol_control%aux%nbss
     482              :             END DO
     483            0 :             smeagolglobal_nebss_bs(smeagol_control%aux%nbss, 2) = n1
     484              :          END IF
     485              : 
     486              :          ! AM.AtomListBS
     487            0 :          IF (ALLOCATED(smeagol_control%aux%atomlist_bs)) THEN
     488            0 :             IF (MAXVAL(smeagol_control%aux%atomlist_bs) > nblkcols_total) THEN
     489            0 :                CALL integer_to_string(MAXVAL(smeagol_control%aux%atomlist_bs), actual_val_str)
     490            0 :                CALL integer_to_string(nblkcols_total, expected_val_str)
     491              :                CALL cp_abort(__LOCATION__, &
     492              :                              "The largest atomic index in AM.AtomListBS keyword ("//TRIM(actual_val_str)// &
     493            0 :                              ") exceeds the number of atoms ("//TRIM(expected_val_str)//") in the extended molecule.")
     494              :             END IF
     495              : 
     496            0 :             smeagolglobal_orbital_BS(:) = .FALSE.
     497            0 :             DO i = 1, SIZE(smeagol_control%aux%atomlist_bs)
     498            0 :                iatom = smeagol_control%aux%atomlist_bs(i)
     499            0 :                smeagolglobal_orbital_BS(col_blk_offset(iatom):col_blk_offset(iatom) + col_blk_size(iatom) - 1) = .TRUE.
     500              :             END DO
     501              :          ELSE
     502            0 :             smeagolglobal_orbital_BS(:) = .TRUE.
     503              :          END IF
     504              : #else
     505              :          CALL cp_abort(__LOCATION__, &
     506              :                        "CP2K was compiled with no SMEAGOL support.")
     507              :          MARK_USED(smeagol_control)
     508              :          MARK_USED(matrix_s)
     509              :          MARK_USED(para_env)
     510              :          MARK_USED(iter)
     511              :          MARK_USED(istep)
     512              :          MARK_USED(inicoor)
     513              :          MARK_USED(iv)
     514              :          MARK_USED(delta)
     515              :          MARK_USED(nk)
     516              :          ! local variables
     517              :          MARK_USED(actual_val_str)
     518              :          MARK_USED(col_blk_offset)
     519              :          MARK_USED(col_blk_size)
     520              :          MARK_USED(expected_val_str)
     521              :          MARK_USED(GetRhoSingleLeadDefault)
     522              :          MARK_USED(i)
     523              :          MARK_USED(iatom)
     524              :          MARK_USED(n1)
     525              :          MARK_USED(nblkcols_total)
     526              :          MARK_USED(NParallelK)
     527              :          MARK_USED(NParallelKbuf)
     528              : #endif
     529              : 
     530            0 :          CALL timestop(handle)
     531            0 :       END SUBROUTINE emtrans_options
     532              : 
     533            0 :       SUBROUTINE emtrans_deallocate_global_arrays()
     534              : 
     535              : #if defined(__SMEAGOL)
     536            0 :          IF (ALLOCATED(smeagolglobal_deltabss_bs)) DEALLOCATE (smeagolglobal_deltabss_bs)
     537            0 :          IF (ALLOCATED(smeagolglobal_nebss_bs)) DEALLOCATE (smeagolglobal_nebss_bs)
     538            0 :          IF (ALLOCATED(smeagolglobal_orbital_BS)) DEALLOCATE (smeagolglobal_orbital_BS)
     539              : #endif
     540              : 
     541            0 :       END SUBROUTINE emtrans_deallocate_global_arrays
     542              : 
     543              :    END MODULE smeagol_emtoptions
     544              : 
        

Generated by: LCOV version 2.0-1