Module that contains dcdreader class.
More...
Module that contains dcdreader class.
◆ dcdfile_close()
subroutine dcdfort_reader::dcdfile_close |
( |
class(dcdfile), intent(inout) |
this | ) |
|
Closes DCD file.
- Parameters
-
[in,out] | this | dcdreader object |
171 class(dcdfile),
intent(inout) :: this
◆ dcdfile_open()
subroutine dcdfort_reader::dcdfile_open |
( |
class(dcdfile), intent(inout) |
this, |
|
|
character (len=*), intent(in) |
filename |
|
) |
| |
Opens file to read from.
- Parameters
-
[in,out] | this | dcdreader object |
[in] | filename | name of of DCD file to read from |
60 character (len=*),
intent(in) :: filename
61 class(dcdfile),
intent(inout) :: this
65 inquire(file=trim(filename), exist=ex, size=this%filesize)
67 if (ex .eqv. .false.)
then 68 call error_stop_program(trim(filename)//
" does not exist.")
71 open(newunit=this%u, file=trim(filename), form=
"unformatted", access=
"stream")
◆ dcdfile_read_header()
subroutine dcdfort_reader::dcdfile_read_header |
( |
class(dcdfile), intent(inout) |
this, |
|
|
integer, intent(out) |
nframes, |
|
|
integer, intent(out) |
istart, |
|
|
integer, intent(out) |
nevery, |
|
|
integer, intent(out) |
iend, |
|
|
real, intent(out) |
timestep, |
|
|
integer, intent(out) |
natoms |
|
) |
| |
Reads header of open DCD file.
Should be called after open()
- Parameters
-
[in,out] | this | dcdreader object |
[in] | nframes | rnumber of frames (snapshots) in file |
[out] | istart | first timestep of trajectory file |
[out] | nevery | how often (in timesteps) file was written to |
[out] | iend | last timestep of trajectory file |
[out] | timestep | timestep of simulation |
[out] | natoms | number of atoms in each snapshot |
89 integer,
intent(out) :: nframes, istart, nevery, iend, natoms
90 integer :: i, ntitle, n, framesize, nframes2, curr_pos
91 character (len=4) :: cord_string
92 character (len=80) :: title_string
93 real,
intent(out) :: timestep
94 class(dcdfile),
intent(inout) :: this
97 if (dummy .ne. 84)
then 98 call error_stop_program(
"This dcd file format is not supported, or the file header is corrupt.")
101 read(this%u) cord_string
102 if (cord_string .ne.
"CORD")
then 103 call error_stop_program(
"This dcd file format is not supported, or the file header is corrupt.")
123 read(this%u) timestep
131 read(this%u) title_string
134 do while (n .le. 80 .and. title_string(n:n) .ne. c_null_char)
138 write(error_unit,
'(a)') trim(title_string(1:n))
143 if (dummy .ne. 4)
then 144 call error_stop_program(
"This dcd file format is not supported, or the file header is corrupt.")
152 inquire(unit=this%u, pos=curr_pos)
155 framesize = natoms*12 + 48
157 nframes2 = (this%filesize-curr_pos)/framesize
158 if ( nframes2 .ne. nframes)
then 159 write(error_unit,
'(a,i0,a,i0,a)')
"WARNING: Header indicates ", nframes, &
160 &
" frames, but file size indicates ", nframes2,
"."
◆ dcdfile_read_next()
subroutine dcdfort_reader::dcdfile_read_next |
( |
class(dcdfile), intent(inout) |
this, |
|
|
real, dimension(:,:), intent(inout), allocatable |
xyz, |
|
|
real(8), dimension(6), intent(inout) |
box |
|
) |
| |
Reads next frame into memory.
- Parameters
-
[in,out] | this | dcdreader object |
[in,out] | xyz | coordinates of all atoms in snapshot |
[in,out] | box | dimensions of snapshot |
184 real,
allocatable,
intent(inout) :: xyz(:,:)
185 real(8),
intent(inout) :: box(6)
187 class(dcdfile),
intent(inout) :: this
198 if (box(4) >= -1.0 .and. box(4) <= 1.0 .and. box(5) >= -1.0 .and. box(5) <= 1.0 .and. &
199 box(6) >= -1.0 .and. box(6) <= 1.0)
then 200 box(4) = 90.0 - asin(box(4)) * 180.0 / pi
201 box(5) = 90.0 - asin(box(5)) * 180.0 / pi
202 box(6) = 90.0 - asin(box(6)) * 180.0 / pi
209 read(this%u) xyz(1,:)
215 read(this%u) xyz(2,:)
221 read(this%u) xyz(3,:)
◆ dcdfile_skip_next()
subroutine dcdfort_reader::dcdfile_skip_next |
( |
class(dcdfile), intent(inout) |
this | ) |
|
Skips reading this frame into memory.
- Parameters
-
[in,out] | this | dcdreader object |
234 real(8) :: box_dummy(6)
235 class(dcdfile),
intent(inout) :: this
240 read(this%u) box_dummy
247 read(this%u) real_dummy
255 read(this%u) real_dummy
263 read(this%u) real_dummy