From e7f6698bfda65989e86edeac173e51f61ff87610 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Mon, 23 Apr 2018 18:24:52 +0200
Subject: [PATCH] Added a file to switch the import of the i/o cooling to mimic
 what is done for the chemistry.

---
 src/Makefile.am                       |  4 +--
 src/chemistry/none/chemistry.h        |  5 +++-
 src/cooling/EAGLE/cooling.h           |  9 +++---
 src/cooling/EAGLE/cooling_io.h        |  6 +++-
 src/cooling/const_du/cooling.h        |  6 ++--
 src/cooling/const_du/cooling_io.h     |  6 +++-
 src/cooling/const_lambda/cooling.h    |  5 ++--
 src/cooling/const_lambda/cooling_io.h |  7 +++--
 src/cooling/grackle/cooling.h         | 14 ++++++----
 src/cooling/grackle/cooling_io.h      |  5 +++-
 src/cooling/none/cooling.h            |  7 +++--
 src/cooling/none/cooling_io.h         |  8 ++++--
 src/cooling_io.h                      | 40 +++++++++++++++++++++++++++
 src/parallel_io.c                     |  2 +-
 src/serial_io.c                       |  2 +-
 src/single_io.c                       |  2 +-
 16 files changed, 97 insertions(+), 31 deletions(-)
 create mode 100644 src/cooling_io.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 749664665a..e21cb6539d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,8 +43,8 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
     engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
     common_io.h single_io.h multipole.h map.h tools.h partition.h clocks.h parser.h \
     physical_constants.h physical_constants_cgs.h potential.h version.h \
-    hydro_properties.h riemann.h threadpool.h cooling.h cooling_struct.h sourceterms.h \
-    sourceterms_struct.h statistics.h memswap.h cache.h runner_doiact_vec.h profiler.h \
+    hydro_properties.h riemann.h threadpool.h cooling_io.h cooling.h cooling_struct.h \
+    sourceterms.h sourceterms_struct.h statistics.h memswap.h cache.h runner_doiact_vec.h profiler.h \
     dump.h logger.h active.h timeline.h xmf.h gravity_properties.h gravity_derivatives.h \
     gravity_softened_derivatives.h vector_power.h collectgroup.h hydro_space.h sort_part.h \
     chemistry.h chemistry_io.h chemistry_struct.h cosmology.h restart.h
diff --git a/src/chemistry/none/chemistry.h b/src/chemistry/none/chemistry.h
index 7a9189357c..3ca51660dd 100644
--- a/src/chemistry/none/chemistry.h
+++ b/src/chemistry/none/chemistry.h
@@ -92,9 +92,12 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
  *
  * Nothing to do here.
  *
+ * @param phys_const The physical constant in internal units.
+ * @param us The unit system.
+ * @param cosmo The current cosmological model.
+ * @param data The global chemistry information used for this run.
  * @param p Pointer to the particle data.
  * @param xp Pointer to the extended particle data.
- * @param data The global chemistry information used for this run.
  */
 __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
     const struct phys_const* restrict phys_const,
diff --git a/src/cooling/EAGLE/cooling.h b/src/cooling/EAGLE/cooling.h
index d0bea0ec76..bdf3801887 100644
--- a/src/cooling/EAGLE/cooling.h
+++ b/src/cooling/EAGLE/cooling.h
@@ -20,19 +20,20 @@
 #define SWIFT_COOLING_EAGLE_H
 
 /**
- * @file src/cooling/none/cooling.h
- * @brief Empty infrastructure for the cases without cooling function
+ * @file src/cooling/EAGLE/cooling.h
+ * @brief EAGLE cooling function
  */
 
+/* Config parameters. */
+#include "../config.h"
+
 /* Some standard headers. */
 #include <float.h>
 #include <math.h>
 
 /* Local includes. */
-#include "cooling_io.h"
 #include "error.h"
 #include "hydro.h"
-#include "io_properties.h"
 #include "parser.h"
 #include "part.h"
 #include "physical_constants.h"
diff --git a/src/cooling/EAGLE/cooling_io.h b/src/cooling/EAGLE/cooling_io.h
index 314c921dd2..d6ed4f1228 100644
--- a/src/cooling/EAGLE/cooling_io.h
+++ b/src/cooling/EAGLE/cooling_io.h
@@ -19,6 +19,10 @@
 #ifndef SWIFT_COOLING_EAGLE_IO_H
 #define SWIFT_COOLING_EAGLE_IO_H
 
+/* Config parameters. */
+#include "../config.h"
+
+/* Local includes */
 #include "io_properties.h"
 
 #ifdef HAVE_HDF5
@@ -49,4 +53,4 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles(
   return 0;
 }
 
-#endif  // SWIFT_COOLING_EAGLE_IO_H
+#endif /* SWIFT_COOLING_EAGLE_IO_H */
diff --git a/src/cooling/const_du/cooling.h b/src/cooling/const_du/cooling.h
index 95d90654d7..ba82111749 100644
--- a/src/cooling/const_du/cooling.h
+++ b/src/cooling/const_du/cooling.h
@@ -30,16 +30,16 @@
  * realistic functions.
  */
 
+/* Config parameters. */
+#include "../config.h"
+
 /* Some standard headers. */
 #include <math.h>
 
 /* Local includes. */
 #include "const.h"
-#include "cooling_io.h"
-#include "cooling_struct.h"
 #include "error.h"
 #include "hydro.h"
-#include "io_properties.h"
 #include "parser.h"
 #include "part.h"
 #include "physical_constants.h"
diff --git a/src/cooling/const_du/cooling_io.h b/src/cooling/const_du/cooling_io.h
index cc9347617f..52a943aca8 100644
--- a/src/cooling/const_du/cooling_io.h
+++ b/src/cooling/const_du/cooling_io.h
@@ -21,6 +21,10 @@
 #ifndef SWIFT_COOLING_CONST_DU_IO_H
 #define SWIFT_COOLING_CONST_DU_IO_H
 
+/* Config parameters. */
+#include "../config.h"
+
+/* Local includes */
 #include "io_properties.h"
 
 #ifdef HAVE_HDF5
@@ -51,4 +55,4 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles(
   return 0;
 }
 
-#endif  // SWIFT_COOLING_CONST_DU_IO_H
+#endif /* SWIFT_COOLING_CONST_DU_IO_H */
diff --git a/src/cooling/const_lambda/cooling.h b/src/cooling/const_lambda/cooling.h
index 5007880ad1..43ca7ab75b 100644
--- a/src/cooling/const_lambda/cooling.h
+++ b/src/cooling/const_lambda/cooling.h
@@ -23,16 +23,17 @@
 #ifndef SWIFT_COOLING_CONST_LAMBDA_H
 #define SWIFT_COOLING_CONST_LAMBDA_H
 
+/* Config parameters. */
+#include "../config.h"
+
 /* Some standard headers. */
 #include <float.h>
 #include <math.h>
 
 /* Local includes. */
 #include "const.h"
-#include "cooling_io.h"
 #include "error.h"
 #include "hydro.h"
-#include "io_properties.h"
 #include "parser.h"
 #include "part.h"
 #include "physical_constants.h"
diff --git a/src/cooling/const_lambda/cooling_io.h b/src/cooling/const_lambda/cooling_io.h
index 49e87ca1d5..89c9471a29 100644
--- a/src/cooling/const_lambda/cooling_io.h
+++ b/src/cooling/const_lambda/cooling_io.h
@@ -19,10 +19,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  ******************************************************************************/
-
 #ifndef SWIFT_COOLING_CONST_LAMBDA_IO_H
 #define SWIFT_COOLING_CONST_LAMBDA_IO_H
 
+/* Config parameters. */
+#include "../config.h"
+
+/* Local includes */
 #include "io_properties.h"
 
 #ifdef HAVE_HDF5
@@ -53,4 +56,4 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles(
   return 0;
 }
 
-#endif  // SWIFT_COOLING_CONST_LAMBDA_IO_H
+#endif /* SWIFT_COOLING_CONST_LAMBDA_IO_H */
diff --git a/src/cooling/grackle/cooling.h b/src/cooling/grackle/cooling.h
index e0c25015ed..dd59e9af14 100644
--- a/src/cooling/grackle/cooling.h
+++ b/src/cooling/grackle/cooling.h
@@ -20,22 +20,24 @@
 #define SWIFT_COOLING_GRACKLE_H
 
 /**
- * @file src/cooling/none/cooling.h
- * @brief Empty infrastructure for the cases without cooling function
+ * @file src/cooling/grackle/cooling.h
+ * @brief Cooling using the GRACKLE 3.0 library.
  */
 
+/* Config parameters. */
+#include "../config.h"
+
 /* Some standard headers. */
 #include <float.h>
-#include <grackle.h>
 #include <math.h>
 
+/* The grackle library itself */
+#include <grackle.h>
+
 /* Local includes. */
-#include "../config.h"
 #include "chemistry.h"
-#include "cooling_io.h"
 #include "error.h"
 #include "hydro.h"
-#include "io_properties.h"
 #include "parser.h"
 #include "part.h"
 #include "physical_constants.h"
diff --git a/src/cooling/grackle/cooling_io.h b/src/cooling/grackle/cooling_io.h
index ef7a8f27f9..5a6edb8f1c 100644
--- a/src/cooling/grackle/cooling_io.h
+++ b/src/cooling/grackle/cooling_io.h
@@ -19,7 +19,10 @@
 #ifndef SWIFT_COOLING_GRACKLE_IO_H
 #define SWIFT_COOLING_GRACKLE_IO_H
 
+/* Config parameters. */
 #include "../config.h"
+
+/* Local includes */
 #include "cooling_struct.h"
 #include "io_properties.h"
 
@@ -163,4 +166,4 @@ __attribute__((always_inline)) INLINE static void cooling_read_parameters(
       parameter_file, "GrackleCooling:ConvergenceLimit", 1e-2);
 }
 
-#endif  // SWIFT_COOLING_GRACKLE_IO_H
+#endif /* SWIFT_COOLING_GRACKLE_IO_H */
diff --git a/src/cooling/none/cooling.h b/src/cooling/none/cooling.h
index 4da220c93f..5081c7cbe6 100644
--- a/src/cooling/none/cooling.h
+++ b/src/cooling/none/cooling.h
@@ -29,10 +29,8 @@
 #include <math.h>
 
 /* Local includes. */
-#include "cooling_io.h"
 #include "error.h"
 #include "hydro.h"
-#include "io_properties.h"
 #include "parser.h"
 #include "part.h"
 #include "physical_constants.h"
@@ -84,9 +82,12 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
  *
  * Nothing to do here.
  *
+ * @param phys_const The physical constant in internal units.
+ * @param us The unit system.
+ * @param cosmo The current cosmological model.
+ * @param data The properties of the cooling function.
  * @param p Pointer to the particle data.
  * @param xp Pointer to the extended particle data.
- * @param cooling The properties of the cooling function.
  */
 __attribute__((always_inline)) INLINE static void cooling_first_init_part(
     const struct phys_const* restrict phys_const,
diff --git a/src/cooling/none/cooling_io.h b/src/cooling/none/cooling_io.h
index ef4bfae10a..e4c84f506b 100644
--- a/src/cooling/none/cooling_io.h
+++ b/src/cooling/none/cooling_io.h
@@ -19,6 +19,10 @@
 #ifndef SWIFT_COOLING_NONE_IO_H
 #define SWIFT_COOLING_NONE_IO_H
 
+/* Config parameters. */
+#include "../config.h"
+
+/* Local includes */
 #include "io_properties.h"
 
 #ifdef HAVE_HDF5
@@ -37,7 +41,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 /**
  * @brief Specifies which particle fields to write to a dataset
  *
- * @param parts The particle array.
+ * @param xparts The extended particle array.
  * @param list The list of i/o properties to write.
  * @param cooling The #cooling_function_data
  *
@@ -49,4 +53,4 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles(
   return 0;
 }
 
-#endif  // SWIFT_COOLING_NONE_IO_H
+#endif /* SWIFT_COOLING_NONE_IO_H */
diff --git a/src/cooling_io.h b/src/cooling_io.h
new file mode 100644
index 0000000000..88eeae2cab
--- /dev/null
+++ b/src/cooling_io.h
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@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_COOLING_IO_H
+#define SWIFT_COOLING_IO_H
+
+/* Config parameters. */
+#include "../config.h"
+
+/* Import the i/o routines of the right cooling definition */
+#if defined(COOLING_NONE)
+#include "./cooling/none/cooling_io.h"
+#elif defined(COOLING_CONST_DU)
+#include "./cooling/const_du/cooling_io.h"
+#elif defined(COOLING_CONST_LAMBDA)
+#include "./cooling/const_lambda/cooling_io.h"
+#elif defined(COOLING_GRACKLE)
+#include "./cooling/grackle/cooling_io.h"
+#elif defined(COOLING_EAGLE)
+#include "./cooling/EAGLE/cooling_io.h"
+#else
+#error "Invalid choice of cooling function."
+#endif
+
+#endif /* SWIFT_COOLING_IO_H */
diff --git a/src/parallel_io.c b/src/parallel_io.c
index ced02a6dba..b5741fb747 100644
--- a/src/parallel_io.c
+++ b/src/parallel_io.c
@@ -38,7 +38,7 @@
 /* Local includes. */
 #include "chemistry_io.h"
 #include "common_io.h"
-#include "cooling.h"
+#include "cooling_io.h"
 #include "dimension.h"
 #include "engine.h"
 #include "error.h"
diff --git a/src/serial_io.c b/src/serial_io.c
index 3167c1681e..fa48d0ac96 100644
--- a/src/serial_io.c
+++ b/src/serial_io.c
@@ -38,7 +38,7 @@
 /* Local includes. */
 #include "chemistry_io.h"
 #include "common_io.h"
-#include "cooling.h"
+#include "cooling_io.h"
 #include "dimension.h"
 #include "engine.h"
 #include "error.h"
diff --git a/src/single_io.c b/src/single_io.c
index 8b9ba65e4d..73c7f5d946 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -37,7 +37,7 @@
 /* Local includes. */
 #include "chemistry_io.h"
 #include "common_io.h"
-#include "cooling.h"
+#include "cooling_io.h"
 #include "dimension.h"
 #include "engine.h"
 #include "error.h"
-- 
GitLab