LCOV - code coverage report
Current view: top level - src - smeagol_control_types.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:4dc10b3) Lines: 31 125 24.8 %
Date: 2024-11-21 06:45:46 Functions: 3 7 42.9 %

          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             : !> \brief Input control types for NEGF/SMEAGOL transport calculations.
      10             : !> \author Sergey Chulkov
      11             : !> \author Christian Ahart
      12             : !> \author Clotilde Cucinotta
      13             : ! **************************************************************************************************
      14             : 
      15             : MODULE smeagol_control_types
      16             :    USE cp_units, ONLY: cp_unit_from_cp2k
      17             :    USE input_constants, ONLY: smeagol_bulklead_leftright, &
      18             :                               smeagol_gridmethod_traditional, &
      19             :                               smeagol_integraltype_gauss_legendre, &
      20             :                               smeagol_runtype_bulktransport, &
      21             :                               smeagol_runtype_emtransport
      22             :    USE input_section_types, ONLY: section_vals_get, &
      23             :                                   section_vals_get_subs_vals, &
      24             :                                   section_vals_type, &
      25             :                                   section_vals_val_get
      26             :    USE kinds, ONLY: default_string_length, &
      27             :                     dp
      28             :    USE physcon, ONLY: kelvin
      29             :    USE string_utilities, ONLY: integer_to_string
      30             :    USE util, ONLY: sort
      31             : #include "./base/base_uses.f90"
      32             :    #:include 'input_cp2k_smeagol.fypp'
      33             : 
      34             :    IMPLICIT NONE
      35             :    PRIVATE
      36             : 
      37             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'smeagol_control_types'
      38             : 
      39             :    PUBLIC :: smeagol_control_type
      40             :    PUBLIC :: smeagol_control_create, smeagol_control_release, read_smeagol_control
      41             : 
      42             : ! **************************************************************************************************
      43             : !> \brief SMEAGOL-related input parameters
      44             : ! **************************************************************************************************
      45             :    TYPE smeagol_control_type
      46             :       LOGICAL                                            :: smeagol_enabled = .FALSE.
      47             : 
      48             :       !> type of calculation
      49             :       INTEGER                                            :: run_type = smeagol_runtype_bulktransport
      50             : 
      51             :       !> regression test mode
      52             :       LOGICAL                                            :: do_regtest = .FALSE.
      53             : 
      54             :       !> current-induced forces. It is set automatically based on GLOBAL/run_type
      55             :       LOGICAL                                            :: emforces = .FALSE.
      56             : 
      57             :       !> scale factor to convert from CP2K (Hartree) to SMEAGOL (Rydberg) default energy unit
      58             :       REAL(kind=dp)                                      :: to_smeagol_energy_units = 2.0_dp
      59             : 
      60             :       !> number of cell images along i and j cell vectors
      61             :       INTEGER, DIMENSION(2)                              :: n_cell_images = (/1, 1/)
      62             : 
      63             :       !> what lead (bulk transport calculation)
      64             :       INTEGER                                            :: lead_label = smeagol_bulklead_leftright
      65             : 
      66             :       !> The length of the SMEAGOL project name is limited by 20 characters (hardcoded in SMEAGOL)
      67             :       CHARACTER(len=20)                                  :: project_name = "PROJECT_NAME"
      68             : 
      69             :       TYPE(smeagol_aux_control_type), POINTER            :: aux => NULL()
      70             : 
      71             :    END TYPE smeagol_control_type
      72             : 
      73             : ! **************************************************************************************************
      74             : !> \brief SMEAGOL-related auxiliary input parameters. They remain unallocated when
      75             : !>        SMEAGOL support is disabled.
      76             : ! **************************************************************************************************
      77             :    TYPE smeagol_aux_control_type
      78             :       !> MD or GEO_OPT iteration. In contrast with other components of smeagol_control_type that are read from the input file,
      79             :       !> these variables are initialised at the first NEGF iteration.
      80             :       !>
      81             :       !> index of MD or GEO_OPT iteration level.
      82             :       !> 0 if there is neither MD nor GEO_OPT iteration level (e.g. single-point energy calculation).
      83             :       !> -1 if it is not initialised by run_smeagol_emtrans() subroutine
      84             :       INTEGER                                            :: md_iter_level = -1
      85             :       !> The starting step value for MD / GEO_OPT iterations. The default value 0 can be overrited via STEP_START_VAL input keyword.
      86             :       INTEGER                                            :: md_first_step = 0
      87             : 
      88             :       !> BS.SubSystemsDelta(1:BS.Subsystems)
      89             :       REAL(kind=dp), ALLOCATABLE, DIMENSION(:)           :: deltabss_bs
      90             :       !> BS.SubSystemsBoundaries(1:BS.Subsystems, 1:2)
      91             :       INTEGER, ALLOCATABLE, DIMENSION(:, :)              :: nebss_bs
      92             :       !>
      93             :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: atomlist_bs
      94             : 
      95             :       REAL(kind=dp)                                      :: temperature = 300.0_dp/kelvin
      96             : 
      97             :       ! reademtr()
      98             :       #:for name1, keyword1, val1 in reademtr_local_llist
      99             :          LOGICAL                                            :: ${name1}$ = ${val1}$
     100             :       #:endfor
     101             : 
     102             :       #:for name1, keyword1, val1, unit1 in reademtr_local_explicit_plist
     103             :          LOGICAL                                            :: isexplicit_${name1}$ = .FALSE.
     104             :       #:endfor
     105             : 
     106             :       #:for name1, keyword1, val1 in reademtr_negfmod_llist
     107             :          LOGICAL                                            :: ${name1}$ = ${val1}$
     108             :       #:endfor
     109             : 
     110             :       #:for name1, keyword1, val1 in reademtr_negfcoop_llist
     111             :          LOGICAL                                            :: ${name1}$ = ${val1}$
     112             :       #:endfor
     113             : 
     114             :       #:for name1, keyword1, val1 in reademtr_local_ilist
     115             :          INTEGER                                            :: ${name1}$ = ${val1}$
     116             :       #:endfor
     117             : 
     118             :       #:for name1, keyword1, val1 in reademtr_negfmod_ilist
     119             :          INTEGER                                            :: ${name1}$ = ${val1}$
     120             :       #:endfor
     121             : 
     122             :       #:for name1, keyword1, val1 in reademtr_negfcoop_ilist
     123             :          INTEGER                                            :: ${name1}$ = ${val1}$
     124             :       #:endfor
     125             : 
     126             :       #:for name1, keyword1, val1 in reademtr_local_rlist
     127             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     128             :       #:endfor
     129             : 
     130             :       #:for name1, keyword1, val1 in reademtr_negfmod_rlist
     131             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     132             :       #:endfor
     133             : 
     134             :       #:for name1, keyword1, val1, unit1 in reademtr_local_plist
     135             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     136             :       #:endfor
     137             : 
     138             :       #:for name1, keyword1, val1, unit1 in reademtr_local_explicit_plist
     139             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     140             :       #:endfor
     141             : 
     142             :       #:for name1, keyword1, val1, unit1 in reademtr_negfmod_rydberg_plist
     143             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     144             :       #:endfor
     145             : 
     146             :       #:for name1, keyword1, val1, unit1 in reademtr_negfmod_plist
     147             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     148             :       #:endfor
     149             : 
     150             :       ! ReadOptionsNEGF_DFT()
     151             :       #:for name1, keyword1, val1 in readoptsnegf_negfmod_llist
     152             :          LOGICAL                                            :: ${name1}$ = ${val1}$
     153             :       #:endfor
     154             : 
     155             :       #:for name1, keyword1, val1, unit1 in readoptsnegf_negfmod_explicit_plist
     156             :          LOGICAL                                            :: isexplicit_${name1}$ = .FALSE.
     157             :       #:endfor
     158             : 
     159             :       #:for name1, keyword1, val1 in readoptsnegf_negfmod_ilist
     160             :          INTEGER                                            :: ${name1}$ = ${val1}$
     161             :       #:endfor
     162             : 
     163             :       #:for name1, keyword1, val1 in readoptsnegf_negfmod_rlist
     164             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     165             :       #:endfor
     166             : 
     167             :       #:for name1, keyword1, val1, unit1 in readoptsnegf_negfmod_explicit_plist
     168             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     169             :       #:endfor
     170             : 
     171             :       #:for name1, keyword1, val1, unit1 in readoptsnegf_bfield_rydberg_plist
     172             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     173             :       #:endfor
     174             : 
     175             :       ! emtrans_options()
     176             :       INTEGER                                            :: gridmethod = smeagol_gridmethod_traditional
     177             :       INTEGER                                            :: integraltype = smeagol_integraltype_gauss_legendre
     178             : 
     179             :       #:for name1, keyword1, val1 in emtoptions_negfmod_llist
     180             :          LOGICAL                                            :: ${name1}$ = ${val1}$
     181             :       #:endfor
     182             : 
     183             :       #:for name1, keyword1, val1, unit1 in emtoptions_local_explicit_ilist
     184             :          LOGICAL                                            :: isexplicit_${name1}$ = .FALSE.
     185             :       #:endfor
     186             : 
     187             :       #:for name1, keyword1, val1, unit1 in emtoptions_negfmod_explicit_ilist
     188             :          LOGICAL                                            :: isexplicit_${name1}$ = .FALSE.
     189             :       #:endfor
     190             : 
     191             :       #:for name1, keyword1, val1, unit1 in emtoptions_negfmod_explicit_rlist
     192             :          LOGICAL                                            :: isexplicit_${name1}$ = .FALSE.
     193             :       #:endfor
     194             : 
     195             :       #:for name1, keyword1, val1 in emtoptions_local_ilist
     196             :          INTEGER                                            :: ${name1}$ = ${val1}$
     197             :       #:endfor
     198             : 
     199             :       #:for name1, keyword1, val1 in emtoptions_local_explicit_ilist
     200             :          INTEGER                                            :: ${name1}$ = ${val1}$
     201             :       #:endfor
     202             : 
     203             :       #:for name1, keyword1, val1 in emtoptions_negfmod_ilist
     204             :          INTEGER                                            :: ${name1}$ = ${val1}$
     205             :       #:endfor
     206             : 
     207             :       #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_ilist
     208             :          INTEGER                                            :: ${name1}$ = ${val1}$
     209             :       #:endfor
     210             : 
     211             :       #:for name1, keyword1, val1 in emtoptions_sigma_ilist
     212             :          INTEGER                                            :: ${name1}$ = ${val1}$
     213             :       #:endfor
     214             : 
     215             :       #:for name1, keyword1, val1 in emtoptions_negfmod_rlist
     216             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     217             :       #:endfor
     218             : 
     219             :       #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_rlist
     220             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     221             :       #:endfor
     222             : 
     223             :       #:for name1, keyword1, val1, unit1 in emtoptions_negfmod_rydberg_plist
     224             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     225             :       #:endfor
     226             : 
     227             :       ! interface options
     228             :       #:for name1, keyword1, val1, unit1 in smeagol_interface_local_plist
     229             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     230             :       #:endfor
     231             :       #:for name1, keyword1, val1, unit1 in smeagol_interface_local_explicit_plist
     232             :          REAL(kind=dp)                                      :: ${name1}$ = ${val1}$
     233             :       #:endfor
     234             :       #:for name1, keyword1, val1, unit1 in smeagol_interface_local_explicit_plist
     235             :          LOGICAL                                            :: isexplicit_${name1}$ = .FALSE.
     236             :       #:endfor
     237             : 
     238             :    END TYPE smeagol_aux_control_type
     239             : CONTAINS
     240             : 
     241             : ! **************************************************************************************************
     242             : !> \brief allocate control options for SMEAGOL calculation
     243             : !> \param smeagol_control an object to create
     244             : ! **************************************************************************************************
     245       13372 :    SUBROUTINE smeagol_control_create(smeagol_control)
     246             :       TYPE(smeagol_control_type), POINTER                :: smeagol_control
     247             : 
     248             :       CHARACTER(len=*), PARAMETER :: routineN = 'smeagol_control_create'
     249             : 
     250             :       INTEGER                                            :: handle
     251             : 
     252        6686 :       CPASSERT(.NOT. ASSOCIATED(smeagol_control))
     253        6686 :       CALL timeset(routineN, handle)
     254             : 
     255       26744 :       ALLOCATE (smeagol_control)
     256             : #if defined(__SMEAGOL)
     257             :       ALLOCATE (smeagol_control%aux)
     258             : #else
     259             :       NULLIFY (smeagol_control%aux)
     260             : #endif
     261             : 
     262        6686 :       CALL timestop(handle)
     263        6686 :    END SUBROUTINE smeagol_control_create
     264             : 
     265             : ! **************************************************************************************************
     266             : !> \brief release SMEAGOL control object
     267             : !> \param smeagol_control an object to release
     268             : ! **************************************************************************************************
     269        6686 :    SUBROUTINE smeagol_control_release(smeagol_control)
     270             :       TYPE(smeagol_control_type), POINTER                :: smeagol_control
     271             : 
     272             :       CHARACTER(len=*), PARAMETER :: routineN = 'smeagol_control_release'
     273             : 
     274             :       INTEGER                                            :: handle
     275             : 
     276        6686 :       CALL timeset(routineN, handle)
     277             : 
     278        6686 :       IF (ASSOCIATED(smeagol_control)) THEN
     279        6686 :          IF (ASSOCIATED(smeagol_control%aux)) THEN
     280           0 :             IF (ALLOCATED(smeagol_control%aux%nebss_bs)) DEALLOCATE (smeagol_control%aux%nebss_bs)
     281           0 :             IF (ALLOCATED(smeagol_control%aux%deltabss_bs)) DEALLOCATE (smeagol_control%aux%deltabss_bs)
     282           0 :             IF (ALLOCATED(smeagol_control%aux%atomlist_bs)) DEALLOCATE (smeagol_control%aux%atomlist_bs)
     283             : 
     284           0 :             DEALLOCATE (smeagol_control%aux)
     285             :          END IF
     286        6686 :          DEALLOCATE (smeagol_control)
     287             :       END IF
     288             : 
     289        6686 :       CALL timestop(handle)
     290        6686 :    END SUBROUTINE smeagol_control_release
     291             : 
     292             : ! **************************************************************************************************
     293             : !> \brief Read SMEAGOL-related input parameters.
     294             : !> \param smeagol_control SMEAGOL control parameters
     295             : !> \param smeagol_section SMEAGOL input section
     296             : ! **************************************************************************************************
     297        6686 :    SUBROUTINE read_smeagol_control(smeagol_control, smeagol_section)
     298             :       TYPE(smeagol_control_type), POINTER                :: smeagol_control
     299             :       TYPE(section_vals_type), POINTER                   :: smeagol_section
     300             : 
     301             :       CHARACTER(len=*), PARAMETER :: routineN = 'read_smeagol_control'
     302             : 
     303             :       CHARACTER(len=default_string_length)               :: project_name
     304             :       INTEGER                                            :: handle
     305        6686 :       INTEGER, DIMENSION(:), POINTER                     :: n_cell_images_ptr
     306             : 
     307        6686 :       CALL timeset(routineN, handle)
     308             : 
     309        6686 :       CALL section_vals_val_get(smeagol_section, "_SECTION_PARAMETERS_", l_val=smeagol_control%smeagol_enabled)
     310             : 
     311             :       ! SMEAGOL project name
     312        6686 :       CALL section_vals_val_get(smeagol_section, "PROJECT_NAME", c_val=project_name)
     313        6686 :       smeagol_control%project_name = project_name
     314        6686 :       IF (smeagol_control%smeagol_enabled .AND. smeagol_control%project_name /= project_name) THEN
     315             :          CALL cp_warn(__LOCATION__, &
     316             :                       "SMEAGOL limits the length of the project name by 20 characters. "// &
     317           0 :                       "The project name is truncated to '"//TRIM(smeagol_control%project_name)//"'.")
     318             :       END IF
     319             : 
     320             :       ! reademtr() enum keywords
     321        6686 :       CALL section_vals_val_get(smeagol_section, "RUN_TYPE", i_val=smeagol_control%run_type)
     322             : 
     323             : #if !defined(__SMEAGOL)
     324        6686 :       IF (smeagol_control%run_type == smeagol_runtype_emtransport) THEN
     325             :          CALL cp_abort(__LOCATION__, &
     326           0 :                        "CP2K was compiled with no SMEAGOL support. SMEAGOL RUN_TYPE EMTransport is not available")
     327             :       END IF
     328             : #endif
     329             : 
     330        6686 :       CALL section_vals_val_get(smeagol_section, "REGRESSION_TEST", l_val=smeagol_control%do_regtest)
     331             : 
     332        6686 :       CALL section_vals_val_get(smeagol_section, "BulkLead", i_val=smeagol_control%lead_label)
     333             : 
     334             :       ! NOTE: keyword NIMAGES_IJ seems to be identical to ignored SMEAGOL keywords BulkTransvCellSizeX and BulkTransvCellSizeY
     335        6686 :       NULLIFY (n_cell_images_ptr)
     336        6686 :       CALL section_vals_val_get(smeagol_section, "NIMAGES_IJ", i_vals=n_cell_images_ptr)
     337       33430 :       smeagol_control%n_cell_images(1:2) = n_cell_images_ptr(1:2)
     338             : 
     339             :       ! Hartree > Rydberg scaling factor
     340        6686 :       smeagol_control%to_smeagol_energy_units = cp_unit_from_cp2k(1.0_dp, "RY")
     341             : 
     342        6686 :       IF (ASSOCIATED(smeagol_control%aux)) CALL read_smeagol_aux_control(smeagol_control%aux, smeagol_section)
     343             : 
     344        6686 :       CALL timestop(handle)
     345        6686 :    END SUBROUTINE read_smeagol_control
     346             : 
     347             : ! **************************************************************************************************
     348             : !> \brief Read SMEAGOL-related auxiliary input parameters.
     349             : !> \param smeagol_control SMEAGOL control parameters
     350             : !> \param smeagol_section SMEAGOL input section
     351             : ! **************************************************************************************************
     352           0 :    SUBROUTINE read_smeagol_aux_control(smeagol_control, smeagol_section)
     353             :       TYPE(smeagol_aux_control_type), POINTER            :: smeagol_control
     354             :       TYPE(section_vals_type), POINTER                   :: smeagol_section
     355             : 
     356             :       CHARACTER(len=*), PARAMETER :: routineN = 'read_smeagol_aux_control'
     357             : 
     358             :       CHARACTER(len=default_string_length)               :: nvals_str
     359             :       INTEGER                                            :: handle, i, n, nrep, n_unique
     360           0 :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: ivec, indices
     361           0 :       INTEGER, DIMENSION(:), POINTER                     :: iptr
     362             :       LOGICAL                                            :: is_explicit, do_abort
     363           0 :       REAL(kind=dp), DIMENSION(:), POINTER               :: rptr
     364             :       TYPE(section_vals_type), POINTER                   :: subsection
     365             : 
     366           0 :       CALL timeset(routineN, handle)
     367             : 
     368           0 :       smeagol_control%md_iter_level = -1
     369           0 :       smeagol_control%md_first_step = 0
     370             : 
     371           0 :       CALL section_vals_val_get(smeagol_section, "TEMPERATURE", r_val=smeagol_control%temperature)
     372             : 
     373             :       ! reademtr() logical keywords
     374             :       ! The following keywords (variables) that are part of the reademtr_local_llist list are read but unused
     375             :       ! CB.WriteComplexBands (WriteComplexBands = .FALSE.) unimplemented.
     376             :       ! Presumably, some of these keywords should be removed.
     377             :       #:for name1, keyword1, val1 in reademtr_local_llist
     378           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", l_val=smeagol_control%${name1}$)
     379             :       #:endfor
     380             :       #:for name1, keyword1, val1 in reademtr_negfmod_llist
     381           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", l_val=smeagol_control%${name1}$)
     382             :       #:endfor
     383             :       #:for name1, keyword1, val1 in reademtr_negfcoop_llist
     384           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", l_val=smeagol_control%${name1}$)
     385             :       #:endfor
     386             : 
     387             :       ! reademtr() integer keywords
     388             :       #:for name1, keyword1, val1 in reademtr_local_ilist
     389           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     390             :       #:endfor
     391             :       #:for name1, keyword1, val1 in reademtr_negfmod_ilist
     392           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     393             :       #:endfor
     394             :       #:for name1, keyword1, val1 in reademtr_negfcoop_ilist
     395           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     396             :       #:endfor
     397             : 
     398             :       ! reademtr() real-valued keywords
     399             :       #:for name1, keyword1, val1 in reademtr_local_rlist
     400           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     401             :       #:endfor
     402             :       #:for name1, keyword1, val1 in reademtr_negfmod_rlist
     403           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     404             :       #:endfor
     405             : 
     406             :       ! reademtr() physical-valued keywords
     407             :       #:for name1, keyword1, val1, unit1 in reademtr_local_plist
     408           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     409             :       #:endfor
     410             :       #:for name1, keyword1, val1, unit1 in reademtr_local_explicit_plist
     411             :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", &
     412             :                                    r_val=smeagol_control%${name1}$, &
     413           0 :                                    explicit=smeagol_control%isexplicit_${name1}$)
     414             :       #:endfor
     415             :       #:for name1, keyword1, val1, unit1 in reademtr_negfmod_rydberg_plist
     416           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     417             :       #:endfor
     418             :       #:for name1, keyword1, val1, unit1 in reademtr_negfmod_plist
     419           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     420             :       #:endfor
     421             : 
     422             :       ! ReadOptionsNEGF_DFT() logical keywords
     423             :       #:for name1, keyword1, val1 in readoptsnegf_negfmod_llist
     424           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", l_val=smeagol_control%${name1}$)
     425             :       #:endfor
     426             : 
     427             :       ! ReadOptionsNEGF_DFT() integer keywords
     428             :       #:for name1, keyword1, val1 in readoptsnegf_negfmod_ilist
     429           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     430             :       #:endfor
     431             : 
     432             :       ! ReadOptionsNEGF_DFT() real-valued keywords
     433             :       #:for name1, keyword1, val1 in readoptsnegf_negfmod_rlist
     434           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     435             :       #:endfor
     436             : 
     437             :       ! ReadOptionsNEGF_DFT() physical-valued keywords
     438             :       #:for name1, keyword1, val1, unit1 in readoptsnegf_negfmod_explicit_plist
     439             :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", &
     440             :                                    r_val=smeagol_control%${name1}$, &
     441           0 :                                    explicit=smeagol_control%isexplicit_${name1}$)
     442             :       #:endfor
     443             : 
     444             :       #:for name1, keyword1, val1, unit1 in readoptsnegf_bfield_rydberg_plist
     445           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     446             :       #:endfor
     447             : 
     448             :       ! emtrans_options() enum keywords
     449           0 :       CALL section_vals_val_get(smeagol_section, "EnergyGridType", i_val=smeagol_control%gridmethod)
     450           0 :       CALL section_vals_val_get(smeagol_section, "TypeOfIntegral", i_val=smeagol_control%integraltype)
     451             : 
     452             :       ! emtrans_options() logical keywords
     453             :       #:for name1, keyword1, val1 in emtoptions_negfmod_llist
     454           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", l_val=smeagol_control%${name1}$)
     455             :       #:endfor
     456             : 
     457             :       ! emtrans_options() integer keywords
     458             :       #:for name1, keyword1, val1 in emtoptions_local_ilist
     459           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     460             :       #:endfor
     461             : 
     462             :       #:for name1, keyword1, val1 in emtoptions_local_explicit_ilist
     463             :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", &
     464             :                                    i_val=smeagol_control%${name1}$, &
     465           0 :                                    explicit=smeagol_control%isexplicit_${name1}$)
     466             :       #:endfor
     467             : 
     468             :       #:for name1, keyword1, val1 in emtoptions_negfmod_ilist
     469           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     470             :       #:endfor
     471             : 
     472             :       #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_ilist
     473             :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", &
     474             :                                    i_val=smeagol_control%${name1}$, &
     475           0 :                                    explicit=smeagol_control%isexplicit_${name1}$)
     476             :       #:endfor
     477             : 
     478             :       #:for name1, keyword1, val1 in emtoptions_sigma_ilist
     479           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", i_val=smeagol_control%${name1}$)
     480             :       #:endfor
     481             : 
     482             :       ! emtrans_options() real-valued keywords
     483             :       #:for name1, keyword1, val1 in emtoptions_negfmod_rlist
     484           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     485             :       #:endfor
     486             : 
     487             :       #:for name1, keyword1, val1 in emtoptions_negfmod_explicit_rlist
     488             :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", &
     489             :                                    r_val=smeagol_control%${name1}$, &
     490           0 :                                    explicit=smeagol_control%isexplicit_${name1}$)
     491             :       #:endfor
     492             : 
     493             :       ! emtrans_options() physical-valued keywords
     494             :       #:for name1, keyword1, val1, unit1 in emtoptions_negfmod_rydberg_plist
     495           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     496             :       #:endfor
     497             : 
     498             :       ! interface physical-valued keywords
     499             :       #:for name1, keyword1, val1, unit1 in smeagol_interface_local_plist
     500           0 :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", r_val=smeagol_control%${name1}$)
     501             :       #:endfor
     502             :       #:for name1, keyword1, val1, unit1 in smeagol_interface_local_explicit_plist
     503             :          CALL section_vals_val_get(smeagol_section, "${keyword1}$", &
     504             :                                    r_val=smeagol_control%${name1}$, &
     505           0 :                                    explicit=smeagol_control%isexplicit_${name1}$)
     506             :       #:endfor
     507             : 
     508             :       ! Bound states
     509           0 :       IF (smeagol_control%nbss <= 0) THEN
     510             :          CALL cp_abort(__LOCATION__, &
     511           0 :                        "BS.Subsystems keyword should have a positive integer value.")
     512             :       END IF
     513             : 
     514           0 :       subsection => section_vals_get_subs_vals(smeagol_section, "BS.SubSystemsBoundaries")
     515           0 :       CALL section_vals_get(subsection, explicit=is_explicit)
     516           0 :       IF (is_explicit) THEN
     517           0 :          CALL section_vals_val_get(subsection, "_DEFAULT_KEYWORD_", n_rep_val=nrep, explicit=is_explicit)
     518           0 :          IF (.NOT. is_explicit) nrep = 0
     519             : 
     520           0 :          do_abort = .FALSE.
     521           0 :          IF (smeagol_control%nbss == nrep) THEN
     522           0 :             IF (is_explicit) THEN
     523           0 :                ALLOCATE (smeagol_control%nebss_bs(nrep, 2))
     524           0 :                DO i = 1, nrep
     525           0 :                   CALL section_vals_val_get(subsection, "_DEFAULT_KEYWORD_", i_rep_val=i, i_vals=iptr)
     526           0 :                   IF (SIZE(iptr) == 2) THEN
     527           0 :                      IF (MINVAL(iptr) > 0 .AND. iptr(1) <= iptr(2)) THEN
     528           0 :                         smeagol_control%nebss_bs(i, 1:2) = iptr(1:2)
     529             :                      ELSE
     530             :                         do_abort = .TRUE.
     531             :                         EXIT
     532             :                      END IF
     533             :                   ELSE
     534             :                      do_abort = .TRUE.
     535             :                      EXIT
     536             :                   END IF
     537             :                END DO
     538             :             END IF
     539             :          ELSE
     540             :             do_abort = .TRUE.
     541             :          END IF
     542             : 
     543           0 :          IF (do_abort) THEN
     544           0 :             CALL integer_to_string(smeagol_control%nbss, nvals_str)
     545             :             CALL cp_abort(__LOCATION__, &
     546             :                           "BS.SubSystemsBoundaries section is expected to have BS.Subsystems ("//TRIM(nvals_str)// &
     547           0 :                           ") lines with two positive integer numbers on each line.")
     548             :          END IF
     549             : 
     550             :       END IF
     551             : 
     552           0 :       CALL section_vals_val_get(smeagol_section, "BS.SubSystemsDelta", explicit=is_explicit)
     553           0 :       IF (is_explicit) THEN
     554           0 :          CALL section_vals_val_get(smeagol_section, "BS.SubSystemsDelta", r_vals=rptr)
     555           0 :          IF (smeagol_control%nbss /= SIZE(rptr)) THEN ! do negative deltas make sense ? .OR. MINVAL(rptr) < 0
     556           0 :             CALL integer_to_string(smeagol_control%nbss, nvals_str)
     557             :             CALL cp_abort(__LOCATION__, &
     558           0 :                           "BS.SubSystemsDelta keyword is expected to have BS.Subsystems ("//TRIM(nvals_str)//") real numbers.")
     559             :          END IF
     560             : 
     561           0 :          n = SIZE(rptr)
     562           0 :          ALLOCATE (smeagol_control%deltabss_bs(n))
     563           0 :          smeagol_control%deltabss_bs(1:n) = rptr(1:n)
     564             :          !ELSE allocate and set deltabss_bs() to deltamin
     565             :       END IF
     566             : 
     567           0 :       CALL section_vals_val_get(smeagol_section, "AM.AtomListBS", explicit=is_explicit)
     568           0 :       IF (is_explicit) THEN
     569           0 :          CALL section_vals_val_get(smeagol_section, "AM.AtomListBS", i_vals=iptr)
     570             : 
     571             :          ! subsys is not available at this stage, so we cannot check that MINVAL(iptr) <= natoms so far
     572           0 :          IF (SIZE(iptr) == 0 .OR. MINVAL(iptr) <= 0) THEN
     573             :             CALL cp_abort(__LOCATION__, &
     574           0 :                           "All atomic indices in AM.AtomListBS should be positive integer numbers.")
     575             :          END IF
     576             : 
     577           0 :          n = SIZE(iptr)
     578           0 :          ALLOCATE (ivec(n), indices(n))
     579           0 :          ivec(1:n) = iptr(1:n)
     580           0 :          CALL sort(ivec, n, indices)
     581             : 
     582           0 :          n_unique = 1
     583           0 :          DO i = 2, n
     584           0 :             IF (ivec(i) > ivec(i - 1)) n_unique = n_unique + 1
     585             :          END DO
     586             : 
     587           0 :          ALLOCATE (smeagol_control%atomlist_bs(n_unique))
     588           0 :          n_unique = 1
     589           0 :          smeagol_control%atomlist_bs(1) = ivec(1)
     590             : 
     591           0 :          DO i = 2, n
     592           0 :             IF (ivec(i) > ivec(i - 1)) THEN
     593           0 :                n_unique = n_unique + 1
     594           0 :                smeagol_control%atomlist_bs(n_unique) = ivec(i)
     595             :             END IF
     596             :          END DO
     597             :       END IF
     598             : 
     599           0 :       CALL timestop(handle)
     600           0 :    END SUBROUTINE read_smeagol_aux_control
     601           0 : END MODULE smeagol_control_types

Generated by: LCOV version 1.15