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
......@@ -43,6 +43,7 @@
#include "const.h"
#include "error.h"
#include "kernel.h"
#include "version.h"
/**
* @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,
*
* 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;
h_space = H5Screate(H5S_SCALAR);
......@@ -262,7 +263,7 @@ void writeAttribute_l(hid_t grp, char* name, long data) {
* @param name The name of the attribute
* @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));
}
......@@ -344,6 +345,23 @@ void writeUnitSystem(hid_t h_file, struct UnitSystem* us) {
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
*
......
......@@ -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_i(hid_t grp, char* name, int 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();
FILE* prepareXMFfile();
......@@ -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,
int dim, enum DATA_TYPE type);
/**
* @brief Writes the current model of SPH to the file
* @param h_file The (opened) HDF5 file in which to write
*/
void writeCodeDescription(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);
#endif
......
......@@ -558,6 +558,9 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us,
/* Close header */
H5Gclose(h_grp);
/* Print the code version */
writeCodeDescription(h_file);
/* Print the SPH parameters */
writeSPHflavour(h_file);
......
......@@ -576,7 +576,6 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank,
double dblTime = e->time;
writeAttribute(h_grp, "Time", DOUBLE, &dblTime, 1);
/* GADGET-2 legacy values */
numParticles[0] = (unsigned int)N_total;
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,
/* Close header */
H5Gclose(h_grp);
/* Print the code version */
writeCodeDescription(h_file);
/* Print the SPH parameters */
writeSPHflavour(h_file);
......
......@@ -445,6 +445,9 @@ void write_output_single(struct engine* e, struct UnitSystem* us) {
/* Close header */
H5Gclose(h_grp);
/* Print the code version */
writeCodeDescription(h_file);
/* Print the SPH parameters */
writeSPHflavour(h_file);
......
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