73 LOGICAL,
INTENT(IN),
OPTIONAL :: overwrite
75 LOGICAL,
INTENT(IN),
OPTIONAL :: save_mem
77 CHARACTER(len=*),
PARAMETER :: routinen =
'read_atoms_input'
79 CHARACTER(len=2*default_string_length) :: line_att
80 CHARACTER(len=default_string_length) :: error_message, my_default_index, strtmp, &
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
93 my_overwrite = .false.
97 IF (
PRESENT(overwrite)) my_overwrite = overwrite
98 IF (
PRESENT(save_mem)) my_save_mem = save_mem
99 NULLIFY (coord_section)
102 IF (.NOT. explicit)
RETURN
104 CALL timeset(routinen, handle)
122 IF (my_overwrite)
THEN
123 cpassert(
SIZE(atom_info%r, 2) == natom)
124 CALL cp_warn(__location__, &
125 "Overwriting coordinates. Active coordinates read from &COORD section."// &
126 " Active coordinates READ from &COORD section ")
130 CALL val_get(val, c_val=line_att)
134 DO j = start_c, len(line_att)
135 IF (line_att(j:j) /=
' ')
THEN
140 end_c = len(line_att) + 1
141 DO j = start_c, len(line_att)
142 IF (line_att(j:j) ==
' ')
THEN
147 IF (len_trim(line_att(start_c:end_c - 1)) == 0)
THEN
148 cpabort(
"incorrectly formatted line in coord section'"//line_att//
"'")
151 atom_info%id_atmname(iatom) =
str2id(
s2s(line_att(start_c:end_c - 1)))
153 READ (line_att(start_c:end_c - 1), *) atom_info%r(wrd - 1, iatom)
162 CALL reallocate(atom_info%id_molname, 1, natom)
163 CALL reallocate(atom_info%id_resname, 1, natom)
165 CALL reallocate(atom_info%id_atmname, 1, natom)
166 CALL reallocate(atom_info%id_element, 1, natom)
169 CALL reallocate(atom_info%atm_charge, 1, natom)
175 CALL val_get(val, c_val=line_att)
177 atom_info%id_molname(iatom) = default_id
178 atom_info%id_resname(iatom) = default_id
179 atom_info%resid(iatom) = 1
180 atom_info%id_atmname(iatom) = default_id
181 atom_info%id_element(iatom) = default_id
186 DO j = start_c, len(line_att)
187 IF (line_att(j:j) /=
' ')
THEN
192 end_c = len(line_att) + 1
193 DO j = start_c, len(line_att)
194 IF (line_att(j:j) ==
' ')
THEN
199 IF (len_trim(line_att(start_c:end_c - 1)) == 0)
THEN
200 CALL cp_abort(__location__, &
201 "Incorrectly formatted input line for atom "// &
203 " found in COORD section. Input line: <"// &
204 trim(line_att)//
"> ")
208 atom_info%id_atmname(iatom) =
str2id(
s2s(line_att(start_c:end_c - 1)))
211 atom_info%r(wrd - 1, iatom), error_message)
212 IF (len_trim(error_message) /= 0)
THEN
213 CALL cp_abort(__location__, &
214 "Incorrectly formatted input line for atom "// &
216 " found in COORD section. "//trim(error_message)// &
217 " Input line: <"//trim(line_att)//
"> ")
220 READ (line_att(start_c:end_c - 1), *) strtmp
221 atom_info%id_molname(iatom) =
str2id(strtmp)
222 atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
223 topology%molname_generated = .false.
225 READ (line_att(start_c:end_c - 1), *) strtmp
226 atom_info%id_resname(iatom) =
str2id(strtmp)
229 IF (start_c > len_trim(line_att))
EXIT
231 IF (
topology%molname_generated)
THEN
233 WRITE (my_default_index,
'(I0)') iatom
234 atom_info%id_molname(iatom) =
str2id(
s2s(trim(
id2str(atom_info%id_atmname(iatom)))//trim(my_default_index)))
235 atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
237 atom_info%id_element(iatom) = atom_info%id_atmname(iatom)
238 atom_info%atm_mass(iatom) = 0.0_dp
239 atom_info%atm_charge(iatom) = -huge(0.0_dp)
247 IF (scaled_coordinates)
THEN
248 r0 = atom_info%r(:, iatom)
251 atom_info%r(:, iatom) = atom_info%r(:, iatom)*unit_conv
257 CALL timestop(handle)
271 subsys_section, core_particle_set, save_mem)
273 TYPE(
particle_type),
DIMENSION(:),
POINTER :: particle_set, shell_particle_set
277 POINTER :: core_particle_set
278 LOGICAL,
INTENT(IN),
OPTIONAL :: save_mem
280 CHARACTER(len=*),
PARAMETER :: routinen =
'read_shell_coord_input'
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 ALLOCATABLE,
DIMENSION(:) :: at_name, at_name_c
286 INTEGER :: end_c, handle, ishell, j, nshell, &
287 output_unit, sh_index, start_c, wrd
288 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, &
294 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: r, rc
301 my_save_mem = .false.
302 NULLIFY (atomic_kind,
list, shell_coord_section, shell, val)
305 IF (
PRESENT(save_mem)) my_save_mem = save_mem
306 NULLIFY (shell_coord_section, core_coord_section)
309 IF (.NOT. explicit)
RETURN
311 CALL timeset(routinen, handle)
312 cpassert(
ASSOCIATED(particle_set))
323 IF (
ASSOCIATED(shell_particle_set))
THEN
324 cpassert((
SIZE(shell_particle_set, 1) == nshell))
325 ALLOCATE (r(3, nshell), at_name(nshell), at_index(nshell))
326 CALL cp_warn(__location__, &
327 "Overwriting shell coordinates. "// &
328 "Active coordinates READ from &SHELL_COORD section. ")
330 DO ishell = 1, nshell
333 CALL val_get(val, c_val=line_att)
336 DO j = start_c, len(line_att)
337 IF (line_att(j:j) /=
' ')
THEN
342 end_c = len(line_att) + 1
343 DO j = start_c, len(line_att)
344 IF (line_att(j:j) ==
' ')
THEN
349 IF (wrd /= 5 .AND. end_c >= len(line_att) + 1)
THEN
350 cpabort(
"incorrectly formatted line in coord section'"//line_att//
"'")
353 at_name(ishell) = line_att(start_c:end_c - 1)
355 ELSE IF (wrd == 5)
THEN
356 READ (line_att(start_c:end_c - 1), *) at_index(ishell)
358 READ (line_att(start_c:end_c - 1), *) r(wrd - 1, ishell)
364 IF (
PRESENT(core_particle_set))
THEN
365 cpassert(
ASSOCIATED(core_particle_set))
375 cpassert((
SIZE(core_particle_set, 1) == nshell))
376 ALLOCATE (rc(3, nshell), at_name_c(nshell), at_index_c(nshell))
377 CALL cp_warn(__location__, &
378 "Overwriting cores coordinates. "// &
379 "Active coordinates READ from &CORE_COORD section. ")
381 DO ishell = 1, nshell
384 CALL val_get(val, c_val=line_att)
387 DO j = start_c, len(line_att)
388 IF (line_att(j:j) /=
' ')
THEN
393 end_c = len(line_att) + 1
394 DO j = start_c, len(line_att)
395 IF (line_att(j:j) ==
' ')
THEN
400 IF (wrd /= 5 .AND. end_c >= len(line_att) + 1)
THEN
401 cpabort(
"incorrectly formatted line in coord section'"//line_att//
"'")
404 at_name_c(ishell) = line_att(start_c:end_c - 1)
406 ELSE IF (wrd == 5)
THEN
407 READ (line_att(start_c:end_c - 1), *) at_index_c(ishell)
409 READ (line_att(start_c:end_c - 1), *) rc(wrd - 1, ishell)
421 DO ishell = 1, nshell
422 atomic_kind => particle_set(at_index(ishell))%atomic_kind
424 name=name_kind, shell_active=is_shell, mass=mass_com, shell=shell)
426 IF ((trim(at_name(ishell)) == trim(name_kind)) .AND. is_shell)
THEN
427 sh_index = particle_set(at_index(ishell))%shell_index
428 IF (shell_scaled_coordinates)
THEN
429 CALL scaled_to_real(shell_particle_set(sh_index)%r(:), r(:, ishell), cell)
431 shell_particle_set(sh_index)%r(:) = r(:, ishell)*unit_conv_shell
434 shell_particle_set(sh_index)%atom_index = at_index(ishell)
436 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 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 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 shell%mass_shell*shell_particle_set(sh_index)%r(3))/shell%mass_core
443 core_particle_set(sh_index)%atom_index = at_index(ishell)
444 rab =
pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
445 ELSE IF (explicit)
THEN
446 IF (core_scaled_coordinates)
THEN
447 CALL scaled_to_real(core_particle_set(sh_index)%r(:), rc(:, ishell), cell)
449 core_particle_set(sh_index)%r(:) = rc(:, ishell)*unit_conv_core
452 core_particle_set(sh_index)%atom_index = at_index_c(ishell)
453 rab =
pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
454 cpassert(trim(at_name(ishell)) == trim(at_name_c(ishell)))
455 cpassert(at_index(ishell) == at_index_c(ishell))
457 rab =
pbc(shell_particle_set(sh_index)%r, particle_set(at_index(ishell))%r, cell)
460 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
461 IF (shell%max_dist > 0.0_dp .AND. shell%max_dist < dab)
THEN
462 IF (output_unit > 0)
THEN
463 WRITE (output_unit, *)
"WARNING : shell and core for atom ", at_index(ishell),
" seem to be too distant."
468 cpabort(
"shell coordinate assigned to the wrong atom. check the shell indexes in the input")
471 DEALLOCATE (r, at_index, at_name)
472 DEALLOCATE (rc, at_index_c, at_name_c)
478 CALL timestop(handle)
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.