diff --git a/examples/main.c b/examples/main.c index 5afbdbba6960c77ee6161063baca76d520074b80..86a6a2c080e1e3e7ce9b7c257d9bec287b7ab845 100644 --- a/examples/main.c +++ b/examples/main.c @@ -858,7 +858,7 @@ int main(int argc, char *argv[]) { * files. */ if (j % restart_stop_steps == 0) { force_stop = restart_stop_now(restart_dir, 0); - if (myrank == 0) + if (myrank == 0 && force_stop) message("Forcing application exit, dumping restart files..."); } diff --git a/src/engine.c b/src/engine.c index 75f35097d952dcb75387b37e30ad2d38f5834748..22befb455bf336992ddf3969fc4682331080cab6 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5211,6 +5211,7 @@ void engine_init( parser_get_opt_param_int(params, "Snapshots:compression", 0); e->snapshotUnits = malloc(sizeof(struct unit_system)); units_init_default(e->snapshotUnits, params, "Snapshots", internal_units); + e->snapshotOutputCount = 0; e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min"); e->dt_max = parser_get_param_double(params, "TimeIntegration:dt_max"); e->deltaTimeStatistics = @@ -5802,9 +5803,11 @@ void engine_struct_dump(struct engine *e, FILE *stream) { units_struct_dump(e->internal_units, stream); units_struct_dump(e->snapshotUnits, stream); +#ifdef WITH_MPI /* Save the partition for restoration. */ partition_store_celllist(e->s, e->reparttype); partition_struct_dump(e->reparttype, stream); +#endif phys_const_struct_dump(e->physical_constants, stream); hydro_props_struct_dump(e->hydro_properties, stream); @@ -5848,9 +5851,11 @@ void engine_struct_restore(struct engine *e, FILE *stream) { units_struct_restore(us, stream); e->snapshotUnits = us; +#ifdef WITH_MPI struct repartition *reparttype = malloc(sizeof(struct repartition)); partition_struct_restore(reparttype, stream); e->reparttype = reparttype; +#endif struct phys_const *physical_constants = malloc(sizeof(struct phys_const)); phys_const_struct_restore(physical_constants, stream); diff --git a/src/engine.h b/src/engine.h index 452abb22007b99b4594f94229f83fbb5f1b02b8e..c2f6fa63eb90a95fc2fe99178a2da40772894977 100644 --- a/src/engine.h +++ b/src/engine.h @@ -195,6 +195,7 @@ struct engine { char snapshotBaseName[PARSER_MAX_LINE_SIZE]; int snapshotCompression; struct unit_system *snapshotUnits; + int snapshotOutputCount; /* Statistics information */ FILE *file_stats; diff --git a/src/parallel_io.c b/src/parallel_io.c index 3e8cadf18a9468d52c0b32c6cb054d668ad5c37d..bc99dd57dd973d45e98ef373fdca83321a3ef924 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -833,7 +833,6 @@ void write_output_parallel(struct engine* e, const char* baseName, struct gpart* gparts = e->s->gparts; struct gpart* dmparts = NULL; struct spart* sparts = e->s->sparts; - static int outputCount = 0; FILE* xmfFile = 0; /* Number of unassociated gparts */ @@ -842,10 +841,10 @@ void write_output_parallel(struct engine* e, const char* baseName, /* File name */ char fileName[FILENAME_BUFFER_SIZE]; snprintf(fileName, FILENAME_BUFFER_SIZE, "%s_%04i.hdf5", baseName, - outputCount); + e->snapshotOutputCount); /* First time, we need to create the XMF file */ - if (outputCount == 0 && mpi_rank == 0) xmf_create_file(baseName); + if (e->snapshotOutputCount == 0 && mpi_rank == 0) xmf_create_file(baseName); /* Prepare the XMF file for the new entry */ if (mpi_rank == 0) xmfFile = xmf_prepare_file(baseName); @@ -1158,7 +1157,7 @@ void write_output_parallel(struct engine* e, const char* baseName, #endif /* Write LXMF file descriptor */ - if (mpi_rank == 0) xmf_write_outputfooter(xmfFile, outputCount, e->time); + if (mpi_rank == 0) xmf_write_outputfooter(xmfFile, e->snapshotOutputCount, e->time); #ifdef IO_SPEED_MEASUREMENT MPI_Barrier(MPI_COMM_WORLD); @@ -1193,7 +1192,7 @@ void write_output_parallel(struct engine* e, const char* baseName, clocks_getunit()); #endif - ++outputCount; + e->snapshotOutputCount++; } #endif /* HAVE_HDF5 */ diff --git a/src/serial_io.c b/src/serial_io.c index 38dd3b3e4d278535fa3f042fb3302bdefb5b5793..52a4a71471c623df557222711f8e9d74a125bddf 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -712,7 +712,6 @@ void write_output_serial(struct engine* e, const char* baseName, struct gpart* gparts = e->s->gparts; struct gpart* dmparts = NULL; struct spart* sparts = e->s->sparts; - static int outputCount = 0; FILE* xmfFile = 0; /* Number of unassociated gparts */ @@ -721,7 +720,7 @@ void write_output_serial(struct engine* e, const char* baseName, /* File name */ char fileName[FILENAME_BUFFER_SIZE]; snprintf(fileName, FILENAME_BUFFER_SIZE, "%s_%04i.hdf5", baseName, - outputCount); + e->snapshotOutputCount); /* Compute offset in the file and total number of particles */ size_t N[swift_type_count] = {Ngas, Ndm, 0, 0, Nstars, 0}; @@ -741,7 +740,7 @@ void write_output_serial(struct engine* e, const char* baseName, if (mpi_rank == 0) { /* First time, we need to create the XMF file */ - if (outputCount == 0) xmf_create_file(baseName); + if (e->snapshotOutputCount == 0) xmf_create_file(baseName); /* Prepare the XMF file for the new entry */ xmfFile = xmf_prepare_file(baseName); @@ -1002,10 +1001,10 @@ void write_output_serial(struct engine* e, const char* baseName, } /* Write footer of LXMF file descriptor */ - if (mpi_rank == 0) xmf_write_outputfooter(xmfFile, outputCount, e->time); + if (mpi_rank == 0) xmf_write_outputfooter(xmfFile, e->snapshotOutputCount, e->time); /* message("Done writing particles..."); */ - ++outputCount; + e->snapshotOutputCount++; } #endif /* HAVE_HDF5 && HAVE_MPI */ diff --git a/src/single_io.c b/src/single_io.c index e8e281b68b183dd6c9aa9aa1a4fdfe33f56b08bf..79dc6d43d645862edb3e0f8a9a6480f368265a50 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -577,7 +577,6 @@ void write_output_single(struct engine* e, const char* baseName, struct gpart* gparts = e->s->gparts; struct gpart* dmparts = NULL; struct spart* sparts = e->s->sparts; - static int outputCount = 0; /* Number of unassociated gparts */ const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0; @@ -587,10 +586,10 @@ void write_output_single(struct engine* e, const char* baseName, /* File name */ char fileName[FILENAME_BUFFER_SIZE]; snprintf(fileName, FILENAME_BUFFER_SIZE, "%s_%04i.hdf5", baseName, - outputCount); + e->snapshotOutputCount); /* First time, we need to create the XMF file */ - if (outputCount == 0) xmf_create_file(baseName); + if (e->snapshotOutputCount == 0) xmf_create_file(baseName); /* Prepare the XMF file for the new entry */ FILE* xmfFile = 0; @@ -807,14 +806,14 @@ void write_output_single(struct engine* e, const char* baseName, } /* Write LXMF file descriptor */ - xmf_write_outputfooter(xmfFile, outputCount, e->time); + xmf_write_outputfooter(xmfFile, e->snapshotOutputCount, e->time); /* message("Done writing particles..."); */ /* Close file */ H5Fclose(h_file); - ++outputCount; + e->snapshotOutputCount++; } #endif /* HAVE_HDF5 */