int CCTK_FCALL cctk_isthornactive_ (ONE_FORTSTRING_ARG) { int retval; ONE_FORTSTRING_CREATE(name) retval = CCTK_IsThornActive(name); free(name); return retval; }
/*@@ @routine CCTKi_ActivateThorns @date Mon May 21 22:06:37 2001 @author Tom Goodale @desc Activates a list of thorns if they are self consistent. @enddesc @calls @calledby @history @endhistory @var activethornlist @vdesc The list of thorns to activate. @vtype const char * @vio in @vcomment @endvar @returntype int @returndesc -ve Number of errors encountered. @endreturndesc @@*/ int CCTKi_ActivateThorns(const char *activethornlist) { int retval; char *local_list; uStringList *required_thorns; uStringList *requested_imps; uStringList *required_imps; char *token; const char *this_imp; int n_warnings; int n_errors; t_sktree *impnode; t_sktree *impthornlist; struct IMPLEMENTATION *imp; int i; const char *imp1, *imp2; const char *thorn; local_list = Util_Strdup(activethornlist); required_thorns = Util_StringListCreate(n_thorns); required_imps = Util_StringListCreate(n_imps); requested_imps = Util_StringListCreate(n_imps); printf("Activation requested for \n--->%s<---\n", activethornlist); n_errors = 0; n_warnings = 0; token = strtok(local_list, " \t\n"); while(token) { if(CCTK_IsThornActive(token)) { printf("Warning: thorn %s already active\n", token); n_warnings++; } else if(! (this_imp = CCTK_ThornImplementation(token))) { printf("Error: Thorn %s not found\n", token); n_errors++; /* Give some more help */ if (CCTK_IsImplementationCompiled(token)) { impthornlist = CCTK_ImpThornList(token); printf(" However, implementation %s was found and is\n",token); printf(" provided by thorn(s):"); SKTreeTraverseInorder(impthornlist, JustPrintThornName, NULL); printf("\n"); } } else if(CCTK_IsImplementationActive(this_imp)) { printf("Error: thorn %s provides implementation %s - already active\n", token, this_imp); n_errors++; } else if(! Util_StringListAdd(required_thorns,token)) { printf("Warning: thorn %s already scheduled for activation\n", token); n_warnings++; } else if(! Util_StringListAdd(requested_imps,this_imp)) { printf("Error: thorn %s provides implementation %s which is already scheduled for activation\n", token, this_imp); n_errors++; } else if((impnode = SKTreeFindNode(implist, this_imp))) { /* Ok, this thorn exists, and isn't active, a duplicate, or provide the same imp as another thorn * which is active or has just been schedule for activation, so can get on with cataloging * dependencies. */ Util_StringListAdd(required_imps,this_imp); imp = (struct IMPLEMENTATION *)(impnode->data); /* Look at ancestors */ for(i=0; imp->ancestors[i]; i++) { if(!CCTK_IsImplementationActive(imp->ancestors[i])) { /* We need this imp */ Util_StringListAdd(required_imps, imp->ancestors[i]); } } /* Look at friends */ for(i=0; imp->friends[i]; i++) { if(!CCTK_IsImplementationActive(imp->friends[i])) { /* We need this imp */ Util_StringListAdd(required_imps, imp->friends[i]); } } } else { CCTK_Warn(0, __LINE__, __FILE__, "Cactus", "Internal error :- please report this to [email protected]"); } token = strtok(NULL," \t\n"); } /* No longer need the local list */ free(local_list); if(! n_errors) { /* So, let's see if we are requesting all the imps we need */ for(imp1=Util_StringListNext(requested_imps,1), imp2=Util_StringListNext(required_imps,1); imp1&&imp2; imp1=Util_StringListNext(requested_imps,0), imp2=Util_StringListNext(required_imps,0)) { do { if(Util_StrCmpi(imp1,imp2)) { printf("Error: Required implementation %s not activated.\n", imp2); printf(" Add a thorn providing this implementation to ActiveThorns parameter.\n"); n_errors++; /* Give some more help */ if (CCTK_IsImplementationCompiled(imp2)) { impthornlist = CCTK_ImpThornList(imp2); printf(" This implementation is provided by compiled thorns:\n"); printf(" "); SKTreeTraverseInorder(impthornlist, JustPrintThornName, NULL); printf("\n"); } else { printf(" This implementation is not provided by any " "compiled thorn\n"); } } else { break; } } while((imp2=Util_StringListNext(required_imps,0))); } /* Since the requested imps is a subset of the required imps, * we may still have some required imps to go through. */ while((imp2)) { printf("Error: required implementation %s not requested\n", imp2); printf(" Add a thorn providing this implementation to ActiveThorns parameter.\n"); n_errors++; /* Give some more help */ if (CCTK_IsImplementationCompiled(imp2)) { impthornlist = CCTK_ImpThornList(imp2); printf(" This implementation is provided by compiled thorns:\n"); printf(" "); SKTreeTraverseInorder(impthornlist, JustPrintThornName, NULL); printf("\n"); } else { printf(" This implementation is not provided by any " "compiled thorn\n"); } imp2=Util_StringListNext(required_imps,0); } } if(! n_errors) { /* Ok, so we have all required imps, so can activate the thorns, finally */ for(thorn = Util_StringListNext(required_thorns, 1); thorn; thorn = Util_StringListNext(required_thorns, 0)) { ActivateThorn(thorn); } retval = 0; } else { printf("Activation failed - %d errors in activation sequence\n", n_errors); retval = -n_errors; } Util_StringListDestroy(required_thorns); Util_StringListDestroy(required_imps); Util_StringListDestroy(requested_imps); return retval; }
/*@@ @routine CCTKi_BindingsParameterRecoveryInitialise @date @author @desc Calls all the thorn parameter recovery bindings file if the thorns are active. @enddesc @calls @calledby @history @endhistory @@*/ int CCTKi_BindingsParameterRecoveryInitialise(void) { int result; int retval = 0; do { if(CCTK_IsThornActive("BenchADM")) { result = CCTKi_BindingsParameterRecovery_BenchADM(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("Boundary")) { result = CCTKi_BindingsParameterRecovery_Boundary(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("Cactus")) { result = CCTKi_BindingsParameterRecovery_Cactus(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("CartGrid3D")) { result = CCTKi_BindingsParameterRecovery_CartGrid3D(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("Einstein")) { result = CCTKi_BindingsParameterRecovery_Einstein(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("IDLinearWaves")) { result = CCTKi_BindingsParameterRecovery_IDLinearWaves(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("IOASCII")) { result = CCTKi_BindingsParameterRecovery_IOASCII(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("IOBasic")) { result = CCTKi_BindingsParameterRecovery_IOBasic(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("IOUtil")) { result = CCTKi_BindingsParameterRecovery_IOUtil(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("PUGH")) { result = CCTKi_BindingsParameterRecovery_PUGH(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("PUGHReduce")) { result = CCTKi_BindingsParameterRecovery_PUGHReduce(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("PUGHSlab")) { result = CCTKi_BindingsParameterRecovery_PUGHSlab(); if (result != 0) retval = result; if (retval > 0) break; } if(CCTK_IsThornActive("Time")) { result = CCTKi_BindingsParameterRecovery_Time(); if (result != 0) retval = result; if (retval > 0) break; } } while (0); return retval; }