aboutsummaryrefslogtreecommitdiff
path: root/src/Storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Storage.c')
-rw-r--r--src/Storage.c153
1 files changed, 85 insertions, 68 deletions
diff --git a/src/Storage.c b/src/Storage.c
index c3f8b6f..066fe18 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -316,43 +316,52 @@ int PUGH_EnableGroupStorage (const cGH *GH, const char *groupname)
{
first_var = CCTK_FirstVarIndexI (group);
- /* get the group info from its index */
- CCTK_GroupData (group, &pgroup);
-
- retval = PUGH_EnableGArrayGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels);
- if (!CCTK_Equals(storage_verbose,"no") && retval == 0)
+ if (first_var >= 0)
{
- /* get GA pointer of first var in group */
- GA = (pGA *) pughGH->variables[first_var][0];
- if (pgroup.grouptype == CCTK_GF)
- {
- totalnumberGF += pgroup.numvars * pgroup.numtimelevels;
- }
- else
- {
- totalnumberGA += pgroup.numvars * pgroup.numtimelevels;
- }
- totalstorage += (GA->extras->npoints * GA->varsize *
- pgroup.numtimelevels * pgroup.numvars) /
- (float) (1024*1024);
- if (totalstorage > maxstorage)
- {
- numberGF = totalnumberGF;
- numberGA = totalnumberGA;
- maxstorage = totalstorage;
- }
- /* Report on memory usage */
- if (CCTK_Equals(storage_verbose,"yes"))
+ /* get the group info from its index */
+ CCTK_GroupData (group, &pgroup);
+
+ retval = PUGH_EnableGArrayGroupStorage (pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels);
+ if (!CCTK_Equals(storage_verbose,"no") && retval == 0)
{
- CCTK_VInfo (CCTK_THORNSTRING, "Switched memory on for group '%s'"
- " [GFs: %d GAs: %d Total Size: %6.2fMB]",
- groupname, totalnumberGF, totalnumberGA, totalstorage);
+ /* get GA pointer of first var in group */
+ GA = (pGA *) pughGH->variables[first_var][0];
+ if (pgroup.grouptype == CCTK_GF)
+ {
+ totalnumberGF += pgroup.numvars * pgroup.numtimelevels;
+ }
+ else
+ {
+ totalnumberGA += pgroup.numvars * pgroup.numtimelevels;
+ }
+ totalstorage += (GA->extras->npoints * GA->varsize *
+ pgroup.numtimelevels * pgroup.numvars) /
+ (float) (1024*1024);
+ if (totalstorage > maxstorage)
+ {
+ numberGF = totalnumberGF;
+ numberGA = totalnumberGA;
+ maxstorage = totalstorage;
+ }
+
+ /* Report on memory usage */
+ if (CCTK_Equals(storage_verbose,"yes"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Switched memory on for group '%s'"
+ " [GFs: %d GAs: %d Total Size: %6.2fMB]",
+ groupname, totalnumberGF, totalnumberGA, totalstorage);
+ }
}
}
+ else
+ {
+ /* don't know what to say here; 0 seems safe */
+ retval = 0;
+ }
}
else
@@ -956,28 +965,32 @@ int PUGH_GroupStorageIncrease(const cGH *GH, int n_groups,const int *groups,cons
first_var = CCTK_FirstVarIndexI (groups[group]);
- /* Enable all timelevels or just some */
- if(timelevels[group] == -1)
+ if (first_var >= 0)
{
- tlevels = pgroup.numtimelevels;
- }
- else
- {
- tlevels = timelevels[group];
- }
- previous = PUGHi_EnableGArrayGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels,
- tlevels);
+ /* Enable all timelevels or just some */
+ if(timelevels[group] == -1)
+ {
+ tlevels = pgroup.numtimelevels;
+ }
+ else
+ {
+ tlevels = timelevels[group];
+ }
+
+ previous = PUGHi_EnableGArrayGroupStorage (pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels,
+ tlevels);
- if(status)
- {
- status[group] = previous;
- }
+ if(status)
+ {
+ status[group] = previous;
+ }
- retval += previous;
+ retval += previous;
+ }
}
}
@@ -1066,28 +1079,32 @@ int PUGH_GroupStorageDecrease(const cGH *GH, int n_groups,const int *groups,cons
first_var = CCTK_FirstVarIndexI (groups[group]);
- /* Disable all timelevels or just some */
- if(timelevels[group] == -1)
+ if (first_var >= 0)
{
- tlevels = 0;
- }
- else
- {
- tlevels = timelevels[group];
- }
- previous = PUGHi_DisableGArrayGroupStorage (pughGH,
- first_var,
- pgroup.numvars,
- pgroup.numtimelevels,
- tlevels);
+ /* Disable all timelevels or just some */
+ if(timelevels[group] == -1)
+ {
+ tlevels = 0;
+ }
+ else
+ {
+ tlevels = timelevels[group];
+ }
- if(status)
- {
- status[group] = previous;
- }
+ previous = PUGHi_DisableGArrayGroupStorage (pughGH,
+ first_var,
+ pgroup.numvars,
+ pgroup.numtimelevels,
+ tlevels);
+
+ if(status)
+ {
+ status[group] = previous;
+ }
- retval += previous;
+ retval += previous;
+ }
}
}