/* lanl_ic2gadget -- convert binary format initial conditions particle files from the Heitmann et al. 2004/2007 Code Comparison Project (so-called "LANL" format) to Gadget2 format Usage: lanl_ic2gadget lanl_ic_file > ic_gadget_particles.dat Example: lanl_ic2gadget particles_ic_lg > ic_lg_gadget.dat Note: lanl_ic2gadget is clever enough to figure out if you are converting the large box (L = 256 Mpc/h) IC file or the small box (L = 64 Mpc/h) file. Warning: Do not use this to convert the z = 0 particle distributions to Gadget format!!! Use lanl_out2gadget instead!!! More info: http://t8web.lanl.gov/people/heitmann/arxiv/data.html Developed from Gadget source C code snippets by Chris Orban (Ohio State University), 10/08 */ #include #include #include #define NumPart 256*256*256 struct io_header_1 { int npart[6]; double mass[6]; double time; double redshift; int flag_sfr; int flag_feedback; int npartTotal[6]; int flag_cooling; int num_files; double BoxSize; double Omega0; double OmegaLambda; double HubbleParam; char fill[256- 6*4- 6*8- 2*8- 2*4- 6*4- 2*4 - 4*8]; /* fills to 256 Bytes */ } header1; struct particle_data { float x,vx; float y,vy; float z,vz; float pmass; int ptag; } P[NumPart]; int main (int argc, char **argv) { float h = 0.71; // The Heitmann et al. 05 comparison uses Ho = 71 km/s/Mpc float sqrta; int i; size_t count; if (argc== 1) { printf("Tool for converting Heitmann et al. 2004 initial conditions files to Gadget format!!! \n\n"); printf("Usage: \n \n"); printf(" lanl_ic2gadget lanl_ic_file > ic_gadget_particles.dat \n \n"); printf("Example: lanl_to_gadget particles_ic_lg > ic_lg_gadget.dat \n\n"); printf("See lanl_ic2gadget.c header for more details. \n"); exit(0); } FILE *fp = fopen(argv[1], "rb"); for(i=0;i 91. ) { counter++ ; } } if (counter > 0) { header1.BoxSize = 256000; } else { header1.BoxSize = 64000; } // header1.BoxSize = boxsize*1000.; // units now in h^-1 kpc header1.Omega0 = 0.314; header1.OmegaLambda = 0.686; header1.HubbleParam = 0.71; // The following is meant to mimic the write commands in io.c from gadget-1.1 int blklen; float dummy[3]; // FILE *fd = fopen("ic_lg_gadget.dat", "w"); #define BLKLEN fwrite(&blklen, sizeof(blklen), 1, stdout); blklen=sizeof(header1); BLKLEN; fwrite(&header1, sizeof(header1), 1, stdout); BLKLEN; blklen=NumPart*3*sizeof(float); BLKLEN; for(i=0;i