confio

November 18, 2022 ยท View on GitHub

conf_t

conf_t is object designed to handle all molecular cinfiguration files.

type :: conf_t
  integer, allocatable           :: atomi(:)
  character(MAXLEN), allocatable :: atomn(:)
  integer, allocatable           :: resi(:)
  character(MAXLEN), allocatable :: resn(:)
  character(MAXLEN), allocatable :: chain(:)
  character(MAXLEN), allocatable :: element(:)
  real, allocatable              :: bfact(:)
  real, allocatable              :: pcharge(:)
  integer, allocatable           :: charge(:)
  real, allocatable              :: coor(:,:)
  real                           :: box(DIM,DIM) = 0.0
  integer                        :: natoms = 0
contains
  procedure :: allocate
  procedure :: reallocate
  procedure :: deallocate
  procedure :: allocated
  generic   :: operator(+)
  generic   :: assignment(=)
  generic   :: write(formatted)
  procedure :: load
  procedure :: save
end type conf_t

Values

integer, allocatable, dimension(:) :: atomi, resi

Atom and residue index.

character(*), allocatable, dimension(:) :: atomn, resn

Atom and residue name.

character(*), allocatable, dimension(:) :: chain

Peptide chain name.

character(*), allocatable, dimension(:) :: element

Element name.

real, allocatable, dimension(:) :: bfact

Beta (temperature) factor.

real, allocatable, dimension(:) :: pcharge

Atom's partial charge.

integer, allocatable, dimension(:) :: charge

Atom's formal charge.

real, allocatable, dimension(:,:) :: coor

Atom's cartesian coordinates (x,y,z).

real, dimension(DIM,DIM) :: box

Simulation box size vector.

integer :: natoms

Number of atoms in configuration.


constructor

Constructor for conf_t derived type.

out = conf_t(natoms, atomi, atomn, resi, resn, chain, element, &
  &  bfact, pcharge, charge, coor, box)

Parameters


allocate

Allocate object to specified number of atoms.

call conf%allocate (natoms, stat, errmsg)

Parameters


reallocate

Reallocate object to specified number of atoms (bigger or smaller).

call conf%reallocate (natoms, stat, errmsg)

Parameters


deallocate

Deallocate object.

call conf%deallocate (stat, errmsg)

Parameters


allocated

Deallocate object.

out = conf%allocated()

Parameters


assignment(=)

Assign value to configuration. Dump data if already allocated.

out = conf

Parameters


operator(+)

Append data to another object. Both object must be initialized.

out = conf + conf

Parameters


write(formatted)

Formatted write to output unit. Use DT or DT(w,d)use for custom output format where w is the number of positions to be used and d is the number of digits to the right of the decimal point.

write (*, *) conf

Parameters


load

Load (read) configuration file. File format is determined from file extension.

call conf%load (file, stat, errmsg)

Parameters


save

Save (write) configuration file. File format is determined from file extension.

call conf%save (file, stat, errmsg)

Parameters


example

program main
  use atomlib_confio
  implicit none
  type(conf_t) :: conf
  character(128) :: message
  integer :: status

  call conf%load ("input.gro", STAT=status, ERMSG=message)
  if (status /= 0) error stop message

  call conf%save ("output.gro", STAT=status, ERMSG=message)
  if (status /= 0) error stop message

end program main