- Timestamp:
- 03/13/12 19:59:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/shared/Numerics/PetscOptionsFromAnalysis.cpp
r9826 r11695 15 15 void PetscOptionsFromAnalysis(Parameters* parameters,int analysis_type){ 16 16 17 int dummy; 18 double* analyses=NULL; 19 char** strings=NULL; 20 int numanalyses; 21 char* string=NULL; 22 int found=-1; 23 int i; 17 /*intermediary: */ 18 char* options=NULL; 24 19 25 numanalyses=0; 26 parameters->FindParam(&strings,&numanalyses,PetscOptionsStringsEnum); 27 28 #ifdef _SERIAL_ //do not take this away, because ISSM loads analyses as a Double Param instead of a DoubleVec Param when running with only 1 analysis 29 if(numanalyses==1){ analyses=(double*)xmalloc(1*sizeof(double)); parameters->FindParam(analyses,PetscOptionsAnalysesEnum); 30 } 31 else parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum); 32 #else 33 parameters->FindParam(&analyses,&dummy,PetscOptionsAnalysesEnum); 34 #endif 35 36 if(numanalyses==0)return; //we did not find petsc options, don't bother. 37 38 /*ok, go through analyses and figure out if it corresponds to our analysis_type: */ 39 found=-1; 40 for(i=0;i<numanalyses;i++){ 41 if (analyses[i]==analysis_type){ 42 /*found the analysis, get out of here: */ 43 found=i; 44 break; 45 } 46 } 47 if(found==-1){ 48 /*still haven't found a list of petsc options, go find the default one, for analysis type NoneAnalysisEnum: */ 49 for(i=0;i<numanalyses;i++){ 50 if (analyses[i]==NoneAnalysisEnum){ 51 /*found the default analysis, get out of here: */ 52 found=i; 53 break; 54 } 55 } 56 } 57 if (found==-1){ 58 /*ok, we did not find anything, this is not good! error out: */ 59 _error_("%s%s","could find neither a default analysis nor analysis ",EnumToStringx(analysis_type)); 60 } 61 62 /*ok, grab the petsc option string: */ 63 string=strings[found]; 20 /*Recover first the options string for this analysis: */ 21 options=OptionsFromAnalysis(parameters,analysis_type); 64 22 65 23 /*now, reset the options database with this string. Taken from petsc/install/src/sys/objects/pinit.c. This … … 72 30 //PetscOptionsCheckInitial_Components(); 73 31 PetscOptionsSetFromOptions(); 74 PetscOptionsInsertMultipleString( string); //our patch32 PetscOptionsInsertMultipleString(options); //our patch 75 33 #else 76 34 PetscOptionsSetFromOptions(); 77 35 PetscOptionsClear(); 78 36 //PetscOptionsSetFromOptions(); 79 PetscOptionsInsertMultipleString( string); //our patch37 PetscOptionsInsertMultipleString(options); //our patch 80 38 #endif 81 39 82 83 /*Free ressources*/ 84 xfree((void**)&analyses); 85 for(i=0;i<numanalyses;i++){ 86 string=strings[i]; 87 xfree((void**)&string); 88 } 89 xfree((void**)&strings); 90 40 /*Free ressources:*/ 41 xfree((void**)&options); 91 42 }
Note:
See TracChangeset
for help on using the changeset viewer.