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) &
148 cpabort(
"incorrectly formatted line in coord section'"//line_att//
"'")
150 atom_info%id_atmname(iatom) =
str2id(
s2s(line_att(start_c:end_c - 1)))
152 READ (line_att(start_c:end_c - 1), *) atom_info%r(wrd - 1, iatom)
161 CALL reallocate(atom_info%id_molname, 1, natom)
162 CALL reallocate(atom_info%id_resname, 1, natom)
164 CALL reallocate(atom_info%id_atmname, 1, natom)
165 CALL reallocate(atom_info%id_element, 1, natom)
168 CALL reallocate(atom_info%atm_charge, 1, natom)
174 CALL val_get(val, c_val=line_att)
176 atom_info%id_molname(iatom) = default_id
177 atom_info%id_resname(iatom) = default_id
178 atom_info%resid(iatom) = 1
179 atom_info%id_atmname(iatom) = default_id
180 atom_info%id_element(iatom) = default_id
185 DO j = start_c, len(line_att)
186 IF (line_att(j:j) /=
' ')
THEN
191 end_c = len(line_att) + 1
192 DO j = start_c, len(line_att)
193 IF (line_att(j:j) ==
' ')
THEN
198 IF (len_trim(line_att(start_c:end_c - 1)) == 0) &
199 CALL cp_abort(__location__, &
200 "Incorrectly formatted input line for atom "// &
202 " found in COORD section. Input line: <"// &
203 trim(line_att)//
"> ")
206 atom_info%id_atmname(iatom) =
str2id(
s2s(line_att(start_c:end_c - 1)))
209 atom_info%r(wrd - 1, iatom), error_message)
210 IF (len_trim(error_message) /= 0) &
211 CALL cp_abort(__location__, &
212 "Incorrectly formatted input line for atom "// &
214 " found in COORD section. "//trim(error_message)// &
215 " Input line: <"//trim(line_att)//
"> ")
217 READ (line_att(start_c:end_c - 1), *) strtmp
218 atom_info%id_molname(iatom) =
str2id(strtmp)
219 atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
220 topology%molname_generated = .false.
222 READ (line_att(start_c:end_c - 1), *) strtmp
223 atom_info%id_resname(iatom) =
str2id(strtmp)
226 IF (start_c > len_trim(line_att))
EXIT
228 IF (
topology%molname_generated)
THEN
230 WRITE (my_default_index,
'(I0)') iatom
231 atom_info%id_molname(iatom) =
str2id(
s2s(trim(
id2str(atom_info%id_atmname(iatom)))//trim(my_default_index)))
232 atom_info%id_resname(iatom) = atom_info%id_molname(iatom)
234 atom_info%id_element(iatom) = atom_info%id_atmname(iatom)
235 atom_info%atm_mass(iatom) = 0.0_dp
236 atom_info%atm_charge(iatom) = -huge(0.0_dp)
244 IF (scaled_coordinates)
THEN
245 r0 = atom_info%r(:, iatom)
248 atom_info%r(:, iatom) = atom_info%r(:, iatom)*unit_conv
254 CALL timestop(handle)
268 subsys_section, core_particle_set, save_mem)
270 TYPE(
particle_type),
DIMENSION(:),
POINTER :: particle_set, shell_particle_set
274 POINTER :: core_particle_set
275 LOGICAL,
INTENT(IN),
OPTIONAL :: save_mem
277 CHARACTER(len=*),
PARAMETER :: routinen =
'read_shell_coord_input'
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 ALLOCATABLE,
DIMENSION(:) :: at_name, at_name_c
283 INTEGER :: end_c, handle, ishell, j, nshell, &
284 output_unit, sh_index, start_c, wrd
285 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, &
291 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: r, rc
298 my_save_mem = .false.
299 NULLIFY (atomic_kind,
list, shell_coord_section, shell, val)
302 IF (
PRESENT(save_mem)) my_save_mem = save_mem
303 NULLIFY (shell_coord_section, core_coord_section)
306 IF (.NOT. explicit)
RETURN
308 CALL timeset(routinen, handle)
309 cpassert(
ASSOCIATED(particle_set))
320 IF (
ASSOCIATED(shell_particle_set))
THEN
321 cpassert((
SIZE(shell_particle_set, 1) == nshell))
322 ALLOCATE (r(3, nshell), at_name(nshell), at_index(nshell))
323 CALL cp_warn(__location__, &
324 "Overwriting shell coordinates. "// &
325 "Active coordinates READ from &SHELL_COORD section. ")
327 DO ishell = 1, nshell
330 CALL val_get(val, c_val=line_att)
333 DO j = start_c, len(line_att)
334 IF (line_att(j:j) /=
' ')
THEN
339 end_c = len(line_att) + 1
340 DO j = start_c, len(line_att)
341 IF (line_att(j:j) ==
' ')
THEN
346 IF (wrd /= 5 .AND. end_c >= len(line_att) + 1) &
347 cpabort(
"incorrectly formatted line in coord section'"//line_att//
"'")
349 at_name(ishell) = line_att(start_c:end_c - 1)
351 ELSE IF (wrd == 5)
THEN
352 READ (line_att(start_c:end_c - 1), *) at_index(ishell)
354 READ (line_att(start_c:end_c - 1), *) r(wrd - 1, ishell)
360 IF (
PRESENT(core_particle_set))
THEN
361 cpassert(
ASSOCIATED(core_particle_set))
371 cpassert((
SIZE(core_particle_set, 1) == nshell))
372 ALLOCATE (rc(3, nshell), at_name_c(nshell), at_index_c(nshell))
373 CALL cp_warn(__location__, &
374 "Overwriting cores coordinates. "// &
375 "Active coordinates READ from &CORE_COORD section. ")
377 DO ishell = 1, nshell
380 CALL val_get(val, c_val=line_att)
383 DO j = start_c, len(line_att)
384 IF (line_att(j:j) /=
' ')
THEN
389 end_c = len(line_att) + 1
390 DO j = start_c, len(line_att)
391 IF (line_att(j:j) ==
' ')
THEN
396 IF (wrd /= 5 .AND. end_c >= len(line_att) + 1) &
397 cpabort(
"incorrectly formatted line in coord section'"//line_att//
"'")
399 at_name_c(ishell) = line_att(start_c:end_c - 1)
401 ELSE IF (wrd == 5)
THEN
402 READ (line_att(start_c:end_c - 1), *) at_index_c(ishell)
404 READ (line_att(start_c:end_c - 1), *) rc(wrd - 1, ishell)
416 DO ishell = 1, nshell
417 atomic_kind => particle_set(at_index(ishell))%atomic_kind
419 name=name_kind, shell_active=is_shell, mass=mass_com, shell=shell)
421 IF ((trim(at_name(ishell)) == trim(name_kind)) .AND. is_shell)
THEN
422 sh_index = particle_set(at_index(ishell))%shell_index
423 IF (shell_scaled_coordinates)
THEN
424 CALL scaled_to_real(shell_particle_set(sh_index)%r(:), r(:, ishell), cell)
426 shell_particle_set(sh_index)%r(:) = r(:, ishell)*unit_conv_shell
429 shell_particle_set(sh_index)%atom_index = at_index(ishell)
431 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 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 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 shell%mass_shell*shell_particle_set(sh_index)%r(3))/shell%mass_core
438 core_particle_set(sh_index)%atom_index = at_index(ishell)
439 rab =
pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
440 ELSE IF (explicit)
THEN
441 IF (core_scaled_coordinates)
THEN
442 CALL scaled_to_real(core_particle_set(sh_index)%r(:), rc(:, ishell), cell)
444 core_particle_set(sh_index)%r(:) = rc(:, ishell)*unit_conv_core
447 core_particle_set(sh_index)%atom_index = at_index_c(ishell)
448 rab =
pbc(shell_particle_set(sh_index)%r, core_particle_set(sh_index)%r, cell)
449 cpassert(trim(at_name(ishell)) == trim(at_name_c(ishell)))
450 cpassert(at_index(ishell) == at_index_c(ishell))
452 rab =
pbc(shell_particle_set(sh_index)%r, particle_set(at_index(ishell))%r, cell)
455 dab = sqrt(rab(1)*rab(1) + rab(2)*rab(2) + rab(3)*rab(3))
456 IF (shell%max_dist > 0.0_dp .AND. shell%max_dist < dab)
THEN
457 IF (output_unit > 0)
THEN
458 WRITE (output_unit, *)
"WARNING : shell and core for atom ", at_index(ishell),
" seem to be too distant."
463 cpabort(
"shell coordinate assigned to the wrong atom. check the shell indexes in the input")
466 DEALLOCATE (r, at_index, at_name)
467 DEALLOCATE (rc, at_index_c, at_name_c)
473 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.