aboutsummaryrefslogtreecommitdiff
path: root/src/Storage.c
diff options
context:
space:
mode:
authorgoodale <goodale@b61c5cb5-eaca-4651-9a7a-d64986f99364>2001-10-07 10:06:32 +0000
committergoodale <goodale@b61c5cb5-eaca-4651-9a7a-d64986f99364>2001-10-07 10:06:32 +0000
commite8cdd90785ee3239b9ba8ffdb974d1b3450f231c (patch)
treeae70f698996c2451c6505dddb121089c2d69db5c /src/Storage.c
parent21374b8c6a67f5d8ddf11a14a2353b7ee11c0054 (diff)
Preliminary support for 'vector' Grid Variables (see commits to interface_parser.ccl for
syntax). Works for GFs and GAs, but not implemented yet for GSs. Please treat this as volatile until it is documented, and let me know if you are using it. Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@351 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/Storage.c')
-rw-r--r--src/Storage.c110
1 files changed, 64 insertions, 46 deletions
diff --git a/src/Storage.c b/src/Storage.c
index a116e77..7426b3c 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -780,54 +780,65 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
fflush (stdout);
#endif
- /* Now assign memory for the variable itself */
- if (GA->padddata)
+ if(GA->vector_size > 1 && GA->vector_entry > 0)
{
- free (GA->padddata);
- GA->padddata = NULL;
- }
-
- if (GA->extras->npoints * GA->varsize <= 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "PUGH_EnableGArrayDataStorage: Tried to allocate storage "
- "for zero-sized variable '%s'", GA->name);
- GA->data = GA->padddata = NULL;
- }
- else if (! padding_active)
- {
- /* Easy case. */
- GA->data = malloc (GA->extras->npoints * GA->varsize);
- GA->padddata = GA->data;
+ GA->data = (char *)(GA->vector_base->data) + GA->extras->npoints * GA->varsize * GA->vector_entry;
+ retval = 0;
}
else
{
- /* Use the Cactus Cache alignment function */
- GA->data = Util_CacheMalloc (GA->arrayid,
- GA->extras->npoints * GA->varsize,
- &GA->padddata);
+
+ /* Now assign memory for the variable itself */
+ if (GA->padddata)
+ {
+ free (GA->padddata);
+ GA->padddata = NULL;
+ }
+
+ if (GA->extras->npoints * GA->varsize <= 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "PUGH_EnableGArrayDataStorage: Tried to allocate storage "
+ "for zero-sized variable '%s'", GA->name);
+ GA->data = GA->padddata = NULL;
+ }
+ else if (! padding_active)
+ {
+ /* Easy case. */
+ GA->data = malloc (GA->extras->npoints * GA->varsize);
+ GA->padddata = GA->data;
+ }
+ else
+ {
+ /* Use the Cactus Cache alignment function */
+ GA->data = Util_CacheMalloc (GA->arrayid,
+ GA->extras->npoints * GA->varsize * GA->vector_size,
+ &GA->padddata);
+ }
+
+ /* Initialize the memory if desired. */
+ if (GA->data && ! CCTK_Equals (initialize_memory, "none"))
+ {
+ PUGH_InitializeMemory (initialize_memory, GA->vtype,
+ GA->extras->npoints * GA->varsize, GA->data);
+ }
}
- /* Initialize the memory if desired. */
- if (GA->data && ! CCTK_Equals (initialize_memory, "none"))
+ retval = GA->extras->npoints * GA->varsize < 0 ||
+ GA->padddata != NULL ? 0 : -1;
+
+
+ if (retval)
{
- PUGH_InitializeMemory (initialize_memory, GA->vtype,
- GA->extras->npoints * GA->varsize, GA->data);
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "PUGH_EnableGArrayDataStorage: Cannot allocate data for '%s' [%d]",
+ GA->name, GA->id);
}
}
- retval = GA->extras->npoints * GA->varsize < 0 ||
- GA->padddata != NULL ? 0 : -1;
- if (retval)
- {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "PUGH_EnableGArrayDataStorage: Cannot allocate data for '%s' [%d]",
- GA->name, GA->id);
- }
-
GA->storage = PUGH_STORAGE;
- return (retval);
+ return retval;
}
@@ -857,28 +868,35 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
{
int retval;
-
retval = GA->storage != PUGH_STORAGE;
if (GA->storage == PUGH_STORAGE)
{
-
+
#ifdef DEBUG_PUGH
- printf ("PUGH_DisableGArrayDataStorage: freeing storage for var '%s'\n",
+ printf ("PUGH_DisableGArrayDataStorage: freeing storage for var '%s'\n",
GA->name);
- fflush (stdout);
+ fflush (stdout);
#endif
-
- if (GA->padddata)
+
+ if(GA->vector_size > 1 && GA->vector_entry > 0)
{
- free (GA->padddata);
+ GA->data = GA->padddata;
}
- GA->padddata = calloc (1, GA->varsize);
- GA->data = GA->padddata;
+ else
+ {
+ if (GA->padddata)
+ {
+ free (GA->padddata);
+ }
+ GA->padddata = calloc (1, GA->varsize);
+ GA->data = GA->padddata;
+ }
+
GA->storage = PUGH_NOSTORAGE;
}
- return (retval);
+ return retval;
}