trajectory_t Derived Type

type, private :: trajectory_t


Contents

Source Code


Components

TypeVisibility AttributesNameInitial
integer, public :: header_size =0
integer, public :: frame_size =0
integer, public :: num_atoms =0
integer, public, dimension(4):: frmcmp =0
character(len=:), public, allocatable:: fn
integer, public :: file_id =0
integer, public :: num_frames =0
logical, public :: isopen =.false.

Type-Bound Procedures

procedure, public :: create => traj_create

  • private subroutine traj_create(this, fn, na, frmcmp)

    Creates a trajectory_t object with a new underlying file named fn. If fn already exists, it will be truncated. The file fn is opened for both reading and writing.

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(out) :: this

    trajectory_t instance.

    character(len=*), intent(in) :: fn

    Name of the underlying trajectory file.

    integer, intent(in) :: na

    Number of atoms

    integer, intent(in), dimension(4):: frmcmp

    Binary flags indicating whether that component is present in a frame. frmcmp(1): coordinates, frmcmp(2): velocities, frmcmp(3): forces, frmcmp(4): charges

procedure, public :: open => traj_open

  • private subroutine traj_open(this, fn, mode, ierr)

    Creates a trajectory_t object with a prexisting underlying file named fn. If fn does not exist, an error will be generated. If mode == 'rw', the file fn is opened for both reading and writing. If mode == 'r', the file fn is opened only for reading.

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(out) :: this
    character(len=*), intent(in) :: fn
    character(len=*), intent(in) :: mode
    integer, intent(out) :: ierr

procedure, public :: delete => traj_delete

  • private subroutine traj_delete(this)

    After a call to this subroutine, all memory within this is deallocated, all components of this are reset to zero, and the underlying file is closed (if open).

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(inout) :: this

procedure, public :: close => traj_close

  • private subroutine traj_close(this)

    Closes the underlying file of a trajectory_t.

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(inout) :: this

procedure, public :: read => traj_read

  • private subroutine traj_read(this, iframe, nts, ierr, coordinates, velocities, forces, charge)

    Read from an open trajectory.

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(in) :: this
    integer, intent(in) :: iframe

    Frame number

    integer(kind=ip_long), intent(out) :: nts

    Time step counter

    integer, intent(out) :: ierr

    Error flag

    real(kind=rp), intent(out), optional dimension(:,:):: coordinates
    real(kind=rp), intent(out), optional dimension(:,:):: velocities
    real(kind=rp), intent(out), optional dimension(:,:):: forces
    real(kind=rp), intent(out), optional dimension(:):: charge

procedure, public :: append_frame => traj_append_frame

  • private subroutine traj_append_frame(this, nts, coordinates)

    Write a frame to an open trajectory

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(inout) :: this
    integer(kind=ip_long), intent(in) :: nts
    real(kind=rp), intent(in), dimension(:,:):: coordinates

procedure, public :: write_frame => traj_write_frame

  • private subroutine traj_write_frame(this, iframe, nts, coordinates)

    Write a frame to an open trajectory

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(inout) :: this
    integer, intent(in) :: iframe
    integer(kind=ip_long), intent(in) :: nts
    real(kind=rp), intent(in), dimension(:,:):: coordinates

generic, public :: init => create, open

  • private subroutine traj_create(this, fn, na, frmcmp)

    Creates a trajectory_t object with a new underlying file named fn. If fn already exists, it will be truncated. The file fn is opened for both reading and writing.

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(out) :: this

    trajectory_t instance.

    character(len=*), intent(in) :: fn

    Name of the underlying trajectory file.

    integer, intent(in) :: na

    Number of atoms

    integer, intent(in), dimension(4):: frmcmp

    Binary flags indicating whether that component is present in a frame. frmcmp(1): coordinates, frmcmp(2): velocities, frmcmp(3): forces, frmcmp(4): charges

  • private subroutine traj_open(this, fn, mode, ierr)

    Creates a trajectory_t object with a prexisting underlying file named fn. If fn does not exist, an error will be generated. If mode == 'rw', the file fn is opened for both reading and writing. If mode == 'r', the file fn is opened only for reading.

    Arguments

    Type IntentOptional AttributesName
    class(trajectory_t), intent(out) :: this
    character(len=*), intent(in) :: fn
    character(len=*), intent(in) :: mode
    integer, intent(out) :: ierr

Source Code

type trajectory_t
    integer :: header_size = 0
    integer :: frame_size = 0
    integer :: num_atoms = 0
    integer, dimension(4) :: frmcmp = 0
    character(len=:), allocatable :: fn
    integer :: file_id = 0
    integer :: num_frames = 0
    logical :: isopen = .false.

    contains
        procedure :: create       => traj_create
        procedure :: open         => traj_open
        procedure :: delete       => traj_delete
        procedure :: close        => traj_close
        procedure :: read         => traj_read
        procedure :: append_frame => traj_append_frame
        procedure :: write_frame  => traj_write_frame
        generic   :: init         => create, open
end type trajectory_t