diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index d51fc4dd54c817def8263556c89bc04e39fc4488..d752cae0db45c9112a177bd8a5e9ddcda042d458 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -33,7 +33,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" -#include "logger_struct.h" +#include "logger.h" /* Extra particle data not needed during the SPH loops over neighbours. */ struct xpart { diff --git a/src/logger.h b/src/logger.h index 164ac2b9cae975ba6c7c2733a8389437a88c01d8..82482cfa9c8a472f932a2e37bbacdd58c7621e07 100644 --- a/src/logger.h +++ b/src/logger.h @@ -23,13 +23,15 @@ /* Includes. */ #include "common_io.h" -#include "engine.h" -#include "logger_struct.h" -#include "part.h" +#include "inline.h" +#include "timeline.h" #include "units.h" /* Forward declaration */ struct dump; +struct part; +struct gpart; +struct engine; /** * Logger entries contain messages representing the particle data at a given @@ -98,6 +100,80 @@ struct dump; extern char logger_version[logger_version_size]; +#define LOGGER_STRING_LENGTH 200 + +/* parameters of the logger */ +struct logger_parameters { + /* size of a label in bytes */ + size_t label_size; + + /* size of an offset in bytes */ + size_t offset_size; + + /* size of a mask in bytes */ + size_t mask_size; + + /* size of a number in bytes */ + size_t number_size; + + /* size of a data type in bytes */ + size_t data_type_size; + + /* number of different mask */ + size_t nber_mask; + + /* value of each masks */ + size_t *masks; + + /* data size of each mask */ + size_t *masks_data_size; + + /* label of each mask */ + char *masks_name; + +}; + + +/* structure containing global data */ +struct logger { + /* Number of particle steps between dumping a chunk of data */ + short int delta_step; + + /* Logger basename */ + char base_name[LOGGER_STRING_LENGTH]; + + /* File name of the dump file */ + struct dump *dump; + + /* timestamp offset for logger*/ + size_t timestamp_offset; + + /* size of the buffer */ + size_t buffer_size; + + /* scaling factor when buffer is too small */ + float buffer_scale; + + /* logger parameters */ + struct logger_parameters *params; + +} SWIFT_STRUCT_ALIGN; + +/* required structure for each particle type */ +struct logger_part_data { + /* Number of particle updates since last output */ + short int last_output; + + /* offset of last particle log entry */ + size_t last_offset; +}; + +INLINE static void logger_part_data_init( + struct logger_part_data *logger ) { + logger->last_offset = 0; + logger->last_output = SHRT_MAX; +} + enum logger_datatype { logger_data_int, logger_data_float, diff --git a/src/logger_struct.h b/src/logger_struct.h deleted file mode 100644 index 2a707491a7ebd77f84ec2c39c55f1e74ad598d38..0000000000000000000000000000000000000000 --- a/src/logger_struct.h +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * This file is part of SWIFT. - * Copyright (c) 2017 Pedro Gonnet (pedro.gonnet@durham.ac.uk) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - ******************************************************************************/ -#ifndef SWIFT_LOGGER_STRUCT_H -#define SWIFT_LOGGER_STRUCT_H - -#ifdef WITH_LOGGER - -#include <limits.h> - -/* Local Includes */ -#include "dump.h" - -#define LOGGER_STRING_LENGTH 200 - -/* parameters of the logger */ -struct logger_parameters { - /* size of a label in bytes */ - size_t label_size; - - /* size of an offset in bytes */ - size_t offset_size; - - /* size of a mask in bytes */ - size_t mask_size; - - /* size of a number in bytes */ - size_t number_size; - - /* size of a data type in bytes */ - size_t data_type_size; - - /* number of different mask */ - size_t nber_mask; - - /* value of each masks */ - size_t *masks; - - /* data size of each mask */ - size_t *masks_data_size; - - /* label of each mask */ - char *masks_name; - -}; - - -/* structure containing global data */ -struct logger { - /* Number of particle steps between dumping a chunk of data */ - short int delta_step; - - /* Logger basename */ - char base_name[LOGGER_STRING_LENGTH]; - - /* File name of the dump file */ - struct dump *dump; - - /* timestamp offset for logger*/ - size_t timestamp_offset; - - /* size of the buffer */ - size_t buffer_size; - - /* scaling factor when buffer is too small */ - float buffer_scale; - - /* logger parameters */ - struct logger_parameters *params; - -} SWIFT_STRUCT_ALIGN; - -/* required structure for each particle type */ -struct logger_part_data { - /* Number of particle updates since last output */ - short int last_output; - - /* offset of last particle log entry */ - size_t last_offset; -}; - -__attribute__((always_inline)) INLINE static void logger_part_data_init( - struct logger_part_data *logger ) { - logger->last_offset = 0; - logger->last_output = SHRT_MAX; -} - -#endif // WITH_LOGGER - -#endif // SWIFT_LOGGER_STRUCT_H diff --git a/src/parallel_io.h b/src/parallel_io.h index 2de83265f3ff964ae4808da14a8db6aff635cd3c..35d0a1e18b54d85b8f8532bab5117a511568ea7f 100644 --- a/src/parallel_io.h +++ b/src/parallel_io.h @@ -47,7 +47,7 @@ void write_output_parallel(struct engine* e, const char* baseName, int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info); -void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile, +void writeArray(struct engine* e, hid_t grp, char* fileName, char* partTypeGroupName, struct io_props props, size_t N, long long N_total, int mpi_rank, long long offset, const struct unit_system* internal_units, diff --git a/src/swift.h b/src/swift.h index 01fe5ae30e1fda25def0b30340813101794e1b0f..153c4ae0d4440d083f1b0c9850e1f2649c0df6fb 100644 --- a/src/swift.h +++ b/src/swift.h @@ -47,7 +47,6 @@ #include "lock.h" #include "logger.h" #include "logger_io.h" -#include "logger_struct.h" #include "map.h" #include "mesh_gravity.h" #include "multipole.h"