Classes | Typedefs | Enumerations | Functions | Variables
PLMD::xdrfile Namespace Reference

Classes

struct  t_trnheader
 
struct  XDR
 
struct  XDRFILE
 Contents of the abstract XDRFILE data structure. More...
 

Typedefs

typedef float matrix[DIM][DIM]
 
typedef int mybool
 
typedef float rvec[DIM]
 
typedef struct XDR XDR
 
typedef struct XDRFILE XDRFILE
 Abstract datatype for an portable binary file handle. More...
 
typedef int(* xdrproc_t) (XDR *, void *,...)
 

Enumerations

enum  {
  exdrOK, exdrHEADER, exdrSTRING, exdrDOUBLE,
  exdrINT, exdrFLOAT, exdrUINT, exdr3DX,
  exdrCLOSE, exdrMAGIC, exdrNOMEM, exdrENDOFFILE,
  exdrFILENOTFOUND, exdrNR
}
 
enum  { FALSE, TRUE }
 
enum  xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 }
 

Functions

static int ctofstr (char *dest, int dest_len, char *src)
 
 ctofstr (str, len, cstr)
 
static int decodebits (int buf[], int num_of_bits)
 
static void decodeints (int buf[], int num_of_ints, int num_of_bits, unsigned int sizes[], int nums[])
 
static int do_htrn (XDRFILE *xd, mybool bRead, t_trnheader *sh, matrix box, rvec *x, rvec *v, rvec *f)
 
static int do_trn (XDRFILE *xd, mybool bRead, int *step, float *t, float *lambda, matrix box, int *natoms, rvec *x, rvec *v, rvec *f)
 
static int do_trnheader (XDRFILE *xd, mybool bRead, t_trnheader *sh)
 
static void encodebits (int buf[], int num_of_bits, int num)
 
static void encodeints (int buf[], int num_of_ints, int num_of_bits, unsigned int sizes[], unsigned int nums[])
 
void F77_FUNC (xddcd, XDRDCD)(int *fid
 
void F77_FUNC (xdrccd, XDRCCD)(int *fid
 
void F77_FUNC (xdrccs, XDRCCS)(int *fid
 
void F77_FUNC (xdrclose, XDRCLOSE)(int *fid)
 
void F77_FUNC (xdrdcs, XDRDCS)(int *fid
 
void F77_FUNC (xdropen, XDROPEN)(int *fid
 
void F77_FUNC (xdrrchar, XDRRCHAR)(int *fid
 
void F77_FUNC (xdrrdouble, XDRRDOUBLE)(int *fid
 
void F77_FUNC (xdrrint, XDRRINT)(int *fid
 
void F77_FUNC (xdrropaque, XDRROPAQUE)(int *fid
 
void F77_FUNC (xdrrshort, XDRRSHORT)(int *fid
 
void F77_FUNC (xdrrsingle, XDRRSINGLE)(int *fid
 
void F77_FUNC (xdrrstring, XDRRSTRING)(int *fid
 
void F77_FUNC (xdrruchar, XDRRUCHAR)(int *fid
 
void F77_FUNC (xdrruint, XDRRUINT)(int *fid
 
void F77_FUNC (xdrrushort, XDRRUSHORT)(int *fid
 
void F77_FUNC (xdrwchar, XDRWCHAR)(int *fid
 
void F77_FUNC (xdrwdouble, XDRWDOUBLE)(int *fid
 
void F77_FUNC (xdrwint, XDRWINT)(int *fid
 
void F77_FUNC (xdrwopaque, XDRWOPAQUE)(int *fid
 
void F77_FUNC (xdrwshort, XDRWSHORT)(int *fid
 
void F77_FUNC (xdrwsingle, XDRWSINGLE)(int *fid
 
void F77_FUNC (xdrwstring, XDRWSTRING)(int *fid
 
void F77_FUNC (xdrwuchar, XDRWUCHAR)(int *fid
 
void F77_FUNC (xdrwuint, XDRWUINT)(int *fid
 
void F77_FUNC (xdrwushort, XDRWUSHORT)(int *fid
 
 free (cstr)
 
static int ftocstr (char *dest, int dest_len, char *src, int src_len)
 
 if ((cstr=(char *) malloc((len+1) *sizeof(char)))==NULL)
 
 if (f77init)
 
else if (ftocstr(cfilename, sizeof(cfilename), filename, fn_len))
 
else if (ftocstr(cmode, sizeof(cmode), mode, mode_len))
 
 if (ftocstr(cstr, len+1, str, len))
 
 if (i==MAX_FORTRAN_XDR)
 
static int nFloatSize (t_trnheader *sh, int *nflsz)
 
int read_trr (XDRFILE *xd, int natoms, int *step, float *t, float *lambda, matrix box, rvec *x, rvec *v, rvec *f)
 
int read_trr_natoms (char *fn, int *natoms)
 
int read_xtc (XDRFILE *xd, int natoms, int *step, float *time, matrix box, rvec *x, float *prec)
 
int read_xtc_natoms (char *fn, int *natoms)
 
static int sizeofint (int size)
 
static int sizeofints (int num_of_ints, unsigned int sizes[])
 
 while (i< MAX_FORTRAN_XDR &&f77xdr[i]!=NULL) i++
 
int write_trr (XDRFILE *xd, int natoms, int step, float t, float lambda, matrix box, rvec *x, rvec *v, rvec *f)
 
int write_xtc (XDRFILE *xd, int natoms, int step, float time, matrix box, rvec *x, float prec)
 
static int xdr_char (XDR *xdrs, char *ip)
 
static int xdr_double (XDR *xdrs, double *ip)
 
static int xdr_float (XDR *xdrs, float *ip)
 
static int32_t xdr_htonl (int32_t x)
 
static int xdr_int (XDR *xdrs, int *ip)
 
static int32_t xdr_ntohl (int x)
 
static int xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt)
 
static int xdr_short (XDR *xdrs, short *ip)
 
static int xdr_string (XDR *xdrs, char **ip, unsigned int maxsize)
 
static int32_t xdr_swapbytes (int32_t x)
 
static int xdr_u_char (XDR *xdrs, unsigned char *ip)
 
static int xdr_u_int (XDR *xdrs, unsigned int *ip)
 
static int xdr_u_short (XDR *xdrs, unsigned short *ip)
 
int xdrfile_close (XDRFILE *xfp)
 Close a previously opened portable binary file, just like fclose() More...
 
int xdrfile_compress_coord_double (double *ptr, int ncoord, double precision, XDRFILE *xfp)
 Compress coordiates in a double array to XDR file. More...
 
int xdrfile_compress_coord_float (float *ptr, int ncoord, float precision, XDRFILE *xfp)
 Compress coordiates in a float array to XDR file. More...
 
int xdrfile_decompress_coord_double (double *ptr, int *ncoord, double *precision, XDRFILE *xfp)
 Decompress coordiates from XDR file to array of doubles. More...
 
int xdrfile_decompress_coord_float (float *ptr, int *ncoord, float *precision, XDRFILE *xfp)
 Decompress coordiates from XDR file to array of floats. More...
 
XDRFILExdrfile_open (const char *path, const char *mode)
 Open a portable binary file, just like fopen() More...
 
int xdrfile_read_char (char *ptr, int ndata, XDRFILE *xfp)
 Read one or more char type variable(s) More...
 
int xdrfile_read_double (double *ptr, int ndata, XDRFILE *xfp)
 Read one or more double type variable(s) More...
 
int xdrfile_read_float (float *ptr, int ndata, XDRFILE *xfp)
 Read one or more float type variable(s) More...
 
int xdrfile_read_int (int *ptr, int ndata, XDRFILE *xfp)
 Read one or more integer type variable(s) More...
 
int xdrfile_read_opaque (char *ptr, int nbytes, XDRFILE *xfp)
 Read raw bytes from file (unknown datatype) More...
 
int xdrfile_read_short (short *ptr, int ndata, XDRFILE *xfp)
 Read one or more short type variable(s) More...
 
int xdrfile_read_string (char *ptr, int maxlen, XDRFILE *xfp)
 Read a string (array of characters) More...
 
int xdrfile_read_uchar (unsigned char *ptr, int ndata, XDRFILE *xfp)
 Read one or more unsigned char type variable(s) More...
 
int xdrfile_read_uint (unsigned int *ptr, int ndata, XDRFILE *xfp)
 Read one or more unsigned integers type variable(s) More...
 
int xdrfile_read_ushort (unsigned short *ptr, int ndata, XDRFILE *xfp)
 Read one or more unsigned short type variable(s) More...
 
int xdrfile_write_char (char *ptr, int ndata, XDRFILE *xfp)
 Write one or more characters type variable(s) More...
 
int xdrfile_write_double (double *ptr, int ndata, XDRFILE *xfp)
 Write one or more double type variable(s) More...
 
int xdrfile_write_float (float *ptr, int ndata, XDRFILE *xfp)
 Write one or more float type variable(s) More...
 
int xdrfile_write_int (int *ptr, int ndata, XDRFILE *xfp)
 Write one or more integer type variable(s) More...
 
int xdrfile_write_opaque (char *ptr, int nbytes, XDRFILE *xfp)
 Write raw bytes to file (unknown datatype) More...
 
int xdrfile_write_short (short *ptr, int ndata, XDRFILE *xfp)
 Write one or more short type variable(s) More...
 
int xdrfile_write_string (char *ptr, XDRFILE *xfp)
 Write a string (array of characters) More...
 
int xdrfile_write_uchar (unsigned char *ptr, int ndata, XDRFILE *xfp)
 Write one or more unsigned characters type variable(s) More...
 
int xdrfile_write_uint (unsigned int *ptr, int ndata, XDRFILE *xfp)
 Write one or more unsigned integer type variable(s) More...
 
int xdrfile_write_ushort (unsigned short *ptr, int ndata, XDRFILE *xfp)
 Write one or more unsigned short type variable(s) More...
 
static void xdrstdio_create (XDR *xdrs, FILE *fp, enum xdr_op xop)
 
static void xdrstdio_destroy (XDR *)
 
static int xdrstdio_getbytes (XDR *, char *, unsigned int)
 
static int xdrstdio_getlong (XDR *, int32_t *)
 
static unsigned int xdrstdio_getpos (XDR *)
 
static int xdrstdio_putbytes (XDR *, char *, unsigned int)
 
static int xdrstdio_putlong (XDR *, int32_t *)
 
static int xdrstdio_setpos (XDR *, unsigned int)
 
static int xtc_coord (XDRFILE *xd, int *natoms, matrix box, rvec *x, float *prec, mybool bRead)
 
static int xtc_header (XDRFILE *xd, int *natoms, int *step, float *time, mybool bRead)
 

Variables

char cmode [5]
 
void int * data
 
 else
 
const char * exdr_message [exdrNR]
 
static int f77init = 1
 
static XDRFILEf77xdr [MAX_FORTRAN_XDR]
 
fid =i
 
void char * filename
 
void char char int fn_len
 
int i =0
 
void char * ip
 
void char int int len
 
static const int magicints []
 
void char char * mode
 
void char char int int mode_len
 
void float int * ncoord
 
void int int * ndata
 
void float int float * precision
 
void int int int * ret
 
void char * str
 
static char xdr_zero [BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}
 
static const XDR::xdr_ops xdrstdio_ops
 

Typedef Documentation

◆ matrix

typedef float PLMD::xdrfile::matrix[DIM][DIM]

◆ mybool

typedef int PLMD::xdrfile::mybool

◆ rvec

typedef float PLMD::xdrfile::rvec[DIM]

◆ XDR

typedef struct XDR PLMD::xdrfile::XDR

◆ XDRFILE

Abstract datatype for an portable binary file handle.

This datatype essentially works just like the standard FILE type in C. The actual contents is hidden in the implementation, so you can only define pointers to it, for use with the xdrfile routines.

If you really need to see the definition it is in xdrfile.c, but you cannot access elements of the structure outside that file.

Warning
The implementation is completely different from the C standard library FILE, so don't even think about using an XDRFILE pointer as an argument to a routine that needs a standard FILE pointer.

◆ xdrproc_t

typedef int(* PLMD::xdrfile::xdrproc_t) (XDR *, void *,...)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
exdrOK 
exdrHEADER 
exdrSTRING 
exdrDOUBLE 
exdrINT 
exdrFLOAT 
exdrUINT 
exdr3DX 
exdrCLOSE 
exdrMAGIC 
exdrNOMEM 
exdrENDOFFILE 
exdrFILENOTFOUND 
exdrNR 

◆ anonymous enum

anonymous enum
Enumerator
FALSE 
TRUE 

◆ xdr_op

Enumerator
XDR_ENCODE 
XDR_DECODE 
XDR_FREE 

Function Documentation

◆ ctofstr() [1/2]

static int PLMD::xdrfile::ctofstr ( char *  dest,
int  dest_len,
char *  src 
)
static

◆ ctofstr() [2/2]

PLMD::xdrfile::ctofstr ( str  ,
len  ,
cstr   
)

◆ decodebits()

static int PLMD::xdrfile::decodebits ( int  buf[],
int  num_of_bits 
)
static

◆ decodeints()

static void PLMD::xdrfile::decodeints ( int  buf[],
int  num_of_ints,
int  num_of_bits,
unsigned int  sizes[],
int  nums[] 
)
static

◆ do_htrn()

static int PLMD::xdrfile::do_htrn ( XDRFILE xd,
mybool  bRead,
t_trnheader sh,
matrix  box,
rvec x,
rvec v,
rvec f 
)
static

◆ do_trn()

static int PLMD::xdrfile::do_trn ( XDRFILE xd,
mybool  bRead,
int *  step,
float *  t,
float *  lambda,
matrix  box,
int *  natoms,
rvec x,
rvec v,
rvec f 
)
static

◆ do_trnheader()

static int PLMD::xdrfile::do_trnheader ( XDRFILE xd,
mybool  bRead,
t_trnheader sh 
)
static

◆ encodebits()

static void PLMD::xdrfile::encodebits ( int  buf[],
int  num_of_bits,
int  num 
)
static

◆ encodeints()

static void PLMD::xdrfile::encodeints ( int  buf[],
int  num_of_ints,
int  num_of_bits,
unsigned int  sizes[],
unsigned int  nums[] 
)
static

◆ F77_FUNC() [1/26]

void PLMD::xdrfile::F77_FUNC ( xddcd  ,
XDRDCD   
)

◆ F77_FUNC() [2/26]

void PLMD::xdrfile::F77_FUNC ( xdrccd  ,
XDRCCD   
)

◆ F77_FUNC() [3/26]

void PLMD::xdrfile::F77_FUNC ( xdrccs  ,
XDRCCS   
)

◆ F77_FUNC() [4/26]

void PLMD::xdrfile::F77_FUNC ( xdrclose  ,
XDRCLOSE   
)

◆ F77_FUNC() [5/26]

void PLMD::xdrfile::F77_FUNC ( xdrdcs  ,
XDRDCS   
)

◆ F77_FUNC() [6/26]

void PLMD::xdrfile::F77_FUNC ( xdropen  ,
XDROPEN   
)

◆ F77_FUNC() [7/26]

void PLMD::xdrfile::F77_FUNC ( xdrrchar  ,
XDRRCHAR   
)

◆ F77_FUNC() [8/26]

void PLMD::xdrfile::F77_FUNC ( xdrrdouble  ,
XDRRDOUBLE   
)

◆ F77_FUNC() [9/26]

void PLMD::xdrfile::F77_FUNC ( xdrrint  ,
XDRRINT   
)

◆ F77_FUNC() [10/26]

void PLMD::xdrfile::F77_FUNC ( xdrropaque  ,
XDRROPAQUE   
)

◆ F77_FUNC() [11/26]

void PLMD::xdrfile::F77_FUNC ( xdrrshort  ,
XDRRSHORT   
)

◆ F77_FUNC() [12/26]

void PLMD::xdrfile::F77_FUNC ( xdrrsingle  ,
XDRRSINGLE   
)

◆ F77_FUNC() [13/26]

void PLMD::xdrfile::F77_FUNC ( xdrrstring  ,
XDRRSTRING   
)

◆ F77_FUNC() [14/26]

void PLMD::xdrfile::F77_FUNC ( xdrruchar  ,
XDRRUCHAR   
)

◆ F77_FUNC() [15/26]

void PLMD::xdrfile::F77_FUNC ( xdrruint  ,
XDRRUINT   
)

◆ F77_FUNC() [16/26]

void PLMD::xdrfile::F77_FUNC ( xdrrushort  ,
XDRRUSHORT   
)

◆ F77_FUNC() [17/26]

void PLMD::xdrfile::F77_FUNC ( xdrwchar  ,
XDRWCHAR   
)

◆ F77_FUNC() [18/26]

void PLMD::xdrfile::F77_FUNC ( xdrwdouble  ,
XDRWDOUBLE   
)

◆ F77_FUNC() [19/26]

void PLMD::xdrfile::F77_FUNC ( xdrwint  ,
XDRWINT   
)

◆ F77_FUNC() [20/26]

void PLMD::xdrfile::F77_FUNC ( xdrwopaque  ,
XDRWOPAQUE   
)

◆ F77_FUNC() [21/26]

void PLMD::xdrfile::F77_FUNC ( xdrwshort  ,
XDRWSHORT   
)

◆ F77_FUNC() [22/26]

void PLMD::xdrfile::F77_FUNC ( xdrwsingle  ,
XDRWSINGLE   
)

◆ F77_FUNC() [23/26]

void PLMD::xdrfile::F77_FUNC ( xdrwstring  ,
XDRWSTRING   
)

◆ F77_FUNC() [24/26]

void PLMD::xdrfile::F77_FUNC ( xdrwuchar  ,
XDRWUCHAR   
)

◆ F77_FUNC() [25/26]

void PLMD::xdrfile::F77_FUNC ( xdrwuint  ,
XDRWUINT   
)

◆ F77_FUNC() [26/26]

void PLMD::xdrfile::F77_FUNC ( xdrwushort  ,
XDRWUSHORT   
)

◆ free()

PLMD::xdrfile::free ( cstr  )

◆ ftocstr()

static int PLMD::xdrfile::ftocstr ( char *  dest,
int  dest_len,
char *  src,
int  src_len 
)
static

◆ if() [1/6]

PLMD::xdrfile::if ( (cstr=(char *) malloc((len+1) *sizeof(char)))  = =NULL)

◆ if() [2/6]

PLMD::xdrfile::if ( f77init  )

◆ if() [3/6]

else PLMD::xdrfile::if ( ftocstr(cfilename, sizeof(cfilename), filename, fn_len )

◆ if() [4/6]

else PLMD::xdrfile::if ( ftocstr(cmode, sizeof(cmode), mode, mode_len )

◆ if() [5/6]

PLMD::xdrfile::if ( ftocstr(cstr, len+1, str, len )

◆ if() [6/6]

PLMD::xdrfile::if ( i  = =MAX_FORTRAN_XDR)

◆ nFloatSize()

static int PLMD::xdrfile::nFloatSize ( t_trnheader sh,
int *  nflsz 
)
static

◆ read_trr()

int PLMD::xdrfile::read_trr ( XDRFILE xd,
int  natoms,
int *  step,
float *  t,
float *  lambda,
matrix  box,
rvec x,
rvec v,
rvec f 
)

◆ read_trr_natoms()

int PLMD::xdrfile::read_trr_natoms ( char *  fn,
int *  natoms 
)

◆ read_xtc()

int PLMD::xdrfile::read_xtc ( XDRFILE xd,
int  natoms,
int *  step,
float *  time,
matrix  box,
rvec x,
float *  prec 
)

◆ read_xtc_natoms()

int PLMD::xdrfile::read_xtc_natoms ( char *  fn,
int *  natoms 
)

◆ sizeofint()

static int PLMD::xdrfile::sizeofint ( int  size)
static

◆ sizeofints()

static int PLMD::xdrfile::sizeofints ( int  num_of_ints,
unsigned int  sizes[] 
)
static

◆ while()

PLMD::xdrfile::while ( )

◆ write_trr()

int PLMD::xdrfile::write_trr ( XDRFILE xd,
int  natoms,
int  step,
float  t,
float  lambda,
matrix  box,
rvec x,
rvec v,
rvec f 
)

◆ write_xtc()

int PLMD::xdrfile::write_xtc ( XDRFILE xd,
int  natoms,
int  step,
float  time,
matrix  box,
rvec x,
float  prec 
)

◆ xdr_char()

static int PLMD::xdrfile::xdr_char ( XDR xdrs,
char *  ip 
)
static

◆ xdr_double()

static int PLMD::xdrfile::xdr_double ( XDR xdrs,
double *  ip 
)
static

◆ xdr_float()

static int PLMD::xdrfile::xdr_float ( XDR xdrs,
float *  ip 
)
static

◆ xdr_htonl()

static int32_t PLMD::xdrfile::xdr_htonl ( int32_t  x)
static

◆ xdr_int()

static int PLMD::xdrfile::xdr_int ( XDR xdrs,
int *  ip 
)
static

◆ xdr_ntohl()

static int32_t PLMD::xdrfile::xdr_ntohl ( int  x)
static

◆ xdr_opaque()

static int PLMD::xdrfile::xdr_opaque ( XDR xdrs,
char *  cp,
unsigned int  cnt 
)
static

◆ xdr_short()

static int PLMD::xdrfile::xdr_short ( XDR xdrs,
short *  ip 
)
static

◆ xdr_string()

static int PLMD::xdrfile::xdr_string ( XDR xdrs,
char **  ip,
unsigned int  maxsize 
)
static

◆ xdr_swapbytes()

static int32_t PLMD::xdrfile::xdr_swapbytes ( int32_t  x)
static

◆ xdr_u_char()

static int PLMD::xdrfile::xdr_u_char ( XDR xdrs,
unsigned char *  ip 
)
static

◆ xdr_u_int()

static int PLMD::xdrfile::xdr_u_int ( XDR xdrs,
unsigned int *  ip 
)
static

◆ xdr_u_short()

static int PLMD::xdrfile::xdr_u_short ( XDR xdrs,
unsigned short *  ip 
)
static

◆ xdrfile_close()

int PLMD::xdrfile::xdrfile_close ( XDRFILE xfp)

Close a previously opened portable binary file, just like fclose()

Use this routine much like calls to the standard library function fopen(). The only difference is that it is used for an XDRFILE handle instead of a FILE handle.

Parameters
xfpPointer to an abstract XDRFILE datatype
Returns
0 on success, non-zero on error.

◆ xdrfile_compress_coord_double()

int PLMD::xdrfile::xdrfile_compress_coord_double ( double *  ptr,
int  ncoord,
double  precision,
XDRFILE xfp 
)

Compress coordiates in a double array to XDR file.

This routine will perform lossy compression on the three-dimensional coordinate data data specified and store it in the XDR file. Double will NOT give you any extra precision since the coordinates are compressed. This routine just avoids allocating a temporary array of floats.

The lossy part of the compression consists of multiplying each coordinate with the precision argument and then rounding to integers. We suggest a default value of 1000.0, which means you are guaranteed three decimals of accuracy. The only limitation is that scaled coordinates must still fit in an integer variable, so if the precision is 1000.0 the coordinate magnitudes must be less than +-2e6.

Parameters
ptrPointer to coordinates to compress (length 3*ncoord)
ncoordNumber of coordinate triplets in data
precisionScaling factor for lossy compression. If it is <=0, the default value of 1000.0 is used.
xfpHandle to portably binary file
Returns
Number of coordinate triplets written. IMPORTANT: Check that this is equal to ncoord - if it is negative, an error occured. This should not happen with normal data, but if your coordinates are NaN or very large (>1e6) it is not possible to use the compression.
Warning
The compression algorithm is not part of the XDR standard, and very complicated, so you will need this xdrfile module to read it later.

◆ xdrfile_compress_coord_float()

int PLMD::xdrfile::xdrfile_compress_coord_float ( float *  ptr,
int  ncoord,
float  precision,
XDRFILE xfp 
)

Compress coordiates in a float array to XDR file.

This routine will perform lossy compression on the three-dimensional coordinate data data specified and store it in the XDR file.

The lossy part of the compression consists of multiplying each coordinate with the precision argument and then rounding to integers. We suggest a default value of 1000.0, which means you are guaranteed three decimals of accuracy. The only limitation is that scaled coordinates must still fit in an integer variable, so if the precision is 1000.0 the coordinate magnitudes must be less than +-2e6.

Parameters
ptrPointer to coordinates to compress (length 3*ncoord)
ncoordNumber of coordinate triplets in data
precisionScaling factor for lossy compression. If it is <=0, the default value of 1000.0 is used.
xfpHandle to portably binary file
Returns
Number of coordinate triplets written. IMPORTANT: Check that this is equal to ncoord - if it is negative, an error occured. This should not happen with normal data, but if your coordinates are NaN or very large (>1e6) it is not possible to use the compression.
Warning
The compression algorithm is not part of the XDR standard, and very complicated, so you will need this xdrfile module to read it later.

◆ xdrfile_decompress_coord_double()

int PLMD::xdrfile::xdrfile_decompress_coord_double ( double *  ptr,
int *  ncoord,
double *  precision,
XDRFILE xfp 
)

Decompress coordiates from XDR file to array of doubles.

This routine will decompress three-dimensional coordinate data previously stored in an XDR file and store it in the specified array of doubles. Double will NOT give you any extra precision since the coordinates are compressed. This routine just avoids allocating a temporary array of floats.

The precision used during the earlier compression is read from the file and returned - you cannot adjust the accuracy at this stage.

Parameters
ptrPointer to coordinates to compress (length>= 3*ncoord)
ncoordMax number of coordinate triplets to read on input, actual number of coordinate triplets read on return. If this is smaller than the number of coordinates in the frame an error will occur.
precisionThe precision used in the previous compression will be written to this variable on return.
xfpHandle to portably binary file
Returns
Number of coordinate triplets read. If this is negative, an error occured.
Warning
Since we cannot count on being able to set/get the position of large files (>2Gb), it is not possible to recover from errors by re-reading the frame if the storage area you provided was too small. To avoid this from happening, we recommend that you store the number of coordinates triplet as an integer either in a header or just before the compressed coordinate data, so you can read it first and allocated enough memory.

◆ xdrfile_decompress_coord_float()

int PLMD::xdrfile::xdrfile_decompress_coord_float ( float *  ptr,
int *  ncoord,
float *  precision,
XDRFILE xfp 
)

Decompress coordiates from XDR file to array of floats.

This routine will decompress three-dimensional coordinate data previously stored in an XDR file and store it in the specified array of floats.

The precision used during the earlier compression is read from the file and returned - you cannot adjust the accuracy at this stage.

Parameters
ptrPointer to coordinates to compress (length>= 3*ncoord)
ncoordMax number of coordinate triplets to read on input, actual number of coordinate triplets read on return. If this is smaller than the number of coordinates in the frame an error will occur.
precisionThe precision used in the previous compression will be written to this variable on return.
xfpHandle to portably binary file
Returns
Number of coordinate triplets read. If this is negative, an error occured.
Warning
Since we cannot count on being able to set/get the position of large files (>2Gb), it is not possible to recover from errors by re-reading the frame if the storage area you provided was too small. To avoid this from happening, we recommend that you store the number of coordinates triplet as an integer either in a header or just before the compressed coordinate data, so you can read it first and allocated enough memory.

◆ xdrfile_open()

XDRFILE * PLMD::xdrfile::xdrfile_open ( const char *  path,
const char *  mode 
)

Open a portable binary file, just like fopen()

Use this routine much like calls to the standard library function fopen(). The only difference is that the returned pointer should only be used with routines defined in this header.

Parameters
pathFull or relative path (including name) of the file
mode"r" for reading, "w" for writing, "a" for append.
Returns
Pointer to abstract xdr file datatype, or NULL if an error occurs.

◆ xdrfile_read_char()

int PLMD::xdrfile::xdrfile_read_char ( char *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more char type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of characters to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of characters read

◆ xdrfile_read_double()

int PLMD::xdrfile::xdrfile_read_double ( double *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more double type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of doubles to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of doubles read

◆ xdrfile_read_float()

int PLMD::xdrfile::xdrfile_read_float ( float *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more float type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of floats to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of floats read

◆ xdrfile_read_int()

int PLMD::xdrfile::xdrfile_read_int ( int *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more integer type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of integers to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of integers read

The integer data type is assumed to be less than or equal to 32 bits.

We do not provide any routines for reading/writing 64-bit integers, since

  • Not all XDR implementations support it
  • Not all machines have 64-bit integers

Split your 64-bit data into two 32-bit integers for portability!

◆ xdrfile_read_opaque()

int PLMD::xdrfile::xdrfile_read_opaque ( char *  ptr,
int  nbytes,
XDRFILE xfp 
)

Read raw bytes from file (unknown datatype)

Parameters
ptrPointer to memory where data should be written
nbytesNumber of bytes to read. No conversion whatsoever is done.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of bytes read from file

◆ xdrfile_read_short()

int PLMD::xdrfile::xdrfile_read_short ( short *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more short type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of shorts to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of shorts read

◆ xdrfile_read_string()

int PLMD::xdrfile::xdrfile_read_string ( char *  ptr,
int  maxlen,
XDRFILE xfp 
)

Read a string (array of characters)

Parameters
ptrPointer to memory where data should be written
maxlenMaximum length of string. If no end-of-string is encountered, one byte less than this is read and end-of-string appended.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of characters read, including end-of-string

◆ xdrfile_read_uchar()

int PLMD::xdrfile::xdrfile_read_uchar ( unsigned char *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more unsigned char type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of unsigned characters to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of unsigned characters read

◆ xdrfile_read_uint()

int PLMD::xdrfile::xdrfile_read_uint ( unsigned int *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more unsigned integers type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of unsigned integers to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of unsigned integers read

The integer data type is assumed to be less than or equal to 32 bits.

We do not provide any routines for reading/writing 64-bit integers, since

  • Not all XDR implementations support it
  • Not all machines have 64-bit integers

Split your 64-bit data into two 32-bit integers for portability!

◆ xdrfile_read_ushort()

int PLMD::xdrfile::xdrfile_read_ushort ( unsigned short *  ptr,
int  ndata,
XDRFILE xfp 
)

Read one or more unsigned short type variable(s)

Parameters
ptrPointer to memory where data should be written
ndataNumber of unsigned shorts to read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of unsigned shorts read

◆ xdrfile_write_char()

int PLMD::xdrfile::xdrfile_write_char ( char *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more characters type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of characters to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of characters written

◆ xdrfile_write_double()

int PLMD::xdrfile::xdrfile_write_double ( double *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more double type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of double to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of doubles written

◆ xdrfile_write_float()

int PLMD::xdrfile::xdrfile_write_float ( float *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more float type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of floats to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of floats written

◆ xdrfile_write_int()

int PLMD::xdrfile::xdrfile_write_int ( int *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more integer type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of integers to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of integers written

The integer data type is assumed to be less than or equal to 32 bits.

We do not provide any routines for reading/writing 64-bit integers, since

  • Not all XDR implementations support it
  • Not all machines have 64-bit integers

Split your 64-bit data into two 32-bit integers for portability!

◆ xdrfile_write_opaque()

int PLMD::xdrfile::xdrfile_write_opaque ( char *  ptr,
int  nbytes,
XDRFILE xfp 
)

Write raw bytes to file (unknown datatype)

Parameters
ptrPointer to memory where data should be read
nbytesNumber of bytes to write. No conversion whatsoever is done.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of bytes written to file

◆ xdrfile_write_short()

int PLMD::xdrfile::xdrfile_write_short ( short *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more short type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of shorts to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of shorts written

◆ xdrfile_write_string()

int PLMD::xdrfile::xdrfile_write_string ( char *  ptr,
XDRFILE xfp 
)

Write a string (array of characters)

Parameters
ptrPointer to memory where data should be read
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of characters written, including end-of-string

◆ xdrfile_write_uchar()

int PLMD::xdrfile::xdrfile_write_uchar ( unsigned char *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more unsigned characters type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of unsigned characters to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of unsigned characters written

◆ xdrfile_write_uint()

int PLMD::xdrfile::xdrfile_write_uint ( unsigned int *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more unsigned integer type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of unsigned integers to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of unsigned integers written

The integer data type is assumed to be less than or equal to 32 bits.

We do not provide any routines for reading/writing 64-bit integers, since

  • Not all XDR implementations support it
  • Not all machines have 64-bit integers

Split your 64-bit data into two 32-bit integers for portability!

◆ xdrfile_write_ushort()

int PLMD::xdrfile::xdrfile_write_ushort ( unsigned short *  ptr,
int  ndata,
XDRFILE xfp 
)

Write one or more unsigned short type variable(s)

Parameters
ptrPointer to memory where data should be read
ndataNumber of unsigned shorts to write.
xfpHandle to portable binary file, created with xdrfile_open()
Returns
Number of unsigned shorts written

◆ xdrstdio_create()

static void PLMD::xdrfile::xdrstdio_create ( XDR xdrs,
FILE *  fp,
enum xdr_op  xop 
)
static

◆ xdrstdio_destroy()

static void PLMD::xdrfile::xdrstdio_destroy ( XDR xdrs)
static

◆ xdrstdio_getbytes()

static int PLMD::xdrfile::xdrstdio_getbytes ( XDR xdrs,
char *  addr,
unsigned int  len 
)
static

◆ xdrstdio_getlong()

static int PLMD::xdrfile::xdrstdio_getlong ( XDR xdrs,
int32_t *  lp 
)
static

◆ xdrstdio_getpos()

static unsigned int PLMD::xdrfile::xdrstdio_getpos ( XDR xdrs)
static

◆ xdrstdio_putbytes()

static int PLMD::xdrfile::xdrstdio_putbytes ( XDR xdrs,
char *  addr,
unsigned int  len 
)
static

◆ xdrstdio_putlong()

static int PLMD::xdrfile::xdrstdio_putlong ( XDR xdrs,
int32_t *  lp 
)
static

◆ xdrstdio_setpos()

static int PLMD::xdrfile::xdrstdio_setpos ( XDR xdrs,
unsigned int  pos 
)
static

◆ xtc_coord()

static int PLMD::xdrfile::xtc_coord ( XDRFILE xd,
int *  natoms,
matrix  box,
rvec x,
float *  prec,
mybool  bRead 
)
static

◆ xtc_header()

static int PLMD::xdrfile::xtc_header ( XDRFILE xd,
int *  natoms,
int *  step,
float *  time,
mybool  bRead 
)
static

Variable Documentation

◆ cmode

char PLMD::xdrfile::cmode[5]

◆ data

void double * PLMD::xdrfile::data

◆ else

PLMD::xdrfile::else
Initial value:
{
f77xdr[i]=xdrfile_open(cfilename,cmode)

◆ exdr_message

const char * PLMD::xdrfile::exdr_message
Initial value:
= {
"OK",
"Header",
"String",
"Double",
"Integer",
"Float",
"Unsigned integer",
"Compressed 3D coordinate",
"Closing file",
"Magic number",
"Not enough memory",
"End of file",
"File not found"
}

◆ f77init

int PLMD::xdrfile::f77init = 1
static

◆ f77xdr

XDRFILE* PLMD::xdrfile::f77xdr[MAX_FORTRAN_XDR]
static

◆ fid

* PLMD::xdrfile::fid =i

◆ filename

void char* PLMD::xdrfile::filename

◆ fn_len

void char char int PLMD::xdrfile::fn_len

◆ i

PLMD::xdrfile::i =0

◆ ip

void unsigned short * PLMD::xdrfile::ip

◆ len

void char int int PLMD::xdrfile::len
Initial value:
{
char *cstr

◆ magicints

const int PLMD::xdrfile::magicints[]
static
Initial value:
=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,
80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,
1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,
16384, 20642, 26007, 32768, 41285, 52015, 65536,82570, 104031,
131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,
832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,
4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216
}

◆ mode

void char char* PLMD::xdrfile::mode

◆ mode_len

void char char int int PLMD::xdrfile::mode_len
Initial value:
{
char cfilename[512]

◆ ncoord

void double int * PLMD::xdrfile::ncoord

◆ ndata

void char int * PLMD::xdrfile::ndata

◆ precision

void double int double * PLMD::xdrfile::precision

◆ ret

void double int double int * PLMD::xdrfile::ret
Initial value:

◆ str

void char * PLMD::xdrfile::str

◆ xdr_zero

char PLMD::xdrfile::xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}
static

◆ xdrstdio_ops

const XDR::xdr_ops PLMD::xdrfile::xdrstdio_ops
static
PLMD::xdrfile::xdrstdio_getpos
static unsigned int xdrstdio_getpos(XDR *)
Definition: xdrfile.cpp:2634
PLMD::xdrfile::xdrstdio_setpos
static int xdrstdio_setpos(XDR *, unsigned int)
Definition: xdrfile.cpp:2640
PLMD::xdrfile::xdrfile_open
XDRFILE * xdrfile_open(const char *path, const char *mode)
Open a portable binary file, just like fopen()
Definition: xdrfile.cpp:226
PLMD::xdrfile::xdrstdio_getbytes
static int xdrstdio_getbytes(XDR *, char *, unsigned int)
Definition: xdrfile.cpp:2615
PLMD::xdrfile::f77xdr
static XDRFILE * f77xdr[MAX_FORTRAN_XDR]
Definition: xdrfile.cpp:1782
PLMD::xdrfile::i
int i
Definition: xdrfile.cpp:1796
PLMD::xdrfile::xdrstdio_getlong
static int xdrstdio_getlong(XDR *, int32_t *)
Definition: xdrfile.cpp:2594
PLMD::xdrfile::xdrstdio_destroy
static void xdrstdio_destroy(XDR *)
Definition: xdrfile.cpp:2587
PLMD::xdrfile::ret
void int int int * ret
Definition: xdrfile.cpp:1834
PLMD::xdrfile::fid
* fid
Definition: xdrfile.cpp:1818
PLMD::xdrfile::ndata
void int int * ndata
Definition: xdrfile.cpp:1833
PLMD::xdrfile::xdrfile_read_int
int xdrfile_read_int(int *ptr, int ndata, XDRFILE *xfp)
Read one or more integer type variable(s)
Definition: xdrfile.cpp:292
PLMD::xdrfile::cmode
char cmode[5]
Definition: xdrfile.cpp:1795
PLMD::xdrfile::data
void int * data
Definition: xdrfile.cpp:1833
PLMD::xdrfile::xdrstdio_putbytes
static int xdrstdio_putbytes(XDR *, char *, unsigned int)
Definition: xdrfile.cpp:2624
PLMD::xdrfile::xdrstdio_putlong
static int xdrstdio_putlong(XDR *, int32_t *)
Definition: xdrfile.cpp:2605