44 #include "./base/base_uses.f90"
48 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'topology_xtl'
75 TYPE(mp_para_env_type),
POINTER :: para_env
76 TYPE(section_vals_type),
POINTER :: subsys_section
78 CHARACTER(len=*),
PARAMETER :: routinen =
'read_coordinate_xtl'
79 INTEGER,
PARAMETER :: nblock = 1000
80 REAL(kind=
dp),
PARAMETER :: threshold = 1.0e-6_dp
82 CHARACTER(LEN=default_string_length) :: strtmp
83 INTEGER :: dimensions, handle, icol, ii, isym, iw, &
84 jj, natom, natom_orig, newsize
85 INTEGER,
DIMENSION(3) :: periodic
86 LOGICAL :: check, found, my_end
87 REAL(kind=
dp) :: pfactor, threshold2
88 REAL(kind=
dp),
DIMENSION(3) :: cell_angles, cell_lengths, r, r1, r2, s, &
90 REAL(kind=
dp),
DIMENSION(3, 3) :: rot_mat
92 TYPE(cell_type),
POINTER :: cell
93 TYPE(cp_logger_type),
POINTER :: logger
94 TYPE(cp_parser_type) :: parser
99 extension=
".subsysLog")
100 CALL timeset(routinen, handle)
102 pfactor =
section_get_rval(subsys_section,
"TOPOLOGY%MEMORY_PROGRESSION_FACTOR")
107 CALL reallocate(atom_info%id_molname, 1, nblock)
108 CALL reallocate(atom_info%id_resname, 1, nblock)
109 CALL reallocate(atom_info%resid, 1, nblock)
110 CALL reallocate(atom_info%id_atmname, 1, nblock)
111 CALL reallocate(atom_info%r, 1, 3, 1, nblock)
112 CALL reallocate(atom_info%atm_mass, 1, nblock)
113 CALL reallocate(atom_info%atm_charge, 1, nblock)
114 CALL reallocate(atom_info%occup, 1, nblock)
115 CALL reallocate(atom_info%beta, 1, nblock)
116 CALL reallocate(atom_info%id_element, 1, nblock)
118 IF (iw > 0)
WRITE (iw, *)
" Reading in XTL file ", trim(
topology%coord_file_name)
123 begin_line=.false., search_from_begin_of_file=.true.)
125 IF (iw > 0)
WRITE (iw,
'(/,A)')
" XTL_INFO| TITLE :: "//trim(parser%input_line(parser%icol:))
130 begin_line=.false., search_from_begin_of_file=.true.)
132 IF (iw > 0)
WRITE (iw,
'(A)')
" XTL_INFO| DIMENSION :: "//trim(parser%input_line(parser%icol:))
133 CALL parser_get_object(parser, dimensions)
134 IF (dimensions /= 3)
THEN
135 cpabort(
"XTL file with working DIMENSION different from 3 cannot be parsed!")
146 begin_line=.false., search_from_begin_of_file=.true.)
148 cpabort(
"The field CELL was not found in XTL file! ")
151 CALL parser_get_object(parser, cell_lengths(1))
154 CALL parser_get_object(parser, cell_lengths(2))
157 CALL parser_get_object(parser, cell_lengths(3))
161 CALL parser_get_object(parser, cell_angles(1))
164 CALL parser_get_object(parser, cell_angles(2))
167 CALL parser_get_object(parser, cell_angles(3))
173 CALL set_cell_param(cell, cell_lengths, cell_angles, periodic=periodic, &
180 begin_line=.false., search_from_begin_of_file=.true.)
182 cpabort(
"The field ATOMS was not found in XTL file! ")
185 found = (index(parser%input_line,
"NAME X Y Z") /= 0)
187 cpabort(
"The field ATOMS in XTL file, is not followed by name and coordinates tags! ")
191 DO WHILE (index(parser%input_line,
"EOF") == 0)
194 IF (natom >
SIZE(atom_info%id_molname))
THEN
195 newsize = int(pfactor*natom)
196 CALL reallocate(atom_info%id_molname, 1, newsize)
197 CALL reallocate(atom_info%id_resname, 1, newsize)
198 CALL reallocate(atom_info%resid, 1, newsize)
199 CALL reallocate(atom_info%id_atmname, 1, newsize)
200 CALL reallocate(atom_info%r, 1, 3, 1, newsize)
201 CALL reallocate(atom_info%atm_mass, 1, newsize)
202 CALL reallocate(atom_info%atm_charge, 1, newsize)
203 CALL reallocate(atom_info%occup, 1, newsize)
204 CALL reallocate(atom_info%beta, 1, newsize)
205 CALL reallocate(atom_info%id_element, 1, newsize)
208 CALL parser_get_object(parser, strtmp)
209 atom_info%id_atmname(natom) =
str2id(strtmp)
210 atom_info%id_molname(natom) =
str2id(
s2s(
"MOL"//trim(adjustl(cp_to_string(natom)))))
211 atom_info%id_resname(natom) = atom_info%id_molname(natom)
212 atom_info%resid(natom) = 1
213 atom_info%id_element(natom) = atom_info%id_atmname(natom)
215 CALL parser_get_object(parser, atom_info%r(1, natom))
217 CALL parser_get_object(parser, atom_info%r(2, natom))
219 CALL parser_get_object(parser, atom_info%r(3, natom))
220 s = atom_info%r(1:3, natom)
226 threshold2 = threshold*threshold
230 r1 = atom_info%r(1:3, ii)
231 DO jj = ii + 1, natom
232 r2 = atom_info%r(1:3, jj)
233 r =
pbc(r1 - r2, cell)
235 check = (dot_product(r, r) >= threshold2)
242 begin_line=.false., search_from_begin_of_file=.true.)
244 IF (iw > 0)
WRITE (iw,
'(A)')
" XTL_INFO| Symmetry Infos :: "//trim(parser%input_line(parser%icol:))
249 begin_line=.false., search_from_begin_of_file=.true.)
251 cpwarn(
"The field SYM MAT was not found in XTL file! ")
252 IF (iw > 0)
WRITE (iw,
'(A,I0)')
" XTL_INFO| Number of atoms before applying symmetry operations :: ", natom
253 IF (iw > 0)
WRITE (iw,
'(A10,1X,3F12.6)') (trim(
id2str(atom_info%id_atmname(ii))), atom_info%r(1:3, ii), ii=1, natom)
260 icol = index(parser%input_line,
"SYM MAT") + 8
261 READ (parser%input_line(icol:), *) ((rot_mat(ii, jj), jj=1, 3), ii=1, 3), transl_vec(1:3)
262 loop_over_unique_atoms:
DO ii = 1, natom_orig
264 r1 = matmul(rot_mat, atom_info%r(1:3, ii)) + transl_vec
268 r2 = atom_info%r(1:3, jj)
269 r =
pbc(r1 - r2, cell)
271 IF (dot_product(r, r) <= threshold2)
THEN
280 IF (natom >
SIZE(atom_info%id_molname))
THEN
281 newsize = int(pfactor*natom)
282 CALL reallocate(atom_info%id_molname, 1, newsize)
283 CALL reallocate(atom_info%id_resname, 1, newsize)
284 CALL reallocate(atom_info%resid, 1, newsize)
285 CALL reallocate(atom_info%id_atmname, 1, newsize)
286 CALL reallocate(atom_info%r, 1, 3, 1, newsize)
287 CALL reallocate(atom_info%atm_mass, 1, newsize)
288 CALL reallocate(atom_info%atm_charge, 1, newsize)
289 CALL reallocate(atom_info%occup, 1, newsize)
290 CALL reallocate(atom_info%beta, 1, newsize)
291 CALL reallocate(atom_info%id_element, 1, newsize)
293 atom_info%id_atmname(natom) = atom_info%id_atmname(ii)
294 atom_info%id_molname(natom) = atom_info%id_molname(ii)
295 atom_info%id_resname(natom) = atom_info%id_resname(ii)
296 atom_info%resid(natom) = atom_info%resid(ii)
297 atom_info%id_element(natom) = atom_info%id_element(ii)
298 atom_info%r(1:3, natom) = r1
300 END DO loop_over_unique_atoms
302 begin_line=.false., search_from_begin_of_file=.false.)
305 IF (iw > 0)
WRITE (iw,
'(A,I0)')
" XTL_INFO| Number of symmetry operations :: ", isym
306 IF (iw > 0)
WRITE (iw,
'(A,I0)')
" XTL_INFO| Number of total atoms :: ", natom
307 IF (iw > 0)
WRITE (iw,
'(A10,1X,3F12.6)') (trim(
id2str(atom_info%id_atmname(ii))), atom_info%r(1:3, ii), ii=1, natom)
314 CALL reallocate(atom_info%id_molname, 1, natom)
315 CALL reallocate(atom_info%id_resname, 1, natom)
316 CALL reallocate(atom_info%resid, 1, natom)
317 CALL reallocate(atom_info%id_atmname, 1, natom)
318 CALL reallocate(atom_info%r, 1, 3, 1, natom)
319 CALL reallocate(atom_info%atm_mass, 1, natom)
320 CALL reallocate(atom_info%atm_charge, 1, natom)
321 CALL reallocate(atom_info%occup, 1, natom)
322 CALL reallocate(atom_info%beta, 1, natom)
323 CALL reallocate(atom_info%id_element, 1, natom)
328 "PRINT%TOPOLOGY_INFO/XTL_INFO")
329 CALL timestop(handle)
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
Handles all functions related to the CELL.
subroutine, public write_cell(cell, subsys_section, tag)
Write the cell parameters to the output unit.
subroutine, public set_cell_param(cell, cell_length, cell_angle, periodic, do_init_cell)
Sets the cell using the internal parameters (a,b,c) (alpha,beta,gamma) using the convention: a parall...
subroutine, public cell_create(cell, hmat, periodic, tag)
allocates and initializes a cell
Handles all functions related to the CELL.
subroutine, public scaled_to_real(r, s, cell)
Transform scaled cell coordinates real coordinates. r=h*s.
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
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.
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 ...
subroutine, public parser_search_string(parser, string, ignore_case, found, line, begin_line, search_from_begin_of_file)
Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search ...
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 dp
integer, parameter, public default_string_length
Utility routines for the memory handling.
Interface to the message passing library MPI.
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
Handles XTL (Molecular Simulations, Inc (MSI)) files.
subroutine, public read_coordinate_xtl(topology, para_env, subsys_section)
Performs the real task of reading the proper information from the XTL file.
Control for reading in different topologies and coordinates.