70 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_coordinate_cp2k'
72 CHARACTER(LEN=default_string_length) :: string
73 CHARACTER(LEN=max_line_length) :: error_message
74 INTEGER :: handle, i, ian, iw, natom, newsize, &
76 LOGICAL :: eof, explicit, scaled_coordinates
77 REAL(kind=
dp) :: pfactor, unit_conv
78 REAL(kind=
dp),
DIMENSION(3) :: r
85 CALL timeset(routinen, handle)
87 NULLIFY (coord_section)
92 extension=
".subsysLog")
102 scaled_coordinates = .false.
111 WRITE (unit=iw, fmt=
"(T2,A)") &
112 "BEGIN of COORD section data read from file "//trim(
topology%coord_file_name)
115 pfactor =
section_get_rval(subsys_section,
"TOPOLOGY%MEMORY_PROGRESSION_FACTOR")
116 number_of_atoms =
section_get_ival(subsys_section,
"TOPOLOGY%NUMBER_OF_ATOMS")
117 IF (number_of_atoms < 1)
THEN
120 newsize = number_of_atoms
123 CALL reallocate(atom_info%id_molname, 1, newsize)
124 CALL reallocate(atom_info%id_resname, 1, newsize)
126 CALL reallocate(atom_info%id_atmname, 1, newsize)
127 CALL reallocate(atom_info%r, 1, 3, 1, newsize)
128 CALL reallocate(atom_info%atm_mass, 1, newsize)
129 CALL reallocate(atom_info%atm_charge, 1, newsize)
132 CALL reallocate(atom_info%id_element, 1, newsize)
134 topology%molname_generated = .false.
146 IF (natom >
SIZE(atom_info%id_atmname))
THEN
147 newsize = int(pfactor*natom)
148 CALL reallocate(atom_info%id_molname, 1, newsize)
149 CALL reallocate(atom_info%id_resname, 1, newsize)
151 CALL reallocate(atom_info%id_atmname, 1, newsize)
152 CALL reallocate(atom_info%r, 1, 3, 1, newsize)
153 CALL reallocate(atom_info%atm_mass, 1, newsize)
154 CALL reallocate(atom_info%atm_charge, 1, newsize)
157 CALL reallocate(atom_info%id_element, 1, newsize)
161 IF (len_trim(error_message) == 0)
THEN
164 IF ((ian < 0) .OR. (ian >
nelem))
THEN
165 error_message =
"Invalid atomic number <"//trim(string)// &
166 "> found in the xyz file <"//trim(
topology%coord_file_name)//
">!"
167 cpabort(trim(error_message))
172 atom_info%id_atmname(natom) =
str2id(
s2s(string))
178 IF (scaled_coordinates)
THEN
181 atom_info%r(1:3, natom) = r(1:3)*unit_conv
186 atom_info%id_molname(natom) =
str2id(
s2s(string))
189 atom_info%id_resname(natom) =
str2id(
s2s(string))
191 atom_info%id_resname(natom) = atom_info%id_molname(natom)
195 WRITE (unit=string, fmt=
"(I0)") natom
196 atom_info%id_molname(natom) =
str2id(
s2s(trim(
id2str(atom_info%id_atmname(natom)))//trim(string)))
197 atom_info%id_resname(natom) = atom_info%id_molname(natom)
200 atom_info%resid(natom) = 1
201 atom_info%id_element(natom) = atom_info%id_atmname(natom)
202 atom_info%atm_mass(natom) = huge(0.0_dp)
203 atom_info%atm_charge(natom) = -huge(0.0_dp)
205 WRITE (unit=iw, fmt=
"(T2,A,3F20.8,2(2X,A))") &
206 trim(
id2str(atom_info%id_atmname(natom))), atom_info%r(1:3, natom), &
207 adjustl(trim(
id2str(atom_info%id_molname(natom)))), &
208 adjustl(trim(
id2str(atom_info%id_resname(natom))))
210 IF (natom == number_of_atoms)
EXIT
217 CALL reallocate(atom_info%id_molname, 1, natom)
218 CALL reallocate(atom_info%id_resname, 1, natom)
220 CALL reallocate(atom_info%id_atmname, 1, natom)
223 CALL reallocate(atom_info%atm_charge, 1, natom)
226 CALL reallocate(atom_info%id_element, 1, natom)
231 WRITE (unit=iw, fmt=
"(T2,A)") &
232 "END of COORD section data read from file "//trim(
topology%coord_file_name)
236 "PRINT%TOPOLOGY_INFO/XYZ_INFO")
238 CALL timestop(handle)