42 #include "./base/base_uses.f90"
46 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'topology_cp2k'
66 TYPE(mp_para_env_type),
POINTER :: para_env
67 TYPE(section_vals_type),
POINTER :: subsys_section
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
79 TYPE(cell_type),
POINTER :: cell
80 TYPE(cp_logger_type),
POINTER :: logger
81 TYPE(cp_parser_type),
POINTER :: parser
82 TYPE(section_vals_type),
POINTER :: coord_section
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)
124 CALL reallocate(atom_info%resid, 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)
129 CALL reallocate(atom_info%occup, 1, newsize)
130 CALL reallocate(atom_info%beta, 1, newsize)
131 CALL reallocate(atom_info%id_element, 1, newsize)
133 topology%molname_generated = .false.
142 CALL parser_get_object(parser, object=string, newline=.true., at_end=eof)
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)
149 CALL reallocate(atom_info%resid, 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)
154 CALL reallocate(atom_info%occup, 1, newsize)
155 CALL reallocate(atom_info%beta, 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))
175 CALL parser_get_object(parser, object=r(i))
177 IF (scaled_coordinates)
THEN
180 atom_info%r(1:3, natom) = r(1:3)*unit_conv
183 CALL parser_get_object(parser, object=string)
184 atom_info%id_molname(natom) =
str2id(
s2s(string))
186 CALL parser_get_object(parser, object=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)
217 CALL reallocate(atom_info%resid, 1, natom)
218 CALL reallocate(atom_info%id_atmname, 1, natom)
219 CALL reallocate(atom_info%r, 1, 3, 1, natom)
220 CALL reallocate(atom_info%atm_mass, 1, natom)
221 CALL reallocate(atom_info%atm_charge, 1, natom)
222 CALL reallocate(atom_info%occup, 1, natom)
223 CALL reallocate(atom_info%beta, 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)
Handles all functions related to the CELL.
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Utility routines to read data from files. Kept as close as possible to the old parser because.
elemental subroutine, public read_integer_object(string, object, error_message)
Returns an integer number read from a string including products of integer numbers like iz1*iz2*iz3.
character(len=3) function, public parser_test_next_token(parser, string_length)
Test next input object.
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Defines the basic variable types.
integer, parameter, public max_line_length
integer, parameter, public dp
integer, parameter, public default_string_length
Utility routines for the memory handling.
Interface to the message passing library MPI.
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
integer, parameter, public nelem
generates a unique id number for a string (str2id) that can be used two compare two strings....
character(len=default_string_length) function, public s2s(str)
converts a string in a string of default_string_length
integer function, public str2id(str)
returns a unique id for a given string, and stores the string for later retrieval using the id.
character(len=default_string_length) function, public id2str(id)
returns the string associated with a given id
subroutine, public read_coordinate_cp2k(topology, para_env, subsys_section)
Read the CP2K &COORD section from an external file, i.e. read atomic coordinates and molecule/residue...
Control for reading in different topologies and coordinates.