aboutsummaryrefslogtreecommitdiff
path: root/src/Startup.c
diff options
context:
space:
mode:
authortradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2000-10-12 11:45:59 +0000
committertradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2000-10-12 11:45:59 +0000
commit87adfe63f5d5e8373345231a5331b14abfd14cab (patch)
tree91d3d5b13a778de67793c8c01432c3969701821e /src/Startup.c
parent52f2259ab2b7445288e2e7d7688cd8e50fa39fd1 (diff)
This commit was generated by cvs2svn to compensate for changes in r2, which
included commits to RCS files with non-trunk default branches. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@3 7842ec3a-9562-4be5-9c5b-06ba18f2b668
Diffstat (limited to 'src/Startup.c')
-rw-r--r--src/Startup.c147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/Startup.c b/src/Startup.c
new file mode 100644
index 0000000..133eb9e
--- /dev/null
+++ b/src/Startup.c
@@ -0,0 +1,147 @@
+ /*@@
+ @file Startup.c
+ @date Fri Oct 6 2000
+ @author Thomas Radke
+ @desc
+ Startup and termination routines for IOHDF5Util.
+ @enddesc
+ @version $Id$
+@@*/
+
+
+#include "cctk.h"
+#include "cctk_Parameters.h"
+#include "ioHDF5UtilGH.h"
+
+
+/* local function prototypes */
+static void *IOHDF5Util_SetupGH (tFleshConfig *config,
+ int convergence_level,
+ cGH *GH);
+
+
+ /*@@
+ @routine IOHDF5Util_Startup
+ @date Fri Oct 6 2000
+ @author Thomas Radke
+ @desc
+ The startup registration routine for IOHDF5Util.
+ Registers the GH extensions needed for IOHDF5Util
+ and the routine to set it up.
+ @enddesc
+
+ @calls CCTK_RegisterGHExtensionSetupGH
+@@*/
+void IOHDF5Util_Startup (void)
+{
+ /* check dynamic thorn dependencies */
+ if (CCTK_GHExtensionHandle ("IO") < 0)
+ {
+ CCTK_WARN (1, "Thorn IOUtil was not activated. "
+ "No HDF5 IO methods will be registered.");
+ }
+ else if (CCTK_GHExtensionHandle ("PUGH") < 0)
+ {
+ CCTK_WARN (1, "Thorn PUGH was not activated. "
+ "No HDF5 IO methods will be registered.");
+ }
+ else
+ {
+ CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOHDF5Util"),
+ IOHDF5Util_SetupGH);
+ }
+}
+
+
+ /*@@
+ @routine IOHDF5Util_Terminate
+ @date Fri Oct 6 2000
+ @author Thomas Radke
+ @desc
+ The termination registration routine for IOHDF5Util.
+ It frees any resources kept on the GH extensions.
+ @enddesc
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype cGH *
+ @vio in
+ @endvar
+@@*/
+void IOHDF5Util_Terminate (cGH *GH)
+{
+ ioHDF5UtilGH *myGH;
+
+
+ myGH = (ioHDF5UtilGH *) CCTK_GHExtension (GH, "IOHDF5Util");
+ if (myGH)
+ {
+ /* close the dataspaces used to write scalar and array attributes */
+ if (myGH->scalar_dataspace >= 0)
+ {
+ IOHDF5_ERROR (H5Sclose (myGH->scalar_dataspace));
+ }
+ if (myGH->array_dataspace >= 0)
+ {
+ IOHDF5_ERROR (H5Sclose (myGH->array_dataspace));
+ }
+
+ /* close the predefined complex and string datatypes */
+ if (myGH->IOHDF5_COMPLEX >= 0)
+ {
+ IOHDF5_ERROR (H5Tclose (myGH->IOHDF5_COMPLEX));
+ }
+ if (myGH->IOHDF5_STRING >= 0)
+ {
+ IOHDF5_ERROR (H5Tclose (myGH->IOHDF5_STRING));
+ }
+ }
+}
+
+
+/****************************************************************************/
+/* local routines */
+/****************************************************************************/
+ /*@@
+ @routine IOHDF5Util_SetupGH
+ @date Fri Oct 6 2000
+ @author Thomas Radke
+ @desc
+ Allocate a GH extension structure for IOHDF5Util and set it up.
+ @enddesc
+
+ @returntype void *
+ @returndesc
+ pointer to the allocated GH extension structure
+ @endreturndesc
+@@*/
+static void *IOHDF5Util_SetupGH (tFleshConfig *config,
+ int convergence_level,
+ cGH *GH)
+{
+ DECLARE_CCTK_PARAMETERS
+ ioHDF5UtilGH *myGH;
+
+
+ myGH = (ioHDF5UtilGH *) malloc (sizeof (ioHDF5UtilGH));
+
+ /* save the original error printing routine and its argument */
+ IOHDF5_ERROR (H5Eget_auto (&myGH->print_error_fn, &myGH->print_error_fn_arg));
+
+ /* predefine dataspaces for writing scalar and array attributes */
+ /* the dimension of the array dataspace is set when used */
+ IOHDF5_ERROR (myGH->scalar_dataspace = H5Screate (H5S_SCALAR));
+ IOHDF5_ERROR (myGH->array_dataspace = H5Screate (H5S_SIMPLE));
+
+ /* predefine a IOHDF5_COMPLEX datatype */
+ IOHDF5_ERROR (myGH->IOHDF5_COMPLEX =
+ H5Tcreate (H5T_COMPOUND, sizeof (CCTK_COMPLEX)));
+ IOHDF5_ERROR (H5Tinsert (myGH->IOHDF5_COMPLEX, "real",
+ offsetof (CCTK_COMPLEX, Re), IOHDF5_REAL));
+ IOHDF5_ERROR (H5Tinsert (myGH->IOHDF5_COMPLEX, "imag",
+ offsetof (CCTK_COMPLEX, Im), IOHDF5_REAL));
+
+ /* predefine a C string datatype */
+ IOHDF5_ERROR (myGH->IOHDF5_STRING = H5Tcopy (H5T_C_S1));
+
+ return (myGH);
+}