45 integer,
public,
parameter :: &
46 READ_COORDS_ERR = 0, &
54 integer,
public,
parameter :: &
55 XYZ_FLAGS_RESIDUE = 1, &
60 character(len=15) :: label
61 real(real64),
allocatable :: x(:)
63 real(real64) :: charge =
m_huge
64 character(len=3) :: residue
73 type(read_coords_atom),
allocatable :: atom(:)
75 real(real64),
allocatable :: latvec(:,:)
83 type(read_coords_info),
intent(out) :: gf
87 gf%source = read_coords_err
97 type(read_coords_info),
intent(inout) :: gf
104 safe_deallocate_a(gf%atom(ia)%x)
106 safe_deallocate_a(gf%atom)
108 safe_deallocate_a(gf%latvec)
116 character(len=*),
intent(in) :: what
117 type(read_coords_info),
intent(inout) :: gf
118 class(space_t),
intent(in) :: space
119 type(namespace_t),
intent(in) :: namespace
121 integer :: ia, ncol, iunit, jdir, int_one, nsteps, istep, step_to_use, periodic_dim
123 character(len=256) :: str
159 gf%flags = ior(gf%flags, xyz_flags_residue)
165 message(1) =
"Reading " // trim(what) //
" from " // trim(str)
168 iunit =
io_open(str, namespace, action=
'read')
195 message(1) =
"Reading " // trim(what) //
" from " // trim(str)
202 write(
message(1),
'(a,i6)')
"Invalid number of atoms ", gf%n
208 safe_allocate(gf%atom(1:gf%n))
211 safe_allocate(gf%atom(ia)%x(1:space%dim))
212 read(iunit,*) gf%atom(ia)%label, gf%atom(ia)%x
238 message(1) =
"Reading " // trim(what) //
" from " // trim(str)
241 iunit =
io_open(str, namespace, action=
'read', status=
'old')
243 read(iunit,
'(a256)') str
244 if (str(1:9) ==
'ANIMSTEPS')
then
245 read(str(10:), *) nsteps
256 call parse_variable(namespace,
'XSFCoordinatesAnimStep', 1, step_to_use)
257 if (step_to_use < 1)
then
258 message(1) =
"XSFCoordinatesAnimStep must be > 0."
260 else if (step_to_use > nsteps)
then
261 write(
message(1),
'(a,i9)')
"XSFCoordinatesAnimStep must be <= available number of steps ", nsteps
264 write(
message(1),
'(a,i9,a,i9)')
'Using animation step ', step_to_use,
' out of ', nsteps
272 select case (trim(str))
284 write(
message(1),
'(3a)')
'Line in file was "', trim(str),
'" instead of CRYSTAL/SLAB/POLYMER/MOLECULE.'
287 if (periodic_dim /= space%periodic_dim)
then
288 message(1) =
"Periodicity in XSF input is incompatible with the value of PeriodicDimensions."
292 do istep = 1, step_to_use - 1
294 do jdir = 1, space%dim
298 read(iunit, *) gf%n, int_one
304 read(iunit,
'(a256)') str
305 if (str(1:7) /=
'PRIMVEC')
then
306 write(
message(1),
'(3a)')
'Line in file was "', trim(str),
'" instead of "PRIMVEC".'
310 read(str(8:), *) istep
311 if (istep /= step_to_use)
then
312 write(
message(1),
'(a,i9,a,i9)')
'Found PRIMVEC index ', istep,
' instead of ', step_to_use
317 safe_allocate(gf%latvec(1:space%dim, 1:space%dim))
319 do jdir = 1, space%dim
320 read(iunit, *) gf%latvec(1:space%dim, jdir)
324 read(iunit,
'(a256)') str
325 if (str(1:9) /=
'PRIMCOORD')
then
326 write(
message(1),
'(3a)')
'Line in file was "', trim(str),
'" instead of "PRIMCOORD".'
330 read(str(10:), *) istep
331 if (istep /= step_to_use)
then
332 write(
message(1),
'(a,i9,a,i9)')
'Found PRIMCOORD index ', istep,
' instead of ', step_to_use
337 read(iunit, *) gf%n, int_one
339 write(
message(1),
'(a,i6)')
"Invalid number of atoms ", gf%n
342 if (int_one /= 1)
then
343 write(
message(1),
'(a,i6,a)')
'Number in file was ', int_one,
' instead of 1.'
346 safe_allocate(gf%atom(1:gf%n))
350 safe_allocate(gf%atom(ia)%x(1:space%dim))
351 read(iunit,*) gf%atom(ia)%label, gf%atom(ia)%x(1:space%dim)
381 if (
parse_block(namespace, trim(what), blk) == 0)
then
389 message(1) =
"Reading " // trim(what) //
" from " // trim(what) //
" block"
392 safe_allocate(gf%atom(1:gf%n))
396 if ((ncol < space%dim + 1) .or. (ncol > space%dim + 2))
then
397 write(
message(1),
'(3a,i2)')
'Error in block ', what,
' line #', ia
402 safe_allocate(gf%atom(ia)%x(1:space%dim))
403 do jdir = 1, space%dim
406 if (ncol == space%dim + 2)
then
409 gf%atom(ia)%move = .
true.
432 if (trim(what) ==
'Coordinates')
then
433 if (
parse_block(namespace,
'Reduced'//trim(what), blk) == 0)
then
441 message(1) =
"Reading " // trim(what) //
" from Reduced" // trim(what) //
" block"
444 safe_allocate(gf%atom(1:gf%n))
448 if ((ncol < space%dim + 1) .or. (ncol > space%dim + 2))
then
449 write(
message(1),
'(3a,i2)')
'Error in block ', what,
' line #', ia
454 safe_allocate(gf%atom(ia)%x(1:space%dim))
455 do jdir = 1, space%dim
458 if (ncol == space%dim + 2)
then
461 gf%atom(ia)%move = .
true.
486 logical,
intent(inout) :: done
493 message(1) =
'Multiple definitions of '//trim(what)//
' in the input file.'
505 character(len=*),
intent(in) :: what
506 integer,
intent(in) :: iunit
509 character(len=80) :: record
510 character(len=6) :: record_name
521 read(iunit,
'(a80)', err=990,
end=990) record
522 read(record,
'(a6)') record_name
523 if (trim(record_name) ==
'ATOM' .or. trim(record_name) ==
'HETATM')
then
529 safe_allocate(gf%atom(1:gf%n))
531 safe_allocate(gf%atom(ia)%x(1:3))
538 read(iunit,
'(a80)', err=991,
end=991) record
539 read(record,
'(a6)') record_name
540 if (trim(record_name) ==
'ATOM' .or. trim(record_name) ==
'HETATM')
then
541 read(record,
'(12x,a4,1x,a3)') gf%atom(na)%label, gf%atom(na)%residue
542 gf%atom(na)%label = trim(adjustl(gf%atom(na)%label))
543 gf%atom(na)%label = gf%atom(na)%label(1:1)
544 gf%atom(na)%residue = trim(adjustl(gf%atom(na)%residue))
546 read(record,
'(30x,3f8.3)') gf%atom(na)%x(1:3)
550 gf%atom(na)%x = units_to_atomic(unit_angstrom, gf%atom(na)%x)
real(real64), parameter, public m_huge
real(real64), parameter, public m_zero
subroutine, public io_close(iunit, grp)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public messages_not_implemented(feature, namespace)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(namespace_t), public global_namespace
logical function, public parse_is_defined(namespace, name)
subroutine, public parse_block_logical(blk, l, c, res)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
integer, parameter, public read_coords_xsf
integer, parameter, public xyz_flags_charge
integer, parameter, public read_coords_reduced
subroutine, public read_coords_init(gf)
integer, parameter, public xyz_flags_move
subroutine, public read_coords_end(gf)
integer, parameter, public read_coords_xyz
subroutine read_coords_read_pdb(what, iunit, gf)
subroutine, public read_coords_read(what, gf, space, namespace)
integer, parameter, public read_coords_pdb
integer, parameter, public read_coords_inp
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_system_t), public units_inp
the units systems for reading and writing
subroutine check_duplicated(done)