From 32d2d2fe0a90e255f268251b22b919d1fafd7554 Mon Sep 17 00:00:00 2001 From: tradke Date: Sun, 9 May 2004 14:49:18 +0000 Subject: Initialize myGH->default_coord_systems[] with default values as defined in CoordBase.h. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/CoordBase/trunk@14 0337457d-221f-4ee6-a5f0-14255d5370d8 --- src/GHExtension.c | 87 +++++++++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 61 deletions(-) diff --git a/src/GHExtension.c b/src/GHExtension.c index 1d5edea..fa0e1c3 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -2,15 +2,16 @@ @file GHExtension.c @date Sun Sept 22 2002 @author Gabrielle Allen and David Rideout - @desc + @desc CoordBase GHExtension setup - @enddesc - @version $Header$ + @enddesc + @version $Id$ @@*/ #include #include "cctk.h" +#include "CoordBase.h" #include "coordbaseGH.h" #include "util_Hash.h" @@ -29,7 +30,6 @@ void CoordBase_Startup (void); ********************************************************************/ static void *CoordBase_SetupGH (tFleshConfig *config, int conv_level, cGH *GH); -static int CoordBase_InitGH (cGH *GH); /******************************************************************** ********************* External Routines ********************** @@ -39,13 +39,12 @@ static int CoordBase_InitGH (cGH *GH); @routine CoordBase_Startup @date Sunday Sept 22 2002 @author Gabrielle Allen - @desc + @desc The startup registration routine for CoordBase. Registers the GH extension needed for CoordBase. - @enddesc + @enddesc @calls CCTK_RegisterGHExtension CCTK_RegisterGHExtensionSetupGH - CCTK_RegisterGHExtensionInitGH @@*/ void CoordBase_Startup (void) { @@ -53,7 +52,6 @@ void CoordBase_Startup (void) GHex_handle = CCTK_RegisterGHExtension ("CoordBase"); CCTK_RegisterGHExtensionSetupGH (GHex_handle, CoordBase_SetupGH); - CCTK_RegisterGHExtensionInitGH (GHex_handle, CoordBase_InitGH); } @@ -65,9 +63,9 @@ void CoordBase_Startup (void) @routine CoordBase_SetupGH @date Sun Sept 22 2002 @author Gabrielle Allen - @desc + @desc Allocates CoordBase's GH extension structure - @enddesc + @enddesc @calls Util_HashCreate @@ -95,6 +93,8 @@ void CoordBase_Startup (void) static void *CoordBase_SetupGH (tFleshConfig *config, int conv_level, cGH *GH) { + int maxdim; + int *default_coord_systems; coordbaseGH *myGH; /* suppress compiler warnings about unused variables */ @@ -102,63 +102,28 @@ static void *CoordBase_SetupGH (tFleshConfig *config, int conv_level, cGH *GH) (void) (conv_level + 0); (void) (GH + 0); - /* allocate the GH extension and its components */ - myGH = (coordbaseGH *) malloc (sizeof (coordbaseGH)); + maxdim = CCTK_MaxDim(); - if (! myGH) + /* allocate the GH extension and its components */ + myGH = malloc (sizeof (coordbaseGH)); + default_coord_systems = malloc(maxdim * sizeof(int)); + if (myGH && default_coord_systems) { - CCTK_WARN (0, "CoordBase_SetupGH: Unable to allocate memory for GH " - "extension"); - } + myGH->default_coord_systems = default_coord_systems; + while (--maxdim >= 0) + { + myGH->default_coord_systems[maxdim] = COORDERROR_NOSYSTEM; + } - myGH->coordsystems = Util_HashCreate(8); - - myGH->default_coord_systems = (int *) malloc(CCTK_MaxDim()*sizeof(int)); - - if (! myGH->default_coord_systems) + myGH->coordsystems = Util_HashCreate(8); + } + else { CCTK_WARN (0, "CoordBase_SetupGH: Unable to allocate memory for GH " - "extension"); + "extension"); + free (default_coord_systems); + myGH = NULL; } return (myGH); } - - /*@@ - @routine CoordBase_InitGH - @date 28 July 2003 - @author David Rideout - @desc - Initializes CoordBase's GH extension structure - @enddesc - - @calls CCTK_GHExtension, CCTK_MaxDim - - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * - @vio in - @endvar - - @returntype int - @returndesc - pointer to the initialized GH extension structure - @endreturndesc -@@*/ - -int CoordBase_InitGH (cGH *GH) -{ - const coordbaseGH *GHex; - int i; - - /* Get the GH extension pointer again... */ - GHex = (const coordbaseGH *) CCTK_GHExtension(GH,"CoordBase"); - - /* Initialize default_coord_systems to invalid table handles */ - for (i=0; idefault_coord_systems[i] = -1; - } - - return 0; -} -- cgit v1.2.3