Commit 871123b8 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Logger: make filename more specific

parent e7ede3af
...@@ -34,36 +34,36 @@ EXTRA_LIBS = $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS ...@@ -34,36 +34,36 @@ EXTRA_LIBS = $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS
# MPI_LIBS = $(MPI_THREAD_LIBS) # MPI_LIBS = $(MPI_THREAD_LIBS)
# MPI_FLAGS = -DWITH_MPI # MPI_FLAGS = -DWITH_MPI
# Build the libswiftsim library # Build the liblogger library
lib_LTLIBRARIES = libswiftlogger.la lib_LTLIBRARIES = liblogger.la
# Build a MPI-enabled version too? # Build a MPI-enabled version too?
# if HAVEMPI # if HAVEMPI
# lib_LTLIBRARIES += libswiftlogger_mpi.la # lib_LTLIBRARIES += liblogger_mpi.la
# endif # endif
# List required headers # List required headers
include_HEADERS = header.h io.h particle.h timeline.h logger_tools.h include_HEADERS = logger_header.h logger_io.h logger_particle.h logger_time.h logger_tools.h logger_reader.h
# Common source files # Common source files
AM_SOURCES = header.c io.c particle.c timeline.c logger_tools.c AM_SOURCES = logger_header.c logger_io.c logger_particle.c logger_time.c logger_tools.c logger_reader.c
if HAVEPYTHON if HAVEPYTHON
AM_SOURCES += logger_loader.c AM_SOURCES += logger_python_wrapper.c
endif endif
# Include files for distribution, not installation. # Include files for distribution, not installation.
nobase_noinst_HEADERS = nobase_noinst_HEADERS =
# Sources and flags for regular library # Sources and flags for regular library
libswiftlogger_la_SOURCES = $(AM_SOURCES) liblogger_la_SOURCES = $(AM_SOURCES)
libswiftlogger_la_CFLAGS = $(AM_CFLAGS) liblogger_la_CFLAGS = $(AM_CFLAGS)
libswiftlogger_la_LDFLAGS = $(AM_LDFLAGS) $(EXTRA_LIBS) $(BIN_LDFLAGS) liblogger_la_LDFLAGS = $(AM_LDFLAGS) $(EXTRA_LIBS) $(BIN_LDFLAGS)
# Sources and flags for MPI library # Sources and flags for MPI library
# libswiftlogger_mpi_la_SOURCES = $(AM_SOURCES) # liblogger_mpi_la_SOURCES = $(AM_SOURCES)
# libswiftlogger_mpi_la_CFLAGS = $(AM_CFLAGS) $(MPI_FLAGS) # liblogger_mpi_la_CFLAGS = $(AM_CFLAGS) $(MPI_FLAGS)
# libswiftlogger_mpi_la_LDFLAGS = $(AM_LDFLAGS) $(MPI_LIBS) $(EXTRA_LIBS) # liblogger_mpi_la_LDFLAGS = $(AM_LDFLAGS) $(MPI_LIBS) $(EXTRA_LIBS)
# libswiftlogger_mpi_la_SHORTNAME = mpi # liblogger_mpi_la_SHORTNAME = mpi
# libswiftlogger_mpi_la_LIBADD = # liblogger_mpi_la_LIBADD =
# Versioning. If any sources change then update the version_string.h file with # Versioning. If any sources change then update the version_string.h file with
# the current git revision and package version. # the current git revision and package version.
......
#include "header.h" #include "logger_header.h"
#include "io.h" #include "logger_io.h"
#include "logger_tools.h" #include "logger_tools.h"
#include <stdio.h> #include <stdio.h>
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include "header.h" #include "logger_header.h"
#include "io.h" #include "logger_io.h"
#include "logger_tools.h" #include "logger_tools.h"
/** /**
......
#ifndef __SWIFT_LOGGER_IO_H__ #ifndef __SWIFT_LOGGER_IO_H__
#define __SWIFT_LOGGER_IO_H__ #define __SWIFT_LOGGER_IO_H__
#include "header.h" #include "logger_header.h"
#include "logger_tools.h" #include "logger_tools.h"
#include <stdio.h> #include <stdio.h>
......
#include "particle.h" #include "logger_particle.h"
#include "header.h" #include "logger_header.h"
#include "io.h" #include "logger_io.h"
#include "logger_tools.h" #include "logger_tools.h"
#include "timeline.h" #include "logger_time.h"
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
......
#ifndef __PARTICLE_H__ #ifndef __PARTICLE_H__
#define __PARTICLE_H__ #define __PARTICLE_H__
#include "header.h" #include "logger_header.h"
#include "logger_tools.h" #include "logger_tools.h"
#include "timeline.h" #include "logger_time.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
......
#include "header.h" #include "logger_header.h"
#include "io.h" #include "logger_io.h"
#include "particle.h" #include "logger_particle.h"
#include "timeline.h" #include "logger_time.h"
#include "logger_reader.h"
#include <Python.h> #include <Python.h>
#include <errno.h> #include <errno.h>
...@@ -9,82 +10,6 @@ ...@@ -9,82 +10,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/**
* @brief Reverse offset in dump file
*
* @param filename string filename of the dump file
*/
int reverseOffset(char *filename) {
struct header h;
/* open file */
int fd;
void *map;
if (io_open_file(filename, &fd, &map) != 0) return 1;
/* read header */
if (header_read(&h, map) != 0) return 1;
header_print(&h);
/* check offset direction */
if (h.forward_offset) {
error_no_return(EIO, "Offset are already reversed");
return 1;
}
/* compute file size */
size_t sz;
int status = io_get_file_size(fd, &sz);
if (status != 0) return 1;
size_t offset;
int error_code;
#ifdef SWIFT_DEBUG_CHECKS
/* check offset */
printf("Check offsets...\n");
offset = h.offset_first;
while (offset < sz) {
error_code = tools_check_offset(&h, map, &offset);
if (error_code != 0) return 1;
}
printf("Check done\n");
#endif
/* reverse header offset */
header_change_offset_direction(&h, map);
offset = h.offset_first;
/* reverse chunks */
printf("Reversing offsets...\n");
while (offset < sz) {
error_code = tools_reverse_offset(&h, map, &offset);
if (error_code != 0) return 1;
}
printf("Reversing done\n");
#ifdef SWIFT_DEBUG_CHECKS
/* check offset */
printf("Check offsets...\n");
offset = h.offset_first;
while (offset < sz) {
error_code = tools_check_offset(&h, map, &offset);
if (error_code != 0) return 1;
}
printf("Check done\n");
#endif
/* free internal variables */
header_free(&h);
if (io_close_file(&fd, &map) != 0) return 1;
return 0;
}
/** /**
* @brief load data from the offset without any interpolation * @brief load data from the offset without any interpolation
* *
...@@ -143,7 +68,7 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self, ...@@ -143,7 +68,7 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
if (!h.forward_offset) { if (!h.forward_offset) {
if (io_close_file(&fd, &map) != 0) return NULL; if (io_close_file(&fd, &map) != 0) return NULL;
if (reverseOffset(filename) != 0) return NULL; if (reverse_offset(filename) != 0) return NULL;
if (io_open_file(filename, &fd, &map) != 0) return NULL; if (io_open_file(filename, &fd, &map) != 0) return NULL;
...@@ -328,14 +253,14 @@ static PyObject *pyReverseOffset(__attribute__((unused)) PyObject *self, ...@@ -328,14 +253,14 @@ static PyObject *pyReverseOffset(__attribute__((unused)) PyObject *self,
if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; if (!PyArg_ParseTuple(args, "s", &filename)) return NULL;
if (reverseOffset(filename) != 0) return NULL; if (reverse_offset(filename) != 0) return NULL;
return Py_BuildValue(""); return Py_BuildValue("");
} }
/* definition of the method table */ /* definition of the method table */
static PyMethodDef libswiftloggerMethods[] = { static PyMethodDef libloggerMethods[] = {
{"loadFromIndex", loadFromIndex, METH_VARARGS, {"loadFromIndex", loadFromIndex, METH_VARARGS,
"Load snapshot directly from the offset in an index file."}, "Load snapshot directly from the offset in an index file."},
{"reverseOffset", pyReverseOffset, METH_VARARGS, {"reverseOffset", pyReverseOffset, METH_VARARGS,
...@@ -344,21 +269,21 @@ static PyMethodDef libswiftloggerMethods[] = { ...@@ -344,21 +269,21 @@ static PyMethodDef libswiftloggerMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */ {NULL, NULL, 0, NULL} /* Sentinel */
}; };
static struct PyModuleDef libswiftloggermodule = { static struct PyModuleDef libloggermodule = {
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
"libswiftlogger", "liblogger",
"Module reading a SWIFTsim logger snapshot", "Module reading a SWIFTsim logger snapshot",
-1, -1,
libswiftloggerMethods, libloggerMethods,
NULL, /* m_slots */ NULL, /* m_slots */
NULL, /* m_traverse */ NULL, /* m_traverse */
NULL, /* m_clear */ NULL, /* m_clear */
NULL /* m_free */ NULL /* m_free */
}; };
PyMODINIT_FUNC PyInit_libswiftlogger(void) { PyMODINIT_FUNC PyInit_liblogger(void) {
PyObject *m; PyObject *m;
m = PyModule_Create(&libswiftloggermodule); m = PyModule_Create(&libloggermodule);
if (m == NULL) return NULL; if (m == NULL) return NULL;
import_array(); import_array();
......
#include "timeline.h" #include "logger_time.h"
#include "io.h" #include "logger_io.h"
/** /**
* @brief convert an integer time to a real time * @brief convert an integer time to a real time
......
#ifndef __TIMELINE_H__ #ifndef __TIMELINE_H__
#define __TIMELINE_H__ #define __TIMELINE_H__
#include "header.h" #include "logger_header.h"
#include "logger_tools.h" #include "logger_tools.h"
typedef char timebin_t; typedef char timebin_t;
......
#include "logger_tools.h" #include "logger_tools.h"
#include "header.h" #include "logger_header.h"
#include "io.h" #include "logger_io.h"
#include "particle.h" #include "logger_particle.h"
#include <stdio.h> #include <stdio.h>
......
...@@ -9,7 +9,7 @@ import numpy as np ...@@ -9,7 +9,7 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
sys.path.append("../.libs/") sys.path.append("../.libs/")
import libswiftlogger as logger import liblogger as logger
# Get filenames # Get filenames
if len(sys.argv) != 3: if len(sys.argv) != 3:
......
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