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

Code formatting. Do not comile the logger functions when MPI is enabled.

parent 656a2df7
......@@ -104,4 +104,4 @@ void logger_particle_interpolate(struct logger_particle *part_curr,
const struct logger_particle *part_next,
const double time);
#endif //LOGGER_LOGGER_PARTICLE_H
#endif // LOGGER_LOGGER_PARTICLE_H
......@@ -45,7 +45,6 @@ void time_array_ensure_size(struct time_array *t) {
/* Set the pointer to the new array */
t->records = tmp;
}
/**
......@@ -236,14 +235,12 @@ size_t time_array_get_index(const struct time_array *t, const size_t offset) {
while (left <= right) {
size_t center = (left + right) / 2;
const size_t offset_center = t->records[center].offset;
if (offset > offset_center) {
left = center + 1;
}
else if (offset < offset_center) {
} else if (offset < offset_center) {
right = center - 1;
}
else {
} else {
return center;
}
}
......@@ -277,8 +274,8 @@ void time_array_print(const struct time_array *t) {
size_t n = t->size;
size_t up_threshold = n - threshold;
printf("Times (size %lu): [%lli (%g)", n,
t->records[0].int_time, t->records[0].time);
printf("Times (size %lu): [%lli (%g)", n, t->records[0].int_time,
t->records[0].time);
/* Loop over all elements. */
for (size_t i = 1; i < n; i++) {
......@@ -308,7 +305,8 @@ void time_array_print_offset(const struct time_array *t) {
/* Loop over all elements. */
for (size_t i = 1; i < n; i++) {
/* Skip the offset in the middle of the array. */
if (i < threshold || i > up_threshold) printf(", %lu", t->records[i].offset);
if (i < threshold || i > up_threshold)
printf(", %lu", t->records[i].offset);
if (i == threshold) printf(", ...");
}
......
......@@ -17,9 +17,9 @@
*
******************************************************************************/
#include "logger_time.h"
#include <time.h>
#include <stdlib.h>
#include <time.h>
#include "logger_time.h"
#define NUMBER_OF_ELEMENT 10000
#define TIME_BASE 0.04
......@@ -40,16 +40,16 @@ int main(int argc, char *argv[]) {
time_array_init(&times);
/* Add elements */
for(size_t i = 0; i < NUMBER_OF_ELEMENT; i++) {
for (size_t i = 0; i < NUMBER_OF_ELEMENT; i++) {
integertime_t int_time = i;
double time = i * TIME_BASE;
size_t offset = i * OFFSET_BASE;
time_array_append(&times, int_time, time, offset);
}
/* Check the elements */
for(size_t i = 0; i < NUMBER_OF_ELEMENT; i++) {
for (size_t i = 0; i < NUMBER_OF_ELEMENT; i++) {
integertime_t int_time = i;
double time = i * TIME_BASE;
size_t offset = i * OFFSET_BASE;
......@@ -66,14 +66,13 @@ int main(int argc, char *argv[]) {
/* Get the index from the offset */
size_t ind = time_array_get_index(&times, read_offset);
/* Check the values obtained */
assert(i == ind);
assert(int_time == times.records[ind].int_time);
assert(time == times.records[ind].time);
assert(offset == times.records[ind].offset);
assert(offset == times.records[ind].offset);
}
return 0;
}
......@@ -4792,7 +4792,7 @@ void engine_dump_snapshot(struct engine *e) {
*/
void engine_dump_index(struct engine *e) {
#if defined(WITH_LOGGER)
#if defined(WITH_LOGGER) && !defined(WITH_MPI)
struct clocks_time time1, time2;
clocks_gettime(&time1);
......
......@@ -21,7 +21,7 @@
/* Config parameters. */
#include "../config.h"
#ifdef WITH_LOGGER
#if defined(WITH_LOGGER) && defined(HAVE_HDF5) && !defined(WITH_MPI)
/* Some standard headers. */
#include <hdf5.h>
......@@ -296,4 +296,4 @@ void write_index_single(struct engine* e, const char* baseName,
++outputCount;
}
#endif /* HAVE_HDF5 */
#endif /* WITH_LOGGER && HAVE_HDF5 && !WITH_MPI */
......@@ -50,11 +50,13 @@ __attribute__((always_inline)) INLINE static void hydro_write_index(
*num_fields = 2;
/* List what we want to write */
list[0] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, 0.f, parts, id, "will be erased");
list[0] =
io_make_output_field("ParticleIDs", ULONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f,
parts, id, "will be erased");
list[1] = io_make_output_field("Offset", ULONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f,
xparts, logger_data.last_offset, "will be erased");
list[1] =
io_make_output_field("Offset", ULONGLONG, 1, UNIT_CONV_NO_UNITS, 0.f,
xparts, logger_data.last_offset, "will be erased");
}
#endif
......
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