Skip to content
Snippets Groups Projects
Commit e185bf92 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Fixes API

parent f10d5d0e
No related branches found
No related tags found
1 merge request!1028WIP: Logger: scheme dependent output
...@@ -64,8 +64,8 @@ void check_data(struct logger_reader *reader, struct part *parts, ...@@ -64,8 +64,8 @@ void check_data(struct logger_reader *reader, struct part *parts,
/* Number of particle found during this time step. */ /* Number of particle found during this time step. */
int count = 0; int count = 0;
/* Set it to an impossible value in order to flag it. */ /* Set it to an impossible value in order to flag it. */
const long long id_flag = 5 * number_parts; const uint64_t id_flag = 5 * number_parts;
long long previous_id = id_flag; uint64_t previous_id = id_flag;
/* Loop over each record. */ /* Loop over each record. */
for (size_t offset = for (size_t offset =
...@@ -89,7 +89,7 @@ void check_data(struct logger_reader *reader, struct part *parts, ...@@ -89,7 +89,7 @@ void check_data(struct logger_reader *reader, struct part *parts,
} }
/* Get the corresponding particle */ /* Get the corresponding particle */
if (lp.id >= number_parts) error("Wrong id %lli", lp.id); if (lp.id >= number_parts) error("Wrong id %li", lp.id);
struct part *p = &parts[lp.id]; struct part *p = &parts[lp.id];
......
...@@ -94,8 +94,7 @@ int main(int argc, char *argv[]) { ...@@ -94,8 +94,7 @@ int main(int argc, char *argv[]) {
array.hydro.parts = particles; array.hydro.parts = particles;
array.hydro.n = n_tot; array.hydro.n = n_tot;
logger_reader_read_all_particles(&reader, begin, logger_reader_const, &array, logger_reader_read_all_particles(&reader, begin, logger_reader_const, &array);
n_tot);
/* Loop over time for a single particle */ /* Loop over time for a single particle */
size_t id = 0; size_t id = 0;
...@@ -112,7 +111,7 @@ int main(int argc, char *argv[]) { ...@@ -112,7 +111,7 @@ int main(int argc, char *argv[]) {
message("Particle %zi: %f %f %f %f", id, p.x[0], p.x[1], p.x[2], p.time); message("Particle %zi: %f %f %f %f", id, p.x[0], p.x[1], p.x[2], p.time);
/* Now you can interpolate */ /* Now you can interpolate */
logger_particle_interpolate(&p, &n, t); p = logger_particle_interpolate(&p, &n, t);
} }
/* Cleanup the memory */ /* Cleanup the memory */
......
...@@ -197,9 +197,12 @@ void test_log_timestamps(struct logger_writer *log) { ...@@ -197,9 +197,12 @@ void test_log_timestamps(struct logger_writer *log) {
size_t offset_old = offset; size_t offset_old = offset;
t = 0; t = 0;
time = 0; time = 0;
int mask = logger_read_timestamp(log, &t, &time, &offset, (const char *)d->data); int mask =
printf("Recovered timestamp %020llu with time %g at offset %#016zx with mask %#04x.\n", t, logger_read_timestamp(log, &t, &time, &offset, (const char *)d->data);
time, offset_old, mask); printf(
"Recovered timestamp %020llu with time %g at offset %#016zx with mask "
"%#04x.\n",
t, time, offset_old, mask);
if (t != 30) { if (t != 30) {
printf("FAIL: could not recover correct timestamp.\n"); printf("FAIL: could not recover correct timestamp.\n");
abort(); abort();
...@@ -213,8 +216,10 @@ void test_log_timestamps(struct logger_writer *log) { ...@@ -213,8 +216,10 @@ void test_log_timestamps(struct logger_writer *log) {
t = 0; t = 0;
time = 0; time = 0;
mask = logger_read_timestamp(log, &t, &time, &offset, (const char *)d->data); mask = logger_read_timestamp(log, &t, &time, &offset, (const char *)d->data);
printf("Recovered timestamp %020llu with time %g at offset %#016zx with mask %#04x.\n", t, printf(
time, offset_old, mask); "Recovered timestamp %020llu with time %g at offset %#016zx with mask "
"%#04x.\n",
t, time, offset_old, mask);
if (t != 20) { if (t != 20) {
printf("FAIL: could not recover correct timestamp.\n"); printf("FAIL: could not recover correct timestamp.\n");
abort(); abort();
...@@ -228,8 +233,10 @@ void test_log_timestamps(struct logger_writer *log) { ...@@ -228,8 +233,10 @@ void test_log_timestamps(struct logger_writer *log) {
t = 0; t = 0;
time = 0; time = 0;
mask = logger_read_timestamp(log, &t, &time, &offset, (const char *)d->data); mask = logger_read_timestamp(log, &t, &time, &offset, (const char *)d->data);
printf("Recovered timestamp %020llu with time %g at offset %#016zx with mask %#04x.\n", t, printf(
time, offset_old, mask); "Recovered timestamp %020llu with time %g at offset %#016zx with mask "
"%#04x.\n",
t, time, offset_old, mask);
if (t != 10) { if (t != 10) {
printf("FAIL: could not recover correct timestamp.\n"); printf("FAIL: could not recover correct timestamp.\n");
abort(); abort();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment