69 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_coordinate_cp2k'
71 CHARACTER(LEN=default_string_length) :: string
72 CHARACTER(LEN=max_line_length) :: error_message
73 INTEGER :: handle, i, ian, iw, natom, newsize, &
75 LOGICAL :: eof, explicit, scaled_coordinates
76 REAL(kind=
dp) :: pfactor, unit_conv
77 REAL(kind=
dp),
DIMENSION(3) :: r
84 CALL timeset(routinen, handle)
86 NULLIFY (coord_section)
91 extension=
".subsysLog")
101 scaled_coordinates = .false.
110 WRITE (unit=iw, fmt=
"(T2,A)") &
111 "BEGIN of COORD section data read from file "//trim(
topology%coord_file_name)
114 pfactor =
section_get_rval(subsys_section,
"TOPOLOGY%MEMORY_PROGRESSION_FACTOR")
115 number_of_atoms =
section_get_ival(subsys_section,
"TOPOLOGY%NUMBER_OF_ATOMS")
116 IF (number_of_atoms < 1)
THEN
119 newsize = number_of_atoms
122 CALL reallocate(atom_info%id_molname, 1, newsize)
123 CALL reallocate(atom_info%id_resname, 1, newsize)
125 CALL reallocate(atom_info%id_atmname, 1, newsize)
126 CALL reallocate(atom_info%r, 1, 3, 1, newsize)
127 CALL reallocate(atom_info%atm_mass, 1, newsize)
128 CALL reallocate(atom_info%atm_charge, 1, newsize)
131 CALL reallocate(atom_info%id_element, 1, newsize)
133 topology%molname_generated = .false.
145 IF (natom >
SIZE(atom_info%id_atmname))
THEN
146 newsize = int(pfactor*natom)
147 CALL reallocate(atom_info%id_molname, 1, newsize)
148 CALL reallocate(atom_info%id_resname, 1, newsize)
150 CALL reallocate(atom_info%id_atmname, 1, newsize)
151 CALL reallocate(atom_info%r, 1, 3, 1, newsize)
152 CALL reallocate(atom_info%atm_mass, 1, newsize)
153 CALL reallocate(atom_info%atm_charge, 1, newsize)
156 CALL reallocate(atom_info%id_element, 1, newsize)
160 IF (len_trim(error_message) == 0)
THEN
163 IF ((ian < 0) .OR. (ian >
nelem))
THEN
164 error_message =
"Invalid atomic number <"//trim(string)// &
165 "> found in the xyz file <"//trim(
topology%coord_file_name)//
">!"
166 cpabort(trim(error_message))
171 atom_info%id_atmname(natom) =
str2id(
s2s(string))
177 IF (scaled_coordinates)
THEN
180 atom_info%r(1:3, natom) = r(1:3)*unit_conv
184 atom_info%id_molname(natom) =
str2id(
s2s(string))
187 atom_info%id_resname(natom) =
str2id(
s2s(string))
189 atom_info%id_resname(natom) = atom_info%id_molname(natom)
193 WRITE (unit=string, fmt=
"(I0)") natom
194 atom_info%id_molname(natom) =
str2id(
s2s(trim(
id2str(atom_info%id_atmname(natom)))//trim(string)))
195 atom_info%id_resname(natom) = atom_info%id_molname(natom)
198 atom_info%resid(natom) = 1
199 atom_info%id_element(natom) = atom_info%id_atmname(natom)
200 atom_info%atm_mass(natom) = huge(0.0_dp)
201 atom_info%atm_charge(natom) = -huge(0.0_dp)
203 WRITE (unit=iw, fmt=
"(T2,A,3F20.8,2(2X,A))") &
204 trim(
id2str(atom_info%id_atmname(natom))), atom_info%r(1:3, natom), &
205 adjustl(trim(
id2str(atom_info%id_molname(natom)))), &
206 adjustl(trim(
id2str(atom_info%id_resname(natom))))
208 IF (natom == number_of_atoms)
EXIT
215 CALL reallocate(atom_info%id_molname, 1, natom)
216 CALL reallocate(atom_info%id_resname, 1, natom)
218 CALL reallocate(atom_info%id_atmname, 1, natom)
221 CALL reallocate(atom_info%atm_charge, 1, natom)
224 CALL reallocate(atom_info%id_element, 1, natom)
229 WRITE (unit=iw, fmt=
"(T2,A)") &
230 "END of COORD section data read from file "//trim(
topology%coord_file_name)
234 "PRINT%TOPOLOGY_INFO/XYZ_INFO")
236 CALL timestop(handle)