Module that contains Trajectory type.
More...
|
subroutine | trajectory_open (this, filename_in, ndxfile) |
| Trajectory class method which opens DCD file and optionally index file. More...
|
|
integer function | trajectory_get_natoms (this, group) |
| Trajectory class method which gets the number of atoms in the system or an index group. More...
|
|
integer function | trajectory_skip_next (this, F) |
| Trajectory class method which skips a specified number of frames. More...
|
|
integer function | trajectory_read_next (this, F, ndxgrp) |
| Trajectory class method which reads a specified number of frames into memory after using the open() method. More...
|
|
real function, dimension(3) | trajectory_get_xyz (this, frame, atom, group) |
| Trajectory class method which returns the coordinates of a particle. More...
|
|
subroutine | trajectory_read (this, dcdfile, ndxfile, ndxgrp) |
| Trajectory class method which opens, reads, and closes a trajectory file. More...
|
|
real(8) function, dimension(6) | trajectory_get_box (this, frame) |
| Trajectory class method which returns the box from a simulation frame. More...
|
|
subroutine | trajectory_close (this) |
| Trajectory class method which closes a DCD file which was opened with open() More...
|
|
Module that contains Trajectory type.
◆ trajectory_close()
subroutine dcdfort_trajectory::trajectory_close |
( |
class(trajectory), intent(inout) |
this | ) |
|
|
private |
Trajectory class method which closes a DCD file which was opened with open()
- Parameters
-
[in,out] | this | Trajectory class |
344 class(trajectory),
intent(inout) :: this
346 call this%dcd%close()
◆ trajectory_get_box()
real(8) function, dimension(6) dcdfort_trajectory::trajectory_get_box |
( |
class(trajectory), intent(in) |
this, |
|
|
integer, intent(in) |
frame |
|
) |
| |
|
private |
Trajectory class method which returns the box from a simulation frame.
- Parameters
-
[in,out] | this | Trajectory class |
[in] | frame | Which frame to return the box dimensions |
- Returns
- A real(8) array with 6 elements containing the x, y, and z dimensions of the box as well as the alpha, beta, and gamma angles
315 real(8) :: trajectory_get_box(6)
316 class(trajectory),
intent(in) :: this
317 integer,
intent(in) :: frame
319 call trajectory_check_frame(this, frame)
320 trajectory_get_box = this%frameArray(frame)%box
◆ trajectory_get_natoms()
integer function dcdfort_trajectory::trajectory_get_natoms |
( |
class(trajectory), intent(inout) |
this, |
|
|
character (len=*), intent(in), optional |
group |
|
) |
| |
|
private |
Trajectory class method which gets the number of atoms in the system or an index group.
- Parameters
-
[in,out] | this | the Trajectory object |
[in] | group | name of index group |
- Returns
- number of atoms in index group (if specified) or in system
124 integer :: trajectory_get_natoms
125 class(trajectory),
intent(inout) :: this
126 character (len=*),
intent(in),
optional :: group
128 if (this%read_only_index_group .and.
present(group))
then 129 call error_stop_program(
"Do not specify an index group in natoms() when already specifying an & 130 &index group with read() or read_next().")
133 trajectory_get_natoms = merge(this%ndx%get_natoms(group), this%NUMATOMS,
present(group))
◆ trajectory_get_xyz()
real function, dimension(3) dcdfort_trajectory::trajectory_get_xyz |
( |
class(trajectory), intent(inout) |
this, |
|
|
integer, intent(in) |
frame, |
|
|
integer, intent(in) |
atom, |
|
|
character (len=*), intent(in), optional |
group |
|
) |
| |
|
private |
Trajectory class method which returns the coordinates of a particle.
Gets the coordinates of a particle from the read in trajectory. Returns a real array with 3 elements (x, y, and z). An optional index group can be specified; if so, the atomid is in relationship to the group.
- Parameters
-
[in,out] | this | Trajectory class |
[in] | frame | |
[in] | atom | atomid of particle to get |
[in] | group | optional index group |
- Returns
- coordinate of the particle
259 real :: trajectory_get_xyz(3)
260 integer,
intent(in) :: frame, atom
261 integer :: atom_tmp, natoms
262 class(trajectory),
intent(inout) :: this
263 character (len=1024) :: message
264 character (len=*),
intent(in),
optional :: group
266 call trajectory_check_frame(this, frame)
268 if (this%read_only_index_group .and.
present(group))
then 269 call error_stop_program(
"Do not specify an index group in x() when already specifying an & 270 &index group with read() or read_next().")
273 atom_tmp = merge(this%ndx%get(group, atom), atom,
present(group))
274 natoms = merge(this%natoms(group), this%natoms(),
present(group))
276 if (atom > natoms .or. atom < 1)
then 277 write(message,
"(a,i0,a,i0,a)")
"Tried to access atom number ", atom_tmp,
" when there are ", &
278 natoms,
". Note that Fortran uses one-based indexing." 279 call error_stop_program(trim(message))
282 trajectory_get_xyz = this%frameArray(frame)%xyz(:,atom_tmp)
◆ trajectory_open()
subroutine dcdfort_trajectory::trajectory_open |
( |
class(trajectory), intent(inout) |
this, |
|
|
character (len=*), intent(in) |
filename_in, |
|
|
character (len=*), intent(in), optional |
ndxfile |
|
) |
| |
Trajectory class method which opens DCD file and optionally index file.
- Parameters
-
[in,out] | this | the Trajectory object |
[in] | filename_in | name of DCD file |
[in] | ndxfile | name of GROMACS style index file |
90 class(trajectory),
intent(inout) :: this
91 character (len=*),
intent(in) :: filename_in
92 character (len=*),
intent(in),
optional :: ndxfile
93 character (len=206) :: filetype
97 call this%dcd%open(trim(filename_in))
99 write(error_unit,
'(a)')
"Opened "//trim(filename_in)//
" for reading." 100 call this%dcd%read_header(this%nframes, this%istart, this%nevery, this%iend, this%timestep, this%NUMATOMS)
102 write(error_unit,
'(i0,a)') this%NUMATOMS,
" atoms present in system." 103 write(error_unit,
'(i0,a)') this%NFRAMES,
" frames present in trajectory file." 104 write(error_unit,
'(a,i0)')
"First timestep saved: ", this%ISTART
105 write(error_unit,
'(a,i0)')
"Last timestep saved: ", this%IEND
106 write(error_unit,
'(a,f12.6)')
"Simulation timestep: ", this%timestep
107 write(error_unit,
'(a,i0,a)')
"Trajectory written every ", this%nevery,
" timesteps." 109 this%FRAMES_REMAINING = this%NFRAMES
111 this%N = this%NUMATOMS
112 if (
present(ndxfile))
call this%ndx%read(ndxfile, this%NUMATOMS)
◆ trajectory_read()
subroutine dcdfort_trajectory::trajectory_read |
( |
class(trajectory), intent(inout) |
this, |
|
|
character (len=*) |
dcdfile, |
|
|
character (len=*), optional |
ndxfile, |
|
|
character (len=*), optional |
ndxgrp |
|
) |
| |
|
private |
Trajectory class method which opens, reads, and closes a trajectory file.
- Parameters
-
[in,out] | this | Trajectory class |
[in] | dcdfile | Name of DCD trajectory file |
[in] | ndxfile | Name of optional index file |
[in] | ndxgrp | Name of optional group. If specified, only that group will be read into memory. |
294 class(trajectory),
intent(inout) :: this
295 character (len=*),
optional :: ndxfile, ndxgrp
296 character (len=*) :: dcdfile
299 call this%open(dcdfile, ndxfile)
301 n = this%read_next(this%NFRAMES, ndxgrp)
◆ trajectory_read_next()
integer function dcdfort_trajectory::trajectory_read_next |
( |
class(trajectory), intent(inout) |
this, |
|
|
integer, intent(in), optional |
F, |
|
|
character (len=*), optional |
ndxgrp |
|
) |
| |
|
private |
Trajectory class method which reads a specified number of frames into memory after using the open() method.
- Parameters
-
[in,out] | this | Trajectory class |
[in] | F | number of frames to read in; if not specified, 1 frame is read |
[in] | ndxgrp | read only this index group into memory |
- Returns
- number of frames read in
177 integer :: trajectory_read_next
178 class(trajectory),
intent(inout) :: this
179 integer,
intent(in),
optional :: f
180 character (len=*),
optional :: ndxgrp
181 integer :: i, j, n, stat
182 real,
allocatable :: xyz(:,:)
185 n = merge(f, 1,
present(f))
188 n = min(this%FRAMES_REMAINING, n)
189 this%FRAMES_REMAINING = this%FRAMES_REMAINING - n
191 if (
allocated(this%frameArray))
deallocate(this%frameArray)
192 allocate(this%frameArray(n))
196 this%read_only_index_group = .false.
198 if (
present(ndxgrp))
then 200 allocate(xyz(3,this%N))
201 this%NUMATOMS = this%natoms(trim(ndxgrp))
204 if (modulo(i, 1000) .eq. 0)
call print_frames_saved(i)
206 allocate(this%frameArray(i)%xyz(3,this%NUMATOMS))
207 call this%dcd%read_next(xyz, this%frameArray(i)%box)
209 do j = 1,
size(this%ndx%group)
210 if (trim(this%ndx%group(j)%title) .eq. trim(ndxgrp))
then 211 this%frameArray(i)%xyz = xyz(:,this%ndx%group(j)%LOC)
219 this%read_only_index_group = .true.
225 if (modulo(i, 1000) .eq. 0)
call print_frames_saved(i)
227 allocate(this%frameArray(i)%xyz(3,this%NUMATOMS))
228 call this%dcd%read_next(this%frameArray(i)%xyz, this%frameArray(i)%box)
235 trajectory_read_next = n
236 call print_frames_saved(n)
◆ trajectory_skip_next()
integer function dcdfort_trajectory::trajectory_skip_next |
( |
class(trajectory), intent(inout) |
this, |
|
|
integer, intent(in), optional |
F |
|
) |
| |
|
private |
Trajectory class method which skips a specified number of frames.
- Parameters
-
[in,out] | this | Trajectory class |
[in] | F | number of frames to skip; if not specified, 1 frame is skipped |
- Returns
- number of frames skipped
144 class(trajectory),
intent(inout) :: this
145 integer,
intent(in),
optional :: f
146 integer :: trajectory_skip_next, i, stat, n
149 n = merge(f, 1,
present(f))
152 n = min(this%FRAMES_REMAINING, n)
153 this%FRAMES_REMAINING = this%FRAMES_REMAINING - n
156 call this%dcd%skip_next()
157 if (stat .ne. 0)
then 158 write(error_unit,
'(a,i0,a)')
"Skipped ", i-1,
" frames." 159 trajectory_skip_next = i-1
163 write(error_unit,
'(a,i0,a)')
"Skipped ", n,
" frames." 164 trajectory_skip_next = n