LCOV - code coverage report
Current view: top level - src - atoms_input.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:06f838d) Lines: 92.3 % 207 191
Test Date: 2026-06-05 07:04:50 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        47859 :    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        10668 :       my_overwrite = .FALSE.
      94        10668 :       my_save_mem = .FALSE.
      95        10668 :       error_message = ""
      96        10668 :       output_unit = cp_logger_get_default_io_unit()
      97        10668 :       IF (PRESENT(overwrite)) my_overwrite = overwrite
      98        10668 :       IF (PRESENT(save_mem)) my_save_mem = save_mem
      99        10668 :       NULLIFY (coord_section)
     100        10668 :       coord_section => section_vals_get_subs_vals(subsys_section, "COORD")
     101        10668 :       CALL section_vals_get(coord_section, explicit=explicit)
     102        10668 :       IF (.NOT. explicit) RETURN
     103              : 
     104         8841 :       CALL timeset(routineN, handle)
     105              :       !-----------------------------------------------------------------------------
     106              :       !-----------------------------------------------------------------------------
     107              :       ! 1. get cell and topology%atom_info
     108              :       !-----------------------------------------------------------------------------
     109         8841 :       atom_info => topology%atom_info
     110         8841 :       cell => topology%cell_muc
     111         8841 :       CALL section_vals_val_get(coord_section, "UNIT", c_val=unit_str)
     112         8841 :       CALL section_vals_val_get(coord_section, "SCALED", l_val=scaled_coordinates)
     113         8841 :       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         8841 :                                 n_rep_val=natom)
     121         8841 :       topology%natoms = natom
     122         8841 :       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) &
     148            0 :                   CPABORT("incorrectly formatted line in coord section'"//line_att//"'")
     149        28128 :                IF (wrd == 1) THEN
     150         7032 :                   atom_info%id_atmname(iatom) = str2id(s2s(line_att(start_c:end_c - 1)))
     151              :                ELSE
     152        21096 :                   READ (line_att(start_c:end_c - 1), *) atom_info%r(wrd - 1, iatom)
     153              :                END IF
     154        35160 :                start_c = end_c
     155              :             END DO
     156              :          END DO
     157              :       ELSE
     158              :          ! Element is assigned on the basis of the atm_name
     159         8759 :          topology%aa_element = .TRUE.
     160              : 
     161         8759 :          CALL reallocate(atom_info%id_molname, 1, natom)
     162         8759 :          CALL reallocate(atom_info%id_resname, 1, natom)
     163         8759 :          CALL reallocate(atom_info%resid, 1, natom)
     164         8759 :          CALL reallocate(atom_info%id_atmname, 1, natom)
     165         8759 :          CALL reallocate(atom_info%id_element, 1, natom)
     166         8759 :          CALL reallocate(atom_info%r, 1, 3, 1, natom)
     167         8759 :          CALL reallocate(atom_info%atm_mass, 1, natom)
     168         8759 :          CALL reallocate(atom_info%atm_charge, 1, natom)
     169              : 
     170         8759 :          CALL section_vals_list_get(coord_section, "_DEFAULT_KEYWORD_", list=list)
     171       228971 :          DO iatom = 1, natom
     172              :             ! we use only the first default_string_length characters of each line
     173       220212 :             is_ok = cp_sll_val_next(list, val)
     174       220212 :             CALL val_get(val, c_val=line_att)
     175       220212 :             default_id = str2id(s2s(""))
     176       220212 :             atom_info%id_molname(iatom) = default_id
     177       220212 :             atom_info%id_resname(iatom) = default_id
     178       220212 :             atom_info%resid(iatom) = 1
     179       220212 :             atom_info%id_atmname(iatom) = default_id
     180       220212 :             atom_info%id_element(iatom) = default_id
     181       220212 :             topology%molname_generated = .TRUE.
     182              :             ! Read name and atomic coordinates
     183       220212 :             start_c = 1
     184      1045304 :             DO wrd = 1, 6
     185      3755041 :                DO j = start_c, LEN(line_att)
     186      3755041 :                   IF (line_att(j:j) /= ' ') THEN
     187              :                      start_c = j
     188              :                      EXIT
     189              :                   END IF
     190              :                END DO
     191      1039124 :                end_c = LEN(line_att) + 1
     192      9608297 :                DO j = start_c, LEN(line_att)
     193      9608297 :                   IF (line_att(j:j) == ' ') THEN
     194              :                      end_c = j
     195              :                      EXIT
     196              :                   END IF
     197              :                END DO
     198      1039124 :                IF (LEN_TRIM(line_att(start_c:end_c - 1)) == 0) &
     199              :                   CALL cp_abort(__LOCATION__, &
     200              :                                 "Incorrectly formatted input line for atom "// &
     201              :                                 TRIM(ADJUSTL(cp_to_string(iatom)))// &
     202              :                                 " found in COORD section. Input line: <"// &
     203            0 :                                 TRIM(line_att)//"> ")
     204       220212 :                SELECT CASE (wrd)
     205              :                CASE (1)
     206       220212 :                   atom_info%id_atmname(iatom) = str2id(s2s(line_att(start_c:end_c - 1)))
     207              :                CASE (2:4)
     208              :                   CALL read_float_object(line_att(start_c:end_c - 1), &
     209       660636 :                                          atom_info%r(wrd - 1, iatom), error_message)
     210       660636 :                   IF (LEN_TRIM(error_message) /= 0) &
     211              :                      CALL cp_abort(__LOCATION__, &
     212              :                                    "Incorrectly formatted input line for atom "// &
     213              :                                    TRIM(ADJUSTL(cp_to_string(iatom)))// &
     214              :                                    " found in COORD section. "//TRIM(error_message)// &
     215            0 :                                    " Input line: <"//TRIM(line_att)//"> ")
     216              :                CASE (5)
     217       116428 :                   READ (line_att(start_c:end_c - 1), *) strtmp
     218       116428 :                   atom_info%id_molname(iatom) = str2id(strtmp)
     219       116428 :                   atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
     220       116428 :                   topology%molname_generated = .FALSE.
     221              :                CASE (6)
     222        41848 :                   READ (line_att(start_c:end_c - 1), *) strtmp
     223      1080972 :                   atom_info%id_resname(iatom) = str2id(strtmp)
     224              :                END SELECT
     225      1039124 :                start_c = end_c
     226      1045304 :                IF (start_c > LEN_TRIM(line_att)) EXIT
     227              :             END DO
     228       220212 :             IF (topology%molname_generated) THEN
     229              :                ! Use defaults, if no molname was specified
     230       103784 :                WRITE (my_default_index, '(I0)') iatom
     231       103784 :                atom_info%id_molname(iatom) = str2id(s2s(TRIM(id2str(atom_info%id_atmname(iatom)))//TRIM(my_default_index)))
     232       103784 :                atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
     233              :             END IF
     234       220212 :             atom_info%id_element(iatom) = atom_info%id_atmname(iatom)
     235       220212 :             atom_info%atm_mass(iatom) = 0.0_dp
     236       228971 :             atom_info%atm_charge(iatom) = -HUGE(0.0_dp)
     237              :          END DO
     238              :       END IF
     239              :       !-----------------------------------------------------------------------------
     240              :       !-----------------------------------------------------------------------------
     241              :       ! 3. Convert coordinates into internal cp2k coordinates
     242              :       !-----------------------------------------------------------------------------
     243       236085 :       DO iatom = 1, natom
     244       236085 :          IF (scaled_coordinates) THEN
     245       116304 :             r0 = atom_info%r(:, iatom)
     246        29076 :             CALL scaled_to_real(atom_info%r(:, iatom), r0, cell)
     247              :          ELSE
     248       792672 :             atom_info%r(:, iatom) = atom_info%r(:, iatom)*unit_conv
     249       198168 :             CALL cell_transform_input_cartesian(cell, atom_info%r(:, iatom))
     250              :          END IF
     251              :       END DO
     252         8841 :       IF (my_save_mem) CALL section_vals_remove_values(coord_section)
     253              : 
     254         8841 :       CALL timestop(handle)
     255              :    END SUBROUTINE read_atoms_input
     256              : 
     257              : ! **************************************************************************************************
     258              : !> \brief ...
     259              : !> \param particle_set ...
     260              : !> \param shell_particle_set ...
     261              : !> \param cell ...
     262              : !> \param subsys_section ...
     263              : !> \param core_particle_set ...
     264              : !> \param save_mem ...
     265              : !> \author MI
     266              : ! **************************************************************************************************
     267          236 :    SUBROUTINE read_shell_coord_input(particle_set, shell_particle_set, cell, &
     268              :                                      subsys_section, core_particle_set, save_mem)
     269              : 
     270              :       TYPE(particle_type), DIMENSION(:), POINTER         :: particle_set, shell_particle_set
     271              :       TYPE(cell_type), POINTER                           :: cell
     272              :       TYPE(section_vals_type), POINTER                   :: subsys_section
     273              :       TYPE(particle_type), DIMENSION(:), OPTIONAL, &
     274              :          POINTER                                         :: core_particle_set
     275              :       LOGICAL, INTENT(IN), OPTIONAL                      :: save_mem
     276              : 
     277              :       CHARACTER(len=*), PARAMETER :: routineN = 'read_shell_coord_input'
     278              : 
     279              :       CHARACTER(len=2*default_string_length)             :: line_att
     280              :       CHARACTER(len=default_string_length)               :: name_kind, unit_str
     281              :       CHARACTER(len=default_string_length), &
     282          236 :          ALLOCATABLE, DIMENSION(:)                       :: at_name, at_name_c
     283              :       INTEGER                                            :: end_c, handle, ishell, j, nshell, &
     284              :                                                             output_unit, sh_index, start_c, wrd
     285          236 :       INTEGER, ALLOCATABLE, DIMENSION(:)                 :: at_index, at_index_c
     286              :       LOGICAL                                            :: core_scaled_coordinates, explicit, &
     287              :                                                             is_ok, is_shell, my_save_mem, &
     288              :                                                             shell_scaled_coordinates
     289              :       REAL(KIND=dp)                                      :: dab, mass_com, rab(3), unit_conv_core, &
     290              :                                                             unit_conv_shell
     291          236 :       REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :)        :: r, rc
     292              :       TYPE(atomic_kind_type), POINTER                    :: atomic_kind
     293              :       TYPE(cp_sll_val_type), POINTER                     :: list
     294              :       TYPE(section_vals_type), POINTER                   :: core_coord_section, shell_coord_section
     295              :       TYPE(shell_kind_type), POINTER                     :: shell
     296              :       TYPE(val_type), POINTER                            :: val
     297              : 
     298          236 :       my_save_mem = .FALSE.
     299          236 :       NULLIFY (atomic_kind, list, shell_coord_section, shell, val)
     300          236 :       output_unit = cp_logger_get_default_io_unit()
     301              : 
     302          236 :       IF (PRESENT(save_mem)) my_save_mem = save_mem
     303          236 :       NULLIFY (shell_coord_section, core_coord_section)
     304          236 :       shell_coord_section => section_vals_get_subs_vals(subsys_section, "SHELL_COORD")
     305          236 :       CALL section_vals_get(shell_coord_section, explicit=explicit)
     306          236 :       IF (.NOT. explicit) RETURN
     307              : 
     308           44 :       CALL timeset(routineN, handle)
     309           44 :       CPASSERT(ASSOCIATED(particle_set))
     310              :       !-----------------------------------------------------------------------------
     311              :       !-----------------------------------------------------------------------------
     312              :       ! 2. Read in the coordinates from &SHELL_COORD section in the input file
     313              :       !-----------------------------------------------------------------------------
     314           44 :       CALL section_vals_val_get(shell_coord_section, "UNIT", c_val=unit_str)
     315           44 :       CALL section_vals_val_get(shell_coord_section, "SCALED", l_val=shell_scaled_coordinates)
     316           44 :       unit_conv_shell = cp_unit_to_cp2k(1.0_dp, TRIM(unit_str))
     317              :       CALL section_vals_val_get(shell_coord_section, "_DEFAULT_KEYWORD_", &
     318           44 :                                 n_rep_val=nshell)
     319              : 
     320           44 :       IF (ASSOCIATED(shell_particle_set)) THEN
     321           44 :          CPASSERT((SIZE(shell_particle_set, 1) == nshell))
     322          308 :          ALLOCATE (r(3, nshell), at_name(nshell), at_index(nshell))
     323              :          CALL cp_warn(__LOCATION__, &
     324              :                       "Overwriting shell coordinates. "// &
     325           44 :                       "Active coordinates READ from &SHELL_COORD section. ")
     326           44 :          CALL section_vals_list_get(shell_coord_section, "_DEFAULT_KEYWORD_", list=list)
     327         4284 :          DO ishell = 1, nshell
     328              :             ! we use only the first default_string_length characters of each line
     329         4240 :             is_ok = cp_sll_val_next(list, val)
     330         4240 :             CALL val_get(val, c_val=line_att)
     331         4240 :             start_c = 1
     332        25484 :             DO wrd = 1, 5
     333        50558 :                DO j = start_c, LEN(line_att)
     334        50558 :                   IF (line_att(j:j) /= ' ') THEN
     335              :                      start_c = j
     336              :                      EXIT
     337              :                   END IF
     338              :                END DO
     339        21200 :                end_c = LEN(line_att) + 1
     340       327022 :                DO j = start_c, LEN(line_att)
     341       327022 :                   IF (line_att(j:j) == ' ') THEN
     342              :                      end_c = j
     343              :                      EXIT
     344              :                   END IF
     345              :                END DO
     346        21200 :                IF (wrd /= 5 .AND. end_c >= LEN(line_att) + 1) &
     347            0 :                   CPABORT("incorrectly formatted line in coord section'"//line_att//"'")
     348        21200 :                IF (wrd == 1) THEN
     349         4240 :                   at_name(ishell) = line_att(start_c:end_c - 1)
     350         4240 :                   CALL uppercase(at_name(ishell))
     351        16960 :                ELSE IF (wrd == 5) THEN
     352         4240 :                   READ (line_att(start_c:end_c - 1), *) at_index(ishell)
     353              :                ELSE
     354        12720 :                   READ (line_att(start_c:end_c - 1), *) r(wrd - 1, ishell)
     355              :                END IF
     356        25440 :                start_c = end_c
     357              :             END DO
     358              :          END DO
     359              : 
     360           44 :          IF (PRESENT(core_particle_set)) THEN
     361           44 :             CPASSERT(ASSOCIATED(core_particle_set))
     362           44 :             core_coord_section => section_vals_get_subs_vals(subsys_section, "CORE_COORD")
     363           44 :             CALL section_vals_get(core_coord_section, explicit=explicit)
     364           44 :             IF (explicit) THEN
     365           44 :                CALL section_vals_val_get(core_coord_section, "UNIT", c_val=unit_str)
     366           44 :                CALL section_vals_val_get(core_coord_section, "SCALED", l_val=core_scaled_coordinates)
     367           44 :                unit_conv_core = cp_unit_to_cp2k(1.0_dp, TRIM(unit_str))
     368              :                CALL section_vals_val_get(core_coord_section, "_DEFAULT_KEYWORD_", &
     369           44 :                                          n_rep_val=nshell)
     370              : 
     371           44 :                CPASSERT((SIZE(core_particle_set, 1) == nshell))
     372          308 :                ALLOCATE (rc(3, nshell), at_name_c(nshell), at_index_c(nshell))
     373              :                CALL cp_warn(__LOCATION__, &
     374              :                             "Overwriting cores coordinates. "// &
     375           44 :                             "Active coordinates READ from &CORE_COORD section. ")
     376           44 :                CALL section_vals_list_get(core_coord_section, "_DEFAULT_KEYWORD_", list=list)
     377         4284 :                DO ishell = 1, nshell
     378              :                   ! we use only the first default_string_length characters of each line
     379         4240 :                   is_ok = cp_sll_val_next(list, val)
     380         4240 :                   CALL val_get(val, c_val=line_att)
     381         4240 :                   start_c = 1
     382        25484 :                   DO wrd = 1, 5
     383        50548 :                      DO j = start_c, LEN(line_att)
     384        50548 :                         IF (line_att(j:j) /= ' ') THEN
     385              :                            start_c = j
     386              :                            EXIT
     387              :                         END IF
     388              :                      END DO
     389        21200 :                      end_c = LEN(line_att) + 1
     390       326746 :                      DO j = start_c, LEN(line_att)
     391       326746 :                         IF (line_att(j:j) == ' ') THEN
     392              :                            end_c = j
     393              :                            EXIT
     394              :                         END IF
     395              :                      END DO
     396        21200 :                      IF (wrd /= 5 .AND. end_c >= LEN(line_att) + 1) &
     397            0 :                         CPABORT("incorrectly formatted line in coord section'"//line_att//"'")
     398        21200 :                      IF (wrd == 1) THEN
     399         4240 :                         at_name_c(ishell) = line_att(start_c:end_c - 1)
     400         4240 :                         CALL uppercase(at_name_c(ishell))
     401        16960 :                      ELSE IF (wrd == 5) THEN
     402         4240 :                         READ (line_att(start_c:end_c - 1), *) at_index_c(ishell)
     403              :                      ELSE
     404        12720 :                         READ (line_att(start_c:end_c - 1), *) rc(wrd - 1, ishell)
     405              :                      END IF
     406        25440 :                      start_c = end_c
     407              :                   END DO
     408              :                END DO
     409          132 :                IF (my_save_mem) CALL section_vals_remove_values(core_coord_section)
     410              :             END IF ! explicit
     411              :          END IF ! core_particle_set
     412              : 
     413              :          !-----------------------------------------------------------------------------
     414              :          ! 3. Check corrispondence and convert coordinates into internal cp2k coordinates
     415              :          !-----------------------------------------------------------------------------
     416         4284 :          DO ishell = 1, nshell
     417         4240 :             atomic_kind => particle_set(at_index(ishell))%atomic_kind
     418              :             CALL get_atomic_kind(atomic_kind=atomic_kind, &
     419         4240 :                                  name=name_kind, shell_active=is_shell, mass=mass_com, shell=shell)
     420         4240 :             CALL uppercase(name_kind)
     421         8524 :             IF ((TRIM(at_name(ishell)) == TRIM(name_kind)) .AND. is_shell) THEN
     422         4240 :                sh_index = particle_set(at_index(ishell))%shell_index
     423         4240 :                IF (shell_scaled_coordinates) THEN
     424            0 :                   CALL scaled_to_real(shell_particle_set(sh_index)%r(:), r(:, ishell), cell)
     425              :                ELSE
     426        16960 :                   shell_particle_set(sh_index)%r(:) = r(:, ishell)*unit_conv_shell
     427         4240 :                   CALL cell_transform_input_cartesian(cell, shell_particle_set(sh_index)%r(:))
     428              :                END IF
     429         4240 :                shell_particle_set(sh_index)%atom_index = at_index(ishell)
     430              : 
     431         4240 :                IF (PRESENT(core_particle_set) .AND. .NOT. explicit) THEN
     432              :                   core_particle_set(sh_index)%r(1) = (mass_com*particle_set(at_index(ishell))%r(1) - &
     433            0 :                                                       shell%mass_shell*shell_particle_set(sh_index)%r(1))/shell%mass_core
     434              :                   core_particle_set(sh_index)%r(2) = (mass_com*particle_set(at_index(ishell))%r(2) - &
     435            0 :                                                       shell%mass_shell*shell_particle_set(sh_index)%r(2))/shell%mass_core
     436              :                   core_particle_set(sh_index)%r(3) = (mass_com*particle_set(at_index(ishell))%r(3) - &
     437            0 :                                                       shell%mass_shell*shell_particle_set(sh_index)%r(3))/shell%mass_core
     438            0 :                   core_particle_set(sh_index)%atom_index = at_index(ishell)
     439            0 :                   rab = pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
     440         4240 :                ELSE IF (explicit) THEN
     441         4240 :                   IF (core_scaled_coordinates) THEN
     442            0 :                      CALL scaled_to_real(core_particle_set(sh_index)%r(:), rc(:, ishell), cell)
     443              :                   ELSE
     444        16960 :                      core_particle_set(sh_index)%r(:) = rc(:, ishell)*unit_conv_core
     445         4240 :                      CALL cell_transform_input_cartesian(cell, core_particle_set(sh_index)%r(:))
     446              :                   END IF
     447         4240 :                   core_particle_set(sh_index)%atom_index = at_index_c(ishell)
     448         4240 :                   rab = pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
     449         4240 :                   CPASSERT(TRIM(at_name(ishell)) == TRIM(at_name_c(ishell)))
     450         4240 :                   CPASSERT(at_index(ishell) == at_index_c(ishell))
     451              :                ELSE
     452            0 :                   rab = pbc(shell_particle_set(sh_index)%r, particle_set(at_index(ishell))%r, cell)
     453              :                END IF
     454              : 
     455         4240 :                dab = SQRT(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
     456         4240 :                IF (shell%max_dist > 0.0_dp .AND. shell%max_dist < dab) THEN
     457            0 :                   IF (output_unit > 0) THEN
     458            0 :                      WRITE (output_unit, *) "WARNING : shell and core for atom ", at_index(ishell), " seem to be too distant."
     459              :                   END IF
     460              :                END IF
     461              : 
     462              :             ELSE
     463            0 :                CPABORT("shell coordinate assigned to the wrong atom. check the shell indexes in the input")
     464              :             END IF
     465              :          END DO
     466           44 :          DEALLOCATE (r, at_index, at_name)
     467           44 :          DEALLOCATE (rc, at_index_c, at_name_c)
     468              : 
     469              :       END IF
     470              : 
     471           44 :       IF (my_save_mem) CALL section_vals_remove_values(shell_coord_section)
     472              : 
     473           44 :       CALL timestop(handle)
     474              : 
     475              :    END SUBROUTINE read_shell_coord_input
     476              : 
     477              : END MODULE atoms_input
        

Generated by: LCOV version 2.0-1