Commit ae60541d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

The code now writes the time to the HDF5 header as well as other legacy...

The code now writes the time to the HDF5 header as well as other legacy GADGET-2 attributes allowing the reading of the file with Gadgetviewer.


Former-commit-id: 14c74a23cef421dc98b1590b461528dcadd7ab95
parent 16cbcb7b
......@@ -795,15 +795,11 @@ int main ( int argc , char *argv[] ) {
/* Dump the first few particles. */
// for(k=0; k<10; ++k)
// printParticle(parts, k);
// printParticle(parts, k, N);
// printParticle( parts , 6178 , N );
// pairs_single( dim , 8525152967533 , parts , N , periodic );
// printParticle( parts , 515150 );
// printParticle( parts , 494849 );
tic = getticks();
write_output("output.hdf5", dim, parts, N, periodic);
printf( "main: writing particle properties took %.3f ms.\n" , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout);
/* Dump the kernel to make sure its ok. */
// kernel_dump( 100 );
......@@ -822,7 +818,7 @@ int main ( int argc , char *argv[] ) {
tic = getticks();
space_init( &s , dim , parts , N , periodic , h_max );
printf( "main: space_init took %.3f ms.\n" , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout);
/* Set the default time step to 1.0f. */
printf( "main: dt_max is %f.\n" , dt_max );
......@@ -850,6 +846,11 @@ int main ( int argc , char *argv[] ) {
tic = getticks();
engine_init( &e , &s , dt_max , nr_threads , nr_queues , engine_policy_steal | engine_policy_keep );
printf( "main: engine_init took %.3f ms.\n" , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout);
/* Write the state of the system as it is before starting time integration. */
tic = getticks();
write_output("output.hdf5", &e);
printf( "main: writing particle properties took %.3f ms.\n" , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout);
/* Init the runner history. */
#ifdef HIST
......@@ -873,7 +874,7 @@ int main ( int argc , char *argv[] ) {
if(j % 100 == 0) {
char fileName[200];
sprintf(fileName, "output_%05i.hdf5", j);
write_output(fileName, dim, parts, N, periodic);
write_output(fileName, &e);
}
/* Dump the first few particles. */
......
......@@ -36,6 +36,7 @@
#include "task.h"
#include "part.h"
#include "space.h"
#include "engine.h"
/**
* @brief Error macro
......@@ -545,10 +546,16 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, enu
* Calls #error() if an error occurs.
*
*/
void write_output ( char* fileName, double dim[3], struct part *parts, int N, int periodic)
void write_output ( char* fileName, struct engine *e)
{
hid_t h_file=0, h_grp=0;
int N = e->s->nr_parts;
int periodic = e->s->periodic;
int numParticles[6]={N,0};
int numParticlesHighWord[6]={0};
int numFiles = 1;
struct part* parts = e->s->parts;
FILE* xmfFile;
writeXMFheader(&xmfFile, fileName, N);
......@@ -584,9 +591,16 @@ void write_output ( char* fileName, double dim[3], struct part *parts, int N, i
error("Error while creating file header\n");
/* Read the relevant information and print status */
writeAttribute(h_grp, "BoxSize", DOUBLE, &dim[0], 1);
writeAttribute(h_grp, "NumPart_Total", UINT, numParticles, 6);
writeAttribute(h_grp, "BoxSize", DOUBLE, e->s->dim, 1);
writeAttribute(h_grp, "NumPart_ThisFile", UINT, numParticles, 6);
writeAttribute(h_grp, "Time", DOUBLE, &e->time, 1);
/* GADGET-2 legacy values */
writeAttribute(h_grp, "NumPart_Total", UINT, numParticles, 6);
writeAttribute(h_grp, "NumPart_Total_HighWord", UINT, numParticlesHighWord, 6);
writeAttribute(h_grp, "Flag_Entropy_ICs", UINT, numParticlesHighWord, 6);
writeAttribute(h_grp, "NumFilesPerSnapshot", INT, &numFiles, 1);
/* Close header */
H5Gclose(h_grp);
......
......@@ -22,6 +22,6 @@
void read_ic ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic);
void write_output ( char* fileName, double dim[3], struct part *parts, int N, int periodic);
void write_output ( char* fileName, struct engine* e);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment