LCOV - code coverage report
Current view: top level - src - atoms_input.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:71c3ab0) Lines: 92.3 % 207 191
Test Date: 2026-07-25 06:35:44 Functions: 100.0 % 2 2

            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              : !> \par History
      10              : !>    cjm, Feb-20-2001 : added all the extended variables to
      11              : !>    system_type
      12              : !>    gt 23-09-2002 : major changes. Pointer part is allocated/deallocated
      13              : !>                    and initialized here. Atomic coordinates can now be
      14              : !>                    read also from &COORD section in the input file.
      15              : !>                    If &COORD is not found, .dat file is read.
      16              : !>                    If & coord is found and .NOT. 'INIT', parsing of the .dat
      17              : !>                    is performed to get the proper coords/vel/eta variables
      18              : !>     CJM 31-7-03  : Major rewrite.  No more atype
      19              : ! **************************************************************************************************
      20              : MODULE atoms_input
      21              :    USE atomic_kind_types,               ONLY: atomic_kind_type,&
      22              :                                               get_atomic_kind
      23              :    USE cell_types,                      ONLY: cell_transform_input_cartesian,&
      24              :                                               cell_type,&
      25              :                                               pbc,&
      26              :                                               scaled_to_real
      27              :    USE cp_linked_list_input,            ONLY: cp_sll_val_next,&
      28              :                                               cp_sll_val_type
      29              :    USE cp_log_handling,                 ONLY: cp_logger_get_default_io_unit,&
      30              :                                               cp_to_string
      31              :    USE cp_parser_methods,               ONLY: read_float_object
      32              :    USE cp_units,                        ONLY: cp_unit_to_cp2k
      33              :    USE input_section_types,             ONLY: section_vals_get,&
      34              :                                               section_vals_get_subs_vals,&
      35              :                                               section_vals_list_get,&
      36              :                                               section_vals_remove_values,&
      37              :                                               section_vals_type,&
      38              :                                               section_vals_val_get
      39              :    USE input_val_types,                 ONLY: val_get,&
      40              :                                               val_type
      41              :    USE kinds,                           ONLY: default_string_length,&
      42              :                                               dp
      43              :    USE memory_utilities,                ONLY: reallocate
      44              :    USE particle_types,                  ONLY: particle_type
      45              :    USE shell_potential_types,           ONLY: shell_kind_type
      46              :    USE string_table,                    ONLY: id2str,&
      47              :                                               s2s,&
      48              :                                               str2id
      49              :    USE string_utilities,                ONLY: uppercase
      50              :    USE topology_types,                  ONLY: atom_info_type,&
      51              :                                               topology_parameters_type
      52              : #include "./base/base_uses.f90"
      53              : 
      54              :    IMPLICIT NONE
      55              : 
      56              :    PRIVATE
      57              :    PUBLIC :: read_atoms_input, read_shell_coord_input
      58              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'atoms_input'
      59              : 
      60              : CONTAINS
      61              : 
      62              : ! **************************************************************************************************
      63              : !> \brief ...
      64              : !> \param topology ...
      65              : !> \param overwrite ...
      66              : !> \param subsys_section ...
      67              : !> \param save_mem ...
      68              : !> \author CJM
      69              : ! **************************************************************************************************
      70        48955 :    SUBROUTINE read_atoms_input(topology, overwrite, subsys_section, save_mem)
      71              : 
      72              :       TYPE(topology_parameters_type)                     :: topology
      73              :       LOGICAL, INTENT(IN), OPTIONAL                      :: overwrite
      74              :       TYPE(section_vals_type), POINTER                   :: subsys_section
      75              :       LOGICAL, INTENT(IN), OPTIONAL                      :: save_mem
      76              : 
      77              :       CHARACTER(len=*), PARAMETER                        :: routineN = 'read_atoms_input'
      78              : 
      79              :       CHARACTER(len=2*default_string_length)             :: line_att
      80              :       CHARACTER(len=default_string_length)               :: error_message, my_default_index, strtmp, &
      81              :                                                             unit_str
      82              :       INTEGER                                            :: default_id, end_c, handle, iatom, j, &
      83              :                                                             natom, output_unit, start_c, wrd
      84              :       LOGICAL                                            :: explicit, is_ok, my_overwrite, &
      85              :                                                             my_save_mem, scaled_coordinates
      86              :       REAL(KIND=dp)                                      :: r0(3), unit_conv
      87              :       TYPE(atom_info_type), POINTER                      :: atom_info
      88              :       TYPE(cell_type), POINTER                           :: cell
      89              :       TYPE(cp_sll_val_type), POINTER                     :: list
      90              :       TYPE(section_vals_type), POINTER                   :: coord_section
      91              :       TYPE(val_type), POINTER                            :: val
      92              : 
      93        10892 :       my_overwrite = .FALSE.
      94        10892 :       my_save_mem = .FALSE.
      95        10892 :       error_message = ""
      96        10892 :       output_unit = cp_logger_get_default_io_unit()
      97        10892 :       IF (PRESENT(overwrite)) my_overwrite = overwrite
      98        10892 :       IF (PRESENT(save_mem)) my_save_mem = save_mem
      99        10892 :       NULLIFY (coord_section)
     100        10892 :       coord_section => section_vals_get_subs_vals(subsys_section, "COORD")
     101        10892 :       CALL section_vals_get(coord_section, explicit=explicit)
     102        10892 :       IF (.NOT. explicit) RETURN
     103              : 
     104         9057 :       CALL timeset(routineN, handle)
     105              :       !-----------------------------------------------------------------------------
     106              :       !-----------------------------------------------------------------------------
     107              :       ! 1. get cell and topology%atom_info
     108              :       !-----------------------------------------------------------------------------
     109         9057 :       atom_info => topology%atom_info
     110         9057 :       cell => topology%cell_muc
     111         9057 :       CALL section_vals_val_get(coord_section, "UNIT", c_val=unit_str)
     112         9057 :       CALL section_vals_val_get(coord_section, "SCALED", l_val=scaled_coordinates)
     113         9057 :       unit_conv = cp_unit_to_cp2k(1.0_dp, TRIM(unit_str))
     114              : 
     115              :       !-----------------------------------------------------------------------------
     116              :       !-----------------------------------------------------------------------------
     117              :       ! 2. Read in the coordinates from &COORD section in the input file
     118              :       !-----------------------------------------------------------------------------
     119              :       CALL section_vals_val_get(coord_section, "_DEFAULT_KEYWORD_", &
     120         9057 :                                 n_rep_val=natom)
     121         9057 :       topology%natoms = natom
     122         9057 :       IF (my_overwrite) THEN
     123           82 :          CPASSERT(SIZE(atom_info%r, 2) == natom)
     124              :          CALL cp_warn(__LOCATION__, &
     125              :                       "Overwriting coordinates. Active coordinates read from &COORD section."// &
     126           82 :                       " Active coordinates READ from &COORD section ")
     127           82 :          CALL section_vals_list_get(coord_section, "_DEFAULT_KEYWORD_", list=list)
     128         7114 :          DO iatom = 1, natom
     129         7032 :             is_ok = cp_sll_val_next(list, val)
     130         7032 :             CALL val_get(val, c_val=line_att)
     131              :             ! Read name and atomic coordinates
     132         7032 :             start_c = 1
     133        35242 :             DO wrd = 1, 4
     134        78238 :                DO j = start_c, LEN(line_att)
     135        78238 :                   IF (line_att(j:j) /= ' ') THEN
     136              :                      start_c = j
     137              :                      EXIT
     138              :                   END IF
     139              :                END DO
     140        28128 :                end_c = LEN(line_att) + 1
     141       506702 :                DO j = start_c, LEN(line_att)
     142       506702 :                   IF (line_att(j:j) == ' ') THEN
     143              :                      end_c = j
     144              :                      EXIT
     145              :                   END IF
     146              :                END DO
     147        28128 :                IF (LEN_TRIM(line_att(start_c:end_c - 1)) == 0) THEN
     148            0 :                   CPABORT("incorrectly formatted line in coord section'"//line_att//"'")
     149              :                END IF
     150        28128 :                IF (wrd == 1) THEN
     151         7032 :                   atom_info%id_atmname(iatom) = str2id(s2s(line_att(start_c:end_c - 1)))
     152              :                ELSE
     153        21096 :                   READ (line_att(start_c:end_c - 1), *) atom_info%r(wrd - 1, iatom)
     154              :                END IF
     155        35160 :                start_c = end_c
     156              :             END DO
     157              :          END DO
     158              :       ELSE
     159              :          ! Element is assigned on the basis of the atm_name
     160         8975 :          topology%aa_element = .TRUE.
     161              : 
     162         8975 :          CALL reallocate(atom_info%id_molname, 1, natom)
     163         8975 :          CALL reallocate(atom_info%id_resname, 1, natom)
     164         8975 :          CALL reallocate(atom_info%resid, 1, natom)
     165         8975 :          CALL reallocate(atom_info%id_atmname, 1, natom)
     166         8975 :          CALL reallocate(atom_info%id_element, 1, natom)
     167         8975 :          CALL reallocate(atom_info%r, 1, 3, 1, natom)
     168         8975 :          CALL reallocate(atom_info%atm_mass, 1, natom)
     169         8975 :          CALL reallocate(atom_info%atm_charge, 1, natom)
     170              : 
     171         8975 :          CALL section_vals_list_get(coord_section, "_DEFAULT_KEYWORD_", list=list)
     172       230303 :          DO iatom = 1, natom
     173              :             ! we use only the first default_string_length characters of each line
     174       221328 :             is_ok = cp_sll_val_next(list, val)
     175       221328 :             CALL val_get(val, c_val=line_att)
     176       221328 :             default_id = str2id(s2s(""))
     177       221328 :             atom_info%id_molname(iatom) = default_id
     178       221328 :             atom_info%id_resname(iatom) = default_id
     179       221328 :             atom_info%resid(iatom) = 1
     180       221328 :             atom_info%id_atmname(iatom) = default_id
     181       221328 :             atom_info%id_element(iatom) = default_id
     182       221328 :             topology%molname_generated = .TRUE.
     183              :             ! Read name and atomic coordinates
     184       221328 :             start_c = 1
     185      1049880 :             DO wrd = 1, 6
     186      3770911 :                DO j = start_c, LEN(line_att)
     187      3770911 :                   IF (line_att(j:j) /= ' ') THEN
     188              :                      start_c = j
     189              :                      EXIT
     190              :                   END IF
     191              :                END DO
     192      1043700 :                end_c = LEN(line_att) + 1
     193      9650543 :                DO j = start_c, LEN(line_att)
     194      9650543 :                   IF (line_att(j:j) == ' ') THEN
     195              :                      end_c = j
     196              :                      EXIT
     197              :                   END IF
     198              :                END DO
     199      1043700 :                IF (LEN_TRIM(line_att(start_c:end_c - 1)) == 0) THEN
     200              :                   CALL cp_abort(__LOCATION__, &
     201              :                                 "Incorrectly formatted input line for atom "// &
     202              :                                 TRIM(ADJUSTL(cp_to_string(iatom)))// &
     203              :                                 " found in COORD section. Input line: <"// &
     204            0 :                                 TRIM(line_att)//"> ")
     205              :                END IF
     206       221328 :                SELECT CASE (wrd)
     207              :                CASE (1)
     208       221328 :                   atom_info%id_atmname(iatom) = str2id(s2s(line_att(start_c:end_c - 1)))
     209              :                CASE (2:4)
     210              :                   CALL read_float_object(line_att(start_c:end_c - 1), &
     211       663984 :                                          atom_info%r(wrd - 1, iatom), error_message)
     212       663984 :                   IF (LEN_TRIM(error_message) /= 0) THEN
     213              :                      CALL cp_abort(__LOCATION__, &
     214              :                                    "Incorrectly formatted input line for atom "// &
     215              :                                    TRIM(ADJUSTL(cp_to_string(iatom)))// &
     216              :                                    " found in COORD section. "//TRIM(error_message)// &
     217            0 :                                    " Input line: <"//TRIM(line_att)//"> ")
     218              :                   END IF
     219              :                CASE (5)
     220       116512 :                   READ (line_att(start_c:end_c - 1), *) strtmp
     221       116512 :                   atom_info%id_molname(iatom) = str2id(strtmp)
     222       116512 :                   atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
     223       116512 :                   topology%molname_generated = .FALSE.
     224              :                CASE (6)
     225        41876 :                   READ (line_att(start_c:end_c - 1), *) strtmp
     226      1085576 :                   atom_info%id_resname(iatom) = str2id(strtmp)
     227              :                END SELECT
     228      1043700 :                start_c = end_c
     229      1049880 :                IF (start_c > LEN_TRIM(line_att)) EXIT
     230              :             END DO
     231       221328 :             IF (topology%molname_generated) THEN
     232              :                ! Use defaults, if no molname was specified
     233       104816 :                WRITE (my_default_index, '(I0)') iatom
     234       104816 :                atom_info%id_molname(iatom) = str2id(s2s(TRIM(id2str(atom_info%id_atmname(iatom)))//TRIM(my_default_index)))
     235       104816 :                atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
     236              :             END IF
     237       221328 :             atom_info%id_element(iatom) = atom_info%id_atmname(iatom)
     238       221328 :             atom_info%atm_mass(iatom) = 0.0_dp
     239       230303 :             atom_info%atm_charge(iatom) = -HUGE(0.0_dp)
     240              :          END DO
     241              :       END IF
     242              :       !-----------------------------------------------------------------------------
     243              :       !-----------------------------------------------------------------------------
     244              :       ! 3. Convert coordinates into internal cp2k coordinates
     245              :       !-----------------------------------------------------------------------------
     246       237417 :       DO iatom = 1, natom
     247       237417 :          IF (scaled_coordinates) THEN
     248       117128 :             r0 = atom_info%r(:, iatom)
     249        29282 :             CALL scaled_to_real(atom_info%r(:, iatom), r0, cell)
     250              :          ELSE
     251       796312 :             atom_info%r(:, iatom) = atom_info%r(:, iatom)*unit_conv
     252       199078 :             CALL cell_transform_input_cartesian(cell, atom_info%r(:, iatom))
     253              :          END IF
     254              :       END DO
     255         9057 :       IF (my_save_mem) CALL section_vals_remove_values(coord_section)
     256              : 
     257         9057 :       CALL timestop(handle)
     258              :    END SUBROUTINE read_atoms_input
     259              : 
     260              : ! **************************************************************************************************
     261              : !> \brief ...
     262              : !> \param particle_set ...
     263              : !> \param shell_particle_set ...
     264              : !> \param cell ...
     265              : !> \param subsys_section ...
     266              : !> \param core_particle_set ...
     267              : !> \param save_mem ...
     268              : !> \author MI
     269              : ! **************************************************************************************************
     270          236 :    SUBROUTINE read_shell_coord_input(particle_set, shell_particle_set, cell, &
     271              :                                      subsys_section, core_particle_set, save_mem)
     272              : 
     273              :       TYPE(particle_type), DIMENSION(:), POINTER         :: particle_set, shell_particle_set
     274              :       TYPE(cell_type), POINTER                           :: cell
     275              :       TYPE(section_vals_type), POINTER                   :: subsys_section
     276              :       TYPE(particle_type), DIMENSION(:), OPTIONAL, &
     277              :          POINTER                                         :: core_particle_set
     278              :       LOGICAL, INTENT(IN), OPTIONAL                      :: save_mem
     279              : 
     280              :       CHARACTER(len=*), PARAMETER :: routineN = 'read_shell_coord_input'
     281              : 
     282              :       CHARACTER(len=2*default_string_length)             :: line_att
     283              :       CHARACTER(len=default_string_length)               :: name_kind, unit_str
     284              :       CHARACTER(len=default_string_length), &
     285          236 :          ALLOCATABLE, DIMENSION(:)                       :: at_name, at_name_c
     286              :       INTEGER                                            :: end_c, handle, ishell, j, nshell, &
     287              :                                                             output_unit, sh_index, start_c, wrd
     288          236 :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: at_index, at_index_c
     289              :       LOGICAL                                            :: core_scaled_coordinates, explicit, &
     290              :                                                             is_ok, is_shell, my_save_mem, &
     291              :                                                             shell_scaled_coordinates
     292              :       REAL(KIND=dp)                                      :: dab, mass_com, rab(3), unit_conv_core, &
     293              :                                                             unit_conv_shell
     294          236 :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :)        :: r, rc
     295              :       TYPE(atomic_kind_type), POINTER                    :: atomic_kind
     296              :       TYPE(cp_sll_val_type), POINTER                     :: list
     297              :       TYPE(section_vals_type), POINTER                   :: core_coord_section, shell_coord_section
     298              :       TYPE(shell_kind_type), POINTER                     :: shell
     299              :       TYPE(val_type), POINTER                            :: val
     300              : 
     301          236 :       my_save_mem = .FALSE.
     302          236 :       NULLIFY (atomic_kind, list, shell_coord_section, shell, val)
     303          236 :       output_unit = cp_logger_get_default_io_unit()
     304              : 
     305          236 :       IF (PRESENT(save_mem)) my_save_mem = save_mem
     306          236 :       NULLIFY (shell_coord_section, core_coord_section)
     307          236 :       shell_coord_section => section_vals_get_subs_vals(subsys_section, "SHELL_COORD")
     308          236 :       CALL section_vals_get(shell_coord_section, explicit=explicit)
     309          236 :       IF (.NOT. explicit) RETURN
     310              : 
     311           44 :       CALL timeset(routineN, handle)
     312           44 :       CPASSERT(ASSOCIATED(particle_set))
     313              :       !-----------------------------------------------------------------------------
     314              :       !-----------------------------------------------------------------------------
     315              :       ! 2. Read in the coordinates from &SHELL_COORD section in the input file
     316              :       !-----------------------------------------------------------------------------
     317           44 :       CALL section_vals_val_get(shell_coord_section, "UNIT", c_val=unit_str)
     318           44 :       CALL section_vals_val_get(shell_coord_section, "SCALED", l_val=shell_scaled_coordinates)
     319           44 :       unit_conv_shell = cp_unit_to_cp2k(1.0_dp, TRIM(unit_str))
     320              :       CALL section_vals_val_get(shell_coord_section, "_DEFAULT_KEYWORD_", &
     321           44 :                                 n_rep_val=nshell)
     322              : 
     323           44 :       IF (ASSOCIATED(shell_particle_set)) THEN
     324           44 :          CPASSERT((SIZE(shell_particle_set, 1) == nshell))
     325          308 :          ALLOCATE (r(3, nshell), at_name(nshell), at_index(nshell))
     326              :          CALL cp_warn(__LOCATION__, &
     327              :                       "Overwriting shell coordinates. "// &
     328           44 :                       "Active coordinates READ from &SHELL_COORD section. ")
     329           44 :          CALL section_vals_list_get(shell_coord_section, "_DEFAULT_KEYWORD_", list=list)
     330         4284 :          DO ishell = 1, nshell
     331              :             ! we use only the first default_string_length characters of each line
     332         4240 :             is_ok = cp_sll_val_next(list, val)
     333         4240 :             CALL val_get(val, c_val=line_att)
     334         4240 :             start_c = 1
     335        25484 :             DO wrd = 1, 5
     336        50558 :                DO j = start_c, LEN(line_att)
     337        50558 :                   IF (line_att(j:j) /= ' ') THEN
     338              :                      start_c = j
     339              :                      EXIT
     340              :                   END IF
     341              :                END DO
     342        21200 :                end_c = LEN(line_att) + 1
     343       327022 :                DO j = start_c, LEN(line_att)
     344       327022 :                   IF (line_att(j:j) == ' ') THEN
     345              :                      end_c = j
     346              :                      EXIT
     347              :                   END IF
     348              :                END DO
     349        21200 :                IF (wrd /= 5 .AND. end_c >= LEN(line_att) + 1) THEN
     350            0 :                   CPABORT("incorrectly formatted line in coord section'"//line_att//"'")
     351              :                END IF
     352        21200 :                IF (wrd == 1) THEN
     353         4240 :                   at_name(ishell) = line_att(start_c:end_c - 1)
     354         4240 :                   CALL uppercase(at_name(ishell))
     355        16960 :                ELSE IF (wrd == 5) THEN
     356         4240 :                   READ (line_att(start_c:end_c - 1), *) at_index(ishell)
     357              :                ELSE
     358        12720 :                   READ (line_att(start_c:end_c - 1), *) r(wrd - 1, ishell)
     359              :                END IF
     360        25440 :                start_c = end_c
     361              :             END DO
     362              :          END DO
     363              : 
     364           44 :          IF (PRESENT(core_particle_set)) THEN
     365           44 :             CPASSERT(ASSOCIATED(core_particle_set))
     366           44 :             core_coord_section => section_vals_get_subs_vals(subsys_section, "CORE_COORD")
     367           44 :             CALL section_vals_get(core_coord_section, explicit=explicit)
     368           44 :             IF (explicit) THEN
     369           44 :                CALL section_vals_val_get(core_coord_section, "UNIT", c_val=unit_str)
     370           44 :                CALL section_vals_val_get(core_coord_section, "SCALED", l_val=core_scaled_coordinates)
     371           44 :                unit_conv_core = cp_unit_to_cp2k(1.0_dp, TRIM(unit_str))
     372              :                CALL section_vals_val_get(core_coord_section, "_DEFAULT_KEYWORD_", &
     373           44 :                                          n_rep_val=nshell)
     374              : 
     375           44 :                CPASSERT((SIZE(core_particle_set, 1) == nshell))
     376          308 :                ALLOCATE (rc(3, nshell), at_name_c(nshell), at_index_c(nshell))
     377              :                CALL cp_warn(__LOCATION__, &
     378              :                             "Overwriting cores coordinates. "// &
     379           44 :                             "Active coordinates READ from &CORE_COORD section. ")
     380           44 :                CALL section_vals_list_get(core_coord_section, "_DEFAULT_KEYWORD_", list=list)
     381         4284 :                DO ishell = 1, nshell
     382              :                   ! we use only the first default_string_length characters of each line
     383         4240 :                   is_ok = cp_sll_val_next(list, val)
     384         4240 :                   CALL val_get(val, c_val=line_att)
     385         4240 :                   start_c = 1
     386        25484 :                   DO wrd = 1, 5
     387        50548 :                      DO j = start_c, LEN(line_att)
     388        50548 :                         IF (line_att(j:j) /= ' ') THEN
     389              :                            start_c = j
     390              :                            EXIT
     391              :                         END IF
     392              :                      END DO
     393        21200 :                      end_c = LEN(line_att) + 1
     394       326746 :                      DO j = start_c, LEN(line_att)
     395       326746 :                         IF (line_att(j:j) == ' ') THEN
     396              :                            end_c = j
     397              :                            EXIT
     398              :                         END IF
     399              :                      END DO
     400        21200 :                      IF (wrd /= 5 .AND. end_c >= LEN(line_att) + 1) THEN
     401            0 :                         CPABORT("incorrectly formatted line in coord section'"//line_att//"'")
     402              :                      END IF
     403        21200 :                      IF (wrd == 1) THEN
     404         4240 :                         at_name_c(ishell) = line_att(start_c:end_c - 1)
     405         4240 :                         CALL uppercase(at_name_c(ishell))
     406        16960 :                      ELSE IF (wrd == 5) THEN
     407         4240 :                         READ (line_att(start_c:end_c - 1), *) at_index_c(ishell)
     408              :                      ELSE
     409        12720 :                         READ (line_att(start_c:end_c - 1), *) rc(wrd - 1, ishell)
     410              :                      END IF
     411        25440 :                      start_c = end_c
     412              :                   END DO
     413              :                END DO
     414          132 :                IF (my_save_mem) CALL section_vals_remove_values(core_coord_section)
     415              :             END IF ! explicit
     416              :          END IF ! core_particle_set
     417              : 
     418              :          !-----------------------------------------------------------------------------
     419              :          ! 3. Check corrispondence and convert coordinates into internal cp2k coordinates
     420              :          !-----------------------------------------------------------------------------
     421         4284 :          DO ishell = 1, nshell
     422         4240 :             atomic_kind => particle_set(at_index(ishell))%atomic_kind
     423              :             CALL get_atomic_kind(atomic_kind=atomic_kind, &
     424         4240 :                                  name=name_kind, shell_active=is_shell, mass=mass_com, shell=shell)
     425         4240 :             CALL uppercase(name_kind)
     426         8524 :             IF ((TRIM(at_name(ishell)) == TRIM(name_kind)) .AND. is_shell) THEN
     427         4240 :                sh_index = particle_set(at_index(ishell))%shell_index
     428         4240 :                IF (shell_scaled_coordinates) THEN
     429            0 :                   CALL scaled_to_real(shell_particle_set(sh_index)%r(:), r(:, ishell), cell)
     430              :                ELSE
     431        16960 :                   shell_particle_set(sh_index)%r(:) = r(:, ishell)*unit_conv_shell
     432         4240 :                   CALL cell_transform_input_cartesian(cell, shell_particle_set(sh_index)%r(:))
     433              :                END IF
     434         4240 :                shell_particle_set(sh_index)%atom_index = at_index(ishell)
     435              : 
     436         4240 :                IF (PRESENT(core_particle_set) .AND. .NOT. explicit) THEN
     437              :                   core_particle_set(sh_index)%r(1) = (mass_com*particle_set(at_index(ishell))%r(1) - &
     438            0 :                                                       shell%mass_shell*shell_particle_set(sh_index)%r(1))/shell%mass_core
     439              :                   core_particle_set(sh_index)%r(2) = (mass_com*particle_set(at_index(ishell))%r(2) - &
     440            0 :                                                       shell%mass_shell*shell_particle_set(sh_index)%r(2))/shell%mass_core
     441              :                   core_particle_set(sh_index)%r(3) = (mass_com*particle_set(at_index(ishell))%r(3) - &
     442            0 :                                                       shell%mass_shell*shell_particle_set(sh_index)%r(3))/shell%mass_core
     443            0 :                   core_particle_set(sh_index)%atom_index = at_index(ishell)
     444            0 :                   rab = pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
     445         4240 :                ELSE IF (explicit) THEN
     446         4240 :                   IF (core_scaled_coordinates) THEN
     447            0 :                      CALL scaled_to_real(core_particle_set(sh_index)%r(:), rc(:, ishell), cell)
     448              :                   ELSE
     449        16960 :                      core_particle_set(sh_index)%r(:) = rc(:, ishell)*unit_conv_core
     450         4240 :                      CALL cell_transform_input_cartesian(cell, core_particle_set(sh_index)%r(:))
     451              :                   END IF
     452         4240 :                   core_particle_set(sh_index)%atom_index = at_index_c(ishell)
     453         4240 :                   rab = pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
     454         4240 :                   CPASSERT(TRIM(at_name(ishell)) == TRIM(at_name_c(ishell)))
     455         4240 :                   CPASSERT(at_index(ishell) == at_index_c(ishell))
     456              :                ELSE
     457            0 :                   rab = pbc(shell_particle_set(sh_index)%r, particle_set(at_index(ishell))%r, cell)
     458              :                END IF
     459              : 
     460         4240 :                dab = SQRT(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
     461         4240 :                IF (shell%max_dist > 0.0_dp .AND. shell%max_dist < dab) THEN
     462            0 :                   IF (output_unit > 0) THEN
     463            0 :                      WRITE (output_unit, *) "WARNING : shell and core for atom ", at_index(ishell), " seem to be too distant."
     464              :                   END IF
     465              :                END IF
     466              : 
     467              :             ELSE
     468            0 :                CPABORT("shell coordinate assigned to the wrong atom. check the shell indexes in the input")
     469              :             END IF
     470              :          END DO
     471           44 :          DEALLOCATE (r, at_index, at_name)
     472           44 :          DEALLOCATE (rc, at_index_c, at_name_c)
     473              : 
     474              :       END IF
     475              : 
     476           44 :       IF (my_save_mem) CALL section_vals_remove_values(shell_coord_section)
     477              : 
     478           44 :       CALL timestop(handle)
     479              : 
     480              :    END SUBROUTINE read_shell_coord_input
     481              : 
     482              : END MODULE atoms_input
        

Generated by: LCOV version 2.0-1