diff --git a/examples/test.c b/examples/test.c index 427b761680bde8c96d23f576cbde792fb13519b2..a09e34aede5c5016eae63b2f6f21d9e999a68ca0 100644 --- a/examples/test.c +++ b/examples/test.c @@ -677,11 +677,16 @@ int main ( int argc , char *argv[] ) { /* Read particles and space information from (GADGET) IC */ tic = getticks(); -#ifdef WITH_MPI +#if defined( WITH_MPI ) +#if defined( HAVE_PARALLEL_HDF5 ) read_ic_parallel( ICfileName , dim , &parts , &N , &periodic, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL ); #else - read_ic( ICfileName , dim , &parts , &N , &periodic ); + read_ic_serial( ICfileName , dim , &parts , &N , &periodic, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL ); +#endif +#else + read_ic_single( ICfileName , dim , &parts , &N , &periodic ); #endif + if ( myrank == 0 ) message( "reading particle properties took %.3f ms." , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout); @@ -778,12 +783,17 @@ int main ( int argc , char *argv[] ) { engine_redistribute ( &e ); #endif + message("Before write !"); /* Write the state of the system as it is before starting time integration. */ tic = getticks(); -#ifdef WITH_MPI +#if defined( WITH_MPI ) +#if defined( HAVE_PARALLEL_HDF5 ) write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); #else - write_output(&e, &us); + write_output_serial(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); +#endif +#else + write_output_single(&e, &us); #endif message( "writing particle properties took %.3f ms." , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout); @@ -837,11 +847,17 @@ int main ( int argc , char *argv[] ) { if ( j % 100 == 0 ) { -#ifdef WITH_MPI - write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); + +#if defined( WITH_MPI ) +#if defined( HAVE_PARALLEL_HDF5 ) + write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); +#else + write_output_serial(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); +#endif #else - write_output(&e, &us); + write_output_single(&e, &us); #endif + } /* Dump a line of agregate output. */ @@ -858,20 +874,18 @@ int main ( int argc , char *argv[] ) { /* for ( k = 0 ; k < 5 ; k++ ) printgParticle( s.gparts , pid[k] , N ); */ - } + } /* Print the values of the runner histogram. */ - #ifdef HIST - printf( "main: runner histogram data:\n" ); - for ( k = 0 ; k < runner_hist_N ; k++ ) - printf( " %e %e %e\n" , - runner_hist_a + k * (runner_hist_b - runner_hist_a) / runner_hist_N , - runner_hist_a + (k + 1) * (runner_hist_b - runner_hist_a) / runner_hist_N , - (double)runner_hist_bins[k] ); - #endif +#ifdef HIST + printf( "main: runner histogram data:\n" ); + for ( k = 0 ; k < runner_hist_N ; k++ ) + printf( " %e %e %e\n" , + runner_hist_a + k * (runner_hist_b - runner_hist_a) / runner_hist_N , + runner_hist_a + (k + 1) * (runner_hist_b - runner_hist_a) / runner_hist_N , + (double)runner_hist_bins[k] ); +#endif - // write_output( &e ); - /* Loop over the parts directly. */ // for ( k = 0 ; k < N ; k++ ) // printf( " %i %e %e\n" , s.parts[k].id , s.parts[k].count , s.parts[k].count_dh ); @@ -904,16 +918,20 @@ int main ( int argc , char *argv[] ) { #endif */ /* Write final output. */ -#ifdef WITH_MPI - write_output_parallel( &e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL ); +#if defined( WITH_MPI ) +#if defined( HAVE_PARALLEL_HDF5 ) + write_output_parallel(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); +#else + write_output_serial(&e, &us, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); +#endif #else - write_output( &e , &us ); + write_output_single(&e, &us); #endif #ifdef WITH_MPI - if ( MPI_Finalize() != MPI_SUCCESS ) - error( "call to MPI_Finalize failed with error %i." , res ); - #endif + if ( MPI_Finalize() != MPI_SUCCESS ) + error( "call to MPI_Finalize failed with error %i." , res ); +#endif /* Say goodbye. */ message( "done." ); @@ -921,4 +939,4 @@ int main ( int argc , char *argv[] ) { /* All is calm, all is bright. */ return 0; - } +} diff --git a/src/Makefile.am b/src/Makefile.am index f9aa25995a20d4aacebf74aa24cd7a9dfc4d2418..99ebb246b99a620b0207784b132e0a8275a12d36 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,12 +35,12 @@ endif # List required headers include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \ engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \ - common_io.h multipole.h + common_io.h single_io.h multipole.h # Common source files AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \ serial_io.c timers.c debug.c scheduler.c proxy.c parallel_io.c \ - units.c common_io.c multipole.c version.c + units.c common_io.c single_io.c multipole.c version.c # Include files for distribution, not installation. noinst_HEADERS = atomic.h cycle.h error.h inline.h kernel.h vector.h \ diff --git a/src/parallel_io.c b/src/parallel_io.c index deb6eab914c8a92513ba64c2733affc4db23ffee..bc8206e97853928685930081d779d8d7fe140768 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -21,7 +21,7 @@ /* Config parameters. */ #include "../config.h" -#if defined(HAVE_HDF5) && defined(WITH_MPI) +#if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5) /* Tell hdf5 that we intend to use shared-memory parallel stuff. */ #define H5_HAVE_PARALLEL diff --git a/src/parallel_io.h b/src/parallel_io.h index 51cfb3a906261f8e260fd4825829bce33fa38dca..78699a5938894ef4577e9a14938e4a16dae2b612 100644 --- a/src/parallel_io.h +++ b/src/parallel_io.h @@ -18,7 +18,7 @@ ******************************************************************************/ -#if defined(HAVE_HDF5) && defined(WITH_MPI) +#if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5) void read_ic_parallel ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info); diff --git a/src/serial_io.c b/src/serial_io.c index 92a576da8588a4b66707de11d002d0636139492a..62306bb879e85411b49cb0edbea99241e678fba3 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -21,7 +21,7 @@ /* Config parameters. */ #include "../config.h" -#if defined(HAVE_HDF5) && !defined(WITH_MPI) +#if defined(HAVE_HDF5) && defined(WITH_MPI) && !defined(HAVE_PARALLEL_HDF5) /* Some standard headers. */ @@ -175,7 +175,7 @@ void readArrayBackEnd(hid_t grp, char* name, enum DATA_TYPE type, int N, int dim * Calls #error() if an error occurs. * */ -void read_ic ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic) +void read_ic_serial ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info) { hid_t h_file=0, h_grp=0; double boxSize[3]={0.0,-1.0,-1.0}; /* GADGET has only cubic boxes (in cosmological mode) */ @@ -390,7 +390,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, enu * Calls #error() if an error occurs. * */ -void write_output (struct engine *e, struct UnitSystem* us) +void write_output_serial ( struct engine* e, struct UnitSystem* us, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info ) { hid_t h_file=0, h_grp=0; diff --git a/src/serial_io.h b/src/serial_io.h index a827a47373fdfbc01b5ff0e5d64faca39d316f6d..3349f221531ce7c4a2a290b121500e5d4336ed6b 100644 --- a/src/serial_io.h +++ b/src/serial_io.h @@ -18,11 +18,11 @@ ******************************************************************************/ -#if defined(HAVE_HDF5) && !defined(WITH_MPI) +#if defined(HAVE_HDF5) && defined(WITH_MPI) && !defined(HAVE_PARALLEL_HDF5) -void read_ic ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic); +void read_ic_serial ( char* fileName, double dim[3], struct part **parts, int* N, int* periodic, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info); -void write_output ( struct engine* e, struct UnitSystem* us ); +void write_output_serial ( struct engine* e, struct UnitSystem* us, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info ); #endif diff --git a/src/swift.h b/src/swift.h index 098092b29006e89a32ffada43284d9047132dbe0..7652191b2e9cfb864cc64e157eeda98627cdccdc 100644 --- a/src/swift.h +++ b/src/swift.h @@ -38,6 +38,7 @@ #include "runner.h" #include "engine.h" #include "units.h" +#include "single_io.h" #include "serial_io.h" #include "parallel_io.h" #include "debug.h"