#include #include #define SUN #define U_CHAR 1 #define U_INT 2 #define U_FLOAT 3 char Revision1[]={'1','.','1','0'}; char Revision2[]={'1','.','1','1'}; main(argc, argv) int argc; char *argv[]; { char Rev[5]; int i, j, nsp=4, np[10]; float ftemp; short temp[10], temp1; FILE *DMPFile; double t1; float **x, **vx, **vy, **vz, t2, sigma; float extq, extq_1, extq_2, extq_3, jwall[10]; /*********************************************************/ if(argc < 2) { puts("Must give 2 args."); exit(1); } if ((DMPFile = fopen(argv[1], "r+b")) == NULL) { puts("Conver: open failed on the first argument."); exit(1); } read_data(Rev, 1, 4, DMPFile, U_CHAR); for (i=0; i<4; i++) if (Rev[i]!=Revision1[i]) { puts("Incompatible dump file version"); putchar(7); exit(1); } read_data(&t2, 4, 1, DMPFile, U_FLOAT); read_data(&sigma, 4, 1, DMPFile, U_FLOAT); read_data(&extq, 4, 1, DMPFile, U_FLOAT); read_data(&extq_1, 4, 1, DMPFile, U_FLOAT); read_data(&extq_2, 4, 1, DMPFile, U_FLOAT); read_data(&extq_3, 4, 1, DMPFile, U_FLOAT); read_data(jwall, 4, nsp, DMPFile, U_FLOAT); read_data(&nsp, 4, 1, DMPFile, U_INT); read_data(np, 4, nsp, DMPFile, U_INT); /*********************************************************/ x = (float **)malloc(nsp*sizeof(float *)); vx = (float **)malloc(nsp*sizeof(float *)); vy = (float **)malloc(nsp*sizeof(float *)); vz = (float **)malloc(nsp*sizeof(float *)); for(i=0; i=0; i--) fread(ptr+j*size+i, 1, 1, stream); } /****************************************************************/ sun_write(ptr, size, nitems, stream) char *ptr; int size; int nitems; FILE *stream; { int i, j; for(j= 0; j =0; i--) fwrite(ptr+j*size+i, 1, 1, stream); } /****************************************************************/ #ifdef UNICOS unicos_read_float(ptr, nitems, stream) float *ptr; FILE *stream; int nitems; { unsigned long *iptr; unsigned char a,b,c,d,t; int j; for(j= 0; j > 7)); *iptr = ((a >> 7) << 63) | ((t -126 + 040000) << 48); *iptr |= (b | 0x80) << 40; *iptr |= c << 32; *iptr |= d << 24; } } } #endif /****************************************************************/ #ifdef UNICOS unicos_read_int(ptr, nitems, stream) int *ptr; FILE *stream; int nitems; { unsigned long *iptr; unsigned char a,b,c,d,t; int j; for(j= 0; j > 7) ? 0xffffffff00000000 : 0x0; } } #endif /****************************************************************/ #ifdef UNICOS unicos_write_float(ptr, nitems, stream) float *ptr; FILE *stream; int nitems; { unsigned long *iptr; unsigned char a,b,c,d,t; int j; for(j= 0; j > 48) & 0xff) - 040000 + 126; a = ((*iptr & (1 << 63)) ? 1 << 7 : 0) | t >> 1; b = (t & 0x1) << 7 | ((*iptr >> 40) & 0x7f); c = *iptr >> 32; d = *iptr >> 24; fwrite(&d,1,1,stream); fwrite(&c,1,1,stream); fwrite(&b,1,1,stream); fwrite(&a,1,1,stream); } } #endif /****************************************************************/ #ifdef UNICOS unicos_write_int(ptr, nitems, stream) int *ptr; FILE *stream; int nitems; { unsigned long *iptr; unsigned char a,b,c,d,t; int j; for(j= 0; j > 8 & 0xff; c = *iptr >> 16 & 0xff; d = *iptr >> 24 & 0xff; fwrite(&a,1,1,stream); fwrite(&b,1,1,stream); fwrite(&c,1,1,stream); fwrite(&d,1,1,stream); } } #endif /****************************************************************/