chfl_trajectory
type¶
-
type
chfl_trajectory
¶ The
chfl_trajectory
type is the main entry point when using chemfiles. Achfl_trajectory
behave a like a file, allowing to read and/or writechfl_frame
.Type fields: %
open
[subroutine] ::chfl_trajectory%open()
%
path
[function] ::chfl_trajectory%path()
%
nsteps
[function] ::chfl_trajectory%nsteps()
%
read
[subroutine] ::chfl_trajectory%read()
%
read_step
[subroutine] ::chfl_trajectory%read_step()
%
write
[subroutine] ::chfl_trajectory%write()
%
set_topology
[subroutine] ::chfl_trajectory%set_topology()
%
topology_file
[subroutine] ::chfl_trajectory%topology_file()
%
set_cell
[subroutine] ::chfl_trajectory%set_cell()
%
close
[subroutine] ::chfl_trajectory%close()
-
subroutine
chfl_trajectory%
open
(path, mode[, format, status])¶ Open the file at the given
path
using the givenmode
. Valid modes are'r'
for read,'w'
for write and'a'
for append.If
format
is not given or an empty string, the format will be guessed from the extension.This subroutine allocate memory which must be released with
chfl_trajectory%close()
.Parameters: - path [character(len=*)] :: path to the trajectory file
- mode [character] :: opening mode
Options: - format [character(len=*)] :: format to use to read and write to the file
- status [integer(chfl_status)] :: status code of the operation. If it
is not
CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
path
([status])¶ Get the path used to open the trajectory. If the path is longer than
CHFL_STRING_LENGTH
, it will be truncated.Return: character (len=CHFL_STRING_LENGTH) Options: status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
function
chfl_trajectory%
nsteps
([status])¶ Get the number of steps (the number of frames) in the trajectory.
Return: integer Options: status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
read
(frame[, status])¶ Read the next step of the trajectory into a
frame
.If the number of atoms in frame does not correspond to the number of atom in the next step, the frame is resized.
Parameters: frame [type(chfl_frame)] :: frame to fill with the data Options: status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
read_step
(step, frame[, status])¶ Read a specific
step
of the trajectory into aframe
. The first trajectory step is the step 0.If the number of atoms in frame does not correspond to the number of atom in the step, the frame is resized.
Parameters: - step [integer] :: step to read
- frame [type(chfl_frame)] :: frame to fill with the data
Options: status [integer(chfl_status)] :: status code of the operation. If it is not
CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
write
(frame[, status])¶ Write a single
frame
to the trajectory.Parameters: frame [type(chfl_frame)] :: frame to be writen to the file Options: status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
set_topology
(topology[, status])¶ Set the
topology
associated with the trajectory. This topology will be used when reading and writing the files, replacing any topology in the frames or files.Parameters: topology [type(chfl_topology)] :: new topology to use Options: status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
topology_file
(path[, format, status])¶ Set the topology associated with the trajectory by reading the first frame of the file at the given
path
using the file format informat
; and extracting the topology of this frame.If
format
is an empty string or not given, the format will be guessed from the extension.Parameters: path [character(len=*)] :: file to read in order to get the new topology
Options: - format [character(len=*)] :: format to use for the topology file
- status [integer(chfl_status)] :: status code of the operation. If it
is not
CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
set_cell
(cell[, status])¶ Set the unit
cell
associated with the trajectory. This cell will be used when reading and writing the files, replacing any pre-existing unit cell.Parameters: cell [type(chfl_cell)] :: new cell to use Options: status [integer(chfl_status)] :: status code of the operation. If it is not CHFL_SUCCESS
, usechfl_last_error()
to learn more about the error.
-
subroutine
chfl_trajectory%
close
([status])¶ Close a trajectory file, and free the associated memory.
Closing a file will synchronize all changes made to the file with the storage (hard drive, network, …) used for this file.