Skip to content
Snippets Groups Projects
Commit 07fc51c5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added Git branch name and revision hash to the HDF5 outputs.

Former-commit-id: 58a47014358ecbbdd6c63a294b7ed5cae3cc0e3c
parent 94e9f3d6
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "const.h" #include "const.h"
#include "error.h" #include "error.h"
#include "kernel.h" #include "kernel.h"
#include "version.h"
/** /**
* @brief Converts a C data type to the HDF5 equivalent. * @brief Converts a C data type to the HDF5 equivalent.
...@@ -182,7 +183,7 @@ void writeAttribute(hid_t grp, char* name, enum DATA_TYPE type, void* data, ...@@ -182,7 +183,7 @@ void writeAttribute(hid_t grp, char* name, enum DATA_TYPE type, void* data,
* *
* Calls #error() if an error occurs. * Calls #error() if an error occurs.
*/ */
void writeStringAttribute(hid_t grp, char* name, char* str, int length) { void writeStringAttribute(hid_t grp, char* name, const char* str, int length) {
hid_t h_space = 0, h_attr = 0, h_err = 0, h_type = 0; hid_t h_space = 0, h_attr = 0, h_err = 0, h_type = 0;
h_space = H5Screate(H5S_SCALAR); h_space = H5Screate(H5S_SCALAR);
...@@ -262,7 +263,7 @@ void writeAttribute_l(hid_t grp, char* name, long data) { ...@@ -262,7 +263,7 @@ void writeAttribute_l(hid_t grp, char* name, long data) {
* @param name The name of the attribute * @param name The name of the attribute
* @param str The string to write * @param str The string to write
*/ */
void writeAttribute_s(hid_t grp, char* name, char* str) { void writeAttribute_s(hid_t grp, char* name, const char* str) {
writeStringAttribute(grp, name, str, strlen(str)); writeStringAttribute(grp, name, str, strlen(str));
} }
...@@ -344,6 +345,23 @@ void writeUnitSystem(hid_t h_file, struct UnitSystem* us) { ...@@ -344,6 +345,23 @@ void writeUnitSystem(hid_t h_file, struct UnitSystem* us) {
H5Gclose(h_grpunit); H5Gclose(h_grpunit);
} }
/**
* @brief Writes the code version to the file
* @param h_file The (opened) HDF5 file in which to write
*/
void writeCodeDescription(hid_t h_file) {
hid_t h_grpcode = 0;
h_grpcode = H5Gcreate1(h_file, "/Code", 0);
if (h_grpcode < 0) error("Error while creating code group");
writeAttribute_s(h_grpcode, "Code Version", package_version());
writeAttribute_s(h_grpcode, "Git Branch", git_branch());
writeAttribute_s(h_grpcode, "Git Revision", git_revision());
H5Gclose(h_grpcode);
}
/** /**
* @brief Prepares the XMF file for the new entry * @brief Prepares the XMF file for the new entry
* *
... ...
......
...@@ -67,7 +67,7 @@ void writeAttribute_d(hid_t grp, char* name, double data); ...@@ -67,7 +67,7 @@ void writeAttribute_d(hid_t grp, char* name, double data);
void writeAttribute_f(hid_t grp, char* name, float data); void writeAttribute_f(hid_t grp, char* name, float data);
void writeAttribute_i(hid_t grp, char* name, int data); void writeAttribute_i(hid_t grp, char* name, int data);
void writeAttribute_l(hid_t grp, char* name, long data); void writeAttribute_l(hid_t grp, char* name, long data);
void writeAttribute_s(hid_t grp, char* name, char* str); void writeAttribute_s(hid_t grp, char* name, const char* str);
void createXMFfile(); void createXMFfile();
FILE* prepareXMFfile(); FILE* prepareXMFfile();
...@@ -76,16 +76,8 @@ void writeXMFheader(FILE* xmfFile, long long N, char* hdfFileName, float time); ...@@ -76,16 +76,8 @@ void writeXMFheader(FILE* xmfFile, long long N, char* hdfFileName, float time);
void writeXMFline(FILE* xmfFile, char* fileName, char* name, long long N, void writeXMFline(FILE* xmfFile, char* fileName, char* name, long long N,
int dim, enum DATA_TYPE type); int dim, enum DATA_TYPE type);
/** void writeCodeDescription(hid_t h_file);
* @brief Writes the current model of SPH to the file
* @param h_file The (opened) HDF5 file in which to write
*/
void writeSPHflavour(hid_t h_file); void writeSPHflavour(hid_t h_file);
/**
* @brief Writes the current Unit System
* @param h_file The (opened) HDF5 file in which to write
*/
void writeUnitSystem(hid_t h_file, struct UnitSystem* us); void writeUnitSystem(hid_t h_file, struct UnitSystem* us);
#endif #endif
... ...
......
...@@ -558,6 +558,9 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us, ...@@ -558,6 +558,9 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us,
/* Close header */ /* Close header */
H5Gclose(h_grp); H5Gclose(h_grp);
/* Print the code version */
writeCodeDescription(h_file);
/* Print the SPH parameters */ /* Print the SPH parameters */
writeSPHflavour(h_file); writeSPHflavour(h_file);
... ...
......
...@@ -576,7 +576,6 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, ...@@ -576,7 +576,6 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
double dblTime = e->time; double dblTime = e->time;
writeAttribute(h_grp, "Time", DOUBLE, &dblTime, 1); writeAttribute(h_grp, "Time", DOUBLE, &dblTime, 1);
/* GADGET-2 legacy values */ /* GADGET-2 legacy values */
numParticles[0] = (unsigned int)N_total; numParticles[0] = (unsigned int)N_total;
writeAttribute(h_grp, "NumPart_ThisFile", UINT, numParticles, 6); writeAttribute(h_grp, "NumPart_ThisFile", UINT, numParticles, 6);
...@@ -592,6 +591,9 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, ...@@ -592,6 +591,9 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
/* Close header */ /* Close header */
H5Gclose(h_grp); H5Gclose(h_grp);
/* Print the code version */
writeCodeDescription(h_file);
/* Print the SPH parameters */ /* Print the SPH parameters */
writeSPHflavour(h_file); writeSPHflavour(h_file);
... ...
......
...@@ -445,6 +445,9 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { ...@@ -445,6 +445,9 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Close header */ /* Close header */
H5Gclose(h_grp); H5Gclose(h_grp);
/* Print the code version */
writeCodeDescription(h_file);
/* Print the SPH parameters */ /* Print the SPH parameters */
writeSPHflavour(h_file); writeSPHflavour(h_file);
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment