summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compression/CMakeLists.txt4
-rw-r--r--src/compression/tng_compress.c378
-rw-r--r--src/lib/md5.c34
-rw-r--r--src/lib/tng_io.c1047
-rw-r--r--src/tests/CMakeLists.txt20
-rw-r--r--src/tests/compression/CMakeLists.txt46
-rw-r--r--src/tests/compression/test1.h2
-rw-r--r--src/tests/compression/test10.h2
-rw-r--r--src/tests/compression/test11.h2
-rw-r--r--src/tests/compression/test12.h2
-rw-r--r--src/tests/compression/test13.h2
-rw-r--r--src/tests/compression/test14.h2
-rw-r--r--src/tests/compression/test15.h2
-rw-r--r--src/tests/compression/test16.h2
-rw-r--r--src/tests/compression/test17.h2
-rw-r--r--src/tests/compression/test18.h2
-rw-r--r--src/tests/compression/test19.h2
-rw-r--r--src/tests/compression/test2.h2
-rw-r--r--src/tests/compression/test20.h2
-rw-r--r--src/tests/compression/test21.h2
-rw-r--r--src/tests/compression/test22.h2
-rw-r--r--src/tests/compression/test23.h2
-rw-r--r--src/tests/compression/test24.h2
-rw-r--r--src/tests/compression/test25.h2
-rw-r--r--src/tests/compression/test26.h2
-rw-r--r--src/tests/compression/test27.h2
-rw-r--r--src/tests/compression/test28.h2
-rw-r--r--src/tests/compression/test29.h2
-rw-r--r--src/tests/compression/test3.h2
-rw-r--r--src/tests/compression/test30.h2
-rw-r--r--src/tests/compression/test31.h2
-rw-r--r--src/tests/compression/test32.h2
-rw-r--r--src/tests/compression/test33.h2
-rw-r--r--src/tests/compression/test34.h2
-rw-r--r--src/tests/compression/test35.h2
-rw-r--r--src/tests/compression/test36.h2
-rw-r--r--src/tests/compression/test37.h2
-rw-r--r--src/tests/compression/test38.h2
-rw-r--r--src/tests/compression/test39.h2
-rw-r--r--src/tests/compression/test4.h2
-rw-r--r--src/tests/compression/test40.h2
-rw-r--r--src/tests/compression/test41.h2
-rw-r--r--src/tests/compression/test42.h2
-rw-r--r--src/tests/compression/test43.h2
-rw-r--r--src/tests/compression/test44.h2
-rw-r--r--src/tests/compression/test45.h2
-rw-r--r--src/tests/compression/test46.h2
-rw-r--r--src/tests/compression/test47.h2
-rw-r--r--src/tests/compression/test48.h2
-rw-r--r--src/tests/compression/test49.h2
-rw-r--r--src/tests/compression/test5.h2
-rw-r--r--src/tests/compression/test50.h2
-rw-r--r--src/tests/compression/test51.h2
-rw-r--r--src/tests/compression/test52.h2
-rw-r--r--src/tests/compression/test53.h2
-rw-r--r--src/tests/compression/test54.h2
-rw-r--r--src/tests/compression/test55.h2
-rw-r--r--src/tests/compression/test56.h2
-rw-r--r--src/tests/compression/test57.h2
-rw-r--r--src/tests/compression/test58.h26
-rw-r--r--src/tests/compression/test59.h28
-rw-r--r--src/tests/compression/test6.h2
-rw-r--r--src/tests/compression/test60.h28
-rw-r--r--src/tests/compression/test61.h25
-rw-r--r--src/tests/compression/test62.h26
-rw-r--r--src/tests/compression/test63.h26
-rw-r--r--src/tests/compression/test64.h27
-rw-r--r--src/tests/compression/test7.h2
-rw-r--r--src/tests/compression/test8.h2
-rw-r--r--src/tests/compression/test9.h2
-rw-r--r--src/tests/compression/test_tng_compress_read.bat13
-rwxr-xr-xsrc/tests/compression/test_tng_compress_read.sh5
-rw-r--r--src/tests/compression/test_tng_compress_write.bat13
-rwxr-xr-xsrc/tests/compression/test_tng_compress_write.sh5
-rw-r--r--src/tests/compression/testsuite.c337
-rwxr-xr-xsrc/tests/compression/testsuite.sh35
76 files changed, 1573 insertions, 664 deletions
diff --git a/src/compression/CMakeLists.txt b/src/compression/CMakeLists.txt
index 35e01f7..605dac7 100644
--- a/src/compression/CMakeLists.txt
+++ b/src/compression/CMakeLists.txt
@@ -5,4 +5,6 @@ include_directories(${COMP_INC_DIR})
set(HEADER_FILES ${COMP_INC_DIR}/bwlzh.h ${COMP_INC_DIR}/bwt.h ${COMP_INC_DIR}/coder.h ${COMP_INC_DIR}/dict.h ${COMP_INC_DIR}/fixpoint.h ${COMP_INC_DIR}/huffman.h ${COMP_INC_DIR}/lz77.h ${COMP_INC_DIR}/merge_sort.h ${COMP_INC_DIR}/mtf.h ${COMP_INC_DIR}/my64bit.h ${COMP_INC_DIR}/rle.h ${COMP_INC_DIR}/tng_compress.h ${COMP_INC_DIR}/vals16.h ${COMP_INC_DIR}/warnmalloc.h ${COMP_INC_DIR}/widemuldiv.h)
add_library(tng_compress SHARED bwlzh.c bwt.c coder.c dict.c fixpoint.c huffman.c huffmem.c lz77.c merge_sort.c mtf.c rle.c tng_compress.c vals16.c warnmalloc.c widemuldiv.c xtc2.c xtc3.c)
-target_link_libraries(tng_compress m) \ No newline at end of file
+if(UNIX)
+target_link_libraries(tng_compress m)
+endif()
diff --git a/src/compression/tng_compress.c b/src/compression/tng_compress.c
index e92f24d..1219f6a 100644
--- a/src/compression/tng_compress.c
+++ b/src/compression/tng_compress.c
@@ -37,13 +37,17 @@ static void quantize(double *x, int natoms, int nframes,
for (i=0; i<natoms; i++)
for (j=0; j<3; j++)
quant[iframe*natoms*3+i*3+j]=(int)floor((x[iframe*natoms*3+i*3+j]/precision)+0.5);
-#if 0
- printf("Q precision=%g\n",precision);
+}
+
+static void quantize_float(float *x, int natoms, int nframes,
+ float precision,
+ int *quant)
+{
+ int iframe, i, j;
for (iframe=0; iframe<nframes; iframe++)
for (i=0; i<natoms; i++)
for (j=0; j<3; j++)
- printf("Q: %d %d %d: %d %g\n",iframe,i,j,quant[iframe*natoms*3+i*3+j],x[iframe*natoms*3+i*3+j]);
-#endif
+ quant[iframe*natoms*3+i*3+j]=(int)floor((x[iframe*natoms*3+i*3+j]/precision)+0.5);
}
static void quant_inter_differences(int *quant, int natoms, int nframes,
@@ -88,6 +92,17 @@ static void unquantize(double *x, int natoms, int nframes,
x[iframe*natoms*3+i*3+j]=(double)quant[iframe*natoms*3+i*3+j]*precision;
}
+static void unquantize_float(float *x, int natoms, int nframes,
+ float precision,
+ int *quant)
+{
+ int iframe, i, j;
+ for (iframe=0; iframe<nframes; iframe++)
+ for (i=0; i<natoms; i++)
+ for (j=0; j<3; j++)
+ x[iframe*natoms*3+i*3+j]=(float)quant[iframe*natoms*3+i*3+j]*precision;
+}
+
static void unquantize_inter_differences(double *x, int natoms, int nframes,
double precision,
int *quant)
@@ -106,6 +121,41 @@ static void unquantize_inter_differences(double *x, int natoms, int nframes,
}
}
+static void unquantize_inter_differences_float(float *x, int natoms, int nframes,
+ float precision,
+ int *quant)
+{
+ int iframe, i, j;
+ for (i=0; i<natoms; i++)
+ for (j=0; j<3; j++)
+ {
+ int q=quant[i*3+j]; /* First value. */
+ x[i*3+j]=(float)q*precision;
+ for (iframe=1; iframe<nframes; iframe++)
+ {
+ q+=quant[iframe*natoms*3+i*3+j];
+ x[iframe*natoms*3+i*3+j]=(float)q*precision;
+ }
+ }
+}
+
+static void unquantize_inter_differences_int(int *x, int natoms, int nframes,
+ int *quant)
+{
+ int iframe, i, j;
+ for (i=0; i<natoms; i++)
+ for (j=0; j<3; j++)
+ {
+ int q=quant[i*3+j]; /* First value. */
+ x[i*3+j]=q;
+ for (iframe=1; iframe<nframes; iframe++)
+ {
+ q+=quant[iframe*natoms*3+i*3+j];
+ x[iframe*natoms*3+i*3+j]=q;
+ }
+ }
+}
+
/* In frame update required for the initial frame if intra-frame
compression was used. */
static void unquant_intra_differences_first_frame(int *quant, int natoms)
@@ -150,6 +200,41 @@ static void unquantize_intra_differences(double *x, int natoms, int nframes,
}
}
+static void unquantize_intra_differences_float(float *x, int natoms, int nframes,
+ float precision,
+ int *quant)
+{
+ int iframe, i, j;
+ for (iframe=0; iframe<nframes; iframe++)
+ for (j=0; j<3; j++)
+ {
+ int q=quant[iframe*natoms*3+j];
+ x[iframe*natoms*3+j]=(float)q*precision;
+ for (i=1; i<natoms; i++)
+ {
+ q+=quant[iframe*natoms*3+i*3+j];
+ x[iframe*natoms*3+i*3+j]=(float)q*precision;
+ }
+ }
+}
+
+static void unquantize_intra_differences_int(int *x, int natoms, int nframes,
+ int *quant)
+{
+ int iframe, i, j;
+ for (iframe=0; iframe<nframes; iframe++)
+ for (j=0; j<3; j++)
+ {
+ int q=quant[iframe*natoms*3+j];
+ x[iframe*natoms*3+j]=q;
+ for (i=1; i<natoms; i++)
+ {
+ q+=quant[iframe*natoms*3+i*3+j];
+ x[iframe*natoms*3+i*3+j]=q;
+ }
+ }
+}
+
/* Buffer num 8 bit bytes into buffer location buf */
static void bufferfix(unsigned char *buf, fix_t v, int num)
{
@@ -1008,22 +1093,20 @@ static void determine_best_vel_coding(int *quant, int *quant_inter, int natoms,
}
}
-char DECLSPECDLLEXPORT *tng_compress_pos(double *pos, int natoms, int nframes,
- double desired_precision,
- int speed,int *algo,
- int *nitems)
+char DECLSPECDLLEXPORT *tng_compress_pos_int(int *pos, int natoms, int nframes,
+ unsigned long prec_hi, unsigned long prec_lo,
+ int speed,int *algo,
+ int *nitems)
{
char *data=malloc(natoms*nframes*14+11*4); /* 12 bytes are required to store 4 32 bit integers
This is 17% extra. The final 11*4 is to store information
needed for decompression. */
- int *quant=malloc(natoms*nframes*3*sizeof *quant);
+ int *quant=pos; /* Already quantized positions. */
int *quant_intra=malloc(natoms*nframes*3*sizeof *quant_intra);
int *quant_inter=malloc(natoms*nframes*3*sizeof *quant_inter);
int initial_coding, initial_coding_parameter;
int coding, coding_parameter;
- fix_t prec_hi, prec_lo;
- Ptngc_d_to_i32x2(desired_precision,&prec_hi,&prec_lo);
if (speed==0)
speed=SPEED_DEFAULT; /* Set the default speed. */
/* Boundaries of speed. */
@@ -1036,7 +1119,6 @@ char DECLSPECDLLEXPORT *tng_compress_pos(double *pos, int natoms, int nframes,
coding=algo[2];
coding_parameter=algo[3];
- quantize(pos,natoms,nframes,PRECISION(prec_hi,prec_lo),quant);
quant_inter_differences(quant,natoms,nframes,quant_inter);
quant_intra_differences(quant,natoms,nframes,quant_intra);
@@ -1080,7 +1162,6 @@ char DECLSPECDLLEXPORT *tng_compress_pos(double *pos, int natoms, int nframes,
prec_hi,prec_lo,nitems,data);
free(quant_inter);
free(quant_intra);
- free(quant);
if (algo[0]==-1)
algo[0]=initial_coding;
if (algo[1]==-1)
@@ -1092,6 +1173,38 @@ char DECLSPECDLLEXPORT *tng_compress_pos(double *pos, int natoms, int nframes,
return data;
}
+char DECLSPECDLLEXPORT *tng_compress_pos(double *pos, int natoms, int nframes,
+ double desired_precision,
+ int speed,int *algo,
+ int *nitems)
+{
+ int *quant=malloc(natoms*nframes*3*sizeof *quant);
+ char *data;
+ fix_t prec_hi, prec_lo;
+ Ptngc_d_to_i32x2(desired_precision,&prec_hi,&prec_lo);
+
+ quantize(pos,natoms,nframes,PRECISION(prec_hi,prec_lo),quant);
+ data=tng_compress_pos_int(quant,natoms,nframes,prec_hi,prec_lo,speed,algo,nitems);
+ free(quant);
+ return data;
+}
+
+char DECLSPECDLLEXPORT *tng_compress_pos_float(float *pos, int natoms, int nframes,
+ float desired_precision,
+ int speed,int *algo,
+ int *nitems)
+{
+ int *quant=malloc(natoms*nframes*3*sizeof *quant);
+ char *data;
+ fix_t prec_hi, prec_lo;
+ Ptngc_d_to_i32x2((double)desired_precision,&prec_hi,&prec_lo);
+
+ quantize_float(pos,natoms,nframes,(float)PRECISION(prec_hi,prec_lo),quant);
+ data=tng_compress_pos_int(quant,natoms,nframes,prec_hi,prec_lo,speed,algo,nitems);
+ free(quant);
+ return data;
+}
+
char DECLSPECDLLEXPORT *tng_compress_pos_find_algo(double *pos, int natoms, int nframes,
double desired_precision,
int speed,
@@ -1105,6 +1218,33 @@ char DECLSPECDLLEXPORT *tng_compress_pos_find_algo(double *pos, int natoms, int
return tng_compress_pos(pos,natoms,nframes,desired_precision,speed,algo,nitems);
}
+char DECLSPECDLLEXPORT *tng_compress_pos_float_find_algo(float *pos, int natoms, int nframes,
+ float desired_precision,
+ int speed,
+ int *algo,
+ int *nitems)
+{
+ algo[0]=-1;
+ algo[1]=-1;
+ algo[2]=-1;
+ algo[3]=-1;
+ return tng_compress_pos_float(pos,natoms,nframes,desired_precision,speed,algo,nitems);
+}
+
+char DECLSPECDLLEXPORT *tng_compress_pos_int_find_algo(int *pos, int natoms, int nframes,
+ unsigned long prec_hi, unsigned long prec_lo,
+ int speed,int *algo,
+ int *nitems)
+{
+ algo[0]=-1;
+ algo[1]=-1;
+ algo[2]=-1;
+ algo[3]=-1;
+ return tng_compress_pos_int(pos,natoms,nframes,prec_hi,prec_lo,speed,algo,nitems);
+}
+
+
+
int DECLSPECDLLEXPORT tng_compress_nalgo(void)
{
return 4; /* There are currently four parameters required:
@@ -1115,21 +1255,19 @@ int DECLSPECDLLEXPORT tng_compress_nalgo(void)
4) One parameter to the algorithm for the remaining frames (the coding parameter). */
}
-char DECLSPECDLLEXPORT *tng_compress_vel(double *vel, int natoms, int nframes,
- double desired_precision,
- int speed, int *algo,
- int *nitems)
+char DECLSPECDLLEXPORT *tng_compress_vel_int(int *vel, int natoms, int nframes,
+ unsigned long prec_hi, unsigned long prec_lo,
+ int speed, int *algo,
+ int *nitems)
{
char *data=malloc(natoms*nframes*14+11*4); /* 12 bytes are required to store 4 32 bit integers
This is 17% extra. The final 11*4 is to store information
needed for decompression. */
- int *quant=malloc(natoms*nframes*3*sizeof *quant);
+ int *quant=vel;
int *quant_inter=malloc(natoms*nframes*3*sizeof *quant_inter);
int initial_coding, initial_coding_parameter;
int coding, coding_parameter;
- fix_t prec_hi, prec_lo;
- Ptngc_d_to_i32x2(desired_precision,&prec_hi,&prec_lo);
if (speed==0)
speed=SPEED_DEFAULT; /* Set the default speed. */
/* Boundaries of speed. */
@@ -1142,7 +1280,6 @@ char DECLSPECDLLEXPORT *tng_compress_vel(double *vel, int natoms, int nframes,
coding=algo[2];
coding_parameter=algo[3];
- quantize(vel,natoms,nframes,PRECISION(prec_hi,prec_lo),quant);
quant_inter_differences(quant,natoms,nframes,quant_inter);
/* If any of the above codings / coding parameters are == -1, the optimal parameters must be found */
@@ -1184,7 +1321,6 @@ char DECLSPECDLLEXPORT *tng_compress_vel(double *vel, int natoms, int nframes,
coding,coding_parameter,
prec_hi,prec_lo,nitems,data);
free(quant_inter);
- free(quant);
if (algo[0]==-1)
algo[0]=initial_coding;
if (algo[1]==-1)
@@ -1196,6 +1332,36 @@ char DECLSPECDLLEXPORT *tng_compress_vel(double *vel, int natoms, int nframes,
return data;
}
+char DECLSPECDLLEXPORT *tng_compress_vel(double *vel, int natoms, int nframes,
+ double desired_precision,
+ int speed, int *algo,
+ int *nitems)
+{
+ int *quant=malloc(natoms*nframes*3*sizeof *quant);
+ char *data;
+ fix_t prec_hi, prec_lo;
+ Ptngc_d_to_i32x2(desired_precision,&prec_hi,&prec_lo);
+ quantize(vel,natoms,nframes,PRECISION(prec_hi,prec_lo),quant);
+ data=tng_compress_vel_int(quant,natoms,nframes,prec_hi,prec_lo,speed,algo,nitems);
+ free(quant);
+ return data;
+}
+
+char DECLSPECDLLEXPORT *tng_compress_vel_float(float *vel, int natoms, int nframes,
+ float desired_precision,
+ int speed, int *algo,
+ int *nitems)
+{
+ int *quant=malloc(natoms*nframes*3*sizeof *quant);
+ char *data;
+ fix_t prec_hi, prec_lo;
+ Ptngc_d_to_i32x2((double)desired_precision,&prec_hi,&prec_lo);
+ quantize_float(vel,natoms,nframes,(float)PRECISION(prec_hi,prec_lo),quant);
+ data=tng_compress_vel_int(quant,natoms,nframes,prec_hi,prec_lo,speed,algo,nitems);
+ free(quant);
+ return data;
+}
+
char DECLSPECDLLEXPORT *tng_compress_vel_find_algo(double *vel, int natoms, int nframes,
double desired_precision,
int speed,
@@ -1209,6 +1375,32 @@ char DECLSPECDLLEXPORT *tng_compress_vel_find_algo(double *vel, int natoms, int
return tng_compress_vel(vel,natoms,nframes,desired_precision,speed,algo,nitems);
}
+char DECLSPECDLLEXPORT *tng_compress_vel_float_find_algo(float *vel, int natoms, int nframes,
+ float desired_precision,
+ int speed,
+ int *algo,
+ int *nitems)
+{
+ algo[0]=-1;
+ algo[1]=-1;
+ algo[2]=-1;
+ algo[3]=-1;
+ return tng_compress_vel_float(vel,natoms,nframes,desired_precision,speed,algo,nitems);
+}
+
+char DECLSPECDLLEXPORT *tng_compress_vel_int_find_algo(int *vel, int natoms, int nframes,
+ unsigned long prec_hi, unsigned long prec_lo,
+ int speed,
+ int *algo,
+ int *nitems)
+{
+ algo[0]=-1;
+ algo[1]=-1;
+ algo[2]=-1;
+ algo[3]=-1;
+ return tng_compress_vel_int(vel,natoms,nframes,prec_hi,prec_lo,speed,algo,nitems);
+}
+
int DECLSPECDLLEXPORT tng_compress_inquire(char *data,int *vel, int *natoms,
int *nframes, double *precision,
int *algo)
@@ -1257,10 +1449,9 @@ int DECLSPECDLLEXPORT tng_compress_inquire(char *data,int *vel, int *natoms,
return 0;
}
-static int tng_compress_uncompress_pos(char *data,double *pos)
+static int tng_compress_uncompress_pos_gen(char *data,double *posd,float *posf,int *posi,unsigned long *prec_hi, unsigned long *prec_lo)
{
int bufloc=0;
- fix_t prec_hi, prec_lo;
int length;
int natoms, nframes;
int initial_coding, initial_coding_parameter;
@@ -1296,9 +1487,9 @@ static int tng_compress_uncompress_pos(char *data,double *pos)
coding_parameter=(int)readbufferfix((unsigned char *)data+bufloc,4);
bufloc+=4;
/* Precision. */
- prec_lo=readbufferfix((unsigned char *)data+bufloc,4);
+ *prec_lo=readbufferfix((unsigned char *)data+bufloc,4);
bufloc+=4;
- prec_hi=readbufferfix((unsigned char *)data+bufloc,4);
+ *prec_hi=readbufferfix((unsigned char *)data+bufloc,4);
bufloc+=4;
/* Allocate the memory for the quantized positions */
quant=malloc(natoms*nframes*3*sizeof *quant);
@@ -1319,12 +1510,22 @@ static int tng_compress_uncompress_pos(char *data,double *pos)
(initial_coding==TNG_COMPRESS_ALGO_POS_TRIPLET_ONETOONE) ||
(initial_coding==TNG_COMPRESS_ALGO_POS_XTC3))
{
- unquantize(pos,natoms,1,PRECISION(prec_hi,prec_lo),quant);
+ if (posd)
+ unquantize(posd,natoms,1,PRECISION(*prec_hi,*prec_lo),quant);
+ else if (posf)
+ unquantize_float(posf,natoms,1,(float)PRECISION(*prec_hi,*prec_lo),quant);
+ else if (posi)
+ memcpy(posi,quant,natoms*3*sizeof *posi);
}
else if ((initial_coding==TNG_COMPRESS_ALGO_POS_TRIPLET_INTRA) ||
(initial_coding==TNG_COMPRESS_ALGO_POS_BWLZH_INTRA))
{
- unquantize_intra_differences(pos,natoms,1,PRECISION(prec_hi,prec_lo),quant);
+ if (posd)
+ unquantize_intra_differences(posd,natoms,1,PRECISION(*prec_hi,*prec_lo),quant);
+ else if (posf)
+ unquantize_intra_differences_float(posf,natoms,1,(float)PRECISION(*prec_hi,*prec_lo),quant);
+ else if (posi)
+ unquantize_intra_differences_int(posi,natoms,1,quant);
unquant_intra_differences_first_frame(quant,natoms);
}
/* The remaining frames. */
@@ -1346,18 +1547,33 @@ static int tng_compress_uncompress_pos(char *data,double *pos)
/* This requires that the first frame is already in one-to-one format, even if intra-frame
compression was done there. Therefore the unquant_intra_differences_first_frame should be called
before to convert it correctly. */
- unquantize_inter_differences(pos,natoms,nframes,PRECISION(prec_hi,prec_lo),quant);
+ if (posd)
+ unquantize_inter_differences(posd,natoms,nframes,PRECISION(*prec_hi,*prec_lo),quant);
+ else if (posf)
+ unquantize_inter_differences_float(posf,natoms,nframes,(float)PRECISION(*prec_hi,*prec_lo),quant);
+ else if (posi)
+ unquantize_inter_differences_int(posi,natoms,nframes,quant);
}
else if ((coding==TNG_COMPRESS_ALGO_POS_XTC2) ||
(coding==TNG_COMPRESS_ALGO_POS_XTC3) ||
(coding==TNG_COMPRESS_ALGO_POS_TRIPLET_ONETOONE))
{
- unquantize(pos+natoms*3,natoms,nframes-1,PRECISION(prec_hi,prec_lo),quant+natoms*3);
+ if (posd)
+ unquantize(posd+natoms*3,natoms,nframes-1,PRECISION(*prec_hi,*prec_lo),quant+natoms*3);
+ else if (posf)
+ unquantize_float(posf+natoms*3,natoms,nframes-1,(float)PRECISION(*prec_hi,*prec_lo),quant+natoms*3);
+ else if (posi)
+ memcpy(posi+natoms*3,quant+natoms*3,natoms*3*(nframes-1)*sizeof *posi);
}
else if ((coding==TNG_COMPRESS_ALGO_POS_TRIPLET_INTRA) ||
(coding==TNG_COMPRESS_ALGO_POS_BWLZH_INTRA))
{
- unquantize_intra_differences(pos+natoms*3,natoms,nframes-1,PRECISION(prec_hi,prec_lo),quant+natoms*3);
+ if (posd)
+ unquantize_intra_differences(posd+natoms*3,natoms,nframes-1,PRECISION(*prec_hi,*prec_lo),quant+natoms*3);
+ else if (posf)
+ unquantize_intra_differences_float(posf+natoms*3,natoms,nframes-1,(float)PRECISION(*prec_hi,*prec_lo),quant+natoms*3);
+ else if (posi)
+ unquantize_intra_differences_int(posi+natoms*3,natoms,nframes-1,quant+natoms*3);
}
}
error:
@@ -1365,10 +1581,26 @@ static int tng_compress_uncompress_pos(char *data,double *pos)
return rval;
}
-static int tng_compress_uncompress_vel(char *data,double *vel)
+static int tng_compress_uncompress_pos(char *data,double *pos)
+{
+ unsigned long prec_hi, prec_lo;
+ return tng_compress_uncompress_pos_gen(data,pos,NULL,NULL,&prec_hi,&prec_lo);
+}
+
+static int tng_compress_uncompress_pos_float(char *data,float *pos)
+{
+ unsigned long prec_hi, prec_lo;
+ return tng_compress_uncompress_pos_gen(data,NULL,pos,NULL,&prec_hi,&prec_lo);
+}
+
+static int tng_compress_uncompress_pos_int(char *data,int *pos, unsigned long *prec_hi, unsigned long *prec_lo)
+{
+ return tng_compress_uncompress_pos_gen(data,NULL,NULL,pos,prec_hi,prec_lo);
+}
+
+static int tng_compress_uncompress_vel_gen(char *data,double *veld,float *velf,int *veli,unsigned long *prec_hi, unsigned long *prec_lo)
{
int bufloc=0;
- fix_t prec_hi, prec_lo;
int length;
int natoms, nframes;
int initial_coding, initial_coding_parameter;
@@ -1404,9 +1636,9 @@ static int tng_compress_uncompress_vel(char *data,double *vel)
coding_parameter=(int)readbufferfix((unsigned char *)data+bufloc,4);
bufloc+=4;
/* Precision. */
- prec_lo=readbufferfix((unsigned char *)data+bufloc,4);
+ *prec_lo=readbufferfix((unsigned char *)data+bufloc,4);
bufloc+=4;
- prec_hi=readbufferfix((unsigned char *)data+bufloc,4);
+ *prec_hi=readbufferfix((unsigned char *)data+bufloc,4);
bufloc+=4;
/* Allocate the memory for the quantized positions */
quant=malloc(natoms*nframes*3*sizeof *quant);
@@ -1427,7 +1659,12 @@ static int tng_compress_uncompress_vel(char *data,double *vel)
(initial_coding==TNG_COMPRESS_ALGO_VEL_TRIPLET_ONETOONE) ||
(initial_coding==TNG_COMPRESS_ALGO_VEL_BWLZH_ONETOONE))
{
- unquantize(vel,natoms,1,PRECISION(prec_hi,prec_lo),quant);
+ if (veld)
+ unquantize(veld,natoms,1,PRECISION(*prec_hi,*prec_lo),quant);
+ else if (velf)
+ unquantize_float(velf,natoms,1,(float)PRECISION(*prec_hi,*prec_lo),quant);
+ else if (veli)
+ memcpy(veli,quant,natoms*3*sizeof *veli);
}
/* The remaining frames. */
if (nframes>1)
@@ -1447,14 +1684,24 @@ static int tng_compress_uncompress_vel(char *data,double *vel)
(coding==TNG_COMPRESS_ALGO_VEL_BWLZH_INTER))
{
/* This requires that the first frame is already in one-to-one format. */
- unquantize_inter_differences(vel,natoms,nframes,PRECISION(prec_hi,prec_lo),quant);
+ if (veld)
+ unquantize_inter_differences(veld,natoms,nframes,PRECISION(*prec_hi,*prec_lo),quant);
+ else if (velf)
+ unquantize_inter_differences_float(velf,natoms,nframes,(float)PRECISION(*prec_hi,*prec_lo),quant);
+ else if (veli)
+ unquantize_inter_differences_int(veli,natoms,nframes,quant);
}
/* One-to-one compression? */
else if ((coding==TNG_COMPRESS_ALGO_VEL_STOPBIT_ONETOONE) ||
(coding==TNG_COMPRESS_ALGO_VEL_TRIPLET_ONETOONE) ||
(coding==TNG_COMPRESS_ALGO_VEL_BWLZH_ONETOONE))
{
- unquantize(vel+natoms*3,natoms,nframes-1,PRECISION(prec_hi,prec_lo),quant+natoms*3);
+ if (veld)
+ unquantize(veld+natoms*3,natoms,nframes-1,PRECISION(*prec_hi,*prec_lo),quant+natoms*3);
+ else if (velf)
+ unquantize_float(velf+natoms*3,natoms,nframes-1,(float)PRECISION(*prec_hi,*prec_lo),quant+natoms*3);
+ else if (veli)
+ memcpy(veli+natoms*3,quant+natoms*3,natoms*3*(nframes-1)*sizeof *veli);
}
}
error:
@@ -1462,6 +1709,23 @@ static int tng_compress_uncompress_vel(char *data,double *vel)
return rval;
}
+static int tng_compress_uncompress_vel(char *data,double *vel)
+{
+ unsigned long prec_hi, prec_lo;
+ return tng_compress_uncompress_vel_gen(data,vel,NULL,NULL,&prec_hi,&prec_lo);
+}
+
+static int tng_compress_uncompress_vel_float(char *data,float *vel)
+{
+ unsigned long prec_hi, prec_lo;
+ return tng_compress_uncompress_vel_gen(data,NULL,vel,NULL,&prec_hi,&prec_lo);
+}
+
+static int tng_compress_uncompress_vel_int(char *data,int *vel, unsigned long *prec_hi, unsigned long *prec_lo)
+{
+ return tng_compress_uncompress_vel_gen(data,NULL,NULL,vel,prec_hi,prec_lo);
+}
+
/* Uncompresses any tng compress block, positions or velocities. It determines whether it is positions or velocities from the data buffer. The return value is 0 if ok, and 1 if not.
*/
int DECLSPECDLLEXPORT tng_compress_uncompress(char *data,double *posvel)
@@ -1476,6 +1740,44 @@ int DECLSPECDLLEXPORT tng_compress_uncompress(char *data,double *posvel)
return 1;
}
+int DECLSPECDLLEXPORT tng_compress_uncompress_float(char *data,float *posvel)
+{
+ int magic_int;
+ magic_int=(int)readbufferfix((unsigned char *)data,4);
+ if (magic_int==MAGIC_INT_POS)
+ return tng_compress_uncompress_pos_float(data,posvel);
+ else if (magic_int==MAGIC_INT_VEL)
+ return tng_compress_uncompress_vel_float(data,posvel);
+ else
+ return 1;
+}
+
+int DECLSPECDLLEXPORT tng_compress_uncompress_int(char *data,int *posvel, unsigned long *prec_hi, unsigned long *prec_lo)
+{
+ int magic_int;
+ magic_int=(int)readbufferfix((unsigned char *)data,4);
+ if (magic_int==MAGIC_INT_POS)
+ return tng_compress_uncompress_pos_int(data,posvel,prec_hi,prec_lo);
+ else if (magic_int==MAGIC_INT_VEL)
+ return tng_compress_uncompress_vel_int(data,posvel,prec_hi,prec_lo);
+ else
+ return 1;
+}
+
+void DECLSPECDLLEXPORT tng_compress_int_to_double(int *posvel_int,unsigned long prec_hi, unsigned long prec_lo,
+ int natoms,int nframes,
+ double *posvel_double)
+{
+ unquantize(posvel_double,natoms,nframes,PRECISION(prec_hi,prec_lo),posvel_int);
+}
+
+void DECLSPECDLLEXPORT tng_compress_int_to_float(int *posvel_int,unsigned long prec_hi, unsigned long prec_lo,
+ int natoms,int nframes,
+ float *posvel_float)
+{
+ unquantize_float(posvel_float,natoms,nframes,(float)PRECISION(prec_hi,prec_lo),posvel_int);
+}
+
static char *compress_algo_pos[TNG_COMPRESS_ALGO_MAX]={
"Positions invalid algorithm",
"Positions stopbits interframe",
diff --git a/src/lib/md5.c b/src/lib/md5.c
index 57c2138..8bd79b9 100644
--- a/src/lib/md5.c
+++ b/src/lib/md5.c
@@ -41,6 +41,18 @@
#define ARCH_IS_BIG_ENDIAN 0
#endif
+#ifndef USE_WINDOWS
+#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+#define USE_WINDOWS
+#endif /* win32... */
+#endif /* not defined USE_WINDOWS */
+
+#ifdef USE_WINDOWS
+#define TNG_INLINE __inline
+#else
+#define TNG_INLINE inline
+#endif
+
/*
Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved.
@@ -169,11 +181,7 @@
#define T63 0x2ad7d2bb
#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
-#ifdef USE_WINDOWS
-static inline void
-#else
-static __inline void
-#endif
+static TNG_INLINE void
md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
{
md5_word_t
@@ -355,8 +363,8 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
pms->abcd[3] += d;
}
-void
-md5_init(md5_state_t *pms)
+void DECLSPECDLLEXPORT
+tng_md5_init(md5_state_t *pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
@@ -365,8 +373,8 @@ md5_init(md5_state_t *pms)
pms->abcd[3] = 0x10325476;
}
-void
-md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
+void DECLSPECDLLEXPORT
+tng_md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
{
const md5_byte_t *p = data;
int left = nbytes;
@@ -403,8 +411,8 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
memcpy(pms->buf, p, left);
}
-void
-md5_finish(md5_state_t *pms, md5_byte_t digest[16])
+void DECLSPECDLLEXPORT
+tng_md5_finish(md5_state_t *pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -419,9 +427,9 @@ md5_finish(md5_state_t *pms, md5_byte_t digest[16])
for (i = 0; i < 8; ++i)
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
- md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ tng_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
- md5_append(pms, data, 8);
+ tng_md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index 37b0b75..410fb7c 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -350,6 +350,19 @@ struct tng_trajectory {
int *compress_algo_vel;
};
+#ifndef USE_WINDOWS
+#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+#define USE_WINDOWS
+#endif /* win32... */
+#endif /* not defined USE_WINDOWS */
+
+#ifdef USE_WINDOWS
+#define TNG_INLINE __inline
+#define TNG_SNPRINTF _snprintf
+#else
+#define TNG_INLINE inline
+#define TNG_SNPRINTF snprintf
+#endif
tng_function_status tng_util_trajectory_open(const char *filename,
const char mode,
@@ -562,6 +575,29 @@ tng_function_status tng_util_force_write(tng_trajectory_t tng_data,
{
}
+static TNG_INLINE int tng_min(int a, int b)
+{
+ int r=a;
+
+ if (b<a)
+ {
+ r=b;
+ }
+
+ return r;
+}
+
+static TNG_INLINE int tng_max(int a, int b)
+{
+ int r=a;
+
+ if (b>a)
+ {
+ r=b;
+ }
+
+ return r;
+}
/** This function swaps the byte order of a 32 bit numerical variable
* to big endian.
@@ -757,10 +793,10 @@ static tng_function_status tng_block_hash_generate(tng_gen_block_t block)
{
md5_state_t md5_state;
- md5_init(&md5_state);
- md5_append(&md5_state, (md5_byte_t *)block->block_contents,
+ tng_md5_init(&md5_state);
+ tng_md5_append(&md5_state, (md5_byte_t *)block->block_contents,
block->block_contents_size);
- md5_finish(&md5_state, (md5_byte_t *)block->hash);
+ tng_md5_finish(&md5_state, (md5_byte_t *)block->hash);
return(TNG_SUCCESS);
}
@@ -785,10 +821,10 @@ static tng_function_status hash_match_verify(tng_gen_block_t block,
*results = TNG_TRUE;
return(TNG_FAILURE);
}
- md5_init(&md5_state);
- md5_append(&md5_state, (md5_byte_t *)block->block_contents,
+ tng_md5_init(&md5_state);
+ tng_md5_append(&md5_state, (md5_byte_t *)block->block_contents,
block->block_contents_size);
- md5_finish(&md5_state, (md5_byte_t *)hash);
+ tng_md5_finish(&md5_state, (md5_byte_t *)hash);
if(strncmp(block->hash, hash, 16) != 0)
{
@@ -1044,7 +1080,7 @@ static tng_function_status tng_block_header_read
}
/* Move the reading position to the beginning of the header. */
- fseek(tng_data->input_file, -sizeof(block->header_contents_size),
+ fseek(tng_data->input_file, -(long)sizeof(block->header_contents_size),
SEEK_CUR);
/* If there is already memory allocated for the contents free it (we do not
@@ -6567,9 +6603,9 @@ static tng_function_status tng_atom_destroy(tng_atom_t atom)
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_add(tng_trajectory_t tng_data,
- const char *name,
- tng_molecule_t *molecule)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_add(tng_trajectory_t tng_data,
+ const char *name,
+ tng_molecule_t *molecule)
{
tng_molecule_t new_molecules;
int64_t *new_molecule_cnt_list;
@@ -6639,9 +6675,9 @@ tng_function_status tng_molecule_add(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_name_set(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const char *new_name)
{
int len;
@@ -6670,9 +6706,9 @@ tng_function_status tng_molecule_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_cnt_get(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- int64_t *cnt)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ int64_t *cnt)
{
int i, index = -1;
@@ -6693,9 +6729,9 @@ tng_function_status tng_molecule_cnt_get(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const int64_t cnt)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const int64_t cnt)
{
int i, index = -1, old_cnt;
@@ -6720,11 +6756,11 @@ tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_chain_find(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const char *name,
- int64_t nr,
- tng_chain_t *chain)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const char *name,
+ int64_t nr,
+ tng_chain_t *chain)
{
int i, n_chains;
@@ -6748,10 +6784,10 @@ tng_function_status tng_molecule_chain_find(tng_trajectory_t tng_data,
}
/* FIXME: For v. 2 the chain nr should also be possible to specify. */
-tng_function_status tng_molecule_chain_add(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const char *name,
- tng_chain_t *chain)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const char *name,
+ tng_chain_t *chain)
{
tng_chain_t new_chains;
@@ -6785,9 +6821,9 @@ tng_function_status tng_molecule_chain_add(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_chain_name_set(tng_trajectory_t tng_data,
- tng_chain_t chain,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_chain_name_set(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *new_name)
{
int len;
@@ -6816,11 +6852,11 @@ tng_function_status tng_chain_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data,
- tng_chain_t chain,
- const char *name,
- int64_t nr,
- tng_residue_t *residue)
+tng_function_status DECLSPECDLLEXPORT tng_chain_residue_find(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *name,
+ int64_t nr,
+ tng_residue_t *residue)
{
int i, n_residues;
@@ -6844,10 +6880,10 @@ tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data,
}
/* FIXME: For v. 2 the residue nr should also be possible to specify. */
-tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data,
- tng_chain_t chain,
- const char *name,
- tng_residue_t *residue)
+tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *name,
+ tng_residue_t *residue)
{
int curr_index;
tng_residue_t new_residues, temp_residue, last_residue;
@@ -6922,9 +6958,9 @@ tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_residue_name_set(tng_trajectory_t tng_data,
- tng_residue_t residue,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_residue_name_set(tng_trajectory_t tng_data,
+ tng_residue_t residue,
+ const char *new_name)
{
int len;
@@ -6954,11 +6990,11 @@ tng_function_status tng_residue_name_set(tng_trajectory_t tng_data,
}
/* FIXME: For v. 2 the atom nr should also be possible to specify. */
-tng_function_status tng_residue_atom_add(tng_trajectory_t tng_data,
- tng_residue_t residue,
- const char *atom_name,
- const char *atom_type,
- tng_atom_t *atom)
+tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add(tng_trajectory_t tng_data,
+ tng_residue_t residue,
+ const char *atom_name,
+ const char *atom_type,
+ tng_atom_t *atom)
{
tng_atom_t new_atoms;
tng_molecule_t molecule = residue->chain->molecule;
@@ -7000,8 +7036,8 @@ tng_function_status tng_residue_atom_add(tng_trajectory_t tng_data,
}
-tng_function_status tng_molecule_init(const tng_trajectory_t tng_data,
- tng_molecule_t molecule)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_init(const tng_trajectory_t tng_data,
+ tng_molecule_t molecule)
{
molecule->quaternary_str = 1;
molecule->name = 0;
@@ -7017,8 +7053,8 @@ tng_function_status tng_molecule_init(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_destroy(const tng_trajectory_t tng_data,
- tng_molecule_t molecule)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy(const tng_trajectory_t tng_data,
+ tng_molecule_t molecule)
{
int i;
@@ -7079,7 +7115,7 @@ tng_function_status tng_molecule_destroy(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_molecule_name_of_particle_nr_get
+tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -7125,7 +7161,7 @@ tng_function_status tng_molecule_name_of_particle_nr_get
return(TNG_SUCCESS);
}
-tng_function_status tng_chain_name_of_particle_nr_get
+tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -7177,7 +7213,7 @@ tng_function_status tng_chain_name_of_particle_nr_get
return(TNG_SUCCESS);
}
-tng_function_status tng_residue_name_of_particle_nr_get
+tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -7229,7 +7265,7 @@ tng_function_status tng_residue_name_of_particle_nr_get
return(TNG_SUCCESS);
}
-tng_function_status tng_atom_name_of_particle_nr_get
+tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -7325,7 +7361,7 @@ tng_function_status tng_atom_type_of_particle_nr_get
return(TNG_SUCCESS);
}
-tng_function_status tng_particle_mapping_add
+tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add
(tng_trajectory_t tng_data,
const int64_t num_first_particle,
const int64_t n_particles,
@@ -7409,7 +7445,7 @@ tng_function_status tng_particle_mapping_add
return(TNG_SUCCESS);
}
-tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p)
+tng_function_status DECLSPECDLLEXPORT tng_trajectory_init(tng_trajectory_t *tng_data_p)
{
time_t seconds;
tng_trajectory_frame_set_t frame_set;
@@ -7500,56 +7536,59 @@ tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p)
tng_data->molecule_cnt_list = 0;
tng_data->n_particles = 0;
- /* Check the endianness of the computer */
- static int32_t endianness_32 = 0x01234567;
- /* 0x01234567 */
- if ( *(const uint8_t*)&endianness_32 == 0x01 )
{
- tng_data->endianness_32 = TNG_BIG_ENDIAN_32;
- }
+ /* Check the endianness of the computer */
+ static int32_t endianness_32 = 0x01234567;
+ /* 0x01234567 */
+ if ( *(const uint8_t*)&endianness_32 == 0x01 )
+ {
+ tng_data->endianness_32 = TNG_BIG_ENDIAN_32;
+ }
- /* 0x67452301 */
- else if( *(const uint8_t*)&endianness_32 == 0x67 )
- {
- tng_data->endianness_32 = TNG_LITTLE_ENDIAN_32;
+ /* 0x67452301 */
+ else if( *(const uint8_t*)&endianness_32 == 0x67 )
+ {
+ tng_data->endianness_32 = TNG_LITTLE_ENDIAN_32;
- }
+ }
- /* 0x45670123 */
- else if ( *(const uint8_t*)&endianness_32 == 0x45 )
- {
- tng_data->endianness_32 = TNG_BYTE_PAIR_SWAP_32;
+ /* 0x45670123 */
+ else if ( *(const uint8_t*)&endianness_32 == 0x45 )
+ {
+ tng_data->endianness_32 = TNG_BYTE_PAIR_SWAP_32;
+ }
}
-
- static int64_t endianness_64 = 0x0123456789ABCDEF;
- /* 0x0123456789ABCDEF */
- if ( *(const uint8_t*)&endianness_64 == 0x01 )
{
- tng_data->endianness_64 = TNG_BIG_ENDIAN_64;
- }
+ static int64_t endianness_64 = 0x0123456789ABCDEF;
+ /* 0x0123456789ABCDEF */
+ if ( *(const uint8_t*)&endianness_64 == 0x01 )
+ {
+ tng_data->endianness_64 = TNG_BIG_ENDIAN_64;
+ }
- /* 0xEFCDAB8967452301 */
- else if ( *(const uint8_t*)&endianness_64 == 0xEF )
- {
- tng_data->endianness_64 = TNG_LITTLE_ENDIAN_64;
- }
+ /* 0xEFCDAB8967452301 */
+ else if ( *(const uint8_t*)&endianness_64 == 0xEF )
+ {
+ tng_data->endianness_64 = TNG_LITTLE_ENDIAN_64;
+ }
- /* 0x89ABCDEF01234567 */
- else if ( *(const uint8_t*)&endianness_64 == 0x89 )
- {
- tng_data->endianness_64 = TNG_QUAD_SWAP_64;
- }
+ /* 0x89ABCDEF01234567 */
+ else if ( *(const uint8_t*)&endianness_64 == 0x89 )
+ {
+ tng_data->endianness_64 = TNG_QUAD_SWAP_64;
+ }
- /* 0x45670123CDEF89AB */
- else if ( *(const uint8_t*)&endianness_64 == 0x45 )
- {
- tng_data->endianness_64 = TNG_BYTE_PAIR_SWAP_64;
- }
+ /* 0x45670123CDEF89AB */
+ else if ( *(const uint8_t*)&endianness_64 == 0x45 )
+ {
+ tng_data->endianness_64 = TNG_BYTE_PAIR_SWAP_64;
+ }
- /* 0x23016745AB89EFCD */
- else if ( *(const uint8_t*)&endianness_64 == 0x23 )
- {
- tng_data->endianness_64 = TNG_BYTE_SWAP_64;
+ /* 0x23016745AB89EFCD */
+ else if ( *(const uint8_t*)&endianness_64 == 0x23 )
+ {
+ tng_data->endianness_64 = TNG_BYTE_SWAP_64;
+ }
}
/* By default do not swap the byte order, i.e. keep the byte order of the
@@ -7568,7 +7607,7 @@ tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p)
return(TNG_SUCCESS);
}
-tng_function_status tng_trajectory_destroy(tng_trajectory_t *tng_data_p)
+tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy(tng_trajectory_t *tng_data_p)
{
int i, j, k, l;
int64_t n_particles, n_values_per_frame;
@@ -7929,7 +7968,7 @@ tng_function_status tng_trajectory_destroy(tng_trajectory_t *tng_data_p)
return(TNG_SUCCESS);
}
-tng_function_status tng_trajectory_init_from_src(tng_trajectory_t src,
+tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajectory_t src,
tng_trajectory_t *dest_p)
{
tng_trajectory_frame_set_t frame_set;
@@ -8044,7 +8083,7 @@ tng_function_status tng_trajectory_init_from_src(tng_trajectory_t src,
return(TNG_SUCCESS);
}
-tng_function_status tng_input_file_get(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_input_file_get(const tng_trajectory_t tng_data,
char *file_name, const int max_len)
{
strncpy(file_name, tng_data->input_file_path, max_len - 1);
@@ -8057,8 +8096,8 @@ tng_function_status tng_input_file_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_input_file_set(tng_trajectory_t tng_data,
- const char *file_name)
+tng_function_status DECLSPECDLLEXPORT tng_input_file_set(tng_trajectory_t tng_data,
+ const char *file_name)
{
int len;
char *temp;
@@ -8103,8 +8142,8 @@ tng_function_status tng_output_file_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_output_file_set(tng_trajectory_t tng_data,
- const char *file_name)
+tng_function_status DECLSPECDLLEXPORT tng_output_file_set(tng_trajectory_t tng_data,
+ const char *file_name)
{
int len;
char *temp;
@@ -8136,7 +8175,7 @@ tng_function_status tng_output_file_set(tng_trajectory_t tng_data,
return(tng_output_file_init(tng_data));
}
-tng_function_status tng_output_file_endianness_get
+tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get
(tng_trajectory_t tng_data, tng_file_endianness *endianness)
{
tng_endianness_32 end_32;
@@ -8210,7 +8249,7 @@ tng_function_status tng_output_file_endianness_get
return(TNG_SUCCESS);
}
-tng_function_status tng_output_file_endianness_set
+tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set
(tng_trajectory_t tng_data,
const tng_file_endianness endianness)
{
@@ -8271,8 +8310,9 @@ tng_function_status tng_output_file_endianness_set
return(TNG_FAILURE);
}
-tng_function_status tng_first_program_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->first_program_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8284,8 +8324,8 @@ tng_function_status tng_first_program_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_program_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set(tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8312,8 +8352,9 @@ tng_function_status tng_first_program_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_program_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->last_program_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8325,8 +8366,9 @@ tng_function_status tng_last_program_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_program_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set
+ (tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8353,8 +8395,9 @@ tng_function_status tng_last_program_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_user_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->first_user_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8366,8 +8409,9 @@ tng_function_status tng_first_user_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_user_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set
+ (tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8396,8 +8440,9 @@ tng_function_status tng_first_user_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_user_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->last_user_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8409,8 +8454,9 @@ tng_function_status tng_last_user_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_user_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set
+ (tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8439,8 +8485,9 @@ tng_function_status tng_last_user_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_computer_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->first_computer_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8452,8 +8499,9 @@ tng_function_status tng_first_computer_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_computer_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set
+ (tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8482,8 +8530,9 @@ tng_function_status tng_first_computer_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_computer_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->last_computer_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8495,8 +8544,9 @@ tng_function_status tng_last_computer_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_computer_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set
+ (tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8526,8 +8576,9 @@ tng_function_status tng_last_computer_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_signature_get(const tng_trajectory_t tng_data,
- char *signature, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_first_signature_get
+ (const tng_trajectory_t tng_data,
+ char *signature, const int max_len)
{
strncpy(signature, tng_data->first_pgp_signature, max_len - 1);
signature[max_len - 1] = 0;
@@ -8539,8 +8590,9 @@ tng_function_status tng_first_signature_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_first_signature_set(tng_trajectory_t tng_data,
- const char *signature)
+tng_function_status DECLSPECDLLEXPORT tng_first_signature_set
+ (tng_trajectory_t tng_data,
+ const char *signature)
{
int len;
@@ -8570,8 +8622,9 @@ tng_function_status tng_first_signature_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_signature_get(const tng_trajectory_t tng_data,
- char *signature, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_last_signature_get
+ (const tng_trajectory_t tng_data,
+ char *signature, const int max_len)
{
strncpy(signature, tng_data->last_pgp_signature, max_len - 1);
signature[max_len - 1] = 0;
@@ -8583,8 +8636,9 @@ tng_function_status tng_last_signature_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_last_signature_set(tng_trajectory_t tng_data,
- const char *signature)
+tng_function_status DECLSPECDLLEXPORT tng_last_signature_set
+ (tng_trajectory_t tng_data,
+ const char *signature)
{
int len;
@@ -8614,8 +8668,9 @@ tng_function_status tng_last_signature_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_forcefield_name_get(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
strncpy(name, tng_data->forcefield_name, max_len - 1);
name[max_len - 1] = 0;
@@ -8627,8 +8682,9 @@ tng_function_status tng_forcefield_name_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_forcefield_name_set(tng_trajectory_t tng_data,
- const char *new_name)
+tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set
+ (tng_trajectory_t tng_data,
+ const char *new_name)
{
int len;
@@ -8657,16 +8713,18 @@ tng_function_status tng_forcefield_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_medium_stride_length_get(const tng_trajectory_t tng_data,
- int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get
+ (const tng_trajectory_t tng_data,
+ int64_t *len)
{
*len = tng_data->medium_stride_length;
return(TNG_SUCCESS);
}
-tng_function_status tng_medium_stride_length_set(tng_trajectory_t tng_data,
- const int64_t len)
+tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set
+ (tng_trajectory_t tng_data,
+ const int64_t len)
{
if(len >= tng_data->long_stride_length)
{
@@ -8677,16 +8735,18 @@ tng_function_status tng_medium_stride_length_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_long_stride_length_get(const tng_trajectory_t tng_data,
- int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get
+ (const tng_trajectory_t tng_data,
+ int64_t *len)
{
*len = tng_data->long_stride_length;
return(TNG_SUCCESS);
}
-tng_function_status tng_long_stride_length_set(tng_trajectory_t tng_data,
- const int64_t len)
+tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set
+ (tng_trajectory_t tng_data,
+ const int64_t len)
{
if(len <= tng_data->medium_stride_length)
{
@@ -8697,16 +8757,18 @@ tng_function_status tng_long_stride_length_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_input_file_len_get(const tng_trajectory_t tng_data,
- int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get
+ (const tng_trajectory_t tng_data,
+ int64_t *len)
{
*len = tng_data->input_file_len;
return(TNG_SUCCESS);
}
-tng_function_status tng_num_frames_get(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_frames_get
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
tng_gen_block_t block;
tng_function_status stat;
@@ -8749,8 +8811,9 @@ tng_function_status tng_num_frames_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_num_particles_get(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_particles_get
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
if(tng_data->var_num_atoms_flag == TNG_CONSTANT_N_ATOMS)
{
@@ -8764,8 +8827,9 @@ tng_function_status tng_num_particles_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_num_molecules_get(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
int64_t *cnt_list, cnt = 0, i;
@@ -8788,7 +8852,7 @@ tng_function_status tng_num_molecules_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_num_frames_per_frame_set_get
+tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get
(const tng_trajectory_t tng_data,
int64_t *n)
{
@@ -8797,7 +8861,7 @@ tng_function_status tng_num_frames_per_frame_set_get
return(TNG_SUCCESS);
}
-tng_function_status tng_num_frames_per_frame_set_set
+tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set
(const tng_trajectory_t tng_data,
const int64_t n)
{
@@ -8806,8 +8870,9 @@ tng_function_status tng_num_frames_per_frame_set_set
return(TNG_SUCCESS);
}
-tng_function_status tng_num_frame_sets_get(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
int64_t long_stride_length, medium_stride_length;
int64_t file_pos;
@@ -8945,7 +9010,7 @@ tng_function_status tng_num_frame_sets_get(const tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_current_frame_set_get
+tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get
(tng_trajectory_t tng_data,
tng_trajectory_frame_set_t *frame_set_p)
{
@@ -8954,8 +9019,9 @@ tng_function_status tng_current_frame_set_get
return(TNG_SUCCESS);
}
-tng_function_status tng_frame_set_nr_find(tng_trajectory_t tng_data,
- const int64_t nr)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
+ (tng_trajectory_t tng_data,
+ const int64_t nr)
{
int64_t long_stride_length, medium_stride_length;
int64_t file_pos, curr_nr = 0, n_frame_sets;
@@ -9268,8 +9334,9 @@ tng_function_status tng_frame_set_nr_find(tng_trajectory_t tng_data,
return(TNG_FAILURE);
}
-tng_function_status tng_frame_set_of_frame_find(tng_trajectory_t tng_data,
- const int64_t frame)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
+ (tng_trajectory_t tng_data,
+ const int64_t frame)
{
int64_t first_frame, last_frame, n_frames_per_frame_set;
int64_t long_stride_length, medium_stride_length;
@@ -9609,7 +9676,7 @@ tng_function_status tng_frame_set_of_frame_find(tng_trajectory_t tng_data,
return(TNG_FAILURE);
}
-tng_function_status tng_frame_set_next_frame_set_file_pos_get
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get
(const tng_trajectory_t tng_data,
const tng_trajectory_frame_set_t frame_set,
int64_t *pos)
@@ -9619,7 +9686,7 @@ tng_function_status tng_frame_set_next_frame_set_file_pos_get
return(TNG_SUCCESS);
}
-tng_function_status tng_frame_set_prev_frame_set_file_pos_get
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get
(const tng_trajectory_t tng_data,
const tng_trajectory_frame_set_t frame_set,
int64_t *pos)
@@ -9629,7 +9696,7 @@ tng_function_status tng_frame_set_prev_frame_set_file_pos_get
return(TNG_SUCCESS);
}
-tng_function_status tng_frame_set_frame_range_get
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get
(const tng_trajectory_t tng_data,
const tng_trajectory_frame_set_t frame_set,
int64_t *first_frame,
@@ -9649,7 +9716,7 @@ tng_function_status tng_frame_set_frame_range_get
* @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the mapping
* cannot be found.
*/
-static inline tng_function_status tng_particle_mapping_get_real_particle
+static TNG_INLINE tng_function_status tng_particle_mapping_get_real_particle
(const tng_trajectory_frame_set_t frame_set,
const int64_t local,
int64_t *real)
@@ -9685,7 +9752,7 @@ static inline tng_function_status tng_particle_mapping_get_real_particle
* @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the mapping
* cannot be found.
*/
-static inline tng_function_status tng_particle_mapping_get_local_particle
+static TNG_INLINE tng_function_status tng_particle_mapping_get_local_particle
(const tng_trajectory_frame_set_t frame_set,
const int64_t real,
int64_t *local)
@@ -9713,7 +9780,7 @@ static inline tng_function_status tng_particle_mapping_get_local_particle
}
-tng_function_status tng_file_headers_read(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_file_headers_read(tng_trajectory_t tng_data,
const tng_hash_mode hash_mode)
{
int cnt = 0, prev_pos = 0;
@@ -9760,7 +9827,7 @@ tng_function_status tng_file_headers_read(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_file_headers_write(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_file_headers_write(tng_trajectory_t tng_data,
const tng_hash_mode hash_mode)
{
int i;
@@ -9810,7 +9877,7 @@ tng_function_status tng_file_headers_write(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_block_read_next(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_block_read_next(tng_trajectory_t tng_data,
tng_gen_block_t block,
const tng_hash_mode hash_mode)
{
@@ -9839,7 +9906,7 @@ tng_function_status tng_block_read_next(tng_trajectory_t tng_data,
}
-tng_function_status tng_frame_set_read_next(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next(tng_trajectory_t tng_data,
const tng_hash_mode hash_mode)
{
long int file_pos;
@@ -10013,9 +10080,10 @@ tng_function_status tng_frame_set_write(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_frame_set_new(tng_trajectory_t tng_data,
- const int64_t first_frame,
- const int64_t n_frames)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
+ (tng_trajectory_t tng_data,
+ const int64_t first_frame,
+ const int64_t n_frames)
{
int i;
tng_gen_block_t block;
@@ -10205,22 +10273,24 @@ tng_function_status tng_frame_set_new(tng_trajectory_t tng_data,
-tng_function_status tng_data_block_add(tng_trajectory_t tng_data,
- const int64_t id,
- const char *block_name,
- const tng_data_type datatype,
- const tng_block_type block_type_flag,
- int64_t n_frames,
- const int64_t n_values_per_frame,
- int64_t stride_length,
- const int64_t codec_id,
- void *new_data)
+tng_function_status DECLSPECDLLEXPORT tng_data_block_add
+ (tng_trajectory_t tng_data,
+ const int64_t id,
+ const char *block_name,
+ const tng_data_type datatype,
+ const tng_block_type block_type_flag,
+ int64_t n_frames,
+ const int64_t n_values_per_frame,
+ int64_t stride_length,
+ const int64_t codec_id,
+ void *new_data)
{
int i, j, block_index, size, len;
tng_trajectory_frame_set_t frame_set;
tng_non_particle_data_t data;
char **first_dim_values;
void *orig;
+ char *new_data_c=new_data;
frame_set = &tng_data->current_trajectory_frame_set;
@@ -10312,7 +10382,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data,
break;
}
- if(new_data)
+ if(new_data_c)
{
/* Allocate memory */
if(tng_allocate_data_mem(tng_data, data, n_frames, stride_length,
@@ -10324,7 +10394,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data,
return(TNG_CRITICAL);
}
- orig = new_data;
+ orig = new_data_c;
if(n_frames > frame_set->n_written_frames)
{
@@ -10338,7 +10408,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data,
first_dim_values = data->strings[i];
for(j = 0; j < n_values_per_frame; j++)
{
- len = tng_min(strlen(new_data) + 1,
+ len = tng_min(strlen(new_data_c) + 1,
TNG_MAX_STR_LEN);
if(first_dim_values[j])
{
@@ -10352,7 +10422,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data,
return(TNG_CRITICAL);
}
strncpy(first_dim_values[j],
- new_data, len);
+ new_data_c, len);
new_data += len;
}
}
@@ -10362,32 +10432,32 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data,
memcpy(data->values, new_data, size * n_frames / stride_length *
n_values_per_frame);
}
-
- new_data = orig;
}
return(TNG_SUCCESS);
}
-tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data,
- const int64_t id,
- const char *block_name,
- const tng_data_type datatype,
- const tng_block_type block_type_flag,
- int64_t n_frames,
- const int64_t n_values_per_frame,
- int64_t stride_length,
- const int64_t num_first_particle,
- const int64_t n_particles,
- const int64_t codec_id,
- void *new_data)
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add
+ (tng_trajectory_t tng_data,
+ const int64_t id,
+ const char *block_name,
+ const tng_data_type datatype,
+ const tng_block_type block_type_flag,
+ int64_t n_frames,
+ const int64_t n_values_per_frame,
+ int64_t stride_length,
+ const int64_t num_first_particle,
+ const int64_t n_particles,
+ const int64_t codec_id,
+ void *new_data)
{
int i, j, k, block_index, size, len;
int64_t tot_n_particles;
char ***first_dim_values, **second_dim_values;
tng_trajectory_frame_set_t frame_set;
tng_particle_data_t data;
- void *orig;
+ char *orig;
+ char *new_data_c=new_data;
frame_set = &tng_data->current_trajectory_frame_set;
@@ -10477,7 +10547,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data,
}
/* If data values are supplied add that data to the data block. */
- if(new_data)
+ if(new_data_c)
{
/* Allocate memory */
if(tng_allocate_particle_data_mem(tng_data, data, n_frames,
@@ -10490,7 +10560,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data,
return(TNG_CRITICAL);
}
- orig = new_data;
+ orig = new_data_c;
if(n_frames > frame_set->n_written_frames)
{
@@ -10508,7 +10578,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data,
second_dim_values = first_dim_values[j];
for(k = 0; k < n_values_per_frame; k++)
{
- len = tng_min(strlen(new_data) + 1,
+ len = tng_min(strlen(new_data_c) + 1,
TNG_MAX_STR_LEN);
if(second_dim_values[k])
{
@@ -10522,8 +10592,8 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data,
return(TNG_CRITICAL);
}
strncpy(second_dim_values[k],
- new_data, len);
- new_data += len;
+ new_data_c, len);
+ new_data_c += len;
}
}
}
@@ -10544,21 +10614,21 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data,
default:
size = sizeof(double);
}
+
memcpy(data->values, new_data, size * n_frames / stride_length *
n_particles * n_values_per_frame);
}
-
- new_data = orig;
}
return(TNG_SUCCESS);
}
-tng_function_status tng_frame_data_write(tng_trajectory_t tng_data,
- const int64_t frame_nr,
- const int64_t block_id,
- const void *values,
- const tng_hash_mode hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
+ (tng_trajectory_t tng_data,
+ const int64_t frame_nr,
+ const int64_t block_id,
+ const void *values,
+ const tng_hash_mode hash_mode)
{
int64_t header_pos, file_pos;
int64_t output_file_len, n_values_per_frame, size, contents_size;
@@ -10964,13 +11034,14 @@ tng_function_status tng_frame_data_write(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data,
- const int64_t frame_nr,
- const int64_t block_id,
- const int64_t val_first_particle,
- const int64_t val_n_particles,
- const void *values,
- const tng_hash_mode hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
+ (tng_trajectory_t tng_data,
+ const int64_t frame_nr,
+ const int64_t block_id,
+ const int64_t val_first_particle,
+ const int64_t val_n_particles,
+ const void *values,
+ const tng_hash_mode hash_mode)
{
int64_t header_pos, file_pos, tot_n_particles;
int64_t output_file_len, n_values_per_frame, size, contents_size;
@@ -11543,11 +11614,12 @@ static tng_function_status tng_data_values_alloc
return(TNG_SUCCESS);
}
-tng_function_status tng_data_values_free(const tng_trajectory_t tng_data,
- union data_values **values,
- const int64_t n_frames,
- const int64_t n_values_per_frame,
- const tng_data_type type)
+tng_function_status DECLSPECDLLEXPORT tng_data_values_free
+ (const tng_trajectory_t tng_data,
+ union data_values **values,
+ const int64_t n_frames,
+ const int64_t n_values_per_frame,
+ const tng_data_type type)
{
int i, j;
@@ -11645,7 +11717,7 @@ static tng_function_status tng_particle_data_values_alloc
return(TNG_SUCCESS);
}
-tng_function_status tng_particle_data_values_free
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free
(const tng_trajectory_t tng_data,
union data_values ***values,
const int64_t n_frames,
@@ -11689,12 +11761,13 @@ tng_function_status tng_particle_data_values_free
}
-tng_function_status tng_data_get(tng_trajectory_t tng_data,
- const int64_t block_id,
- union data_values ***values,
- int64_t *n_frames,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_data_get
+ (tng_trajectory_t tng_data,
+ const int64_t block_id,
+ union data_values ***values,
+ int64_t *n_frames,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
int64_t file_pos;
int i, j, block_index, len, size;
@@ -11959,14 +12032,15 @@ tng_function_status tng_data_vector_get(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
-tng_function_status tng_data_interval_get(tng_trajectory_t tng_data,
- const int64_t block_id,
- const int64_t start_frame_nr,
- const int64_t end_frame_nr,
- const tng_hash_mode hash_mode,
- union data_values ***values,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_data_interval_get
+ (tng_trajectory_t tng_data,
+ const int64_t block_id,
+ const int64_t start_frame_nr,
+ const int64_t end_frame_nr,
+ const tng_hash_mode hash_mode,
+ union data_values ***values,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
int64_t i, j, n_frames, file_pos, current_frame_pos;
int block_index, len, size;
@@ -12145,13 +12219,14 @@ tng_function_status tng_data_interval_get(tng_trajectory_t tng_data,
}
-tng_function_status tng_particle_data_get(tng_trajectory_t tng_data,
- const int64_t block_id,
- union data_values ****values,
- int64_t *n_frames,
- int64_t *n_particles,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_get
+ (tng_trajectory_t tng_data,
+ const int64_t block_id,
+ union data_values ****values,
+ int64_t *n_frames,
+ int64_t *n_particles,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
int64_t i, j, k, mapping, file_pos, i_step;
int block_index, len, size;
@@ -12345,15 +12420,16 @@ tng_function_status tng_particle_data_get(tng_trajectory_t tng_data,
}
-tng_function_status tng_particle_data_interval_get(tng_trajectory_t tng_data,
- const int64_t block_id,
- const int64_t start_frame_nr,
- const int64_t end_frame_nr,
- const tng_hash_mode hash_mode,
- union data_values ****values,
- int64_t *n_particles,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get
+ (tng_trajectory_t tng_data,
+ const int64_t block_id,
+ const int64_t start_frame_nr,
+ const int64_t end_frame_nr,
+ const tng_hash_mode hash_mode,
+ union data_values ****values,
+ int64_t *n_particles,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
int64_t i, j, k, mapping, n_frames, file_pos, current_frame_pos, i_step;
int block_index, len, size;
@@ -12570,8 +12646,9 @@ tng_function_status tng_particle_data_interval_get(tng_trajectory_t tng_data,
}
-tng_function_status tng_time_get_str(const tng_trajectory_t tng_data,
- char *time)
+tng_function_status DECLSPECDLLEXPORT tng_time_get_str
+ (const tng_trajectory_t tng_data,
+ char *time)
{
struct tm *time_data;
time_t secs;
@@ -12579,7 +12656,7 @@ tng_function_status tng_time_get_str(const tng_trajectory_t tng_data,
secs = tng_data->time;
time_data = localtime(&secs); // Returns a statically allocated variable.
- snprintf(time, TNG_MAX_DATE_STR_LEN,
+ TNG_SNPRINTF(time, TNG_MAX_DATE_STR_LEN,
"%4d-%02d-%02d %02d:%02d:%02d",
time_data->tm_year+1900, time_data->tm_mon+1, time_data->tm_mday,
time_data->tm_hour, time_data->tm_min, time_data->tm_sec);
@@ -12591,29 +12668,29 @@ tng_function_status tng_time_get_str(const tng_trajectory_t tng_data,
#ifdef BUILD_FORTRAN
/* The following is for calling the library from fortran */
-tng_function_status tng_trajectory_init_(tng_trajectory_t *tng_data_p)
+tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_(tng_trajectory_t *tng_data_p)
{
return(tng_trajectory_init(tng_data_p));
}
-tng_function_status tng_trajectory_destroy_(tng_trajectory_t *tng_data_p)
+tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy_(tng_trajectory_t *tng_data_p)
{
return(tng_trajectory_destroy(tng_data_p));
}
-tng_function_status tng_trajectory_init_from_src_(tng_trajectory_t src,
+tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src_(tng_trajectory_t src,
tng_trajectory_t *dest_p)
{
return(tng_trajectory_init_from_src(src, dest_p));
}
-tng_function_status tng_input_file_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_input_file_get_(const tng_trajectory_t tng_data,
char *file_name, const int max_len)
{
return(tng_input_file_get(tng_data, file_name, max_len));
}
-tng_function_status tng_input_file_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_input_file_set_(tng_trajectory_t tng_data,
const char *file_name, int name_len)
{
char *name = malloc(name_len + 1);
@@ -12626,13 +12703,13 @@ tng_function_status tng_input_file_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_output_file_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_output_file_get_(const tng_trajectory_t tng_data,
char *file_name, const int max_len)
{
return(tng_output_file_get(tng_data, file_name, max_len));
}
-tng_function_status tng_output_file_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_output_file_set_(tng_trajectory_t tng_data,
const char *file_name, int name_len)
{
char *name = malloc(name_len + 1);
@@ -12645,25 +12722,25 @@ tng_function_status tng_output_file_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_first_program_name_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get_(const tng_trajectory_t tng_data,
char *name, const int max_len)
{
return(tng_first_program_name_get(tng_data, name, max_len));
}
-tng_function_status tng_output_file_endianness_get_
+tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get_
(tng_trajectory_t tng_data, tng_file_endianness *endianness)
{
return(tng_output_file_endianness_get(tng_data, endianness));
}
-tng_function_status tng_output_file_endianness_set_
+tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set_
(tng_trajectory_t tng_data, const tng_file_endianness *endianness)
{
return(tng_output_file_endianness_set(tng_data, *endianness));
}
-tng_function_status tng_first_program_name_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set_(tng_trajectory_t tng_data,
const char *new_name,
int name_len)
{
@@ -12677,13 +12754,13 @@ tng_function_status tng_first_program_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_last_program_name_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get_(const tng_trajectory_t tng_data,
char *name, const int max_len)
{
return(tng_last_program_name_get(tng_data, name, max_len));
}
-tng_function_status tng_last_program_name_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set_(tng_trajectory_t tng_data,
const char *new_name,
int name_len)
{
@@ -12697,13 +12774,13 @@ tng_function_status tng_last_program_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_first_user_name_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get_(const tng_trajectory_t tng_data,
char *name, const int max_len)
{
return(tng_first_user_name_get(tng_data, name, max_len));
}
-tng_function_status tng_first_user_name_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set_(tng_trajectory_t tng_data,
const char *new_name,
int name_len)
{
@@ -12717,13 +12794,13 @@ tng_function_status tng_first_user_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_last_user_name_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get_(const tng_trajectory_t tng_data,
char *name, const int max_len)
{
return(tng_last_user_name_get(tng_data, name, max_len));
}
-tng_function_status tng_last_user_name_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set_(tng_trajectory_t tng_data,
const char *new_name,
int name_len)
{
@@ -12737,13 +12814,13 @@ tng_function_status tng_last_user_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_first_computer_name_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get_(const tng_trajectory_t tng_data,
char *name, const int max_len)
{
return(tng_first_computer_name_get(tng_data, name, max_len));
}
-tng_function_status tng_first_computer_name_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set_(tng_trajectory_t tng_data,
const char *new_name,
int name_len)
{
@@ -12757,13 +12834,13 @@ tng_function_status tng_first_computer_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_last_computer_name_get_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get_(const tng_trajectory_t tng_data,
char *name, const int max_len)
{
return(tng_last_computer_name_get(tng_data, name, max_len));
}
-tng_function_status tng_last_computer_name_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set_(tng_trajectory_t tng_data,
const char *new_name,
int name_len)
{
@@ -12777,13 +12854,14 @@ tng_function_status tng_last_computer_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_first_signature_get_(const tng_trajectory_t tng_data,
- char *signature, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_first_signature_get_
+ (const tng_trajectory_t tng_data,
+ char *signature, const int max_len)
{
return(tng_first_signature_get(tng_data, signature, max_len));
}
-tng_function_status tng_first_signature_set_(tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_first_signature_set_(tng_trajectory_t tng_data,
const char *signature,
int sign_len)
{
@@ -12797,15 +12875,17 @@ tng_function_status tng_first_signature_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_last_signature_get_(const tng_trajectory_t tng_data,
- char *signature, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_last_signature_get_
+ (const tng_trajectory_t tng_data,
+ char *signature, const int max_len)
{
return(tng_last_signature_get(tng_data, signature, max_len));
}
-tng_function_status tng_last_signature_set_(tng_trajectory_t tng_data,
- const char *signature,
- int sign_len)
+tng_function_status DECLSPECDLLEXPORT tng_last_signature_set_
+ (tng_trajectory_t tng_data,
+ const char *signature,
+ int sign_len)
{
char *sign = malloc(sign_len + 1);
tng_function_status stat;
@@ -12817,15 +12897,17 @@ tng_function_status tng_last_signature_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_forcefield_name_get_(const tng_trajectory_t tng_data,
- char *name, const int max_len)
+tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get_
+ (const tng_trajectory_t tng_data,
+ char *name, const int max_len)
{
return(tng_forcefield_name_get(tng_data, name, max_len));
}
-tng_function_status tng_forcefield_name_set_(tng_trajectory_t tng_data,
- const char *new_name,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set_
+ (tng_trajectory_t tng_data,
+ const char *new_name,
+ int name_len)
{
char *name = malloc(name_len + 1);
tng_function_status stat;
@@ -12837,95 +12919,104 @@ tng_function_status tng_forcefield_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_medium_stride_length_get_(const tng_trajectory_t tng_data,
- int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get_
+ (const tng_trajectory_t tng_data,
+ int64_t *len)
{
return(tng_medium_stride_length_get(tng_data, len));
}
-tng_function_status tng_medium_stride_length_set_(tng_trajectory_t tng_data,
- const int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set_
+ (tng_trajectory_t tng_data,
+ const int64_t *len)
{
return(tng_medium_stride_length_set(tng_data, *len));
}
-tng_function_status tng_long_stride_length_get_(const tng_trajectory_t tng_data,
- int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get_
+ (const tng_trajectory_t tng_data,
+ int64_t *len)
{
return(tng_long_stride_length_get(tng_data, len));
}
-tng_function_status tng_long_stride_length_set_(tng_trajectory_t tng_data,
- const int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set_
+ (tng_trajectory_t tng_data,
+ const int64_t *len)
{
return(tng_long_stride_length_set(tng_data, *len));
}
-tng_function_status tng_input_file_len_get_(const tng_trajectory_t tng_data,
- int64_t *len)
+tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get_
+ (const tng_trajectory_t tng_data,
+ int64_t *len)
{
return(tng_input_file_len_get(tng_data, len));
}
-tng_function_status tng_num_frames_get_(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_frames_get_
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
return(tng_num_frames_get(tng_data, n));
}
-tng_function_status tng_num_particles_get_(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_particles_get_
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
return(tng_num_particles_get(tng_data, n));
}
-tng_function_status tng_num_molecules_get_(const tng_trajectory_t tng_data,
- int64_t *n)
+tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get_
+ (const tng_trajectory_t tng_data,
+ int64_t *n)
{
return(tng_num_molecules_get(tng_data, n));
}
-tng_function_status tng_num_frames_per_frame_set_get_
+tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get_
(const tng_trajectory_t tng_data,
int64_t *n)
{
return(tng_num_frames_per_frame_set_get(tng_data, n));
}
-tng_function_status tng_num_frames_per_frame_set_set_
+tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set_
(const tng_trajectory_t tng_data,
int64_t *n)
{
return(tng_num_frames_per_frame_set_set(tng_data, *n));
}
-tng_function_status tng_num_frame_sets_get_
+tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get_
(const tng_trajectory_t tng_data,
int64_t *n)
{
return(tng_num_frame_sets_get(tng_data, n));
}
-tng_function_status tng_current_frame_set_get_
+tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get_
(tng_trajectory_t tng_data,
tng_trajectory_frame_set_t *frame_set_p)
{
return(tng_current_frame_set_get(tng_data, frame_set_p));
}
-tng_function_status tng_frame_set_nr_find_(tng_trajectory_t tng_data,
- const int64_t *nr)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find_(tng_trajectory_t tng_data,
+ const int64_t *nr)
{
return(tng_frame_set_nr_find(tng_data, *nr));
}
-tng_function_status tng_frame_set_of_frame_find_(tng_trajectory_t tng_data,
- const int64_t *frame)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find_
+ (tng_trajectory_t tng_data,
+ const int64_t *frame)
{
return(tng_frame_set_of_frame_find(tng_data, *frame));
}
-tng_function_status tng_frame_set_next_frame_set_file_pos_get_
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get_
(const tng_trajectory_t tng_data,
const tng_trajectory_frame_set_t frame_set,
int64_t *pos)
@@ -12933,7 +13024,7 @@ tng_function_status tng_frame_set_next_frame_set_file_pos_get_
return(tng_frame_set_next_frame_set_file_pos_get(tng_data, frame_set, pos));
}
-tng_function_status tng_frame_set_prev_frame_set_file_pos_get_
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get_
(const tng_trajectory_t tng_data,
const tng_trajectory_frame_set_t frame_set,
int64_t *pos)
@@ -12941,7 +13032,7 @@ tng_function_status tng_frame_set_prev_frame_set_file_pos_get_
return(tng_frame_set_prev_frame_set_file_pos_get(tng_data, frame_set, pos));
}
-tng_function_status tng_frame_set_frame_range_get_
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get_
(const tng_trajectory_t tng_data,
const tng_trajectory_frame_set_t frame_set,
int64_t *first_frame,
@@ -12951,22 +13042,23 @@ tng_function_status tng_frame_set_frame_range_get_
last_frame));
}
-tng_function_status tng_molecule_init_(const tng_trajectory_t tng_data,
+tng_function_status DECLSPECDLLEXPORT tng_molecule_init_(const tng_trajectory_t tng_data,
tng_molecule_t molecule)
{
return(tng_molecule_init(tng_data, molecule));
}
-tng_function_status tng_molecule_destroy_(const tng_trajectory_t tng_data,
- tng_molecule_t molecule)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy_
+ (const tng_trajectory_t tng_data,
+ tng_molecule_t molecule)
{
return(tng_molecule_destroy(tng_data, molecule));
}
-tng_function_status tng_molecule_add_(tng_trajectory_t tng_data,
- const char *name,
- tng_molecule_t *molecule,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_add_(tng_trajectory_t tng_data,
+ const char *name,
+ tng_molecule_t *molecule,
+ int name_len)
{
char *n = malloc(name_len + 1);
tng_function_status stat;
@@ -12978,10 +13070,10 @@ tng_function_status tng_molecule_add_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_molecule_name_set_(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const char *new_name,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set_(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const char *new_name,
+ int name_len)
{
char *name = malloc(name_len + 1);
tng_function_status stat;
@@ -12993,26 +13085,26 @@ tng_function_status tng_molecule_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_molecule_cnt_get_(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- int64_t *cnt)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get_(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ int64_t *cnt)
{
return(tng_molecule_cnt_get(tng_data, molecule, cnt));
}
-tng_function_status tng_molecule_cnt_set_(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- int64_t *cnt)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set_(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ int64_t *cnt)
{
return(tng_molecule_cnt_set(tng_data, molecule, *cnt));
}
-tng_function_status tng_molecule_chain_find_(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const char *name,
- int64_t id,
- tng_chain_t *chain,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find_(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const char *name,
+ int64_t id,
+ tng_chain_t *chain,
+ int name_len)
{
char *n = malloc(name_len + 1);
tng_function_status stat;
@@ -13024,11 +13116,11 @@ tng_function_status tng_molecule_chain_find_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_molecule_chain_add_(tng_trajectory_t tng_data,
- tng_molecule_t molecule,
- const char *name,
- tng_chain_t *chain,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add_(tng_trajectory_t tng_data,
+ tng_molecule_t molecule,
+ const char *name,
+ tng_chain_t *chain,
+ int name_len)
{
char *n = malloc(name_len + 1);
tng_function_status stat;
@@ -13040,10 +13132,10 @@ tng_function_status tng_molecule_chain_add_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_chain_name_set_(tng_trajectory_t tng_data,
- tng_chain_t chain,
- const char *new_name,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_chain_name_set_(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *new_name,
+ int name_len)
{
char *name = malloc(name_len + 1);
tng_function_status stat;
@@ -13055,11 +13147,11 @@ tng_function_status tng_chain_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_chain_residue_add_(tng_trajectory_t tng_data,
- tng_chain_t chain,
- const char *name,
- tng_residue_t *residue,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add_(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *name,
+ tng_residue_t *residue,
+ int name_len)
{
char *n = malloc(name_len + 1);
tng_function_status stat;
@@ -13071,10 +13163,10 @@ tng_function_status tng_chain_residue_add_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_residue_name_set_(tng_trajectory_t tng_data,
- tng_residue_t residue,
- const char *new_name,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_residue_name_set_(tng_trajectory_t tng_data,
+ tng_residue_t residue,
+ const char *new_name,
+ int name_len)
{
char *name = malloc(name_len + 1);
tng_function_status stat;
@@ -13086,13 +13178,13 @@ tng_function_status tng_residue_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_residue_atom_add_(tng_trajectory_t tng_data,
- tng_residue_t residue,
- const char *atom_name,
- const char *atom_type,
- tng_atom_t *atom,
- int name_len,
- int type_len)
+tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add_(tng_trajectory_t tng_data,
+ tng_residue_t residue,
+ const char *atom_name,
+ const char *atom_type,
+ tng_atom_t *atom,
+ int name_len,
+ int type_len)
{
char *name = malloc(name_len + 1);
char *type = malloc(type_len + 1);
@@ -13108,10 +13200,10 @@ tng_function_status tng_residue_atom_add_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_atom_name_set_(tng_trajectory_t tng_data,
- tng_atom_t atom,
- const char *new_name,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_atom_name_set_(tng_trajectory_t tng_data,
+ tng_atom_t atom,
+ const char *new_name,
+ int name_len)
{
char *name = malloc(name_len + 1);
tng_function_status stat;
@@ -13123,10 +13215,10 @@ tng_function_status tng_atom_name_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_atom_type_set_(tng_trajectory_t tng_data,
- tng_atom_t atom,
- const char *new_type,
- int type_len)
+tng_function_status DECLSPECDLLEXPORT tng_atom_type_set_(tng_trajectory_t tng_data,
+ tng_atom_t atom,
+ const char *new_type,
+ int type_len)
{
char *type = malloc(type_len + 1);
tng_function_status stat;
@@ -13138,7 +13230,7 @@ tng_function_status tng_atom_type_set_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_molecule_name_of_particle_nr_get_
+tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get_
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -13147,7 +13239,7 @@ tng_function_status tng_molecule_name_of_particle_nr_get_
return(tng_molecule_name_of_particle_nr_get(tng_data, nr, name, max_len));
}
-tng_function_status tng_chain_name_of_particle_nr_get_
+tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get_
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -13156,7 +13248,7 @@ tng_function_status tng_chain_name_of_particle_nr_get_
return(tng_chain_name_of_particle_nr_get(tng_data, nr, name, max_len));
}
-tng_function_status tng_residue_name_of_particle_nr_get_
+tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get_
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -13165,7 +13257,7 @@ tng_function_status tng_residue_name_of_particle_nr_get_
return(tng_residue_name_of_particle_nr_get(tng_data, nr, name, max_len));
}
-tng_function_status tng_atom_name_of_particle_nr_get_
+tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get_
(const tng_trajectory_t tng_data,
const int64_t nr,
char *name,
@@ -13174,7 +13266,7 @@ tng_function_status tng_atom_name_of_particle_nr_get_
return(tng_atom_name_of_particle_nr_get(tng_data, nr, name, max_len));
}
-tng_function_status tng_atom_type_of_particle_nr_get_
+tng_function_status DECLSPECDLLEXPORT tng_atom_type_of_particle_nr_get_
(const tng_trajectory_t tng_data,
const int64_t nr,
char *type,
@@ -13183,7 +13275,7 @@ tng_function_status tng_atom_type_of_particle_nr_get_
return(tng_atom_type_of_particle_nr_get(tng_data, nr, type, max_len));
}
-tng_function_status tng_particle_mapping_add_
+tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add_
(tng_trajectory_t tng_data,
const int64_t *first_particle_number,
const int64_t *n_particles,
@@ -13193,55 +13285,59 @@ tng_function_status tng_particle_mapping_add_
*n_particles, mapping_table));
}
-tng_function_status tng_file_headers_read_(tng_trajectory_t tng_data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_file_headers_read_(tng_trajectory_t tng_data,
+ const tng_hash_mode *hash_mode)
{
return(tng_file_headers_read(tng_data, *hash_mode));
}
-tng_function_status tng_file_headers_write_(tng_trajectory_t tng_data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_file_headers_write_
+ (tng_trajectory_t tng_data,
+ const tng_hash_mode *hash_mode)
{
return(tng_file_headers_write(tng_data, *hash_mode));
}
-tng_function_status tng_block_read_next_(tng_trajectory_t tng_data,
- tng_gen_block_t block_data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_block_read_next_
+ (tng_trajectory_t tng_data,
+ tng_gen_block_t block_data,
+ const tng_hash_mode *hash_mode)
{
return(tng_block_read_next(tng_data, block_data, *hash_mode));
}
-tng_function_status tng_frame_set_read_next_(tng_trajectory_t tng_data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_
+ (tng_trajectory_t tng_data,
+ const tng_hash_mode *hash_mode)
{
return(tng_frame_set_read_next(tng_data, *hash_mode));
}
-tng_function_status tng_frame_set_write_(tng_trajectory_t tng_data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_write_(tng_trajectory_t tng_data,
+ const tng_hash_mode *hash_mode)
{
return(tng_frame_set_write(tng_data, *hash_mode));
}
-tng_function_status tng_frame_set_new_(tng_trajectory_t tng_data,
- const int64_t *first_frame,
- const int64_t *n_frames)
+tng_function_status DECLSPECDLLEXPORT tng_frame_set_new_(tng_trajectory_t tng_data,
+ const int64_t *first_frame,
+ const int64_t *n_frames)
{
return(tng_frame_set_new(tng_data, *first_frame, *n_frames));
}
-tng_function_status tng_data_block_add_(tng_trajectory_t tng_data,
- const int64_t *id,
- const char *block_name,
- const tng_data_type *datatype,
- const tng_block_type *block_type_flag,
- int64_t *n_frames,
- const int64_t *n_values_per_frame,
- const int64_t *stride_length,
- const int64_t *codec_id,
- void *new_data,
- int name_len)
+tng_function_status DECLSPECDLLEXPORT tng_data_block_add_
+ (tng_trajectory_t tng_data,
+ const int64_t *id,
+ const char *block_name,
+ const tng_data_type *datatype,
+ const tng_block_type *block_type_flag,
+ int64_t *n_frames,
+ const int64_t *n_values_per_frame,
+ const int64_t *stride_length,
+ const int64_t *codec_id,
+ void *new_data,
+ int name_len)
{
char *name = malloc(name_len + 1);
tng_function_status stat;
@@ -13255,7 +13351,7 @@ tng_function_status tng_data_block_add_(tng_trajectory_t tng_data,
return(stat);
}
-tng_function_status tng_particle_data_block_add_
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add_
(tng_trajectory_t tng_data,
const int64_t *id,
const char *block_name,
@@ -13284,96 +13380,104 @@ tng_function_status tng_particle_data_block_add_
return(stat);
}
-tng_function_status tng_frame_data_write_(tng_trajectory_t tng_data,
- const int64_t *frame_nr,
- const int64_t *block_id,
- const void *data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_frame_data_write_
+ (tng_trajectory_t tng_data,
+ const int64_t *frame_nr,
+ const int64_t *block_id,
+ const void *data,
+ const tng_hash_mode *hash_mode)
{
return(tng_frame_data_write(tng_data, *frame_nr, *block_id, data,
*hash_mode));
}
-tng_function_status tng_frame_particle_data_write_(tng_trajectory_t tng_data,
- const int64_t *frame_nr,
- const int64_t *block_id,
- const int64_t *val_first_particle,
- const int64_t *val_n_particles,
- const void *data,
- const tng_hash_mode *hash_mode)
+tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write_
+ (tng_trajectory_t tng_data,
+ const int64_t *frame_nr,
+ const int64_t *block_id,
+ const int64_t *val_first_particle,
+ const int64_t *val_n_particles,
+ const void *data,
+ const tng_hash_mode *hash_mode)
{
return(tng_frame_particle_data_write(tng_data, *frame_nr, *block_id,
*val_first_particle, *val_n_particles,
data, *hash_mode));
}
-tng_function_status tng_data_values_free_(const tng_trajectory_t tng_data,
- union data_values **values,
- const int64_t *n_frames,
- const int64_t *n_values_per_frame,
- const tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_data_values_free_
+ (const tng_trajectory_t tng_data,
+ union data_values **values,
+ const int64_t *n_frames,
+ const int64_t *n_values_per_frame,
+ const tng_data_type *type)
{
return(tng_data_values_free(tng_data, values, *n_frames,
*n_values_per_frame, *type));
}
-tng_function_status tng_particle_data_values_free_(const tng_trajectory_t tng_data,
- union data_values ***values,
- const int64_t *n_frames,
- const int64_t *n_particles,
- const int64_t *n_values_per_frame,
- const tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free_
+ (const tng_trajectory_t tng_data,
+ union data_values ***values,
+ const int64_t *n_frames,
+ const int64_t *n_particles,
+ const int64_t *n_values_per_frame,
+ const tng_data_type *type)
{
return(tng_particle_data_values_free(tng_data, values, *n_frames, *n_particles,
*n_values_per_frame, *type));
}
-tng_function_status tng_data_get_(tng_trajectory_t tng_data,
- const int64_t *block_id,
- union data_values ***values,
- int64_t *n_frames,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_data_get_
+ (tng_trajectory_t tng_data,
+ const int64_t *block_id,
+ union data_values ***values,
+ int64_t *n_frames,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
return(tng_data_get(tng_data, *block_id, values, n_frames,
n_values_per_frame, type));
}
-tng_function_status tng_data_interval_get_(tng_trajectory_t tng_data,
- const int64_t *block_id,
- const int64_t *start_frame_nr,
- const int64_t *end_frame_nr,
- const tng_hash_mode *hash_mode,
- union data_values ***values,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_data_interval_get_
+ (tng_trajectory_t tng_data,
+ const int64_t *block_id,
+ const int64_t *start_frame_nr,
+ const int64_t *end_frame_nr,
+ const tng_hash_mode *hash_mode,
+ union data_values ***values,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
return(tng_data_interval_get(tng_data, *block_id, *start_frame_nr,
*end_frame_nr, *hash_mode, values,
n_values_per_frame, type));
}
-tng_function_status tng_particle_data_get_(tng_trajectory_t tng_data,
- const int64_t *block_id,
- union data_values ****values,
- int64_t *n_frames,
- int64_t *n_particles,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_get_
+ (tng_trajectory_t tng_data,
+ const int64_t *block_id,
+ union data_values ****values,
+ int64_t *n_frames,
+ int64_t *n_particles,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
return(tng_particle_data_get(tng_data, *block_id, values, n_frames,
n_particles, n_values_per_frame, type));
}
-tng_function_status tng_particle_data_interval_get_(tng_trajectory_t tng_data,
- const int64_t *block_id,
- const int64_t *start_frame_nr,
- const int64_t *end_frame_nr,
- const tng_hash_mode *hash_mode,
- union data_values ****values,
- int64_t *n_particles,
- int64_t *n_values_per_frame,
- tng_data_type *type)
+tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get_
+ (tng_trajectory_t tng_data,
+ const int64_t *block_id,
+ const int64_t *start_frame_nr,
+ const int64_t *end_frame_nr,
+ const tng_hash_mode *hash_mode,
+ union data_values ****values,
+ int64_t *n_particles,
+ int64_t *n_values_per_frame,
+ tng_data_type *type)
{
return(tng_particle_data_interval_get(tng_data, *block_id, *start_frame_nr,
*end_frame_nr, *hash_mode, values,
@@ -13381,8 +13485,9 @@ tng_function_status tng_particle_data_interval_get_(tng_trajectory_t tng_data,
type));
}
-tng_function_status tng_time_get_str_(const tng_trajectory_t tng_data,
- char *time, int64_t str_len)
+tng_function_status DECLSPECDLLEXPORT tng_time_get_str_
+ (const tng_trajectory_t tng_data,
+ char *time, int64_t str_len)
{
return(tng_time_get_str(tng_data, time));
}
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 6320769..303035e 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -12,7 +12,10 @@ configure_file(${TRAJECTORY_SOURCE_DIR}/include/tng_io_testing.h.in ${CMAKE_BINA
include_directories(${CMAKE_BINARY_DIR}/generated/)
add_executable(tng_testing tng_io_testing.c)
-target_link_libraries(tng_testing tng_io m)
+target_link_libraries(tng_testing tng_io)
+if(UNIX)
+target_link_libraries(tng_testing m)
+endif()
if(HAVE_INTTYPES_H)
set_target_properties(tng_testing PROPERTIES COMPILE_DEFINITIONS USE_STD_INTTYPES_H=1)
@@ -20,14 +23,23 @@ endif()
if(OPENMP_FOUND)
add_executable(md_openmp md_openmp.c)
- target_link_libraries(md_openmp tng_io ${OpenMP_LIBS} m)
+ target_link_libraries(md_openmp tng_io ${OpenMP_LIBS})
+ if(UNIX)
+ target_link_libraries(md_openmp m)
+ endif()
endif()
add_executable(tng_io_read_pos tng_io_read_pos.c)
-target_link_libraries(tng_io_read_pos tng_io m)
+target_link_libraries(tng_io_read_pos tng_io)
+if(UNIX)
+target_link_libraries(tng_io_read_pos m)
+endif()
add_executable(tng_parallel_read tng_parallel_read.c)
-target_link_libraries(tng_parallel_read tng_io m)
+target_link_libraries(tng_parallel_read tng_io)
+if(UNIX)
+target_link_libraries(tng_parallel_read m)
+endif()
if(BUILD_FORTRAN)
# This does not work due to a bug in CMake. Remove lines below if no fortran compiler is found.
diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt
index e69de29..930bcfc 100644
--- a/src/tests/compression/CMakeLists.txt
+++ b/src/tests/compression/CMakeLists.txt
@@ -0,0 +1,46 @@
+link_directories(${TRAJECTORY_BINARY_DIR}/src/lib)
+
+set(TNG_COMPRESS_FILES_DIR ${CMAKE_BINARY_DIR}/test_tng_compress_files/ CACHE STRING "Directory where to write tng_compress test files.")
+
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test_tng_compress_files)
+configure_file(${TRAJECTORY_SOURCE_DIR}/include/compression/tng_compress_testing.h.in ${CMAKE_BINARY_DIR}/generated/tng_compress_testing.h)
+
+include_directories(${CMAKE_SOURCE_DIR}/include/compression)
+include_directories(${CMAKE_BINARY_DIR}/generated/)
+
+set(number 0)
+set(numtests 64)
+
+while( number LESS ${numtests})
+
+math( EXPR number "${number} + 1" )
+
+add_executable(test_tng_compress_gen${number} testsuite.c)
+target_link_libraries(test_tng_compress_gen${number} tng_compress)
+if(UNIX)
+target_link_libraries(test_tng_compress_gen${number} m)
+endif()
+list(APPEND gen${number}_build_definitions GEN)
+list(APPEND gen${number}_build_definitions TESTPARAM="test${number}.h")
+set_target_properties(test_tng_compress_gen${number} PROPERTIES COMPILE_DEFINITIONS "${gen${number}_build_definitions}")
+add_dependencies(test_tng_compress_gen${number} test${number}.h)
+
+add_executable(test_tng_compress_read${number} testsuite.c)
+target_link_libraries(test_tng_compress_read${number} tng_compress)
+if(UNIX)
+target_link_libraries(test_tng_compress_read${number} m)
+endif()
+list(APPEND read${number}_build_definitions TESTPARAM="test${number}.h")
+set_target_properties(test_tng_compress_read${number} PROPERTIES COMPILE_DEFINITIONS "${read${number}_build_definitions}")
+add_dependencies(test_tng_compress_read${number} test${number}.h)
+
+endwhile()
+
+if(UNIX)
+file(COPY test_tng_compress_write.sh DESTINATION ${CMAKE_BINARY_DIR}/bin)
+file(COPY test_tng_compress_read.sh DESTINATION ${CMAKE_BINARY_DIR}/bin)
+endif()
+if(WIN32)
+file(COPY test_tng_compress_write.bat DESTINATION ${CMAKE_BINARY_DIR}/bin)
+file(COPY test_tng_compress_read.bat DESTINATION ${CMAKE_BINARY_DIR}/bin)
+endif()
diff --git a/src/tests/compression/test1.h b/src/tests/compression/test1.h
index ad802e0..b45abc4 100644
--- a/src/tests/compression/test1.h
+++ b/src/tests/compression/test1.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Intra frame triple algorithm. Cubic cell."
-#define FILENAME "test1.tng"
+#define FILENAME "test1.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test10.h b/src/tests/compression/test10.h
index 471dcab..d5135eb 100644
--- a/src/tests/compression/test10.h
+++ b/src/tests/compression/test10.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. Triple intraframe algorithm. Cubic cell."
-#define FILENAME "test10.tng"
+#define FILENAME "test10.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test11.h b/src/tests/compression/test11.h
index b9d7039..596d63c 100644
--- a/src/tests/compression/test11.h
+++ b/src/tests/compression/test11.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. Triple one-to-one algorithm. Cubic cell."
-#define FILENAME "test11.tng"
+#define FILENAME "test11.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test12.h b/src/tests/compression/test12.h
index 5d692d8..43eb15d 100644
--- a/src/tests/compression/test12.h
+++ b/src/tests/compression/test12.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. BWLZH interframe algorithm. Cubic cell."
-#define FILENAME "test12.tng"
+#define FILENAME "test12.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test13.h b/src/tests/compression/test13.h
index b650f91..72aa99e 100644
--- a/src/tests/compression/test13.h
+++ b/src/tests/compression/test13.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. BWLZH intraframe algorithm. Cubic cell."
-#define FILENAME "test13.tng"
+#define FILENAME "test13.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test14.h b/src/tests/compression/test14.h
index 0db6853..382c70e 100644
--- a/src/tests/compression/test14.h
+++ b/src/tests/compression/test14.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. XTC3 algorithm. Cubic cell."
-#define FILENAME "test14.tng"
+#define FILENAME "test14.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test15.h b/src/tests/compression/test15.h
index 35f94ba..c593bf5 100644
--- a/src/tests/compression/test15.h
+++ b/src/tests/compression/test15.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Automatic selection of algorithms. Cubic cell."
-#define FILENAME "test15.tng"
+#define FILENAME "test15.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test16.h b/src/tests/compression/test16.h
index 5f972cb..a29c5e5 100644
--- a/src/tests/compression/test16.h
+++ b/src/tests/compression/test16.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. Automatic selection of algorithms. Cubic cell."
-#define FILENAME "test16.tng"
+#define FILENAME "test16.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test17.h b/src/tests/compression/test17.h
index 226e34c..9787976 100644
--- a/src/tests/compression/test17.h
+++ b/src/tests/compression/test17.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding of velocities. Stopbits one-to-one . Cubic cell."
-#define FILENAME "test17.tng"
+#define FILENAME "test17.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test18.h b/src/tests/compression/test18.h
index 1248a6d..5a329ad 100644
--- a/src/tests/compression/test18.h
+++ b/src/tests/compression/test18.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding of velocities. Triplet one-to-one. Cubic cell."
-#define FILENAME "test18.tng"
+#define FILENAME "test18.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test19.h b/src/tests/compression/test19.h
index ac09bc2..b298309 100644
--- a/src/tests/compression/test19.h
+++ b/src/tests/compression/test19.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding of velocities. BWLZH one-to-one. Cubic cell."
-#define FILENAME "test19.tng"
+#define FILENAME "test19.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test2.h b/src/tests/compression/test2.h
index f2a0f9a..0e2c3b0 100644
--- a/src/tests/compression/test2.h
+++ b/src/tests/compression/test2.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. XTC2 algorithm. Cubic cell."
-#define FILENAME "test2.tng"
+#define FILENAME "test2.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test20.h b/src/tests/compression/test20.h
index 7df8f09..4a45135 100644
--- a/src/tests/compression/test20.h
+++ b/src/tests/compression/test20.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding of velocities. Stopbit one-to-one. Cubic cell."
-#define FILENAME "test20.tng"
+#define FILENAME "test20.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test21.h b/src/tests/compression/test21.h
index 2ea2353..773c1da 100644
--- a/src/tests/compression/test21.h
+++ b/src/tests/compression/test21.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding of velocities. Triplet inter. Cubic cell."
-#define FILENAME "test21.tng"
+#define FILENAME "test21.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test22.h b/src/tests/compression/test22.h
index 8b16428..1d8cfa9 100644
--- a/src/tests/compression/test22.h
+++ b/src/tests/compression/test22.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding of velocities. Triplet one-to-one. Cubic cell."
-#define FILENAME "test22.tng"
+#define FILENAME "test22.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test23.h b/src/tests/compression/test23.h
index 85025d6..950f7ee 100644
--- a/src/tests/compression/test23.h
+++ b/src/tests/compression/test23.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding of velocities. Stopbit interframe. Cubic cell."
-#define FILENAME "test23.tng"
+#define FILENAME "test23.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test24.h b/src/tests/compression/test24.h
index dae943c..4b20897 100644
--- a/src/tests/compression/test24.h
+++ b/src/tests/compression/test24.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding of velocities. BWLZH interframe. Cubic cell."
-#define FILENAME "test24.tng"
+#define FILENAME "test24.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 25
diff --git a/src/tests/compression/test25.h b/src/tests/compression/test25.h
index 6145cb9..37d777a 100644
--- a/src/tests/compression/test25.h
+++ b/src/tests/compression/test25.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding of velocities. BWLZH one-to-one. Cubic cell."
-#define FILENAME "test25.tng"
+#define FILENAME "test25.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 25
diff --git a/src/tests/compression/test26.h b/src/tests/compression/test26.h
index 74523ad..2c3b304 100644
--- a/src/tests/compression/test26.h
+++ b/src/tests/compression/test26.h
@@ -1,5 +1,5 @@
#define TESTNAME "XTC2 algorithm. Orthorhombic cell."
-#define FILENAME "test26.tng"
+#define FILENAME "test26.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test27.h b/src/tests/compression/test27.h
index 30aea07..af7c9ff 100644
--- a/src/tests/compression/test27.h
+++ b/src/tests/compression/test27.h
@@ -1,5 +1,5 @@
#define TESTNAME "XTC3 algorithm. Orthorhombic cell."
-#define FILENAME "test27.tng"
+#define FILENAME "test27.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test28.h b/src/tests/compression/test28.h
index 995b81c..99a70fc 100644
--- a/src/tests/compression/test28.h
+++ b/src/tests/compression/test28.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Autoselect algorithm. Repetitive molecule. Cubic cell."
-#define FILENAME "test28.tng"
+#define FILENAME "test28.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test29.h b/src/tests/compression/test29.h
index f48f909..be6a8bf 100644
--- a/src/tests/compression/test29.h
+++ b/src/tests/compression/test29.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Autoselect algorithm. Repetitive molecule. Cubic cell."
-#define FILENAME "test29.tng"
+#define FILENAME "test29.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test3.h b/src/tests/compression/test3.h
index c4bbebd..768a208 100644
--- a/src/tests/compression/test3.h
+++ b/src/tests/compression/test3.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Triplet one-to-one algorithm. Cubic cell."
-#define FILENAME "test3.tng"
+#define FILENAME "test3.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test30.h b/src/tests/compression/test30.h
index 2ea607b..b719c7b 100644
--- a/src/tests/compression/test30.h
+++ b/src/tests/compression/test30.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Intra frame triple algorithm. Large system. Cubic cell."
-#define FILENAME "test30.tng"
+#define FILENAME "test30.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 1
diff --git a/src/tests/compression/test31.h b/src/tests/compression/test31.h
index d5d86d4..c0763e8 100644
--- a/src/tests/compression/test31.h
+++ b/src/tests/compression/test31.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. XTC2 algorithm. Large system. Cubic cell."
-#define FILENAME "test31.tng"
+#define FILENAME "test31.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 1
diff --git a/src/tests/compression/test32.h b/src/tests/compression/test32.h
index 7b66438..5f2e2f9 100644
--- a/src/tests/compression/test32.h
+++ b/src/tests/compression/test32.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. XTC3 algorithm. Large system. Cubic cell."
-#define FILENAME "test32.tng"
+#define FILENAME "test32.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 1
diff --git a/src/tests/compression/test33.h b/src/tests/compression/test33.h
index 9463eeb..3d08a65 100644
--- a/src/tests/compression/test33.h
+++ b/src/tests/compression/test33.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Intra frame BWLZH algorithm. Large system. Cubic cell."
-#define FILENAME "test33.tng"
+#define FILENAME "test33.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 1
diff --git a/src/tests/compression/test34.h b/src/tests/compression/test34.h
index 14fe88f..4242c18 100644
--- a/src/tests/compression/test34.h
+++ b/src/tests/compression/test34.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Stop bits algorithm. Large system. Cubic cell."
-#define FILENAME "test34.tng"
+#define FILENAME "test34.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test35.h b/src/tests/compression/test35.h
index 44af4c4..8f742b7 100644
--- a/src/tests/compression/test35.h
+++ b/src/tests/compression/test35.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Inter frame triple algorithm. Large system. Cubic cell."
-#define FILENAME "test35.tng"
+#define FILENAME "test35.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test36.h b/src/tests/compression/test36.h
index 56f5dcd..fba6feb 100644
--- a/src/tests/compression/test36.h
+++ b/src/tests/compression/test36.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Intra frame triple algorithm. Large system. Cubic cell."
-#define FILENAME "test36.tng"
+#define FILENAME "test36.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test37.h b/src/tests/compression/test37.h
index 68b4872..d2722bf 100644
--- a/src/tests/compression/test37.h
+++ b/src/tests/compression/test37.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. XTC2 algorithm. Large system. Cubic cell."
-#define FILENAME "test37.tng"
+#define FILENAME "test37.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test38.h b/src/tests/compression/test38.h
index 7e43348..26a6740 100644
--- a/src/tests/compression/test38.h
+++ b/src/tests/compression/test38.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. XTC3 algorithm. Large system. Cubic cell."
-#define FILENAME "test38.tng"
+#define FILENAME "test38.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test39.h b/src/tests/compression/test39.h
index bb3ecc0..db09a18 100644
--- a/src/tests/compression/test39.h
+++ b/src/tests/compression/test39.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Intra frame BWLZH algorithm. Large system. Cubic cell."
-#define FILENAME "test39.tng"
+#define FILENAME "test39.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test4.h b/src/tests/compression/test4.h
index 63ec9da..dfda25d 100644
--- a/src/tests/compression/test4.h
+++ b/src/tests/compression/test4.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. BWLZH one-to-one algorithm. Cubic cell."
-#define FILENAME "test4.tng"
+#define FILENAME "test4.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test40.h b/src/tests/compression/test40.h
index 5eb9c0d..c7511e5 100644
--- a/src/tests/compression/test40.h
+++ b/src/tests/compression/test40.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Inter frame BWLZH algorithm. Large system. Cubic cell."
-#define FILENAME "test40.tng"
+#define FILENAME "test40.tng_compress"
#define ALGOTEST
#define NATOMS 5000000
#define CHUNKY 2
diff --git a/src/tests/compression/test41.h b/src/tests/compression/test41.h
index f673944..dab390c 100644
--- a/src/tests/compression/test41.h
+++ b/src/tests/compression/test41.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Intra frame triple algorithm. High accuracy. Cubic cell."
-#define FILENAME "test41.tng"
+#define FILENAME "test41.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 1
diff --git a/src/tests/compression/test42.h b/src/tests/compression/test42.h
index b40f963..4452924 100644
--- a/src/tests/compression/test42.h
+++ b/src/tests/compression/test42.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. XTC2 algorithm. High accuracy. Cubic cell."
-#define FILENAME "test42.tng"
+#define FILENAME "test42.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 1
diff --git a/src/tests/compression/test43.h b/src/tests/compression/test43.h
index 38a59db..915d58e 100644
--- a/src/tests/compression/test43.h
+++ b/src/tests/compression/test43.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. XTC3 algorithm. High accuracy. Cubic cell."
-#define FILENAME "test43.tng"
+#define FILENAME "test43.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 1
diff --git a/src/tests/compression/test44.h b/src/tests/compression/test44.h
index 0bab871..f749cce 100644
--- a/src/tests/compression/test44.h
+++ b/src/tests/compression/test44.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. Intra frame BWLZH algorithm. High accuracy. Cubic cell."
-#define FILENAME "test44.tng"
+#define FILENAME "test44.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 1
diff --git a/src/tests/compression/test45.h b/src/tests/compression/test45.h
index 095efed..e558083 100644
--- a/src/tests/compression/test45.h
+++ b/src/tests/compression/test45.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Stop bits algorithm. High accuracy. Cubic cell."
-#define FILENAME "test45.tng"
+#define FILENAME "test45.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test46.h b/src/tests/compression/test46.h
index dc0b8bb..dde45ab 100644
--- a/src/tests/compression/test46.h
+++ b/src/tests/compression/test46.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Inter frame triple algorithm. High accuracy. Cubic cell."
-#define FILENAME "test46.tng"
+#define FILENAME "test46.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test47.h b/src/tests/compression/test47.h
index 5a5182d..a668946 100644
--- a/src/tests/compression/test47.h
+++ b/src/tests/compression/test47.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Intra frame triple algorithm. High accuracy. Cubic cell."
-#define FILENAME "test47.tng"
+#define FILENAME "test47.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test48.h b/src/tests/compression/test48.h
index 1562779..3b2be95 100644
--- a/src/tests/compression/test48.h
+++ b/src/tests/compression/test48.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. XTC2 algorithm. High accuracy. Cubic cell."
-#define FILENAME "test48.tng"
+#define FILENAME "test48.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test49.h b/src/tests/compression/test49.h
index dcad4ec..6c618a0 100644
--- a/src/tests/compression/test49.h
+++ b/src/tests/compression/test49.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. XTC3 algorithm. High accuracy. Cubic cell."
-#define FILENAME "test49.tng"
+#define FILENAME "test49.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test5.h b/src/tests/compression/test5.h
index a933044..4c6a638 100644
--- a/src/tests/compression/test5.h
+++ b/src/tests/compression/test5.h
@@ -1,5 +1,5 @@
#define TESTNAME "Initial coding. XTC3 algorithm. Cubic cell."
-#define FILENAME "test5.tng"
+#define FILENAME "test5.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 1
diff --git a/src/tests/compression/test50.h b/src/tests/compression/test50.h
index a00e209..130f1b9 100644
--- a/src/tests/compression/test50.h
+++ b/src/tests/compression/test50.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Intra frame BWLZH algorithm. High accuracy. Cubic cell."
-#define FILENAME "test50.tng"
+#define FILENAME "test50.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test51.h b/src/tests/compression/test51.h
index 4641b61..c3a57bf 100644
--- a/src/tests/compression/test51.h
+++ b/src/tests/compression/test51.h
@@ -1,5 +1,5 @@
#define TESTNAME "Position coding. Inter frame BWLZH algorithm. High accuracy. Cubic cell."
-#define FILENAME "test51.tng"
+#define FILENAME "test51.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test52.h b/src/tests/compression/test52.h
index 2f49a8b..97f37c7 100644
--- a/src/tests/compression/test52.h
+++ b/src/tests/compression/test52.h
@@ -1,5 +1,5 @@
#define TESTNAME "Velocity coding. Stop bits algorithm. High accuracy. Cubic cell."
-#define FILENAME "test52.tng"
+#define FILENAME "test52.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test53.h b/src/tests/compression/test53.h
index 679b680..583e0b2 100644
--- a/src/tests/compression/test53.h
+++ b/src/tests/compression/test53.h
@@ -1,5 +1,5 @@
#define TESTNAME "Velocity coding. Triple algorithm. High accuracy. Cubic cell."
-#define FILENAME "test53.tng"
+#define FILENAME "test53.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test54.h b/src/tests/compression/test54.h
index c2c2869..50b051f 100644
--- a/src/tests/compression/test54.h
+++ b/src/tests/compression/test54.h
@@ -1,5 +1,5 @@
#define TESTNAME "Velocity coding. Interframe triple algorithm. High accuracy. Cubic cell."
-#define FILENAME "test54.tng"
+#define FILENAME "test54.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test55.h b/src/tests/compression/test55.h
index a094d97..f8c98f9 100644
--- a/src/tests/compression/test55.h
+++ b/src/tests/compression/test55.h
@@ -1,5 +1,5 @@
#define TESTNAME "Velocity coding. Interframe stop-bits algorithm. High accuracy. Cubic cell."
-#define FILENAME "test55.tng"
+#define FILENAME "test55.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test56.h b/src/tests/compression/test56.h
index 6655ad0..7fb9b23 100644
--- a/src/tests/compression/test56.h
+++ b/src/tests/compression/test56.h
@@ -1,5 +1,5 @@
#define TESTNAME "Velocity coding. Intraframe BWLZH algorithm. High accuracy. Cubic cell."
-#define FILENAME "test56.tng"
+#define FILENAME "test56.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test57.h b/src/tests/compression/test57.h
index 2788e98..5c626d8 100644
--- a/src/tests/compression/test57.h
+++ b/src/tests/compression/test57.h
@@ -1,5 +1,5 @@
#define TESTNAME "Velocity coding. Interframe BWLZH algorithm. High accuracy. Cubic cell."
-#define FILENAME "test57.tng"
+#define FILENAME "test57.tng_compress"
#define ALGOTEST
#define NATOMS 100000
#define CHUNKY 10
diff --git a/src/tests/compression/test58.h b/src/tests/compression/test58.h
new file mode 100644
index 0000000..9988106
--- /dev/null
+++ b/src/tests/compression/test58.h
@@ -0,0 +1,26 @@
+#define TESTNAME "Coding. Test float."
+#define FILENAME "test58.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 5
+#define INITIALCODINGPARAMETER 0
+#define CODING 5
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER -1
+#define VELCODING 3
+#define VELCODINGPARAMETER -1
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 1000
+#define TEST_FLOAT
+#define EXPECTED_FILESIZE 6986313.
diff --git a/src/tests/compression/test59.h b/src/tests/compression/test59.h
new file mode 100644
index 0000000..9817976
--- /dev/null
+++ b/src/tests/compression/test59.h
@@ -0,0 +1,28 @@
+#define TESTNAME "Coding. Test write float, read double."
+#define FILENAME "test59.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 5
+#define INITIALCODINGPARAMETER 0
+#define CODING 5
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER -1
+#define VELCODING 3
+#define VELCODINGPARAMETER -1
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 1000
+#ifdef GEN
+#define TEST_FLOAT
+#endif
+#define EXPECTED_FILESIZE 6986313.
diff --git a/src/tests/compression/test6.h b/src/tests/compression/test6.h
index cd3cfee..ecbc443 100644
--- a/src/tests/compression/test6.h
+++ b/src/tests/compression/test6.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. XTC2 algorithm. Cubic cell."
-#define FILENAME "test6.tng"
+#define FILENAME "test6.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test60.h b/src/tests/compression/test60.h
new file mode 100644
index 0000000..cf94e3b
--- /dev/null
+++ b/src/tests/compression/test60.h
@@ -0,0 +1,28 @@
+#define TESTNAME "Coding. Test write double, read float."
+#define FILENAME "test60.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 5
+#define INITIALCODINGPARAMETER 0
+#define CODING 5
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER -1
+#define VELCODING 3
+#define VELCODINGPARAMETER -1
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 1000
+#ifndef GEN
+#define TEST_FLOAT
+#endif
+#define EXPECTED_FILESIZE 6986313.
diff --git a/src/tests/compression/test61.h b/src/tests/compression/test61.h
new file mode 100644
index 0000000..373456d
--- /dev/null
+++ b/src/tests/compression/test61.h
@@ -0,0 +1,25 @@
+#define TESTNAME "Coding. Recompression test. Stage 1: Generate"
+#define FILENAME "test61.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 5
+#define INITIALCODINGPARAMETER 0
+#define CODING 5
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER -1
+#define VELCODING 3
+#define VELCODINGPARAMETER -1
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 100
+#define EXPECTED_FILESIZE 698801.
diff --git a/src/tests/compression/test62.h b/src/tests/compression/test62.h
new file mode 100644
index 0000000..c8a2b48
--- /dev/null
+++ b/src/tests/compression/test62.h
@@ -0,0 +1,26 @@
+#define TESTNAME "Coding. Recompression test. Stage 2: Recompress"
+#define FILENAME "test62.tng_compress"
+#define RECOMPRESS "test61.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 10
+#define INITIALCODINGPARAMETER 0
+#define CODING 10
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER 0
+#define VELCODING 8
+#define VELCODINGPARAMETER 0
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 100
+#define EXPECTED_FILESIZE 151226.
diff --git a/src/tests/compression/test63.h b/src/tests/compression/test63.h
new file mode 100644
index 0000000..65a4768
--- /dev/null
+++ b/src/tests/compression/test63.h
@@ -0,0 +1,26 @@
+#define TESTNAME "Coding. Read int and convert to double."
+#define FILENAME "test63.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 5
+#define INITIALCODINGPARAMETER 0
+#define CODING 5
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER -1
+#define VELCODING 3
+#define VELCODINGPARAMETER -1
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 100
+#define INTTODOUBLE
+#define EXPECTED_FILESIZE 698801.
diff --git a/src/tests/compression/test64.h b/src/tests/compression/test64.h
new file mode 100644
index 0000000..02f99b5
--- /dev/null
+++ b/src/tests/compression/test64.h
@@ -0,0 +1,27 @@
+#define TESTNAME "Coding. Read int and convert to float."
+#define FILENAME "test64.tng_compress"
+#define ALGOTEST
+#define NATOMS 1000
+#define CHUNKY 100
+#define SCALE 0.1
+#define PRECISION 0.01
+#define WRITEVEL 1
+#define VELPRECISION 0.1
+#define INITIALCODING 5
+#define INITIALCODINGPARAMETER 0
+#define CODING 5
+#define CODINGPARAMETER 0
+#define INITIALVELCODING 3
+#define INITIALVELCODINGPARAMETER -1
+#define VELCODING 3
+#define VELCODINGPARAMETER -1
+#define INTMIN1 0
+#define INTMIN2 0
+#define INTMIN3 0
+#define INTMAX1 10000
+#define INTMAX2 10000
+#define INTMAX3 10000
+#define NFRAMES 100
+#define INTTOFLOAT
+#define TEST_FLOAT
+#define EXPECTED_FILESIZE 698801.
diff --git a/src/tests/compression/test7.h b/src/tests/compression/test7.h
index 90a2657..d0e3532 100644
--- a/src/tests/compression/test7.h
+++ b/src/tests/compression/test7.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. Stopbit interframe algorithm. Cubic cell."
-#define FILENAME "test7.tng"
+#define FILENAME "test7.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test8.h b/src/tests/compression/test8.h
index 5a21053..2ce103c 100644
--- a/src/tests/compression/test8.h
+++ b/src/tests/compression/test8.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. Stopbit interframe algorithm with intraframe compression as initial. Cubic cell."
-#define FILENAME "test8.tng"
+#define FILENAME "test8.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test9.h b/src/tests/compression/test9.h
index 1247beb..f0672e2 100644
--- a/src/tests/compression/test9.h
+++ b/src/tests/compression/test9.h
@@ -1,5 +1,5 @@
#define TESTNAME "Coding. Triple interframe algorithm. Cubic cell."
-#define FILENAME "test9.tng"
+#define FILENAME "test9.tng_compress"
#define ALGOTEST
#define NATOMS 1000
#define CHUNKY 100
diff --git a/src/tests/compression/test_tng_compress_read.bat b/src/tests/compression/test_tng_compress_read.bat
new file mode 100644
index 0000000..8bedeb4
--- /dev/null
+++ b/src/tests/compression/test_tng_compress_read.bat
@@ -0,0 +1,13 @@
+@echo off
+setlocal enableextensions enabledelayedexpansion
+SET /A I=0
+:start
+SET /A I+=1
+test_tng_compress_read%I%
+IF "%I%" == "64" (
+ GOTO end
+) ELSE (
+ GOTO start
+)
+:end
+endlocal
diff --git a/src/tests/compression/test_tng_compress_read.sh b/src/tests/compression/test_tng_compress_read.sh
new file mode 100755
index 0000000..2d7a044
--- /dev/null
+++ b/src/tests/compression/test_tng_compress_read.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+numtests=64
+for x in $(seq 1 $numtests); do
+ ./test_tng_compress_read$x
+done \ No newline at end of file
diff --git a/src/tests/compression/test_tng_compress_write.bat b/src/tests/compression/test_tng_compress_write.bat
new file mode 100644
index 0000000..7542fc8
--- /dev/null
+++ b/src/tests/compression/test_tng_compress_write.bat
@@ -0,0 +1,13 @@
+@echo off
+setlocal enableextensions enabledelayedexpansion
+SET /A I=0
+:start
+SET /A I+=1
+test_tng_compress_gen%I%
+IF "%I%" == "64" (
+ GOTO end
+) ELSE (
+ GOTO start
+)
+:end
+endlocal
diff --git a/src/tests/compression/test_tng_compress_write.sh b/src/tests/compression/test_tng_compress_write.sh
new file mode 100755
index 0000000..1a5700b
--- /dev/null
+++ b/src/tests/compression/test_tng_compress_write.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+numtests=64
+for x in $(seq 1 $numtests); do
+ ./test_tng_compress_gen$x
+done \ No newline at end of file
diff --git a/src/tests/compression/testsuite.c b/src/tests/compression/testsuite.c
index 1c5b613..27450d6 100644
--- a/src/tests/compression/testsuite.c
+++ b/src/tests/compression/testsuite.c
@@ -9,9 +9,19 @@
#include <string.h>
#include <math.h>
#include <tng_compress.h>
-#include <warnmalloc.h>
+#include "tng_compress_testing.h"
#include TESTPARAM
+#ifdef TEST_FLOAT
+#define REAL float
+#else
+#define REAL double
+#endif
+
+#ifndef TNG_COMPRESS_FILES_DIR
+#define TNG_COMPRESS_FILES_DIR ""
+#endif
+
#define FUDGE 1.1 /* 10% off target precision is acceptable */
static void keepinbox(int *val)
@@ -201,39 +211,39 @@ static void genivelbox(int *intvelbox, int iframe)
#define GENVELPRECISION VELPRECISION
#endif
-static void realbox(int *intbox, double *realbox, int stride)
+static void realbox(int *intbox, REAL *realbox, int stride)
{
int i,j;
for (i=0; i<NATOMS; i++)
{
for (j=0; j<3; j++)
- realbox[i*stride+j]=(double)(intbox[i*3+j]*GENPRECISION*SCALE);
+ realbox[i*stride+j]=(REAL)(intbox[i*3+j]*GENPRECISION*SCALE);
for (j=3; j<stride; j++)
realbox[i*stride+j]=0.;
}
}
-static void realvelbox(int *intbox, double *realbox, int stride)
+static void realvelbox(int *intbox, REAL *realbox, int stride)
{
int i,j;
for (i=0; i<NATOMS; i++)
{
for (j=0; j<3; j++)
- realbox[i*stride+j]=(double)(intbox[i*3+j]*GENVELPRECISION*SCALE);
+ realbox[i*stride+j]=(REAL)(intbox[i*3+j]*GENVELPRECISION*SCALE);
for (j=3; j<stride; j++)
realbox[i*stride+j]=0.;
}
}
-static int equalarr(double *arr1, double *arr2, double prec, int len, int itemlen, int stride1, int stride2)
+static int equalarr(REAL *arr1, REAL *arr2, REAL prec, int len, int itemlen, int stride1, int stride2)
{
- double maxdiff=0.;
+ REAL maxdiff=0.;
int i,j;
for (i=0; i<len; i++)
{
for (j=0; j<itemlen; j++)
if (fabs(arr1[i*stride1+j]-arr2[i*stride2+j])>maxdiff)
- maxdiff=(double)fabs(arr1[i*stride1+j]-arr2[i*stride2+j]);
+ maxdiff=(REAL)fabs(arr1[i*stride1+j]-arr2[i*stride2+j]);
}
#if 0
for (i=0; i<len; i++)
@@ -258,8 +268,8 @@ struct tng_file
FILE *f;
int natoms;
int chunky;
- double precision;
- double velprecision;
+ REAL precision;
+ REAL velprecision;
int initial_coding;
int initial_coding_parameter;
int coding;
@@ -272,8 +282,12 @@ struct tng_file
int nframes;
int nframes_delivered;
int writevel;
- double *pos;
- double *vel;
+ REAL *pos;
+ REAL *vel;
+ int *ipos;
+ int *ivel;
+ unsigned int prec_hi, prec_lo;
+ unsigned int velprec_hi, velprec_lo;
};
static size_t fwrite_int_le(int *x,FILE *f)
@@ -302,9 +316,9 @@ static size_t fread_int_le(int *x,FILE *f)
static struct tng_file *open_tng_file_write(char *filename,
int natoms,int chunky,
- double precision,
+ REAL precision,
int writevel,
- double velprecision,
+ REAL velprecision,
int initial_coding,
int initial_coding_parameter,
int coding,
@@ -318,6 +332,8 @@ static struct tng_file *open_tng_file_write(char *filename,
struct tng_file *tng_file=malloc(sizeof *tng_file);
tng_file->pos=NULL;
tng_file->vel=NULL;
+ tng_file->ipos=NULL;
+ tng_file->ivel=NULL;
tng_file->nframes=0;
tng_file->chunky=chunky;
tng_file->precision=precision;
@@ -341,7 +357,48 @@ static struct tng_file *open_tng_file_write(char *filename,
return tng_file;
}
-static void flush_tng_frames(struct tng_file *tng_file)
+static struct tng_file *open_tng_file_write_int(char *filename,
+ int natoms,int chunky,
+ int writevel,
+ int initial_coding,
+ int initial_coding_parameter,
+ int coding,
+ int coding_parameter,
+ int initial_velcoding,
+ int initial_velcoding_parameter,
+ int velcoding,
+ int velcoding_parameter,
+ int speed)
+{
+ struct tng_file *tng_file=malloc(sizeof *tng_file);
+ tng_file->pos=NULL;
+ tng_file->vel=NULL;
+ tng_file->ipos=NULL;
+ tng_file->ivel=NULL;
+ tng_file->nframes=0;
+ tng_file->chunky=chunky;
+ tng_file->natoms=natoms;
+ tng_file->writevel=writevel;
+ tng_file->initial_coding=initial_coding;
+ tng_file->initial_coding_parameter=initial_coding_parameter;
+ tng_file->coding=coding;
+ tng_file->coding_parameter=coding_parameter;
+ tng_file->initial_velcoding=initial_velcoding;
+ tng_file->initial_velcoding_parameter=initial_velcoding_parameter;
+ tng_file->velcoding=velcoding;
+ tng_file->velcoding_parameter=velcoding_parameter;
+ tng_file->speed=speed;
+ tng_file->ipos=malloc(natoms*chunky*3*sizeof *tng_file->ipos);
+ tng_file->f=fopen(filename,"wb");
+ if (writevel)
+ tng_file->ivel=malloc(natoms*chunky*3*sizeof *tng_file->ivel);
+ fwrite_int_le(&natoms,tng_file->f);
+ return tng_file;
+}
+
+static void flush_tng_frames(struct tng_file *tng_file,
+ unsigned long prec_hi, unsigned long prec_lo,
+ unsigned long velprec_hi, unsigned long velprec_lo)
{
int algo[4];
char *buf;
@@ -351,11 +408,27 @@ static void flush_tng_frames(struct tng_file *tng_file)
algo[1]=tng_file->initial_coding_parameter;
algo[2]=tng_file->coding;
algo[3]=tng_file->coding_parameter;
+#ifdef RECOMPRESS
+ buf=tng_compress_pos_int(tng_file->ipos,
+ tng_file->natoms,
+ tng_file->nframes,
+ prec_hi,prec_lo,
+ tng_file->speed,algo,&nitems);
+#else /* RECOMPRESS */
+#ifdef TEST_FLOAT
+ buf=tng_compress_pos_float(tng_file->pos,
+ tng_file->natoms,
+ tng_file->nframes,
+ tng_file->precision,
+ tng_file->speed,algo,&nitems);
+#else /* TEST_FLOAT */
buf=tng_compress_pos(tng_file->pos,
tng_file->natoms,
tng_file->nframes,
tng_file->precision,
tng_file->speed,algo,&nitems);
+#endif /* TEST_FLOAT */
+#endif /* RECOMPRESS */
tng_file->initial_coding=algo[0];
tng_file->initial_coding_parameter=algo[1];
tng_file->coding=algo[2];
@@ -369,11 +442,27 @@ static void flush_tng_frames(struct tng_file *tng_file)
algo[1]=tng_file->initial_velcoding_parameter;
algo[2]=tng_file->velcoding;
algo[3]=tng_file->velcoding_parameter;
+#ifdef RECOMPRESS
+ buf=tng_compress_vel_int(tng_file->ivel,
+ tng_file->natoms,
+ tng_file->nframes,
+ velprec_hi,velprec_lo,
+ tng_file->speed,algo,&nitems);
+#else /* RECOMPRESS */
+#ifdef TEST_FLOAT
+ buf=tng_compress_vel_float(tng_file->vel,
+ tng_file->natoms,
+ tng_file->nframes,
+ tng_file->velprecision,
+ tng_file->speed,algo,&nitems);
+#else /* TEST_FLOAT */
buf=tng_compress_vel(tng_file->vel,
tng_file->natoms,
tng_file->nframes,
tng_file->velprecision,
tng_file->speed,algo,&nitems);
+#endif /* TEST_FLOAT */
+#endif /* RECOMPRESS */
tng_file->initial_velcoding=algo[0];
tng_file->initial_velcoding_parameter=algo[1];
tng_file->velcoding=algo[2];
@@ -386,23 +475,42 @@ static void flush_tng_frames(struct tng_file *tng_file)
}
static void write_tng_file(struct tng_file *tng_file,
- double *pos,double *vel)
+ REAL *pos,REAL *vel)
{
memcpy(tng_file->pos+tng_file->nframes*tng_file->natoms*3,pos,tng_file->natoms*3*sizeof *tng_file->pos);
if (tng_file->writevel)
memcpy(tng_file->vel+tng_file->nframes*tng_file->natoms*3,vel,tng_file->natoms*3*sizeof *tng_file->vel);
tng_file->nframes++;
if (tng_file->nframes==tng_file->chunky)
- flush_tng_frames(tng_file);
+ flush_tng_frames(tng_file,0,0,0,0);
+}
+
+static void write_tng_file_int(struct tng_file *tng_file,
+ int *ipos,int *ivel,
+ unsigned long prec_hi, unsigned long prec_lo,
+ unsigned long velprec_hi, unsigned long velprec_lo)
+{
+ memcpy(tng_file->ipos+tng_file->nframes*tng_file->natoms*3,ipos,tng_file->natoms*3*sizeof *tng_file->ipos);
+ if (tng_file->writevel)
+ memcpy(tng_file->ivel+tng_file->nframes*tng_file->natoms*3,ivel,tng_file->natoms*3*sizeof *tng_file->ivel);
+ tng_file->nframes++;
+ if (tng_file->nframes==tng_file->chunky)
+ flush_tng_frames(tng_file,prec_hi,prec_lo,velprec_hi,velprec_lo);
+ tng_file->prec_hi=prec_hi;
+ tng_file->prec_lo=prec_lo;
+ tng_file->velprec_hi=velprec_hi;
+ tng_file->velprec_lo=velprec_lo;
}
static void close_tng_file_write(struct tng_file *tng_file)
{
if (tng_file->nframes)
- flush_tng_frames(tng_file);
+ flush_tng_frames(tng_file,tng_file->prec_hi,tng_file->prec_lo,tng_file->velprec_hi,tng_file->velprec_lo);
fclose(tng_file->f);
free(tng_file->pos);
free(tng_file->vel);
+ free(tng_file->ipos);
+ free(tng_file->ivel);
free(tng_file);
}
@@ -411,17 +519,46 @@ static struct tng_file *open_tng_file_read(char *filename, int writevel)
struct tng_file *tng_file=malloc(sizeof *tng_file);
tng_file->pos=NULL;
tng_file->vel=NULL;
+ tng_file->ipos=NULL;
+ tng_file->ivel=NULL;
+ tng_file->f=fopen(filename,"rb");
+ tng_file->nframes=0;
+ tng_file->nframes_delivered=0;
+ tng_file->writevel=writevel;
+ if (tng_file->f)
+ fread_int_le(&tng_file->natoms,tng_file->f);
+ else
+ {
+ free(tng_file);
+ tng_file=NULL;
+ }
+ return tng_file;
+}
+
+static struct tng_file *open_tng_file_read_int(char *filename, int writevel)
+{
+ struct tng_file *tng_file=malloc(sizeof *tng_file);
+ tng_file->pos=NULL;
+ tng_file->vel=NULL;
+ tng_file->ipos=NULL;
+ tng_file->ivel=NULL;
tng_file->f=fopen(filename,"rb");
tng_file->nframes=0;
tng_file->nframes_delivered=0;
tng_file->writevel=writevel;
- fread_int_le(&tng_file->natoms,tng_file->f);
+ if (tng_file->f)
+ fread_int_le(&tng_file->natoms,tng_file->f);
+ else
+ {
+ free(tng_file);
+ tng_file=NULL;
+ }
return tng_file;
}
static int read_tng_file(struct tng_file *tng_file,
- double *pos,
- double *vel)
+ REAL *pos,
+ REAL *vel)
{
if (tng_file->nframes==tng_file->nframes_delivered)
{
@@ -451,7 +588,11 @@ static int read_tng_file(struct tng_file *tng_file,
printf("ivel=%d natoms=%d nframes=%d precision=%g initial pos=%s pos=%s\n",ivel,natoms,nframes,precision,initial_coding,coding);
}
#endif
+#ifdef TEST_FLOAT
+ tng_compress_uncompress_float(buf,tng_file->pos);
+#else
tng_compress_uncompress(buf,tng_file->pos);
+#endif
free(buf);
if (tng_file->writevel)
{
@@ -472,7 +613,11 @@ static int read_tng_file(struct tng_file *tng_file,
printf("ivel=%d natoms=%d nframes=%d precision=%g initial vel=%s vel=%s\n",ivel,natoms,nframes,precision,initial_coding,coding);
}
#endif
+#ifdef TEST_FLOAT
+ tng_compress_uncompress_float(buf,tng_file->vel);
+#else
tng_compress_uncompress(buf,tng_file->vel);
+#endif
free(buf);
}
tng_file->nframes_delivered=0;
@@ -484,10 +629,55 @@ static int read_tng_file(struct tng_file *tng_file,
return 0;
}
+static int read_tng_file_int(struct tng_file *tng_file,
+ int *ipos,
+ int *ivel,
+ unsigned long *prec_hi, unsigned long *prec_lo,
+ unsigned long *velprec_hi, unsigned long *velprec_lo)
+{
+ if (tng_file->nframes==tng_file->nframes_delivered)
+ {
+ int nitems;
+ char *buf;
+ free(tng_file->ipos);
+ free(tng_file->ivel);
+ if (!fread_int_le(&tng_file->nframes,tng_file->f))
+ return 1;
+ if (!fread_int_le(&nitems,tng_file->f))
+ return 1;
+ buf=malloc(nitems);
+ if (!fread(buf,1,nitems,tng_file->f))
+ return 1;
+ tng_file->ipos=malloc(tng_file->natoms*tng_file->nframes*3*sizeof *tng_file->ipos);
+ if (tng_file->writevel)
+ tng_file->ivel=malloc(tng_file->natoms*tng_file->nframes*3*sizeof *tng_file->ivel);
+ tng_compress_uncompress_int(buf,tng_file->ipos,prec_hi,prec_lo);
+ free(buf);
+ if (tng_file->writevel)
+ {
+ if (!fread_int_le(&nitems,tng_file->f))
+ return 1;
+ buf=malloc(nitems);
+ if (!fread(buf,1,nitems,tng_file->f))
+ return 1;
+ tng_compress_uncompress_int(buf,tng_file->ivel,velprec_hi,velprec_lo);
+ free(buf);
+ }
+ tng_file->nframes_delivered=0;
+ }
+ memcpy(ipos,tng_file->ipos+tng_file->nframes_delivered*tng_file->natoms*3,tng_file->natoms*3*sizeof *ipos);
+ if (tng_file->writevel)
+ memcpy(ivel,tng_file->ivel+tng_file->nframes_delivered*tng_file->natoms*3,tng_file->natoms*3*sizeof *ivel);
+ tng_file->nframes_delivered++;
+ return 0;
+}
+
static void close_tng_file_read(struct tng_file *tng_file)
{
free(tng_file->vel);
free(tng_file->pos);
+ free(tng_file->ivel);
+ free(tng_file->ipos);
fclose(tng_file->f);
free(tng_file);
}
@@ -519,35 +709,51 @@ static void close_tng_file_read(struct tng_file *tng_file)
static int algotest()
{
int i;
- int *intbox=warnmalloc(NATOMS*3*sizeof *intbox);
- int *intvelbox=warnmalloc(NATOMS*3*sizeof *intvelbox);
- double *box1=warnmalloc(NATOMS*STRIDE1*sizeof *box1);
- double *velbox1=warnmalloc(NATOMS*STRIDE1*sizeof *velbox1);
- double time1, lambda1;
- double H1[9];
+ int *intbox=malloc(NATOMS*3*sizeof *intbox);
+ int *intvelbox=malloc(NATOMS*3*sizeof *intvelbox);
+#ifdef RECOMPRESS
+ unsigned long pos_prec_hi,pos_prec_lo;
+ unsigned long vel_prec_hi,vel_prec_lo;
+#endif
+ REAL *box1=malloc(NATOMS*STRIDE1*sizeof *box1);
+ REAL *velbox1=malloc(NATOMS*STRIDE1*sizeof *velbox1);
+ REAL time1, lambda1;
+ REAL H1[9];
int startframe=0;
int endframe=NFRAMES;
#ifdef GEN
FILE *file;
- double filesize;
+ REAL filesize;
#else
int i2;
int readreturn;
- double H2[9];
- double time2, lambda2;
- double *box2=warnmalloc(NATOMS*STRIDE2*sizeof *box2);
- double *velbox2=warnmalloc(NATOMS*STRIDE2*sizeof *velbox2);
+ REAL H2[9];
+ REAL time2, lambda2;
+ REAL *box2=malloc(NATOMS*STRIDE2*sizeof *box2);
+ REAL *velbox2=malloc(NATOMS*STRIDE2*sizeof *velbox2);
#endif
+#ifdef RECOMPRESS
+ void *dumpfile=open_tng_file_write_int(TNG_COMPRESS_FILES_DIR FILENAME,NATOMS,CHUNKY,
+ WRITEVEL,
+ INITIALCODING,
+ INITIALCODINGPARAMETER,CODING,CODINGPARAMETER,
+ INITIALVELCODING,INITIALVELCODINGPARAMETER,
+ VELCODING,VELCODINGPARAMETER,SPEED);
+ void *dumpfile_recompress=open_tng_file_read_int(TNG_COMPRESS_FILES_DIR RECOMPRESS,WRITEVEL);
+ if (!dumpfile_recompress)
+ return 1;
+#else /* RECOMPRESS */
#ifdef GEN
- void *dumpfile=open_tng_file_write(FILENAME,NATOMS,CHUNKY,
+ void *dumpfile=open_tng_file_write(TNG_COMPRESS_FILES_DIR FILENAME,NATOMS,CHUNKY,
PRECISION,WRITEVEL,VELPRECISION,
INITIALCODING,
INITIALCODINGPARAMETER,CODING,CODINGPARAMETER,
INITIALVELCODING,INITIALVELCODINGPARAMETER,
VELCODING,VELCODINGPARAMETER,SPEED);
#else
- void *dumpfile=open_tng_file_read(FILENAME,WRITEVEL);
+ void *dumpfile=open_tng_file_read(TNG_COMPRESS_FILES_DIR FILENAME,WRITEVEL);
#endif
+#endif /* RECOMPRESS */
if (!dumpfile)
return 1;
for (i=0; i<9; i++)
@@ -557,41 +763,82 @@ static int algotest()
H1[8]=INTMAX3*PRECISION*SCALE;
for (i=startframe; i<endframe; i++)
{
+#ifdef RECOMPRESS
+ unsigned long prec_hi, prec_lo;
+ unsigned long velprec_hi, velprec_lo;
+ if (read_tng_file_int(dumpfile_recompress,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo))
+ return 1;
+ write_tng_file_int(dumpfile,intbox,intvelbox,prec_hi,prec_lo,velprec_hi,velprec_lo);
+#else /* RECOMPRESS */
genibox(intbox,i);
realbox(intbox,box1,STRIDE1);
#if WRITEVEL
genivelbox(intvelbox,i);
realvelbox(intvelbox,velbox1,STRIDE1);
#endif
- time1=(double)i;
- lambda1=(double)(i+100);
+ time1=(REAL)i;
+ lambda1=(REAL)(i+100);
#ifdef GEN
write_tng_file(dumpfile,box1,velbox1);
-#else
+#else /* GEN */
+#ifdef INTTOFLOAT
+ {
+ unsigned long prec_hi, prec_lo;
+ unsigned long velprec_hi, velprec_lo;
+ readreturn=read_tng_file_int(dumpfile,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo);
+ if (!readreturn)
+ {
+ tng_compress_int_to_float(intbox,prec_hi,prec_lo,NATOMS,1,box2);
+#if WRITEVEL
+ tng_compress_int_to_float(intvelbox,velprec_hi,velprec_lo,NATOMS,1,velbox2);
+#endif
+ }
+ }
+#else /* INTTOFLOAT */
+#ifdef INTTODOUBLE
+ {
+ unsigned long prec_hi, prec_lo;
+ unsigned long velprec_hi, velprec_lo;
+ readreturn=read_tng_file_int(dumpfile,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo);
+ if (!readreturn)
+ {
+ tng_compress_int_to_double(intbox,prec_hi,prec_lo,NATOMS,1,box2);
+#if WRITEVEL
+ tng_compress_int_to_double(intvelbox,velprec_hi,velprec_lo,NATOMS,1,velbox2);
+#endif
+ }
+ }
+#else /* INTTODOUBLE */
readreturn=read_tng_file(dumpfile,box2,velbox2);
+#endif /* INTTODOUBLE */
+#endif /* INTTOFLOAT */
if (readreturn==1) /* general read error */
return 1;
-#endif
+#endif /* GEN */
#ifndef GEN
/* Check for equality of boxes. */
- if (!equalarr(box1,box2,(double)PRECISION,NATOMS,3,STRIDE1,STRIDE2))
+ if (!equalarr(box1,box2,(REAL)PRECISION,NATOMS,3,STRIDE1,STRIDE2))
return 4;
#if WRITEVEL
- if (!equalarr(velbox1,velbox2,(double)VELPRECISION,NATOMS,3,STRIDE1,STRIDE2))
+ if (!equalarr(velbox1,velbox2,(REAL)VELPRECISION,NATOMS,3,STRIDE1,STRIDE2))
return 5;
#endif
-#endif
+#endif /* GEN */
+#endif /* RECOMPRESS */
}
#ifdef GEN
close_tng_file_write(dumpfile);
#else
close_tng_file_read(dumpfile);
#endif
+#ifdef RECOMPRESS
+ close_tng_file_read(dumpfile_recompress);
+#endif
#ifdef GEN
/* Check against expected filesize for this test. */
- if (!(file=fopen(FILENAME,"rb")))
+ if (!(file=fopen(TNG_COMPRESS_FILES_DIR FILENAME,"rb")))
{
- fprintf(stderr,"ERROR: Cannot open file "FILENAME"\n");
+ fprintf(stderr,"ERROR: Cannot open file "TNG_COMPRESS_FILES_DIR FILENAME"\n");
exit(EXIT_FAILURE);
}
filesize=0;
@@ -621,9 +868,9 @@ int main()
exit(EXIT_FAILURE);
}
#ifdef GEN
- printf("Tng compress testsuite generating test: %s\n",TESTNAME);
+ printf("Tng compress testsuite generating (writing) test: %s\n",TESTNAME);
#else
- printf("Tng compress testsuite running test: %s\n",TESTNAME);
+ printf("Tng compress testsuite running (reading) test: %s\n",TESTNAME);
#endif
testval=algotest();
if (testval==0)
diff --git a/src/tests/compression/testsuite.sh b/src/tests/compression/testsuite.sh
deleted file mode 100755
index 6aecff5..0000000
--- a/src/tests/compression/testsuite.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-do_write_test="Yes"
-if [ -n "$1" ]; then
- do_write_test=""
-fi
-STARTTEST=1
-ENDTEST=57
-#CFLAGS="-Wall -O2 -I../../../include/compress"
-CFLAGS="-O2 -I../../../include/compression"
-LIBS="-L../../../build/lib -ltng_compress -lm"
-LD_LIBRARY_PATH="../../../build/lib:$LD_LIBRARY_PATH"
-export LD_LIBRARY_PATH
-#CFLAGS="-O0 -Wall -g"
-#LIBS="-lm -lefence"
-CC="gcc"
-# 32 bit
-#CC="gcc -m32"
-for testnum in $(seq $STARTTEST $ENDTEST); do
- testname=$(grep "TESTNAME" test$testnum.h|sed 's/#define TESTNAME//')
- sed "s/TESTPARAM/\"test$testnum.h\"/" <testsuite.c >test$testnum.c
- if [ -n "$do_write_test" ]; then
- echo Write test $testnum: $testname
- $CC -DGEN $CFLAGS -o gen$testnum test$testnum.c -ltng_compress $LIBS
- ./gen$testnum
- rm -f gen$testnum
- fi
- echo Read test $testnum: $testname
- $CC $CFLAGS -o read$testnum test$testnum.c -ltng_compress $LIBS
- ./read$testnum
- rm -f read$testnum
- rm -f test$testnum.c
-done
-
-
-
contact: Jan Huwald // Impressum