/* part_write_dx.c * * Last change: Mon May 8 23:09:43 EDT 1995 * * Modified rml 9/12/95 - added cellfile and nodefile feature * processors now numbered 0..NPROCS-1 * Modified rml 10/6/95 - added error detection for file i/o * and optional compression */ /* #include "/dept/scorec/big/teresj/PMDB-3.2/src/include/libpmshops.h" */ #include "libpmshops.h" #include "msg.h" /* * declarations * */ extern int my_pmdb_write_dx( char *file, pMeshPB pmeshpb, char *cellfile, int celldim, char *nodefile, int nodedim, int compress); static int dx_owc_object( char *filename, pMesh mesh, char *cellfile, int celldim, char *nodefile, int nodedim); static int dx_owc_group( char *filename, pMesh mesh, char *cellfile, int celldim, char *nodefile, int nodedim); static int dx_write_object( FILE *fp, pMesh mesh, char *cellfile, int celldim, char *nodefile, int nodedim); static int dx_write_group( FILE *fp, pMesh mesh, char *cellfile, char *nodefile); static void dx_number_verts(pMesh mesh); static void dx_clean_verts(pMesh mesh); /* * macro for checking return from fprintf * should only be used if routine doesn't need to * clean up before returning * calling routine should decare "int ret" and * do a "return(ret)" at the end * */ #define FPRINTF if (ret==EOF) return(0); else ret=fprintf /* * Main routine * * int my_pmdb_write_dx(char *filename, * pMeshPB pmeshpb, * char *cellfile, * int celldim, * char *nodefile, * int nodedim, * int compress) * * Write out a dx file of the current mesh. There is only one file * containing a component for each processor's part of the mesh. * * If cellfile is non-null, it specifies a file name template for cell * data. The cellfile string must contain a %d which will be replaced * with the processor number. You should create a separate cell data * file for each processor. Each file should have one line for each * cell (in order of M_nextRegion() ) with celldim numbers on each * line. E.g. cellfile name "cell.%d.dat" will make dx look for cell * data in cell.0.dat, cell.1.dat, etc. Cellfile may be NULL in which * case there is no cell data attached to the dx object. * * Likewise for nodefile and nodedim. * * If compress is nonzero, the dx file will be compressed after * it is written. * * Returns 0/nonzero for failure/success. * It should catch ANY file i/o errors e.g. out of disk space * Note: Failure to compress prints out a warning but does not cause * the routine to return 0. * */ static char *funcname="pmdb_write_dx"; int my_pmdb_write_dx( char *filename, pMeshPB pmeshpb, char *cellfile, int celldim, char *nodefile, int nodedim, int compress) { pMesh mesh; char dxname[FILENAME_MAX]; int i; int ret; int status; char command[128]; ret=1; mesh=pmdb_get_pmesh(pmeshpb); sprintf(dxname,"%s.dx",filename); dx_number_verts(mesh); for(i=0; (i