aboutsummaryrefslogtreecommitdiff
path: root/src/Storage.c
diff options
context:
space:
mode:
authorallen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364>2001-04-13 09:29:50 +0000
committerallen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364>2001-04-13 09:29:50 +0000
commit69b22218e428b18d0fe0dfbf5640081262c7c997 (patch)
tree51ebf7b19f02a9ac1f86d981a062d5d91fc33a4d /src/Storage.c
parent64d94866466ea247ad2c56f8c319f3db672c207b (diff)
Adding back PUGH::enable_all_storage which got accidently removed some time ago.
Also a bit more error checking. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@314 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/Storage.c')
-rw-r--r--src/Storage.c100
1 files changed, 61 insertions, 39 deletions
diff --git a/src/Storage.c b/src/Storage.c
index fbd1311..8918c5a 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -235,55 +235,77 @@ int PUGH_EnableGroupStorage(cGH *GH, const char *groupname)
pughGH = PUGH_pGH(GH);
group = CCTK_GroupIndex(groupname);
- first_var = CCTK_FirstVarIndexI(group);
-
- /* get the group info from its index */
- CCTK_GroupData(group, &pgroup);
- /* SCALAR types have always switched on memory */
- if (pgroup.grouptype == CCTK_SCALAR)
- {
- rc = 1;
- }
- else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
+ if (group > -1 && pughGH)
{
- rc = PUGH_EnableGArrayGroupStorage(pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels);
+ first_var = CCTK_FirstVarIndexI(group);
+
+ /* get the group info from its index */
+ CCTK_GroupData(group, &pgroup);
+
+ /* SCALAR types have always switched on memory */
+ if (pgroup.grouptype == CCTK_SCALAR)
+ {
+ rc = 1;
+ }
+ else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY)
+ {
+ rc = PUGH_EnableGArrayGroupStorage(pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels);
+ }
+ else
+ {
+ CCTK_WARN(1, "Unknown group type in PUGH_EnableGroupStorage");
+ rc = -1;
+ }
+
+ if (rc == 0)
+ {
+ /* get GA pointer of first var in group */
+ GA = (pGA *) pughGH->variables[first_var][0];
+ totalnumber += pgroup.numvars*pgroup.numtimelevels;
+ totalstorage += ((float)(GA->extras->npoints * GA->varsize *
+ pgroup.numtimelevels * pgroup.numvars))/(1024*1024);
+ }
+
+ /* Report on memory usage */
+ if (storage_verbose)
+ {
+ if (rc == 0)
+ {
+ /* Memory toggled */
+ printf("Switched memory on for %s \n "
+ " [Num Arrays: %d Total Size: %6.2fMB]\n",
+ groupname, totalnumber, totalstorage);
+ }
+ else if (rc == 1)
+ {
+ /* Memory already on */
+ printf("Memory already on for %s\n "
+ " [Num Arrays: %d Total Size: %6.2fMB]\n",
+ groupname, totalnumber, totalstorage);
+ }
+ }
}
else
{
- CCTK_WARN(1, "Unknown group type in PUGH_EnableGroupStorage");
- rc = -1;
- }
-
- if (rc == 0)
- {
- /* get GA pointer of first var in group */
- GA = (pGA *) pughGH->variables[first_var][0];
- totalnumber += pgroup.numvars*pgroup.numtimelevels;
- totalstorage += ((float)(GA->extras->npoints * GA->varsize *
- pgroup.numtimelevels * pgroup.numvars))/(1024*1024);
- }
- /* Report on memory usage */
- if (storage_verbose)
- {
- if (rc == 0)
+ if (!pughGH)
{
- /* Memory toggled */
- printf("Switched memory on for %s \n "
- " [Num Arrays: %d Total Size: %6.2fMB]\n",
- groupname, totalnumber, totalstorage);
+ CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "PUGH_EnableGroupStorage: Error with cctkGH pointer "
+ "for group %s",groupname);
+ rc = -2;
}
- else if (rc == 1)
+ else
{
- /* Memory already on */
- printf("Memory already on for %s\n "
- " [Num Arrays: %d Total Size: %6.2fMB]\n",
- groupname, totalnumber, totalstorage);
+ CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "PUGH_EnableGroupStorage: Invalid group %s",groupname);
+ rc = -3;
}
+
}
return (rc);