From 001587d24fed7a0ce10071a5eb03726c687fa667 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Mon, 5 Aug 2019 20:18:48 +0200
Subject: [PATCH] Documentation and i/o fixes.

---
 src/io_properties.h                       | 74 +++++++++++++++++++++--
 src/star_formation/EAGLE/star_formation.h |  1 +
 src/star_formation/none/star_formation.h  |  1 +
 src/stars/Default/stars_io.h              |  1 +
 src/stars/EAGLE/stars_io.h                |  1 +
 src/units.c                               |  4 +-
 6 files changed, 76 insertions(+), 6 deletions(-)

diff --git a/src/io_properties.h b/src/io_properties.h
index 07d29c3ce4..d7cc0ebb68 100644
--- a/src/io_properties.h
+++ b/src/io_properties.h
@@ -466,25 +466,34 @@ INLINE static struct io_props io_make_output_field_convert_part_LONGLONG(
  * @param type The type of the data
  * @param dimension Dataset dimension (1D, 3D, ...)
  * @param units The units of the dataset
+ * @param a_exponent Exponent of the scale-factor to convert to physical units.
  * @param gpartSize The size in byte of the particle
  * @param gparts The particle array
  * @param functionPtr The function used to convert a g-particle to a float
+ * @param description Description of the field added to the meta-data.
  *
  * Do not call this function directly. Use the macro defined above.
  */
 INLINE static struct io_props io_make_output_field_convert_gpart_INT(
     const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
-    enum unit_conversion_factor units, size_t gpartSize,
-    const struct gpart* gparts, conversion_func_gpart_int functionPtr) {
+    enum unit_conversion_factor units, float a_exponent, size_t gpartSize,
+    const struct gpart* gparts, conversion_func_gpart_int functionPtr,
+    const char description[DESCRIPTION_BUFFER_SIZE]) {
 
   struct io_props r;
   bzero(&r, sizeof(struct io_props));
 
   strcpy(r.name, name);
+  if (strlen(description) == 0) {
+    sprintf(r.description, "No description given");
+  } else {
+    strcpy(r.description, description);
+  }
   r.type = type;
   r.dimension = dimension;
   r.importance = UNUSED;
   r.units = units;
+  r.scale_factor_exponent = a_exponent;
   r.partSize = gpartSize;
   r.gparts = gparts;
   r.conversion = 1;
@@ -500,9 +509,11 @@ INLINE static struct io_props io_make_output_field_convert_gpart_INT(
  * @param type The type of the data
  * @param dimension Dataset dimension (1D, 3D, ...)
  * @param units The units of the dataset
+ * @param a_exponent Exponent of the scale-factor to convert to physical units.
  * @param gpartSize The size in byte of the particle
  * @param gparts The particle array
  * @param functionPtr The function used to convert a g-particle to a float
+ * @param description Description of the field added to the meta-data.
  *
  * Do not call this function directly. Use the macro defined above.
  */
@@ -639,23 +650,31 @@ INLINE static struct io_props io_make_output_field_convert_gpart_LONGLONG(
  * @param a_exponent Exponent of the scale-factor to convert to physical units.
  * @param spartSize The size in byte of the particle
  * @param sparts The particle array
- * @param functionPtr The function used to convert a g-particle to a float
+ * @param functionPtr The function used to convert a s-particle to a float
+ * @param description Description of the field added to the meta-data.
  *
  * Do not call this function directly. Use the macro defined above.
  */
 INLINE static struct io_props io_make_output_field_convert_spart_INT(
     const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
-    enum unit_conversion_factor units, size_t spartSize,
-    const struct spart* sparts, conversion_func_spart_int functionPtr) {
+    enum unit_conversion_factor units, float a_exponent, size_t spartSize,
+    const struct spart* sparts, conversion_func_spart_int functionPtr,
+    const char description[DESCRIPTION_BUFFER_SIZE]) {
 
   struct io_props r;
   bzero(&r, sizeof(struct io_props));
 
   strcpy(r.name, name);
+  if (strlen(description) == 0) {
+    sprintf(r.description, "No description given");
+  } else {
+    strcpy(r.description, description);
+  }
   r.type = type;
   r.dimension = dimension;
   r.importance = UNUSED;
   r.units = units;
+  r.scale_factor_exponent = a_exponent;
   r.partSize = spartSize;
   r.sparts = sparts;
   r.conversion = 1;
@@ -671,9 +690,11 @@ INLINE static struct io_props io_make_output_field_convert_spart_INT(
  * @param type The type of the data
  * @param dimension Dataset dimension (1D, 3D, ...)
  * @param units The units of the dataset
+ * @param a_exponent Exponent of the scale-factor to convert to physical units.
  * @param spartSize The size in byte of the particle
  * @param sparts The particle array
  * @param functionPtr The function used to convert a g-particle to a float
+ * @param description Description of the field added to the meta-data.
  *
  * Do not call this function directly. Use the macro defined above.
  */
@@ -800,6 +821,49 @@ INLINE static struct io_props io_make_output_field_convert_spart_LONGLONG(
                                             a_exponent, sizeof(bpart[0]),      \
                                             bpart, convert, desc)
 
+/**
+ * @brief Construct an #io_props from its parameters
+ *
+ * @param name Name of the field to read
+ * @param type The type of the data
+ * @param dimension Dataset dimension (1D, 3D, ...)
+ * @param units The units of the dataset
+ * @param a_exponent Exponent of the scale-factor to convert to physical units.
+ * @param bpartSize The size in byte of the particle
+ * @param bparts The particle array
+ * @param functionPtr The function used to convert a b-particle to a float
+ * @param description Description of the field added to the meta-data.
+ *
+ * Do not call this function directly. Use the macro defined above.
+ */
+INLINE static struct io_props io_make_output_field_convert_spart_INT(
+    const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
+    enum unit_conversion_factor units, float a_exponent, size_t bpartSize,
+    const struct bpart* bparts, conversion_func_bpart_int functionPtr,
+    const char description[DESCRIPTION_BUFFER_SIZE]) {
+
+  struct io_props r;
+  bzero(&r, sizeof(struct io_props));
+
+  strcpy(r.name, name);
+  if (strlen(description) == 0) {
+    sprintf(r.description, "No description given");
+  } else {
+    strcpy(r.description, description);
+  }
+  r.type = type;
+  r.dimension = dimension;
+  r.importance = UNUSED;
+  r.units = units;
+  r.scale_factor_exponent = a_exponent;
+  r.partSize = bpartSize;
+  r.bparts = bparts;
+  r.conversion = 1;
+  r.convert_bpart_i = functionPtr;
+
+  return r;
+}
+
 /**
  * @brief Construct an #io_props from its parameters
  *
diff --git a/src/star_formation/EAGLE/star_formation.h b/src/star_formation/EAGLE/star_formation.h
index 55f1c8d427..f2c77e0368 100644
--- a/src/star_formation/EAGLE/star_formation.h
+++ b/src/star_formation/EAGLE/star_formation.h
@@ -687,6 +687,7 @@ star_formation_first_init_part(const struct phys_const* restrict phys_const,
  * density loop for the EAGLE star formation model.
  *
  * @param p Pointer to the particle data.
+ * @param xp Pointer to the extended particle data.
  * @param data The global star_formation information.
  */
 __attribute__((always_inline)) INLINE static void star_formation_init_part(
diff --git a/src/star_formation/none/star_formation.h b/src/star_formation/none/star_formation.h
index 3275e1a4c4..6b83010ec5 100644
--- a/src/star_formation/none/star_formation.h
+++ b/src/star_formation/none/star_formation.h
@@ -216,6 +216,7 @@ star_formation_first_init_part(const struct phys_const* restrict phys_const,
  * Nothing to do here.
  *
  * @param p Pointer to the particle data.
+ * @param xp Pointer to the extended particle data.
  * @param data The global star_formation information.
  */
 __attribute__((always_inline)) INLINE static void star_formation_init_part(
diff --git a/src/stars/Default/stars_io.h b/src/stars/Default/stars_io.h
index 2a824aaa99..54e6b5d05a 100644
--- a/src/stars/Default/stars_io.h
+++ b/src/stars/Default/stars_io.h
@@ -102,6 +102,7 @@ INLINE static void convert_spart_vel(const struct engine *e,
  * @param sparts The s-particle array.
  * @param list The list of i/o properties to write.
  * @param num_fields The number of i/o fields to write.
+ * @param with_cosmology Are we running a cosmological simulation?
  */
 INLINE static void stars_write_particles(const struct spart *sparts,
                                          struct io_props *list, int *num_fields,
diff --git a/src/stars/EAGLE/stars_io.h b/src/stars/EAGLE/stars_io.h
index 8e3f605692..b67c570787 100644
--- a/src/stars/EAGLE/stars_io.h
+++ b/src/stars/EAGLE/stars_io.h
@@ -105,6 +105,7 @@ INLINE static void convert_spart_vel(const struct engine *e,
  * @param sparts The s-particle array.
  * @param list The list of i/o properties to write.
  * @param num_fields The number of i/o fields to write.
+ * @param with_cosmology Are we running a cosmological simulation?
  */
 INLINE static void stars_write_particles(const struct spart *sparts,
                                          struct io_props *list, int *num_fields,
diff --git a/src/units.c b/src/units.c
index 58422bfffe..c7fe549aff 100644
--- a/src/units.c
+++ b/src/units.c
@@ -489,7 +489,9 @@ float units_general_h_factor(const struct unit_system* us,
  * 140 chars at most)
  * @param us The UnitsSystem in use.
  * @param baseUnitsExponents The exponent of each base units required to form
- * the desired quantity. See conversionFactor() for a working example
+ * the desired quantity. See conversionFactor() for a working example.
+ * @param scale_factor_exponent The scale-factor exponent to use to convert this
+ * unit to physical units.
  */
 void units_general_cgs_conversion_string(char* buffer,
                                          const struct unit_system* us,
-- 
GitLab