Changeset 7737
- Timestamp:
- 03/31/11 16:12:40 (14 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 21 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Container.h
r4236 r7737 13 13 #include "./Materials.h" 14 14 #include "./Nodes.h" 15 #include "./Options.h" 15 16 #include "./Parameters.h" 16 17 #include "./Results.h" … … 18 19 19 20 #endif //ifndef _CONTAINER_H_ 20 -
issm/trunk/src/c/Makefile.am
r7733 r7737 111 111 ./objects/KML/KML_SubStyle.cpp\ 112 112 ./objects/KML/KML_SubStyle.h\ 113 ./objects/Options/Option sObject.cpp\114 ./objects/Options/Option sObject.h\113 ./objects/Options/Option.cpp\ 114 ./objects/Options/Option.h\ 115 115 ./objects/Options/OptionsDouble.cpp\ 116 116 ./objects/Options/OptionsDouble.h\ … … 270 270 ./Container/Nodes.h\ 271 271 ./Container/Nodes.cpp\ 272 ./Container/Options.h\ 273 ./Container/Options.cpp\ 272 274 ./Container/Parameters.h\ 273 275 ./Container/Parameters.cpp\ … … 750 752 ./objects/KML/KML_SubStyle.cpp\ 751 753 ./objects/KML/KML_SubStyle.h\ 752 ./objects/Options/Option sObject.cpp\753 ./objects/Options/Option sObject.h\754 ./objects/Options/Option.cpp\ 755 ./objects/Options/Option.h\ 754 756 ./objects/Options/OptionsDouble.cpp\ 755 757 ./objects/Options/OptionsDouble.h\ … … 863 865 ./objects/Numerics/ElementVector.h\ 864 866 ./objects/Numerics/ElementVector.cpp\ 865 ./shared/Numerics/PetscOptionsFromAnalysis.cpp\866 867 ./objects/Params/Param.h\ 867 868 ./objects/Params/BoolParam.cpp\ … … 906 907 ./Container/Nodes.h\ 907 908 ./Container/Nodes.cpp\ 909 ./Container/Options.h\ 910 ./Container/Options.cpp\ 908 911 ./Container/Parameters.h\ 909 912 ./Container/Parameters.cpp\ … … 941 944 ./shared/Numerics/extrema.cpp\ 942 945 ./shared/Numerics/UnitConversion.cpp\ 946 ./shared/Numerics/PetscOptionsFromAnalysis.cpp\ 943 947 ./shared/Exceptions/exceptions.h\ 944 948 ./shared/Exceptions/Exceptions.cpp\ -
issm/trunk/src/c/io/OptionsParse.cpp
r7732 r7737 15 15 #include <mex.h> 16 16 17 DataSet* OptionsParse( int istart, int nrhs, const mxArray* prhs[]){ 18 19 int i; 20 char* name=NULL; 21 DataSet* options=NULL; 22 OptionsObject* oobject=NULL; 23 24 options=new DataSet; 25 26 /* loop over each name and value */ 27 28 for (i=istart; i<nrhs; i=i+2) { 29 if (!mxIsChar(prhs[i])) 30 _error_("Argument %d must be name of option.",i+1); 31 32 FetchData(&name,prhs[i]); 33 if (i+1 == nrhs) { 34 _error_("Argument %d must exist and be value of option \"%s\".",i+2,name); 35 } 36 37 _printf_(true," Processing option \"%s\" of class \"%s\".\n", 38 name,mxGetClassName(prhs[i+1])); 39 oobject=(OptionsObject*)OptionsObjectParse(name,&prhs[i+1]); 40 options->AddObject((Object*)oobject); 41 oobject=NULL; 42 } 43 44 /* echo the dataset */ 45 46 if (options->Size()) 47 for (i=0; i<options->Size(); i++) 48 ((OptionsObject *)options->GetObjectByOffset(i))->Echo(); 49 50 return(options); 51 } 52 53 54 OptionsObject* OptionsObjectParse( char* name, const mxArray* prhs[]){ 55 56 OptionsObject* oobject=NULL; 57 mxArray* lhs[1]; 58 59 /* parse the value according to the matlab data type */ 60 17 /*FUNCTION OptionParse{{{1*/ 18 Option* OptionParse(char* name, const mxArray* prhs[]){ 19 20 Option *oobject = NULL; 21 mxArray *lhs[1]; 22 23 /*parse the value according to the matlab data type */ 61 24 if (mxIsDouble(prhs[0])) 62 oobject=(Option sObject*)OptionsDoubleParse(name,prhs);25 oobject=(Option*)OptionsDoubleParse(name,prhs); 63 26 else if (mxIsLogical(prhs[0])) 64 oobject=(Option sObject*)OptionsLogicalParse(name,prhs);27 oobject=(Option*)OptionsLogicalParse(name,prhs); 65 28 else if (mxIsChar(prhs[0])) 66 oobject=(Option sObject*)OptionsCharParse(name,prhs);29 oobject=(Option*)OptionsCharParse(name,prhs); 67 30 else if (mxIsStruct(prhs[0])) 68 oobject=(Option sObject*)OptionsStructParse(name,prhs);31 oobject=(Option*)OptionsStructParse(name,prhs); 69 32 else if (mxIsCell(prhs[0])) 70 oobject=(Option sObject*)OptionsCellParse(name,prhs);33 oobject=(Option*)OptionsCellParse(name,prhs); 71 34 else { 72 _printf_(true," Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n", 73 name,mxGetClassName(prhs[0]),"struct"); 35 _printf_(true," Converting value of option \"%s\" from unrecognized class \"%s\" to class \"%s\".\n",name,mxGetClassName(prhs[0]),"struct"); 74 36 if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) { 75 oobject=(Option sObject*)OptionsStructParse(name,(const mxArray**)lhs);37 oobject=(Option*)OptionsStructParse(name,(const mxArray**)lhs); 76 38 mxDestroyArray(lhs[0]); 77 39 } 78 else 79 _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".", 80 name,mxGetClassName(prhs[0])); 40 else _error_("Second argument value of option \"%s\" is of unrecognized class \"%s\".",name,mxGetClassName(prhs[0])); 81 41 } 82 42 83 43 return(oobject); 84 } 85 86 44 }/*}}}*/ 45 /*FUNCTION OptionsDoubleParse {{{1*/ 87 46 OptionsDouble* OptionsDoubleParse( char* name, const mxArray* prhs[]){ 88 47 89 int i; 90 OptionsDouble* odouble=NULL; 91 const mwSize* ipt=NULL; 92 93 /* check and parse the name */ 94 48 OptionsDouble *odouble = NULL; 49 const mwSize *ipt = NULL; 50 51 /*check and parse the name */ 95 52 odouble=new OptionsDouble; 96 53 odouble->name =(char *) xmalloc((strlen(name)+1)*sizeof(char)); 97 54 strcpy(odouble->name,name); 98 55 99 /* check and parse the value */ 100 101 if (!mxIsDouble(prhs[0])) 102 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".", 103 odouble->name,"double",odouble->name,mxGetClassName(prhs[0])); 56 /*check and parse the value */ 57 if (!mxIsDouble(prhs[0])){ 58 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",odouble->name,"double",odouble->name,mxGetClassName(prhs[0])); 59 } 104 60 105 61 odouble->numel=mxGetNumberOfElements(prhs[0]); … … 107 63 ipt =mxGetDimensions(prhs[0]); 108 64 odouble->size =(int *) xmalloc(odouble->ndims*sizeof(int)); 109 for (i=0; i<odouble->ndims; i++) 110 odouble->size[i]=(int)ipt[i]; 111 112 // note that FetchData does not correctly handle ndims >= 3 65 for (int i=0; i<odouble->ndims; i++) odouble->size[i]=(int)ipt[i]; 66 67 // note that FetchData does not correctly handle ndims >= 3 113 68 if (odouble->ndims > 2) { 114 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" has ndims=%d and will be skipped.\n", 115 odouble->name,mxGetClassName(prhs[0]),odouble->ndims); 116 } 117 else 118 FetchData(&odouble->values,NULL,NULL,prhs[0]); 119 120 odouble->DeepEcho(); 69 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" has ndims=%d and will be skipped.\n",odouble->name,mxGetClassName(prhs[0]),odouble->ndims); 70 } 71 else FetchData(&odouble->values,NULL,NULL,prhs[0]); 121 72 122 73 return(odouble); 123 } 124 125 74 }/*}}}*/ 75 /*FUNCTION OptionsLogicalParse {{{1*/ 126 76 OptionsLogical* OptionsLogicalParse( char* name, const mxArray* prhs[]){ 127 77 128 int i; 129 OptionsLogical* ological=NULL; 130 const mwSize* ipt=NULL; 131 bool btemp; 132 133 /* check and parse the name */ 134 78 OptionsLogical *ological = NULL; 79 const mwSize *ipt = NULL; 80 bool btemp; 81 82 /*check and parse the name */ 135 83 ological=new OptionsLogical; 136 84 ological->name =(char *) xmalloc((strlen(name)+1)*sizeof(char)); 137 85 strcpy(ological->name,name); 138 86 139 /* check and parse the value */ 140 141 if (!mxIsLogical(prhs[0])) 142 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".", 143 ological->name,"logical",ological->name,mxGetClassName(prhs[0])); 87 /*check and parse the value */ 88 if (!mxIsLogical(prhs[0])){ 89 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ological->name,"logical",ological->name,mxGetClassName(prhs[0])); 90 } 144 91 145 92 ological->numel=mxGetNumberOfElements(prhs[0]); … … 147 94 ipt =mxGetDimensions(prhs[0]); 148 95 ological->size =(int *) xmalloc(ological->ndims*sizeof(int)); 149 for (i=0; i<ological->ndims; i++) 150 ological->size[i]=(int)ipt[i]; 151 152 // note that FetchData does not correctly handle non-scalar logicals 96 for (int i=0; i<ological->ndims; i++) ological->size[i]=(int)ipt[i]; 97 98 // note that FetchData does not correctly handle non-scalar logicals 153 99 if (ological->ndims > 2 || ological->size[0] > 1 || ological->size[1] > 1) { 154 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" is more than [1x1] and will be skipped.\n", 155 ological->name,mxGetClassName(prhs[0])); 100 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" is more than [1x1] and will be skipped.\n",ological->name,mxGetClassName(prhs[0])); 156 101 } 157 102 else { 158 //FetchData(&ological->values,prhs[0]);159 //could be memory leak until FetchData handles logical arrays103 //FetchData(&ological->values,prhs[0]); 104 //could be memory leak until FetchData handles logical arrays 160 105 ological->values=(bool *) xmalloc(sizeof(bool)); 161 106 FetchData(ological->values,prhs[0]); 162 107 } 163 108 164 ological->DeepEcho();165 166 109 return(ological); 167 } 168 169 110 }/*}}}*/ 111 /*FUNCTION OptionsCharParse {{{1*/ 170 112 OptionsChar* OptionsCharParse( char* name, const mxArray* prhs[]){ 171 113 172 int i; 173 OptionsChar* ochar=NULL; 174 const mwSize* ipt=NULL; 175 176 /* check and parse the name */ 177 114 OptionsChar *ochar = NULL; 115 const mwSize *ipt = NULL; 116 117 /*check and parse the name */ 178 118 ochar=new OptionsChar; 179 119 ochar->name =(char *) xmalloc((strlen(name)+1)*sizeof(char)); 180 120 strcpy(ochar->name,name); 181 121 182 /* check and parse the value */ 183 184 if (!mxIsChar(prhs[0])) 185 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".", 186 ochar->name,"char",ochar->name,mxGetClassName(prhs[0])); 122 /*check and parse the value */ 123 if (!mxIsChar(prhs[0])){ 124 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ochar->name,"char",ochar->name,mxGetClassName(prhs[0])); 125 } 187 126 188 127 ochar->numel=mxGetNumberOfElements(prhs[0]); … … 190 129 ipt =mxGetDimensions(prhs[0]); 191 130 ochar->size =(int *) xmalloc(ochar->ndims*sizeof(int)); 192 for (i=0; i<ochar->ndims; i++) 193 ochar->size[i]=(int)ipt[i]; 194 195 // note that FetchData does not correctly handle ndims >= 2 or multiple rows 131 for(int i=0; i<ochar->ndims; i++) ochar->size[i]=(int)ipt[i]; 132 133 //note that FetchData does not correctly handle ndims >= 2 or multiple rows 196 134 if (ochar->ndims > 2 || ochar->size[0] > 1) { 197 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" is more than [1xn] and will be skipped.\n", 198 ochar->name,mxGetClassName(prhs[0])); 199 } 200 else 201 FetchData(&ochar->values,prhs[0]); 202 203 ochar->DeepEcho(); 135 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" is more than [1xn] and will be skipped.\n",ochar->name,mxGetClassName(prhs[0])); 136 } 137 else FetchData(&ochar->values,prhs[0]); 204 138 205 139 return(ochar); 206 } 207 208 140 }/*}}}*/ 141 /*FUNCTION OptionsStructParse {{{1*/ 209 142 OptionsStruct* OptionsStructParse( char* name, const mxArray* prhs[]){ 210 143 211 int i;212 char namei[161];213 OptionsStruct * ostruct=NULL;214 Option sObject* oobject=NULL;215 const mwSize * ipt=NULL;216 const mxArray *structi;144 int i; 145 char namei[161]; 146 OptionsStruct *ostruct = NULL; 147 Option *oobject = NULL; 148 const mwSize *ipt = NULL; 149 const mxArray *structi; 217 150 mwIndex sindex; 218 151 219 /* check and parse the name */ 220 152 /*check and parse the name */ 221 153 ostruct=new OptionsStruct; 222 154 ostruct->name =(char *) xmalloc((strlen(name)+1)*sizeof(char)); 223 155 strcpy(ostruct->name,name); 224 156 225 /* check and parse the value */ 226 227 if (!mxIsStruct(prhs[0])) 228 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".", 229 ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0])); 157 /*check and parse the value */ 158 if (!mxIsStruct(prhs[0])){ 159 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ostruct->name,"struct",ostruct->name,mxGetClassName(prhs[0])); 160 } 230 161 231 162 ostruct->numel=mxGetNumberOfElements(prhs[0]); … … 233 164 ipt =mxGetDimensions(prhs[0]); 234 165 ostruct->size =(int *) xmalloc(ostruct->ndims*sizeof(int)); 235 for (i=0; i<ostruct->ndims; i++) 236 ostruct->size[i]=(int)ipt[i]; 237 if (ostruct->numel) 238 ostruct->values=(DataSet **) xmalloc(ostruct->numel*sizeof(DataSet *)); 239 240 /* loop through and process each element of the struct array */ 241 166 for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i]; 167 if (ostruct->numel) ostruct->values=(Options**) xmalloc(ostruct->numel*sizeof(Options *)); 168 169 /*loop through and process each element of the struct array */ 242 170 for (sindex=0; sindex<ostruct->numel; sindex++) { 243 ostruct->values[sindex]=new DataSet; 244 245 /* loop through and process each field for the element */ 246 171 ostruct->values[sindex]=new Options; 172 173 /*loop through and process each field for the element */ 247 174 for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) { 248 175 sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i)); 249 176 structi=mxGetFieldByNumber(prhs[0],sindex,i); 250 177 251 oobject=(Option sObject*)OptionsObjectParse(namei,&structi);178 oobject=(Option*)OptionParse(namei,&structi); 252 179 ostruct->values[sindex]->AddObject((Object*)oobject); 253 180 oobject=NULL; … … 255 182 } 256 183 257 ostruct->DeepEcho();258 259 184 return(ostruct); 260 } 261 262 185 }/*}}}*/ 186 /*FUNCTION OptionsCellParse {{{1*/ 263 187 OptionsCell* OptionsCellParse( char* name, const mxArray* prhs[]){ 264 188 265 int i;266 int *dims;267 char namei[161];268 char cstr[81];269 OptionsCell * ocell=NULL;270 Option sObject* oobject=NULL;271 const mwSize * ipt=NULL;272 const mxArray *celli;189 int i; 190 int *dims; 191 char namei[161]; 192 char cstr[81]; 193 OptionsCell *ocell = NULL; 194 Option *oobject = NULL; 195 const mwSize *ipt = NULL; 196 const mxArray *celli; 273 197 mwIndex cindex; 274 198 275 /* check and parse the name */ 276 199 /*check and parse the name */ 277 200 ocell=new OptionsCell; 278 201 ocell->name =(char *) xmalloc((strlen(name)+1)*sizeof(char)); 279 202 strcpy(ocell->name,name); 280 203 281 /* check and parse the value */ 282 283 if (!mxIsCell(prhs[0])) 284 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".", 285 ocell->name,"cell",ocell->name,mxGetClassName(prhs[0])); 204 /*check and parse the value */ 205 if (!mxIsCell(prhs[0])){ 206 _error_("Value of option \"%s\" must be class \"%s\", not class \"%s\".",ocell->name,"cell",ocell->name,mxGetClassName(prhs[0])); 207 } 286 208 287 209 ocell->numel=mxGetNumberOfElements(prhs[0]); … … 291 213 for (i=0; i<ocell->ndims; i++) 292 214 ocell->size[i]=(int)ipt[i]; 293 ocell->values=new DataSet; 294 295 /* loop through and process each element of the cell array */ 296 215 ocell->values=new Options; 216 217 /*loop through and process each element of the cell array */ 297 218 dims=(int *) xmalloc(ocell->ndims*sizeof(int)); 298 219 for (cindex=0; cindex<ocell->numel; cindex++) { 299 ColumnWiseDimsFromIndex(dims, 300 (int)cindex, 301 ocell->size, 302 ocell->ndims); 303 StringFromDims(cstr, 304 dims, 305 ocell->ndims); 220 ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims); 221 StringFromDims(cstr,dims,ocell->ndims); 306 222 sprintf(namei,"%s%s",name,cstr); 307 223 celli=mxGetCell(prhs[0],cindex); 308 224 309 oobject=(Option sObject*)OptionsObjectParse(namei,&celli);225 oobject=(Option*)OptionParse(namei,&celli); 310 226 ocell->values->AddObject((Object*)oobject); 311 227 oobject=NULL; … … 313 229 xfree((void**)&dims); 314 230 315 ocell->DeepEcho();316 317 231 return(ocell); 318 } 232 }/*}}}*/ 319 233 320 234 #endif -
issm/trunk/src/c/io/io.h
r7732 r7737 58 58 void FetchParams(Parameters** pparameters, DataHandle dataref); 59 59 60 DataSet* OptionsParse( int istart, int nrhs, const mxArray* prhs[]); 61 OptionsObject* OptionsObjectParse( char* name, const mxArray* prhs[]); 62 OptionsDouble* OptionsDoubleParse( char* name, const mxArray* prhs[]); 63 OptionsLogical* OptionsLogicalParse( char* name, const mxArray* prhs[]); 64 OptionsChar* OptionsCharParse( char* name, const mxArray* prhs[]); 65 OptionsStruct* OptionsStructParse( char* name, const mxArray* prhs[]); 66 OptionsCell* OptionsCellParse( char* name, const mxArray* prhs[]); 60 Option* OptionParse(char* name, const mxArray* prhs[]); 61 OptionsDouble* OptionsDoubleParse( char* name, const mxArray* prhs[]); 62 OptionsLogical* OptionsLogicalParse( char* name, const mxArray* prhs[]); 63 OptionsChar* OptionsCharParse( char* name, const mxArray* prhs[]); 64 OptionsStruct* OptionsStructParse( char* name, const mxArray* prhs[]); 65 OptionsCell* OptionsCellParse( char* name, const mxArray* prhs[]); 67 66 68 67 #endif -
issm/trunk/src/c/modules/GroundingLineMigrationx/GroundingLineMigrationx.cpp
r7323 r7737 25 25 if(migration_style==AgressiveMigrationEnum) AgressiveMigration(elements,nodes, vertices,loads,materials, parameters); 26 26 else if(migration_style==SoftMigrationEnum) SoftMigration(elements,nodes, vertices,loads,materials, parameters); 27 else if(migration_style==NoneEnum) _printf_("%s\n","NoneEnum supplied for migration style, doing nothing!");27 else if(migration_style==NoneEnum) _printf_(true,"%s\n","NoneEnum supplied for migration style, doing nothing!"); 28 28 else _error_("%s not supported yet!",EnumToString(migration_style)); 29 29 -
issm/trunk/src/c/objects/Options/Option.cpp
r7733 r7737 1 /*!\file Option sObject.cpp1 /*!\file Option.cpp 2 2 * \brief: implementation of the optionsobject abstract object 3 3 */ … … 20 20 21 21 /*Constructors/destructor/copy*/ 22 /*FUNCTION Option sObject::OptionsObject(){{{1*/23 Option sObject::OptionsObject(){22 /*FUNCTION Option::Option(){{{1*/ 23 Option::Option(){ 24 24 25 name 26 numel 27 ndims 28 size 25 name =NULL; 26 numel =0; 27 ndims =0; 28 size =NULL; 29 29 30 30 } 31 31 /*}}}*/ 32 /*FUNCTION Option sObject::~OptionsObject(){{{1*/33 Option sObject::~OptionsObject(){32 /*FUNCTION Option::~Option(){{{1*/ 33 Option::~Option(){ 34 34 35 if 36 if 35 if(size) xfree((void**)&size); 36 if(name) xfree((void**)&name); 37 37 38 38 } … … 40 40 41 41 /*Other*/ 42 /*FUNCTION Option sObject::Echo {{{1*/43 void Option sObject::Echo(){42 /*FUNCTION Option::Echo {{{1*/ 43 void Option::Echo(){ 44 44 45 45 char cstr[81]; … … 49 49 _printf_(flag," numel: %d\n" ,numel); 50 50 _printf_(flag," ndims: %d\n" ,ndims); 51 if (size) { 52 StringFromSize(cstr, 53 size, 54 ndims); 51 if(size){ 52 StringFromSize(cstr,size,ndims); 55 53 _printf_(flag," size: %s\n" ,cstr); 56 54 } 57 else 58 _printf_(flag," size: [empty]\n" ); 55 else _printf_(flag," size: [empty]\n" ); 56 } 57 /*}}}*/ 58 /*FUNCTION Option::DeepEcho() {{{1*/ 59 void Option::DeepEcho(){ 60 61 char indent[81]=""; 62 63 Option::DeepEcho(indent); 59 64 60 65 return; 61 66 } 62 67 /*}}}*/ 63 64 /*FUNCTION OptionsObject::DeepEcho {{{1*/ 65 void OptionsObject::DeepEcho(){ 66 67 char indent[81]=""; 68 69 OptionsObject::DeepEcho(indent); 70 71 return; 72 } 73 /*}}}*/ 74 75 /*FUNCTION OptionsObject::DeepEcho {{{1*/ 76 void OptionsObject::DeepEcho(char* indent){ 68 /*FUNCTION Option::DeepEcho(char* indent) {{{1*/ 69 void Option::DeepEcho(char* indent){ 77 70 78 71 char cstr[81]; … … 82 75 _printf_(flag,"%s numel: %d\n" ,indent,numel); 83 76 _printf_(flag,"%s ndims: %d\n" ,indent,ndims); 84 if (size) { 85 StringFromSize(cstr, 86 size, 87 ndims); 77 if(size){ 78 StringFromSize(cstr,size,ndims); 88 79 _printf_(flag,"%s size: %s\n" ,indent,cstr); 89 80 } 90 else 91 _printf_(flag,"%s size: [empty]\n" ,indent); 92 93 return; 81 else _printf_(flag,"%s size: [empty]\n" ,indent); 94 82 } 95 83 /*}}}*/ 96 97 /*FUNCTION OptionsObject::Name {{{1*/ 98 char* OptionsObject::Name(){ 84 /*FUNCTION Option::Name {{{1*/ 85 char* Option::Name(){ 99 86 100 87 return(name); 101 88 } 102 89 /*}}}*/ 103 104 /*FUNCTION OptionsObject::NumEl {{{1*/ 105 int OptionsObject::NumEl(){ 90 /*FUNCTION Option::NumEl {{{1*/ 91 int Option::NumEl(){ 106 92 107 93 return(numel); 108 94 } 109 95 /*}}}*/ 110 111 /*FUNCTION OptionsObject::NDims {{{1*/ 112 int OptionsObject::NDims(){ 96 /*FUNCTION Option::NDims {{{1*/ 97 int Option::NDims(){ 113 98 114 99 return(ndims); 115 100 } 116 101 /*}}}*/ 117 118 /*FUNCTION OptionsObject::Size {{{1*/ 119 int* OptionsObject::Size(){ 102 /*FUNCTION Option::Size {{{1*/ 103 int* Option::Size(){ 120 104 121 105 return(size); 122 106 } 123 107 /*}}}*/ 124 125 /*FUNCTION OptionsObject::Get {{{1*/ 126 //void* OptionsObject::Get(){ 108 /*FUNCTION Option::Get {{{1*/ 109 //void* Option::Get(){ 127 110 128 111 // ; … … 131 114 //} 132 115 /*}}}*/ 133 134 /*FUNCTION OptionsObject::Id {{{1*/135 int OptionsObject::Id(){136 }137 /*}}}*/138 139 /*FUNCTION OptionsObject::MyRank {{{1*/140 int OptionsObject::MyRank(){141 }142 /*}}}*/143 144 /*FUNCTION OptionsObject::Marshall {{{1*/145 void OptionsObject::Marshall(char** pmarshalled_dataset){146 }147 /*}}}*/148 149 /*FUNCTION OptionsObject::MarshallSize {{{1*/150 int OptionsObject::MarshallSize(){151 }152 /*}}}*/153 154 /*FUNCTION OptionsObject::Demarshall {{{1*/155 void OptionsObject::Demarshall(char** pmarshalled_dataset){156 }157 /*}}}*/158 159 /*FUNCTION OptionsObject::Enum {{{1*/160 int OptionsObject::Enum(){161 }162 /*}}}*/163 164 /*FUNCTION OptionsObject::copy {{{1*/165 Object* OptionsObject::copy(){166 }167 /*}}}*/168 -
issm/trunk/src/c/objects/Options/Option.h
r7733 r7737 1 /*! \file Option sObject.h1 /*! \file Option.h 2 2 * \brief: header file for optionsobject abstract object 3 3 */ … … 14 14 /*}}}*/ 15 15 16 class Option sObject: public Object {16 class Option: public Object { 17 17 18 18 public: … … 23 23 int* size; 24 24 25 /*Option sObjectconstructors, destructors {{{1*/26 Option sObject();27 ~Option sObject();25 /*Option constructors, destructors {{{1*/ 26 Option(); 27 ~Option(); 28 28 /*}}}*/ 29 29 /*Object virtual functions definitions:{{{1*/ … … 31 31 void DeepEcho(); 32 32 void DeepEcho(char* indent); 33 int Id() ;34 int MyRank() ;35 void Marshall(char** pmarshalled_dataset) ;36 int MarshallSize() ;37 void Demarshall(char** pmarshalled_dataset) ;38 int Enum() ;39 Object* copy() ;33 int Id(){_error_("Not implemented yet");}; 34 int MyRank(){_error_("Not implemented yet");}; 35 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 36 int MarshallSize(){_error_("Not implemented yet");}; 37 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 38 int Enum(){_error_("Not implemented yet");}; 39 Object* copy(){_error_("Not implemented yet");}; 40 40 /*}}}*/ 41 41 -
issm/trunk/src/c/objects/Options/OptionsCell.cpp
r7731 r7737 30 30 OptionsCell::~OptionsCell(){ 31 31 32 if (values) 32 if (values){ 33 33 delete values; 34 34 values =NULL; … … 42 42 void OptionsCell::Echo(){ 43 43 44 char 45 bool flag=true;44 char cstr[81]; 45 bool flag = true; 46 46 47 47 _printf_(flag,"OptionsCell Echo:\n"); 48 Option sObject::Echo();48 Option::Echo(); 49 49 50 50 if (values && size) { 51 StringFromSize(cstr, 52 size, 53 ndims); 51 StringFromSize(cstr,size,ndims); 54 52 _printf_(flag," values: %s %s\n" ,cstr,"cell"); 55 53 } 56 else 57 _printf_(flag," values: [empty]\n" ); 58 59 return; 54 else _printf_(flag," values: [empty]\n" ); 60 55 } 61 56 /*}}}*/ 62 63 /*FUNCTION OptionsCell::DeepEcho {{{1*/ 57 /*FUNCTION OptionsCell::DeepEcho() {{{1*/ 64 58 void OptionsCell::DeepEcho(){ 65 59 … … 71 65 } 72 66 /*}}}*/ 73 74 /*FUNCTION OptionsCell::DeepEcho {{{1*/ 67 /*FUNCTION OptionsCell::DeepEcho(char* indent) {{{1*/ 75 68 void OptionsCell::DeepEcho(char* indent){ 76 69 … … 82 75 83 76 _printf_(flag,"%sOptionsCell DeepEcho:\n",indent); 84 Option sObject::DeepEcho(indent);77 Option::DeepEcho(indent); 85 78 86 79 strcpy(indent2,indent); … … 90 83 dims=(int *) xmalloc(ndims*sizeof(int)); 91 84 for (i=0; i<values->Size(); i++) { 92 ColumnWiseDimsFromIndex(dims, 93 i, 94 size, 95 ndims); 96 StringFromDims(cstr, 97 dims, 98 ndims); 85 ColumnWiseDimsFromIndex(dims,i,size,ndims); 86 StringFromDims(cstr,dims,ndims); 99 87 _printf_(flag,"%s values: %s begin\n" ,indent,cstr); 100 ((Option sObject*)values->GetObjectByOffset(i))->DeepEcho(indent2);88 ((Option *)values->GetObjectByOffset(i))->DeepEcho(indent2); 101 89 _printf_(flag,"%s values: %s end\n" ,indent,cstr); 102 90 } 103 91 xfree((void**)&dims); 104 92 } 105 else 106 _printf_(flag,"%s values: [empty]\n" ,indent); 107 108 return; 93 else _printf_(flag,"%s values: [empty]\n" ,indent); 109 94 } 110 95 /*}}}*/ 111 112 96 /*FUNCTION OptionsCell::Name {{{1*/ 113 97 char* OptionsCell::Name(){ 114 98 115 return(Option sObject::Name());99 return(Option::Name()); 116 100 } 117 101 /*}}}*/ 118 119 102 /*FUNCTION OptionsCell::NumEl {{{1*/ 120 103 int OptionsCell::NumEl(){ 121 104 122 return(Option sObject::NumEl());105 return(Option::NumEl()); 123 106 } 124 107 /*}}}*/ 125 126 108 /*FUNCTION OptionsCell::NDims {{{1*/ 127 109 int OptionsCell::NDims(){ 128 110 129 return(Option sObject::NDims());111 return(Option::NDims()); 130 112 } 131 113 /*}}}*/ 132 133 114 /*FUNCTION OptionsCell::Size {{{1*/ 134 115 int* OptionsCell::Size(){ 135 116 136 return(Option sObject::Size());117 return(Option::Size()); 137 118 } 138 119 /*}}}*/ 139 140 120 /*FUNCTION OptionsCell::Get {{{1*/ 141 121 //void* OptionsCell::Get(){ … … 146 126 //} 147 127 /*}}}*/ 148 149 /*FUNCTION OptionsCell::Id {{{1*/150 int OptionsCell::Id(){151 }152 /*}}}*/153 154 /*FUNCTION OptionsCell::MyRank {{{1*/155 int OptionsCell::MyRank(){156 }157 /*}}}*/158 159 /*FUNCTION OptionsCell::Marshall {{{1*/160 void OptionsCell::Marshall(char** pmarshalled_dataset){161 }162 /*}}}*/163 164 /*FUNCTION OptionsCell::MarshallSize {{{1*/165 int OptionsCell::MarshallSize(){166 }167 /*}}}*/168 169 /*FUNCTION OptionsCell::Demarshall {{{1*/170 void OptionsCell::Demarshall(char** pmarshalled_dataset){171 }172 /*}}}*/173 174 /*FUNCTION OptionsCell::Enum {{{1*/175 int OptionsCell::Enum(){176 }177 /*}}}*/178 179 /*FUNCTION OptionsCell::copy {{{1*/180 Object* OptionsCell::copy(){181 }182 /*}}}*/183 -
issm/trunk/src/c/objects/Options/OptionsCell.h
r7731 r7737 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 #include "./Option sObject.h"13 #include "./Option.h" 14 14 /*}}}*/ 15 15 16 class OptionsCell: public Option sObject{16 class OptionsCell: public Option { 17 17 18 18 public: 19 19 20 DataSet* values;20 Options* values; 21 21 22 22 /*OptionsCell constructors, destructors {{{1*/ … … 28 28 void DeepEcho(); 29 29 void DeepEcho(char* indent); 30 int Id() ;31 int MyRank() ;32 void Marshall(char** pmarshalled_dataset) ;33 int MarshallSize() ;34 void Demarshall(char** pmarshalled_dataset) ;35 int Enum() ;36 Object* copy() ;30 int Id(){_error_("Not implemented yet");}; 31 int MyRank(){_error_("Not implemented yet");}; 32 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 33 int MarshallSize(){_error_("Not implemented yet");}; 34 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 35 int Enum(){_error_("Not implemented yet");}; 36 Object* copy(){_error_("Not implemented yet");}; 37 37 /*}}}*/ 38 38 -
issm/trunk/src/c/objects/Options/OptionsChar.cpp
r7731 r7737 43 43 44 44 _printf_(flag,"OptionsChar Echo:\n"); 45 Option sObject::Echo();45 Option::Echo(); 46 46 47 47 if (values && size) { … … 52 52 } 53 53 else { 54 StringFromSize(cstr, 55 size, 56 ndims); 54 StringFromSize(cstr,size,ndims); 57 55 _printf_(flag," values: %s %s\n" ,cstr,"char"); 58 56 } 59 57 } 60 else 61 _printf_(flag," values: [empty]\n" ); 62 63 return; 58 else _printf_(flag," values: [empty]\n" ); 64 59 } 65 60 /*}}}*/ 66 67 /*FUNCTION OptionsChar::DeepEcho {{{1*/ 61 /*FUNCTION OptionsChar::DeepEcho() {{{1*/ 68 62 void OptionsChar::DeepEcho(){ 69 63 … … 75 69 } 76 70 /*}}}*/ 77 78 /*FUNCTION OptionsChar::DeepEcho {{{1*/ 71 /*FUNCTION OptionsChar::DeepEcho(char* indent) {{{1*/ 79 72 void OptionsChar::DeepEcho(char* indent){ 80 73 … … 86 79 87 80 _printf_(flag,"%sOptionsChar DeepEcho:\n",indent); 88 Option sObject::DeepEcho(indent);81 Option::DeepEcho(indent); 89 82 90 83 strcpy(indent2,indent); … … 100 93 dims=(int *) xmalloc(ndims*sizeof(int)); 101 94 for (i=0; i<numel; i++) { 102 RowWiseDimsFromIndex(dims, 103 i, 104 size, 105 ndims); 106 StringFromDims(cstr, 107 dims, 108 ndims); 95 RowWiseDimsFromIndex(dims,i,size,ndims); 96 StringFromDims(cstr,dims,ndims); 109 97 _printf_(flag,"%s values%s: \"%s\"\n" ,indent,cstr,values[i]); 110 98 } … … 112 100 } 113 101 } 114 else 115 _printf_(flag,"%s values: [empty]\n" ,indent); 116 117 return; 102 else _printf_(flag,"%s values: [empty]\n" ,indent); 118 103 } 119 104 /*}}}*/ 120 121 105 /*FUNCTION OptionsChar::Name {{{1*/ 122 106 char* OptionsChar::Name(){ 123 107 124 return(Option sObject::Name());108 return(Option::Name()); 125 109 } 126 110 /*}}}*/ 127 128 111 /*FUNCTION OptionsChar::NumEl {{{1*/ 129 112 int OptionsChar::NumEl(){ 130 113 131 return(Option sObject::NumEl());114 return(Option::NumEl()); 132 115 } 133 116 /*}}}*/ 134 135 117 /*FUNCTION OptionsChar::NDims {{{1*/ 136 118 int OptionsChar::NDims(){ 137 119 138 return(Option sObject::NDims());120 return(Option::NDims()); 139 121 } 140 122 /*}}}*/ 141 142 123 /*FUNCTION OptionsChar::Size {{{1*/ 143 124 int* OptionsChar::Size(){ 144 125 145 return(Option sObject::Size());126 return(Option::Size()); 146 127 } 147 128 /*}}}*/ 148 149 129 /*FUNCTION OptionsChar::Get {{{1*/ 150 130 //void* OptionsChar::Get(){ … … 155 135 //} 156 136 /*}}}*/ 157 158 /*FUNCTION OptionsChar::Id {{{1*/159 int OptionsChar::Id(){160 }161 /*}}}*/162 163 /*FUNCTION OptionsChar::MyRank {{{1*/164 int OptionsChar::MyRank(){165 }166 /*}}}*/167 168 /*FUNCTION OptionsChar::Marshall {{{1*/169 void OptionsChar::Marshall(char** pmarshalled_dataset){170 }171 /*}}}*/172 173 /*FUNCTION OptionsChar::MarshallSize {{{1*/174 int OptionsChar::MarshallSize(){175 }176 /*}}}*/177 178 /*FUNCTION OptionsChar::Demarshall {{{1*/179 void OptionsChar::Demarshall(char** pmarshalled_dataset){180 }181 /*}}}*/182 183 /*FUNCTION OptionsChar::Enum {{{1*/184 int OptionsChar::Enum(){185 }186 /*}}}*/187 188 /*FUNCTION OptionsChar::copy {{{1*/189 Object* OptionsChar::copy(){190 }191 /*}}}*/192 -
issm/trunk/src/c/objects/Options/OptionsChar.h
r7731 r7737 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 #include "./Option sObject.h"13 #include "./Option.h" 14 14 /*}}}*/ 15 15 16 class OptionsChar: public Option sObject{16 class OptionsChar: public Option { 17 17 18 18 public: … … 28 28 void DeepEcho(); 29 29 void DeepEcho(char* indent); 30 int Id() ;31 int MyRank() ;32 void Marshall(char** pmarshalled_dataset) ;33 int MarshallSize() ;34 void Demarshall(char** pmarshalled_dataset) ;35 int Enum() ;36 Object* copy() ;30 int Id(){_error_("Not implemented yet");}; 31 int MyRank(){_error_("Not implemented yet");}; 32 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 33 int MarshallSize(){_error_("Not implemented yet");}; 34 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 35 int Enum(){_error_("Not implemented yet");}; 36 Object* copy(){_error_("Not implemented yet");}; 37 37 /*}}}*/ 38 38 -
issm/trunk/src/c/objects/Options/OptionsDouble.cpp
r7731 r7737 43 43 44 44 _printf_(flag,"OptionsDouble Echo:\n"); 45 Option sObject::Echo();45 Option::Echo(); 46 46 47 47 if (values && size) { 48 if (numel == 1) { 49 _printf_(flag," values: %g\n" ,values[0]); 50 } 48 if(numel == 1) _printf_(flag," values: %g\n" ,values[0]); 51 49 else { 52 StringFromSize(cstr, 53 size, 54 ndims); 50 StringFromSize(cstr,size,ndims); 55 51 _printf_(flag," values: %s %s\n" ,cstr,"double"); 56 52 } 57 53 } 58 else 59 _printf_(flag," values: [empty]\n" ); 60 61 return; 54 else _printf_(flag," values: [empty]\n" ); 62 55 } 63 56 /*}}}*/ 64 65 /*FUNCTION OptionsDouble::DeepEcho {{{1*/ 57 /*FUNCTION OptionsDouble::DeepEcho() {{{1*/ 66 58 void OptionsDouble::DeepEcho(){ 67 59 … … 73 65 } 74 66 /*}}}*/ 75 76 /*FUNCTION OptionsDouble::DeepEcho {{{1*/ 67 /*FUNCTION OptionsDouble::DeepEcho(char* indent) {{{1*/ 77 68 void OptionsDouble::DeepEcho(char* indent){ 78 69 … … 84 75 85 76 _printf_(flag,"%sOptionsDouble DeepEcho:\n",indent); 86 Option sObject::DeepEcho(indent);77 Option::DeepEcho(indent); 87 78 88 79 strcpy(indent2,indent); … … 91 82 if (values) { 92 83 dims=(int *) xmalloc(ndims*sizeof(int)); 93 if (numel == 1) { 94 _printf_(flag,"%s values: %g\n" ,indent,values[0]); 95 } 96 else { 84 if(numel==1) _printf_(flag,"%s values: %g\n" ,indent,values[0]); 85 else{ 97 86 for (i=0; i<numel; i++) { 98 RowWiseDimsFromIndex(dims, 99 i, 100 size, 101 ndims); 102 StringFromDims(cstr, 103 dims, 104 ndims); 87 RowWiseDimsFromIndex(dims,i,size,ndims); 88 StringFromDims(cstr,dims,ndims); 105 89 _printf_(flag,"%s values%s: %g\n" ,indent,cstr,values[i]); 106 90 } … … 108 92 xfree((void**)&dims); 109 93 } 110 else 111 _printf_(flag,"%s values: [empty]\n" ,indent); 112 113 return; 94 else _printf_(flag,"%s values: [empty]\n" ,indent); 114 95 } 115 96 /*}}}*/ 116 117 97 /*FUNCTION OptionsDouble::Name {{{1*/ 118 98 char* OptionsDouble::Name(){ 119 99 120 return(Option sObject::Name());100 return(Option::Name()); 121 101 } 122 102 /*}}}*/ 123 124 103 /*FUNCTION OptionsDouble::NumEl {{{1*/ 125 104 int OptionsDouble::NumEl(){ 126 105 127 return(Option sObject::NumEl());106 return(Option::NumEl()); 128 107 } 129 108 /*}}}*/ 130 131 109 /*FUNCTION OptionsDouble::NDims {{{1*/ 132 110 int OptionsDouble::NDims(){ 133 111 134 return(Option sObject::NDims());112 return(Option::NDims()); 135 113 } 136 114 /*}}}*/ 137 138 115 /*FUNCTION OptionsDouble::Size {{{1*/ 139 116 int* OptionsDouble::Size(){ 140 117 141 return(Option sObject::Size());118 return(Option::Size()); 142 119 } 143 120 /*}}}*/ 144 145 121 /*FUNCTION OptionsDouble::Get {{{1*/ 146 122 //void* OptionsDouble::Get(){ … … 151 127 //} 152 128 /*}}}*/ 153 154 /*FUNCTION OptionsDouble::Id {{{1*/155 int OptionsDouble::Id(){156 }157 /*}}}*/158 159 /*FUNCTION OptionsDouble::MyRank {{{1*/160 int OptionsDouble::MyRank(){161 }162 /*}}}*/163 164 /*FUNCTION OptionsDouble::Marshall {{{1*/165 void OptionsDouble::Marshall(char** pmarshalled_dataset){166 }167 /*}}}*/168 169 /*FUNCTION OptionsDouble::MarshallSize {{{1*/170 int OptionsDouble::MarshallSize(){171 }172 /*}}}*/173 174 /*FUNCTION OptionsDouble::Demarshall {{{1*/175 void OptionsDouble::Demarshall(char** pmarshalled_dataset){176 }177 /*}}}*/178 179 /*FUNCTION OptionsDouble::Enum {{{1*/180 int OptionsDouble::Enum(){181 }182 /*}}}*/183 184 /*FUNCTION OptionsDouble::copy {{{1*/185 Object* OptionsDouble::copy(){186 }187 /*}}}*/188 -
issm/trunk/src/c/objects/Options/OptionsDouble.h
r7731 r7737 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 #include "./Option sObject.h"13 #include "./Option.h" 14 14 /*}}}*/ 15 15 16 class OptionsDouble: public Option sObject{16 class OptionsDouble: public Option { 17 17 18 18 public: … … 28 28 void DeepEcho(); 29 29 void DeepEcho(char* indent); 30 int Id() ;31 int MyRank() ;32 void Marshall(char** pmarshalled_dataset) ;33 int MarshallSize() ;34 void Demarshall(char** pmarshalled_dataset) ;35 int Enum() ;36 Object* copy() ;30 int Id(){_error_("Not implemented yet");}; 31 int MyRank(){_error_("Not implemented yet");}; 32 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 33 int MarshallSize(){_error_("Not implemented yet");}; 34 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 35 int Enum(){_error_("Not implemented yet");}; 36 Object* copy(){_error_("Not implemented yet");}; 37 37 /*}}}*/ 38 38 -
issm/trunk/src/c/objects/Options/OptionsLogical.cpp
r7731 r7737 43 43 44 44 _printf_(flag,"OptionsLogical Echo:\n"); 45 Option sObject::Echo();45 Option::Echo(); 46 46 47 47 if (values && size) { 48 if (numel == 1) { 49 _printf_(flag," values: %s\n" ,(values[0] ? "true" : "false")); 50 } 51 else { 52 StringFromSize(cstr, 53 size, 54 ndims); 48 if(numel == 1) _printf_(flag," values: %s\n" ,(values[0] ? "true" : "false")); 49 else{ 50 StringFromSize(cstr,size,ndims); 55 51 _printf_(flag," values: %s %s\n" ,cstr,"logical"); 56 52 } 57 53 } 58 else 59 _printf_(flag," values: [empty]\n" ); 60 61 return; 54 else _printf_(flag," values: [empty]\n" ); 62 55 } 63 56 /*}}}*/ 64 65 /*FUNCTION OptionsLogical::DeepEcho {{{1*/ 57 /*FUNCTION OptionsLogical::DeepEcho() {{{1*/ 66 58 void OptionsLogical::DeepEcho(){ 67 59 … … 73 65 } 74 66 /*}}}*/ 75 76 /*FUNCTION OptionsLogical::DeepEcho {{{1*/ 67 /*FUNCTION OptionsLogical::DeepEcho(char* indent) {{{1*/ 77 68 void OptionsLogical::DeepEcho(char* indent){ 78 69 … … 84 75 85 76 _printf_(flag,"%sOptionsLogical DeepEcho:\n",indent); 86 Option sObject::DeepEcho(indent);77 Option::DeepEcho(indent); 87 78 88 79 strcpy(indent2,indent); … … 90 81 91 82 if (values) { 92 if (numel == 1) { 93 _printf_(flag,"%s values: %s\n" ,indent,(values[0] ? "true" : "false")); 94 } 95 else { 83 if(numel==1) _printf_(flag,"%s values: %s\n" ,indent,(values[0] ? "true" : "false")); 84 else{ 96 85 dims=(int *) xmalloc(ndims*sizeof(int)); 97 86 for (i=0; i<numel; i++) { 98 RowWiseDimsFromIndex(dims, 99 i, 100 size, 101 ndims); 102 StringFromDims(cstr, 103 dims, 104 ndims); 87 RowWiseDimsFromIndex(dims,i,size,ndims); 88 StringFromDims(cstr,dims,ndims); 105 89 _printf_(flag,"%s values%s: %s\n" ,indent,cstr,(values[i] ? "true" : "false")); 106 90 } … … 108 92 } 109 93 } 110 else 111 _printf_(flag,"%s values: [empty]\n" ,indent); 112 113 return; 94 else _printf_(flag,"%s values: [empty]\n" ,indent); 114 95 } 115 96 /*}}}*/ 116 117 97 /*FUNCTION OptionsLogical::Name {{{1*/ 118 98 char* OptionsLogical::Name(){ 119 99 120 return(Option sObject::Name());100 return(Option::Name()); 121 101 } 122 102 /*}}}*/ 123 124 103 /*FUNCTION OptionsLogical::NumEl {{{1*/ 125 104 int OptionsLogical::NumEl(){ 126 105 127 return(Option sObject::NumEl());106 return(Option::NumEl()); 128 107 } 129 108 /*}}}*/ 130 131 109 /*FUNCTION OptionsLogical::NDims {{{1*/ 132 110 int OptionsLogical::NDims(){ 133 111 134 return(Option sObject::NDims());112 return(Option::NDims()); 135 113 } 136 114 /*}}}*/ 137 138 115 /*FUNCTION OptionsLogical::Size {{{1*/ 139 116 int* OptionsLogical::Size(){ 140 117 141 return(Option sObject::Size());118 return(Option::Size()); 142 119 } 143 120 /*}}}*/ 144 145 121 /*FUNCTION OptionsLogical::Get {{{1*/ 146 122 //void* OptionsLogical::Get(){ … … 151 127 //} 152 128 /*}}}*/ 153 154 /*FUNCTION OptionsLogical::Id {{{1*/155 int OptionsLogical::Id(){156 }157 /*}}}*/158 159 /*FUNCTION OptionsLogical::MyRank {{{1*/160 int OptionsLogical::MyRank(){161 }162 /*}}}*/163 164 /*FUNCTION OptionsLogical::Marshall {{{1*/165 void OptionsLogical::Marshall(char** pmarshalled_dataset){166 }167 /*}}}*/168 169 /*FUNCTION OptionsLogical::MarshallSize {{{1*/170 int OptionsLogical::MarshallSize(){171 }172 /*}}}*/173 174 /*FUNCTION OptionsLogical::Demarshall {{{1*/175 void OptionsLogical::Demarshall(char** pmarshalled_dataset){176 }177 /*}}}*/178 179 /*FUNCTION OptionsLogical::Enum {{{1*/180 int OptionsLogical::Enum(){181 }182 /*}}}*/183 184 /*FUNCTION OptionsLogical::copy {{{1*/185 Object* OptionsLogical::copy(){186 }187 /*}}}*/188 -
issm/trunk/src/c/objects/Options/OptionsLogical.h
r7731 r7737 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 #include "./Option sObject.h"13 #include "./Option.h" 14 14 /*}}}*/ 15 15 16 class OptionsLogical: public Option sObject{16 class OptionsLogical: public Option { 17 17 18 18 public: … … 28 28 void DeepEcho(); 29 29 void DeepEcho(char* indent); 30 int Id() ;31 int MyRank() ;32 void Marshall(char** pmarshalled_dataset) ;33 int MarshallSize() ;34 void Demarshall(char** pmarshalled_dataset) ;35 int Enum() ;36 Object* copy() ;30 int Id(){_error_("Not implemented yet");}; 31 int MyRank(){_error_("Not implemented yet");}; 32 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 33 int MarshallSize(){_error_("Not implemented yet");}; 34 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 35 int Enum(){_error_("Not implemented yet");}; 36 Object* copy(){_error_("Not implemented yet");}; 37 37 /*}}}*/ 38 38 -
issm/trunk/src/c/objects/Options/OptionsStruct.cpp
r7731 r7737 32 32 int i; 33 33 34 if (values){35 for 34 if(values){ 35 for(i=0; i<numel; i++) { 36 36 delete values[i]; 37 37 values[i] =NULL; … … 51 51 52 52 _printf_(flag,"OptionsStruct Echo:\n"); 53 Option sObject::Echo();53 Option::Echo(); 54 54 55 55 if (values && size) { 56 StringFromSize(cstr, 57 size, 58 ndims); 56 StringFromSize(cstr,size,ndims); 59 57 _printf_(flag," values: %s %s\n" ,cstr,"struct"); 60 58 } 61 else 62 _printf_(flag," values: [empty]\n" ); 63 64 return; 59 else _printf_(flag," values: [empty]\n" ); 65 60 } 66 61 /*}}}*/ 67 68 /*FUNCTION OptionsStruct::DeepEcho {{{1*/ 62 /*FUNCTION OptionsStruct::DeepEcho() {{{1*/ 69 63 void OptionsStruct::DeepEcho(){ 70 64 … … 76 70 } 77 71 /*}}}*/ 78 79 /*FUNCTION OptionsStruct::DeepEcho {{{1*/ 72 /*FUNCTION OptionsStruct::DeepEcho(char* indent) {{{1*/ 80 73 void OptionsStruct::DeepEcho(char* indent){ 81 74 … … 87 80 88 81 _printf_(flag,"%sOptionsStruct DeepEcho:\n",indent); 89 Option sObject::DeepEcho(indent);82 Option::DeepEcho(indent); 90 83 91 84 strcpy(indent2,indent); … … 93 86 94 87 if (values) { 95 dims=(int *) 88 dims=(int *)xmalloc(ndims*sizeof(int)); 96 89 for (i=0; i<numel; i++) { 97 ColumnWiseDimsFromIndex(dims, 98 i, 99 size, 100 ndims); 101 StringFromDims(cstr, 102 dims, 103 ndims); 104 if (values[i]->Size()) { 90 ColumnWiseDimsFromIndex(dims,i,size,ndims); 91 StringFromDims(cstr,dims,ndims); 92 if (values[i]->Size()){ 105 93 _printf_(flag,"%s values: %s begin\n" ,indent,cstr); 106 for (j=0; j<values[i]->Size(); j++) 107 ((OptionsObject *)values[i]->GetObjectByOffset(j))->DeepEcho(indent2); 94 for (j=0; j<values[i]->Size(); j++) ((Option *)values[i]->GetObjectByOffset(j))->DeepEcho(indent2); 108 95 _printf_(flag,"%s values: %s end\n" ,indent,cstr); 109 96 } 110 else 111 _printf_(flag,"%s values: %s [empty]\n" ,indent,cstr); 97 else _printf_(flag,"%s values: %s [empty]\n" ,indent,cstr); 112 98 } 113 99 xfree((void**)&dims); 114 100 } 115 else 116 _printf_(flag,"%s values: [empty]\n" ,indent); 117 118 return; 101 else _printf_(flag,"%s values: [empty]\n" ,indent); 119 102 } 120 103 /*}}}*/ 121 122 104 /*FUNCTION OptionsStruct::Name {{{1*/ 123 105 char* OptionsStruct::Name(){ 124 106 125 return(Option sObject::Name());107 return(Option::Name()); 126 108 } 127 109 /*}}}*/ 128 129 110 /*FUNCTION OptionsStruct::NumEl {{{1*/ 130 111 int OptionsStruct::NumEl(){ 131 112 132 return(Option sObject::NumEl());113 return(Option::NumEl()); 133 114 } 134 115 /*}}}*/ 135 136 116 /*FUNCTION OptionsStruct::NDims {{{1*/ 137 117 int OptionsStruct::NDims(){ 138 118 139 return(Option sObject::NDims());119 return(Option::NDims()); 140 120 } 141 121 /*}}}*/ 142 143 122 /*FUNCTION OptionsStruct::Size {{{1*/ 144 123 int* OptionsStruct::Size(){ 145 124 146 return(Option sObject::Size());125 return(Option::Size()); 147 126 } 148 127 /*}}}*/ 149 150 128 /*FUNCTION OptionsStruct::Get {{{1*/ 151 129 //void* OptionsStruct::Get(){ … … 156 134 //} 157 135 /*}}}*/ 158 159 /*FUNCTION OptionsStruct::Id {{{1*/160 int OptionsStruct::Id(){161 }162 /*}}}*/163 164 /*FUNCTION OptionsStruct::MyRank {{{1*/165 int OptionsStruct::MyRank(){166 }167 /*}}}*/168 169 /*FUNCTION OptionsStruct::Marshall {{{1*/170 void OptionsStruct::Marshall(char** pmarshalled_dataset){171 }172 /*}}}*/173 174 /*FUNCTION OptionsStruct::MarshallSize {{{1*/175 int OptionsStruct::MarshallSize(){176 }177 /*}}}*/178 179 /*FUNCTION OptionsStruct::Demarshall {{{1*/180 void OptionsStruct::Demarshall(char** pmarshalled_dataset){181 }182 /*}}}*/183 184 /*FUNCTION OptionsStruct::Enum {{{1*/185 int OptionsStruct::Enum(){186 }187 /*}}}*/188 189 /*FUNCTION OptionsStruct::copy {{{1*/190 Object* OptionsStruct::copy(){191 }192 /*}}}*/193 -
issm/trunk/src/c/objects/Options/OptionsStruct.h
r7731 r7737 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 #include "./Option sObject.h"13 #include "./Option.h" 14 14 /*}}}*/ 15 15 16 class OptionsStruct: public Option sObject{16 class OptionsStruct: public Option { 17 17 18 18 public: 19 19 20 DataSet** values;20 Options** values; 21 21 22 22 /*OptionsStruct constructors, destructors {{{1*/ … … 28 28 void DeepEcho(); 29 29 void DeepEcho(char* indent); 30 int Id() ;31 int MyRank() ;32 void Marshall(char** pmarshalled_dataset) ;33 int MarshallSize() ;34 void Demarshall(char** pmarshalled_dataset) ;35 int Enum() ;36 Object* copy() ;30 int Id(){_error_("Not implemented yet");}; 31 int MyRank(){_error_("Not implemented yet");}; 32 void Marshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 33 int MarshallSize(){_error_("Not implemented yet");}; 34 void Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet");}; 35 int Enum(){_error_("Not implemented yet");}; 36 Object* copy(){_error_("Not implemented yet");}; 37 37 /*}}}*/ 38 38 -
issm/trunk/src/c/objects/Options/OptionsUtilities.cpp
r7731 r7737 19 19 /*}}}*/ 20 20 21 int ColumnWiseDimsFromIndex(int* dims, 22 int index, 23 int* size, 24 int ndims) { 21 /*FUNCTION ColumnWiseDimsFromIndex{{{1*/ 22 int ColumnWiseDimsFromIndex(int* dims,int index,int* size,int ndims){ 25 23 26 24 int i; 27 25 int aprod=1; 28 26 29 /* check for index too large */ 27 /*check for index too large */ 28 for (i=0;i<ndims;i++) aprod*=size[i]; 29 if (index >= aprod) _error_("Index %d exceeds number of elements %d.",index,aprod); 30 30 31 for (i=0; i<ndims; i++) 32 aprod*=size[i]; 33 34 if (index >= aprod) 35 _error_("Index %d exceeds number of elements %d.",index,aprod); 36 37 /* calculate the dimensions (being careful of integer division) */ 38 31 /*calculate the dimensions (being careful of integer division) */ 39 32 for (i=ndims-1; i>=0; i--) { 40 33 aprod=(int)(((double)aprod+0.5)/(double)size[i]); … … 44 37 45 38 return(0); 46 } 47 48 int IndexFromColumnWiseDims(int* dims, 49 int* size, 50 int ndims) { 39 }/*}}}*/ 40 /*FUNCTION IndexFromColumnWiseDims{{{1*/ 41 int IndexFromColumnWiseDims(int* dims, int* size, int ndims) { 51 42 52 43 int i; 53 44 int index=0; 54 45 55 /* check for any dimension too large */ 46 /*check for any dimension too large */ 47 for (i=0;i<ndims;i++){ 48 if (dims[i] >= size[i]) _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]); 49 } 56 50 57 for (i=0; i<ndims; i++) 58 if (dims[i] >= size[i]) 59 _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]); 60 61 /* calculate the index */ 62 63 for (i=ndims-1; i>=0; i--) { 51 /*calculate the index */ 52 for (i=ndims-1; i>=0; i--){ 64 53 index*=size[i]; 65 54 index+=dims[i]; … … 67 56 68 57 return(index); 69 } 70 71 72 int RowWiseDimsFromIndex(int* dims, 73 int index, 74 int* size, 75 int ndims) { 58 }/*}}}*/ 59 /*FUNCTION RowWiseDimsFromIndex{{{1*/ 60 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims) { 76 61 77 62 int i; 78 63 int aprod=1; 79 64 80 /* check for index too large */ 65 /*check for index too large */ 66 for (i=0; i<ndims; i++) aprod*=size[i]; 67 if (index >= aprod) _error_("Index %d exceeds number of elements %d.",index,aprod); 81 68 82 for (i=0; i<ndims; i++) 83 aprod*=size[i]; 84 85 if (index >= aprod) 86 _error_("Index %d exceeds number of elements %d.",index,aprod); 87 88 /* calculate the dimensions (being careful of integer division) */ 89 69 /*calculate the dimensions (being careful of integer division) */ 90 70 for (i=0; i<ndims; i++) { 91 71 aprod=(int)(((double)aprod+0.5)/(double)size[i]); … … 95 75 96 76 return(0); 97 } 98 99 100 int IndexFromRowWiseDims(int* dims, 101 int* size, 102 int ndims) { 77 }/*}}}*/ 78 /*FUNCTION IndexFromRowWiseDims{{{1*/ 79 int IndexFromRowWiseDims(int* dims, int* size, int ndims) { 103 80 104 81 int i; 105 82 int index=0; 106 83 107 /* check for any dimension too large */ 84 /*check for any dimension too large */ 85 for (i=0; i<ndims; i++){ 86 if (dims[i] >= size[i]) _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]); 87 } 108 88 109 for (i=0; i<ndims; i++) 110 if (dims[i] >= size[i]) 111 _error_("Dimension %d of %d exceeds size of %d.",i,dims[i],size[i]); 112 113 /* calculate the index */ 114 89 /*calculate the index */ 115 90 for (i=0; i<ndims; i++) { 116 91 index*=size[i]; … … 119 94 120 95 return(index); 121 } 122 123 124 int StringFromDims(char* cstr, 125 int* dims, 126 int ndims) { 127 128 int i; 96 }/*}}}*/ 97 /*FUNCTION StringFromDims{{{1*/ 98 int StringFromDims(char* cstr, int* dims, int ndims) { 129 99 130 100 sprintf(&cstr[0],"["); 131 for (i=0; i<ndims-1; i++) 132 sprintf(&cstr[strlen(cstr)],"%d,",dims[i]); 101 for(int i=0; i<ndims-1; i++) sprintf(&cstr[strlen(cstr)],"%d,",dims[i]); 133 102 sprintf(&cstr[strlen(cstr)],"%d]",dims[ndims-1]); 134 103 135 104 return(0); 136 } 137 138 139 int StringFromSize(char* cstr, 140 int* size, 141 int ndims) { 142 143 int i; 105 }/*}}}*/ 106 /*FUNCTION StringFromSize{{{1*/ 107 int StringFromSize(char* cstr, int* size, int ndims) { 144 108 145 109 sprintf(&cstr[0],"["); 146 for (i=0; i<ndims-1; i++) 147 sprintf(&cstr[strlen(cstr)],"%dx",size[i]); 110 for(int i=0; i<ndims-1; i++) sprintf(&cstr[strlen(cstr)],"%dx",size[i]); 148 111 sprintf(&cstr[strlen(cstr)],"%d]",size[ndims-1]); 149 112 150 113 return(0); 151 } 152 114 }/*}}}*/ -
issm/trunk/src/c/objects/Options/OptionsUtilities.h
r7731 r7737 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 #include "./Option sObject.h"13 #include "./Option.h" 14 14 /*}}}*/ 15 15 16 int ColumnWiseDimsFromIndex(int* dims, 17 int index, 18 int* size, 19 int ndims); 20 int IndexFromColumnWiseDims(int* dims, 21 int* size, 22 int ndims); 23 int RowWiseDimsFromIndex(int* dims, 24 int index, 25 int* size, 26 int ndims); 27 int IndexFromRowWiseDims(int* dims, 28 int* size, 29 int ndims); 30 int StringFromDims(char* cstr, 31 int* dims, 32 int ndims); 33 int StringFromSize(char* cstr, 34 int* size, 35 int ndims); 16 int ColumnWiseDimsFromIndex(int* dims, int index, int* size, int ndims); 17 int IndexFromColumnWiseDims(int* dims, int* size, int ndims); 18 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims); 19 int IndexFromRowWiseDims(int* dims, int* size, int ndims); 20 int StringFromDims(char* cstr, int* dims, int ndims); 21 int StringFromSize(char* cstr, int* size, int ndims); 36 22 37 23 #endif /* _OPTIONSUTILITIES_H */ -
issm/trunk/src/c/objects/Params/Param.h
r6165 r7737 27 27 28 28 public: 29 30 29 virtual ~Param(){}; 31 30 -
issm/trunk/src/c/objects/objects.h
r7733 r7737 64 64 65 65 /*Option parsing objects: */ 66 #include "./Options/Option sObject.h"66 #include "./Options/Option.h" 67 67 #include "./Options/OptionsDouble.h" 68 68 #include "./Options/OptionsLogical.h" -
issm/trunk/src/c/shared/Matlab/ModuleBoot.cpp
r6014 r7737 17 17 int ModuleBoot(void){ 18 18 19 /*Declare my_ 19 /*Declare my_rank and num_procs global variables!: */ 20 20 my_rank=0; 21 21 num_procs=1; -
issm/trunk/src/c/shared/Matlab/PrintfFunction.cpp
r1439 r7737 24 24 //First use vsprintf to get the whole input string. 25 25 va_start(ap,format); 26 26 #ifndef WIN32 27 27 string_size=vsprintf(string,format,ap); //printf style coding 28 28 #else … … 40 40 return 1; 41 41 } 42 43
Note:
See TracChangeset
for help on using the changeset viewer.