#include #include #include #include #include "tipsydefs.h" /* needed by readdmstd */ #include #include static XDR xdrs; /**/ FILE *fp; /* Prototypes */ void readdmtip_(int *ndark, int *nstar, int *nsph, float *xx, float *yy, float *zz,float *vx, float *vy, float *vz, float *mass, float *eps, float *phi,double *time, float *soft,float *metals, float *tform, float* rho,float* temp, float *pot ); void readdmstd_(int *ndark, int *nstar, int *nsph, float *xx, float *yy, float *zz, float *vx, float *vy, float *vz, float *mass, float *eps, float *phi,double *time,float *soft,float *metals, float *tform, float* rho,float* temp, float *pot ); /* XDR handling functions */ int xdr_header() { int pad; if(xdr_double(&xdrs, &header.time) != TRUE) return 0; if(xdr_int(&xdrs, &header.nbodies) != TRUE) return 0; if(xdr_int(&xdrs, &header.ndim) != TRUE) return 0; if(xdr_int(&xdrs, &header.nsph) != TRUE) return 0; if(xdr_int(&xdrs, &header.ndark) != TRUE) return 0; if(xdr_int(&xdrs, &header.nstar) != TRUE) return 0; if(xdr_int(&xdrs, &pad) != TRUE) return 0; return 1; } int xdr_gas() { int i; if(sizeof(Real) == sizeof(float)) { xdr_vector(&xdrs,(char *)gas_particles, header.nsph*(sizeof(*gas_particles)/sizeof(Real)), sizeof(Real),(xdrproc_t) xdr_float); } return 0; } int xdr_dark() { int i; if(sizeof(Real) == sizeof(float)) { xdr_vector(&xdrs,(char *)dark_particles, header.ndark*(sizeof(*dark_particles)/sizeof(Real)), sizeof(Real),(xdrproc_t) xdr_float); } return 0; } int xdr_star() { int i; if(sizeof(Real) == sizeof(float)) { xdr_vector(&xdrs,(char *)star_particles, header.nstar*(sizeof(*star_particles)/sizeof(Real)), sizeof(Real),(xdrproc_t) xdr_float); } return 0; } /* Function definitions */ void readdmtip_(int *ndark, int *nstar, int *nsph, float *xx, float *yy, float *zz, float *vx, float *vy, float *vz, float *mass, float *eps, float *phi,double *time, float *soft,float *metals, float *tform, float* rho,float* temp, float *pot ) { /* FILE *fp; */ struct dark_particle dp; struct gas_particle gp; struct star_particle sp; struct dump head; int i; int j; /* ** reads header */ printf(" read files\n"); fread(&head,sizeof(struct dump),1,fp); printf(" Particles in TIPSY file: %d gas, %d dark, %d stars\n", head.nsph,head.ndark,head.nstar); assert(head.ndim==3); *time=head.time; printf(" Time: %g\n",*time); /* ** reads gas particles */ i= 0; while (i