33 #include "./base/base_uses.f90"
37 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'topology_xyz'
53 TYPE(mp_para_env_type),
POINTER :: para_env
54 TYPE(section_vals_type),
POINTER :: subsys_section
56 CHARACTER(len=*),
PARAMETER :: routinen =
'read_coordinate_xyz'
58 CHARACTER(LEN=default_string_length) :: my_default_index, strtmp
59 CHARACTER(LEN=max_line_length) :: error_message
60 INTEGER :: frame, handle, ian, iw, j, natom
63 TYPE(cp_logger_type),
POINTER :: logger
64 TYPE(cp_parser_type) :: parser
66 CALL timeset(routinen, handle)
71 extension=
".subsysLog")
76 WRITE (unit=iw, fmt=
"(T2,A)") &
77 "BEGIN of XYZ data read from file "//trim(
topology%coord_file_name)
81 parse_white_lines=.true.)
91 CALL parser_get_object(parser, natom)
94 CALL reallocate(atom_info%id_molname, 1, natom)
95 CALL reallocate(atom_info%id_resname, 1, natom)
96 CALL reallocate(atom_info%resid, 1, natom)
97 CALL reallocate(atom_info%id_atmname, 1, natom)
98 CALL reallocate(atom_info%r, 1, 3, 1, natom)
99 CALL reallocate(atom_info%atm_mass, 1, natom)
100 CALL reallocate(atom_info%atm_charge, 1, natom)
101 CALL reallocate(atom_info%occup, 1, natom)
102 CALL reallocate(atom_info%beta, 1, natom)
103 CALL reallocate(atom_info%id_element, 1, natom)
104 ELSE IF (natom >
SIZE(atom_info%id_atmname))
THEN
105 cpabort(
"Atom number differs in different frames!")
111 READ (parser%input_line, *) strtmp, &
117 IF (len_trim(error_message) == 0)
THEN
120 IF ((ian < 0) .OR. (ian >
nelem))
THEN
121 error_message =
"Invalid atomic number <"//trim(strtmp)// &
122 "> found in the xyz file <"//trim(
topology%coord_file_name)//
">!"
123 cpabort(trim(error_message))
128 atom_info%id_atmname(j) =
str2id(
s2s(strtmp))
131 WRITE (my_default_index,
'(I0)') j
132 atom_info%id_molname(j) =
str2id(
s2s(trim(
id2str(atom_info%id_atmname(j)))//trim(my_default_index)))
133 atom_info%id_resname(j) = atom_info%id_molname(j)
134 atom_info%resid(j) = 1
135 atom_info%id_element(j) = atom_info%id_atmname(j)
136 atom_info%atm_mass(j) = huge(0.0_dp)
137 atom_info%atm_charge(j) = -huge(0.0_dp)
139 WRITE (unit=iw, fmt=
"(T2,A4,3F8.3,2X,A)") &
140 trim(
id2str(atom_info%id_atmname(j))), &
144 adjustl(trim(
id2str(atom_info%id_molname(j))))
152 my_end = my_end .OR. (len_trim(parser%input_line) == 0)
155 CALL cp_abort(__location__, &
156 "Number of lines in XYZ format not equal to the number of atoms."// &
157 " Error in XYZ format. Very probably the line with title is missing or is empty."// &
158 " Please check the XYZ file and rerun your job!")
166 WRITE (unit=iw, fmt=
"(T2,A)") &
167 "END of XYZ frame data read from file "//trim(
topology%coord_file_name)
174 "PRINT%TOPOLOGY_INFO/XYZ_INFO")
176 CALL timestop(handle)
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.
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
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_xyz(topology, para_env, subsys_section)
...
Control for reading in different topologies and coordinates.