#define U_CHAR 1 #define U_INT 2 #define U_FLOAT 3 #include "view.h" /***************************************************************/ /* Dumping the current state of the system into a binary file. */ /* Note: the binary file is written in the format used by IBM */ /* and DEC compatible machines (low bytes followed by high */ /* bytes). For this Dump() and Restore() call the functions */ /* sun_read() and sun_write(). */ char Revision[]={'1','.','1','0'}; void Dump(filename) char *filename; { int i, j; float ftemp; FILE *DMPFile; if ((DMPFile = fopen(filename, "w")) == NULL) { puts("Dump: open failed"); return; } write_data(Revision, 1, 4, DMPFile, U_CHAR); ftemp = t; write_data(&ftemp, 4, 1, DMPFile, U_FLOAT); write_data(&sigma, 4, 1, DMPFile, U_FLOAT); write_data(&extq, 4, 1, DMPFile, U_FLOAT); write_data(&extq_1, 4, 1, DMPFile, U_FLOAT); write_data(&extq_2, 4, 1, DMPFile, U_FLOAT); write_data(&extq_3, 4, 1, DMPFile, U_FLOAT); write_data(jwall, 4, 2, DMPFile, U_FLOAT); write_data(&nsp, 4, 1, DMPFile, U_INT); write_data(np, 4, nsp, DMPFile, U_INT); for (j=0; j=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 /****************************************************************/