int PUGH_DisableGroupComm(cGH *GH, const char *groupname) { int group; /* group index */ cGroup pgroup; /* pointer to group information */ int rc; /* return code */ pGH *pughGH; int var; #ifdef DEBUG_PUGH printf(" PUGH_DisableGroupComm: request for group '%s'\n", groupname); fflush(stdout); #endif /* get the group info from its index */ group = CCTK_GroupIndex(groupname); CCTK_GroupData(group, &pgroup); if (pgroup.grouptype == CCTK_SCALAR) { rc = 1; } else if (pgroup.grouptype == CCTK_GF || pgroup.grouptype == CCTK_ARRAY) { pughGH=PUGH_pGH(GH); var = CCTK_FirstVarIndexI(group); /* FIXME: workaround. This one is really bad ! */ rc = PUGH_DisableGArrayGroupComm(pughGH, var,(((pGA ***)pughGH->variables)[var][0])->groupcomm); } else { CCTK_WARN(1, "Unknown group type in PUGH_DisableGroupComm"); rc = 0; } return (rc); }
/*@@ @routine PUGH_DestroyPGH @date Thu Aug 21 11:38:10 1997 @author Paul Walker @desc Destroys a GH object. @enddesc @var GHin @vdesc address of PUGH GH extensions object to be destroyed @vtype pGH ** @vio in @endvar @@*/ void PUGH_DestroyPGH (pGH **GHin) { pGH *GH; pGA *GA; cGroup pgroup; int i; int variable; int group; int this_var; GH = *GHin; #ifdef CCTK_MPI CACTUS_MPI_ERROR (MPI_Comm_free (&GH->PUGH_COMM_WORLD)); CACTUS_MPI_ERROR (MPI_Type_free (&GH->PUGH_mpi_complex)); #ifdef CCTK_REAL4 CACTUS_MPI_ERROR (MPI_Type_free (&GH->PUGH_mpi_complex8)); #endif #ifdef CCTK_REAL8 CACTUS_MPI_ERROR (MPI_Type_free (&GH->PUGH_mpi_complex16)); #endif #ifdef CCTK_REAL16 CACTUS_MPI_ERROR (MPI_Type_free (&GH->PUGH_mpi_complex32)); #endif #endif /* Great. Now go about the work of destroying me. */ variable = 0; for(group = 0; group < CCTK_NumGroups(); group++) { #ifdef DEBUG_PUGH printf("Calling Destroying Group %s\n", CCTK_GroupName(group)); fflush(stdout); #endif CCTK_GroupData(group,&pgroup); if (pgroup.grouptype == CCTK_ARRAY || pgroup.grouptype == CCTK_GF) { GA = (pGA *) GH->variables[variable][0]; /* Destroy group comm buffers */ if (GA->groupcomm) { if (GA->groupcomm->commflag != PUGH_NOCOMM) { PUGH_DisableGArrayGroupComm (GH, variable, GA->groupcomm); } PUGH_DestroyComm (&GA->groupcomm); } /* Destroy the group's connectivity and extras structure for CCTK_ARRAY groups. Remember that the connectivity and extras for CCTK_GF types are shared between all such groups and are destroyed later. */ if (GA->connectivity != GH->Connectivity[pgroup.dim-1]) { PUGH_DestroyConnectivity (&GA->connectivity); } if (GA->extras != GH->GFExtras[pgroup.dim-1]) { PUGH_DestroyPGExtras (&GA->extras); } } for (this_var = 0; this_var < pgroup.numvars; this_var++, variable++) { for(i = 0 ; i < pgroup.numtimelevels; i++) { switch(pgroup.grouptype) { case CCTK_GF: case CCTK_ARRAY: PUGH_DestroyGArray(&(((pGA ***)GH->variables)[variable][i])); break; case CCTK_SCALAR: if (GH->variables[variable][i]) { free(GH->variables[variable][i]); } break; } } free(GH->variables[variable]); } } for (i=1;i<=GH->dim;i++) { PUGH_DestroyConnectivity(&GH->Connectivity[i-1]); PUGH_DestroyPGExtras(&GH->GFExtras[i-1]); } if(GH->identity_string) { free(GH->identity_string); } free(GH->Connectivity); free(GH->GFExtras); free(GH->variables); free(GH); *GHin = NULL; }