Changeset 20653
- Timestamp:
- 05/26/16 00:34:45 (9 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r20644 r20653 26 26 ./classes/gauss/GaussTetra.cpp\ 27 27 ./classes/gauss/GaussPenta.cpp\ 28 ./classes/IoModel.cpp\ 28 29 ./classes/FemModel.cpp\ 29 30 ./classes/Loads/Friction.cpp\ 30 31 ./classes/Inputs/TransientInput.cpp\ 31 32 ./classes/Constraints/SpcTransient.cpp\ 32 ./classes/IndependentObject.cpp\33 33 ./classes/DependentObject.cpp\ 34 34 ./classes/DofIndexing.cpp\ 35 ./classes/IoModel.cpp\36 35 ./classes/Contours.cpp\ 37 36 ./classes/Nodes.cpp\ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r20645 r20653 3 3 * into ISSM, from Matlab, or through a binary file opened for reading. 4 4 */ 5 6 /*CODES: 7 * 1: boolean constant 8 * 2: integer constant 9 * 3: IssmDouble constant 10 * 5: boolean vector 11 * 6: int vector 12 * 7: IssmDouble vector*/ 5 13 6 14 #ifdef HAVE_CONFIG_H … … 19 27 #include "../shared/shared.h" 20 28 29 /*NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW*/ 30 IoConstant::IoConstant(){/*{{{*/ 31 this->isindependent = false; 32 this->data_enum = -1; 33 this->name = NULL; 34 this->constant = NULL; 35 } 36 /*}}}*/ 37 IoConstant::~IoConstant(){/*{{{*/ 38 xDelete<char>(this->name); 39 delete this->constant; 40 } 41 /*}}}*/ 42 IoConstant::IoConstant(bool value,int enum_in){/*{{{*/ 43 this->isindependent = false; 44 this->data_enum = enum_in; 45 this->name = NULL; 46 this->constant = new BoolParam(enum_in,value); 47 } 48 /*}}}*/ 49 IoConstant::IoConstant(int value,int enum_in){/*{{{*/ 50 this->isindependent = false; 51 this->data_enum = enum_in; 52 this->name = NULL; 53 this->constant = new IntParam(enum_in,value); 54 } 55 /*}}}*/ 56 IoConstant::IoConstant(IssmDouble value,int enum_in){/*{{{*/ 57 this->isindependent = false; 58 this->data_enum = enum_in; 59 this->name = NULL; 60 this->constant = new DoubleParam(enum_in,value); 61 } 62 /*}}}*/ 63 IoConstant::IoConstant(char* value,int enum_in){/*{{{*/ 64 this->isindependent = false; 65 this->data_enum = enum_in; 66 this->name = NULL; 67 this->constant = new StringParam(enum_in,value); 68 } 69 /*}}}*/ 70 71 IoData::IoData(){/*{{{*/ 72 this->isindependent = false; 73 this->data_enum = -1; 74 this->name = NULL; 75 this->code = -1; 76 this->layout = -1; 77 this->M = 0; 78 this->N = 0; 79 this->data = NULL; 80 } 81 /*}}}*/ 82 IoData::~IoData(){/*{{{*/ 83 xDelete<char>(this->name); 84 xDelete<IssmDouble>(this->data); 85 } 86 /*}}}*/ 87 IoData::IoData(IssmDouble* matrix,int code_in,int layout_in,int M_in,int N_in,int enum_in){/*{{{*/ 88 this->isindependent = false; 89 this->data_enum = enum_in; 90 this->name = NULL; 91 this->code = code_in; 92 this->layout = layout_in; 93 this->M = M_in; 94 this->N = N_in; 95 this->data = matrix; /*do not copy*/ 96 _assert_(code_in==5 || code_in==6 || code_in==7); 97 } 98 /*}}}*/ 99 100 void IoModel::AddConstant(IoConstant* in_constant){/*{{{*/ 101 102 _assert_(in_constant); 103 104 /*Go through dataset of constant and check whether it already exists */ 105 vector<IoConstant*>::iterator iter; 106 107 for(iter=constants.begin();iter<constants.end();iter++){ 108 if((*iter)->data_enum==in_constant->data_enum){ 109 delete in_constant; 110 return; 111 } 112 } 113 114 this->constants.push_back(in_constant); 115 } 116 /*}}}*/ 117 void IoModel::AddConstantIndependent(IoConstant* in_constant){/*{{{*/ 118 119 _assert_(in_constant); 120 121 /*Set constant as independent*/ 122 in_constant->isindependent = true; 123 124 /*Add to constnats*/ 125 this->AddConstant(in_constant); 126 } 127 /*}}}*/ 128 void IoModel::AddData(IoData* in_data){/*{{{*/ 129 130 _assert_(in_data); 131 132 /*Go through dataset of data and check whether it already exists */ 133 vector<IoData*>::iterator iter; 134 135 for(iter=data.begin();iter<data.end();iter++){ 136 if((*iter)->data_enum==in_data->data_enum){ 137 delete in_data; 138 return; 139 } 140 } 141 142 this->data.push_back(in_data); 143 } 144 /*}}}*/ 145 void IoModel::AddDataIndependent(IoData* in_data){/*{{{*/ 146 147 _assert_(in_data); 148 149 /*Set data as independent*/ 150 in_data->isindependent = true; 151 152 /*Add to constnats*/ 153 this->AddData(in_data); 154 } 155 /*}}}*/ 156 void IoModel::FetchIndependentConstant(int* pXcount,IssmPDouble* X,int name){/*{{{*/ 157 158 /*recover my_rank:*/ 159 int my_rank=IssmComm::GetRank(); 160 161 /*recover Xcount if X is not NULL:*/ 162 int Xcount = 0; 163 if(X) Xcount=*pXcount; 164 165 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents: 166 167 /*output: */ 168 IssmPDouble pscalar; 169 IssmDouble scalar; //same as pscalar, except it's an ADOLC independent variable 170 int code; 171 172 /*Set file pointer to beginning of the data: */ 173 fid=this->SetFilePointerToData(&code,NULL,name); 174 if(code!=3) _error_("expecting a IssmDouble for enum " << EnumToStringx(name)); 175 176 /*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */ 177 if(my_rank==0){ 178 if(fread(&pscalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar "); 179 180 /*Now, before we even broadcast this to other nodes, declare the scalar as an independent variable!. If we 181 *have been supplied an X vector, use it instead of what we just read: */ 182 if(X){ 183 scalar<<=X[Xcount]; 184 } 185 else{ 186 scalar<<=pscalar; 187 } 188 } 189 190 ISSM_MPI_Bcast(&scalar,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 191 this->AddConstantIndependent(new IoConstant(scalar,name)); 192 193 /*increment offset into X vector, now that we have read 1 value:*/ 194 Xcount++; *pXcount=Xcount; 195 #endif 196 } 197 /*}}}*/ 198 void IoModel::FetchIndependentData(int* pXcount,IssmPDouble* X,int name){/*{{{*/ 199 200 /*recover my_rank:*/ 201 int my_rank=IssmComm::GetRank(); 202 203 /*recover Xcount if X is not NULL:*/ 204 int Xcount = 0; 205 if(X) Xcount=*pXcount; 206 207 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents: 208 209 /*Intermediaries*/ 210 int M,N; 211 IssmPDouble* buffer=NULL; //a buffer to read the data from disk 212 IssmDouble* matrix=NULL; //our independent variable 213 int code,layout; 214 215 /*Set file pointer to beginning of the data: */ 216 fid=this->SetFilePointerToData(&code,&layout,name); 217 if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(name)); 218 219 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 220 /*numberofelements: */ 221 if(my_rank==0){ 222 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 223 } 224 ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 225 226 if(my_rank==0){ 227 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 228 } 229 ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 230 231 /*Now allocate matrix: */ 232 if(M*N){ 233 buffer=xNew<IssmPDouble>(M*N); 234 matrix=xNew<IssmDouble>(M*N); 235 236 /*Read matrix on node 0, then broadcast: */ 237 if(my_rank==0){ 238 if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 239 240 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable! 241 If we have been supplied an X vector, use it instead of what we just read: */ 242 if(X){ 243 for(int i=0;i<M*N;i++) matrix[i]<<=X[Xcount+i]; /*<<= ADOLC overloaded operator to declare independent*/ 244 } 245 else{ 246 for(int i=0;i<M*N;i++) matrix[i]<<=buffer[i]; 247 } 248 } 249 ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 250 251 xDelete<IssmPDouble>(buffer); 252 } 253 else _error_("cannot declare the independent variable " << EnumToStringx(name) << "if it's empty!"); 254 255 /*Add to data as independent*/ 256 this->AddDataIndependent(new IoData(matrix,code,layout,M,N,name)); 257 258 /*increment offset into X vector, now that we have read M*N values:*/ 259 Xcount+=M*N; *pXcount=Xcount; 260 #endif 261 } 262 /*}}}*/ 263 void IoModel::FindConstant(bool* pvalue,int constant_enum){/*{{{*/ 264 265 /*Intermediary*/ 266 vector<IoConstant*>::iterator iter; 267 268 for(iter=constants.begin();iter<constants.end();iter++){ 269 IoConstant* ioconstant=*iter; 270 271 if(ioconstant->data_enum==constant_enum){ 272 ioconstant->constant->GetParameterValue(pvalue); 273 return; 274 } 275 } 276 277 for(vector<IoConstant*>::iterator iter=constants.begin();iter<constants.end();iter++) (*iter)->constant->Echo(); 278 _error_("Could not find constant \""<<EnumToStringx(constant_enum) <<"\""); 279 } 280 /*}}}*/ 281 void IoModel::FindConstant(int* pvalue,int constant_enum){/*{{{*/ 282 283 /*Intermediary*/ 284 vector<IoConstant*>::iterator iter; 285 286 for(iter=constants.begin();iter<constants.end();iter++){ 287 IoConstant* ioconstant=*iter; 288 289 if(ioconstant->data_enum==constant_enum){ 290 ioconstant->constant->GetParameterValue(pvalue); 291 return; 292 } 293 } 294 295 _error_("Could not find constant \""<<EnumToStringx(constant_enum) <<"\""); 296 } 297 /*}}}*/ 298 void IoModel::FindConstant(IssmDouble* pvalue,int constant_enum){/*{{{*/ 299 300 /*Intermediary*/ 301 vector<IoConstant*>::iterator iter; 302 303 for(iter=constants.begin();iter<constants.end();iter++){ 304 IoConstant* ioconstant=*iter; 305 306 if(ioconstant->data_enum==constant_enum){ 307 ioconstant->constant->GetParameterValue(pvalue); 308 return; 309 } 310 } 311 312 _error_("Could not find constant \""<<EnumToStringx(constant_enum) <<"\""); 313 } 314 /*}}}*/ 315 void IoModel::FindConstant(char** pvalue,int constant_enum){/*{{{*/ 316 317 /*Intermediary*/ 318 vector<IoConstant*>::iterator iter; 319 320 for(iter=constants.begin();iter<constants.end();iter++){ 321 IoConstant* ioconstant=*iter; 322 323 if(ioconstant->data_enum==constant_enum){ 324 ioconstant->constant->GetParameterValue(pvalue); 325 return; 326 } 327 } 328 329 _error_("Could not find constant \""<<EnumToStringx(constant_enum) <<"\""); 330 } 331 /*}}}*/ 332 int IoModel::NumIndependents(void){/*{{{*/ 333 334 /*Initialize output*/ 335 int num_independents = 0; 336 337 /*Process constants*/ 338 for(vector<IoConstant*>::iterator iter=constants.begin();iter<constants.end();iter++){ 339 if((*iter)->isindependent){ 340 num_independents+= 1; 341 } 342 } 343 344 /*Process data*/ 345 for(vector<IoData*>::iterator iter=data.begin();iter<data.end();iter++){ 346 if((*iter)->isindependent){ 347 num_independents+= (*iter)->M*(*iter)->N; 348 } 349 } 350 351 /*return*/ 352 return num_independents; 353 } 354 /*}}}*/ 355 void IoModel::FillIndependents(IssmDouble* xp){/*{{{*/ 356 357 _assert_(xp); 358 359 /*Initialize local num ind*/ 360 int local_num_ind = 0; 361 362 /*Process constants*/ 363 for(vector<IoConstant*>::iterator iter=constants.begin();iter<constants.end();iter++){ 364 if((*iter)->isindependent){ 365 (*iter)->constant->GetParameterValue(&xp[local_num_ind]); 366 local_num_ind += 1; 367 } 368 } 369 370 /*Process data*/ 371 for(vector<IoData*>::iterator iter=data.begin();iter<data.end();iter++){ 372 if((*iter)->isindependent){ 373 for(int i=0;i<(*iter)->M*(*iter)->N;i++){ 374 xp[local_num_ind+i] = (*iter)->data[i]; 375 } 376 local_num_ind += (*iter)->M*(*iter)->N; 377 } 378 } 379 380 _assert_(local_num_ind == this->NumIndependents()); 381 } 382 /*}}}*/ 383 /*NEW NEW NEW NEW NEW NEW NEW NEW NEW NEW*/ 384 21 385 IoModel::IoModel(){/*{{{*/ 386 22 387 this->fid=NULL; 23 388 this->solution_enum=-1; 24 this->data=NULL;25 this->independents=NULL;26 this->independent_objects=NULL;27 this->constants=NULL;28 389 29 390 this->my_elements=NULL; … … 65 426 this->solution_enum = solution_enum_in; 66 427 67 /*Initialize data: */68 this->data=xNew<IssmDouble*>(MaximumNumberOfDefinitionsEnum);69 for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++) this->data[i]=NULL;70 71 428 /*If we are running in AD mode, we need to start the trace and declare our independent variables now, 72 429 *and prevent them from being erased during successive calls to iomodel->FetchConstants, iomodel->FetchData and … … 76 433 77 434 /*Initialize and read constants:*/ 78 this->constants=new Parameters(); 79 this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/ 80 81 /*Now some very specific piece of logic. We want to know whether we are going to carry out an autodiff run. There are 82 *several cases: either trace is true (which bypasses the isautodiff choice), or trace is false but isautodiff is on, in which 83 *case two cases are possible: are we running a control method or not? To make things simpler, we are going to pin down everyting 84 *on isautodiff. By the way, we could not do this before we had the constants dataset initialized! {{{*/ 85 this->constants->FindParam(&autodiff,AutodiffIsautodiffEnum); 86 this->constants->FindParam(&iscontrol,InversionIscontrolEnum); 87 88 if(trace)autodiff=true; 435 this->FetchConstants(); /*this routine goes through the input file, and fetches bool, int, IssmDouble and string only, nothing memory intensive*/ 436 437 /*Is this an autodiff run?*/ 438 this->FindConstant(&autodiff,AutodiffIsautodiffEnum); 439 this->FindConstant(&iscontrol,InversionIscontrolEnum); 440 if(trace){ 441 autodiff=true; 442 } 89 443 else{ 90 if(autodiff && !iscontrol) autodiff=true; 91 else autodiff=false; 92 } 93 this->constants->SetParam(autodiff,AutodiffIsautodiffEnum); 94 /*}}}*/ 444 if(autodiff && !iscontrol) 445 autodiff=true; 446 else 447 autodiff=false; 448 } 449 this->AddConstant(new IoConstant(autodiff,AutodiffIsautodiffEnum)); 95 450 96 451 /*Initialize permanent data: */ … … 119 474 IoModel::~IoModel(){/*{{{*/ 120 475 121 /*Delete independents*/ 122 if(this->independents){ 123 for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++){ 124 if(this->independents[i]){ 125 IssmDouble* array=this->data[i]; 126 xDelete<IssmDouble>(array); 127 } 128 } 129 } 130 131 /*checks in debugging mode*/ 132 #if defined(_ISSM_DEBUG_) && !defined(_HAVE_ADOLC_) 133 if(this->data){ 134 for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++){ 135 if(this->data[i]){ 136 _printf0_("WARNING: previous pointer of " << EnumToStringx(i) << " has not been freed (DeleteData has not been called)\n"); 137 } 138 } 139 } 140 #endif 141 142 if(this->constants) delete this->constants; 143 144 xDelete<IssmDouble*>(this->data); 145 xDelete<bool>(this->independents); 146 if(this->independent_objects)delete this->independent_objects; 476 /*Delete constants*/ 477 vector<IoConstant*>::iterator iter1; 478 for(iter1=constants.begin();iter1<constants.end();iter1++){ 479 delete *iter1; 480 } 481 this->constants.clear(); 482 483 /*Delete data*/ 484 vector<IoData*>::iterator iter2; 485 for(iter2=data.begin();iter2<data.end();iter2++){ 486 #if defined(_ISSM_DEBUG_) 487 if(!(*iter2)->isindependent){ 488 _printf0_("WARNING: IoData " << EnumToStringx((*iter2)->data_enum) << " has not been freed (DeleteData has not been called)\n"); 489 } 490 #endif 491 delete *iter2; 492 } 493 this->data.clear(); 147 494 148 495 xDelete<bool>(this->my_elements); … … 244 591 } 245 592 /*}}}*/ 246 void IoModel::FindConstant(bool* poutput,int constant_enum){/*{{{*/247 248 _assert_(constant_enum>=0);249 _assert_(this->constants);250 251 this->constants->FindParam(poutput,constant_enum);252 }253 /*}}}*/254 void IoModel::FindConstant(int* poutput,int constant_enum){/*{{{*/255 256 _assert_(constant_enum>=0);257 _assert_(this->constants);258 259 this->constants->FindParam(poutput,constant_enum);260 }261 /*}}}*/262 void IoModel::FindConstant(IssmDouble* poutput,int constant_enum){/*{{{*/263 264 _assert_(constant_enum>=0);265 _assert_(this->constants);266 267 this->constants->FindParam(poutput,constant_enum);268 }269 /*}}}*/270 void IoModel::FindConstant(char** poutput,int constant_enum){/*{{{*/271 272 _assert_(constant_enum>=0);273 _assert_(this->constants);274 275 this->constants->FindParam(poutput,constant_enum);276 }277 /*}}}*/278 593 Param* IoModel::CopyConstantObject(int constant_enum){/*{{{*/ 279 594 280 _assert_(this->constants); 281 282 /*Find constant*/ 283 //FIXME _error_("Needs to be FIXED"); 284 Param* param=this->constants->FindParamObject(constant_enum); 285 if(!param) _error_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel"); 286 287 return xDynamicCast<Param*>(param->copy()); 595 /*Intermediary*/ 596 vector<IoConstant*>::iterator iter; 597 598 for(iter=constants.begin();iter<constants.end();iter++){ 599 IoConstant* ioconstant=*iter; 600 601 if(ioconstant->data_enum==constant_enum){ 602 return ioconstant->constant->copy(); 603 } 604 } 605 606 _error_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel"); 607 return NULL; 288 608 } 289 609 /*}}}*/ 290 610 IssmDouble* IoModel::Data(int data_enum){/*{{{*/ 291 611 292 _assert_(data_enum<MaximumNumberOfDefinitionsEnum); 293 _assert_(data_enum>=0); 294 295 return this->data[data_enum]; 612 /*Intermediary*/ 613 vector<IoData*>::iterator iter; 614 615 for(iter=data.begin();iter<data.end();iter++){ 616 IoData* iodata=*iter; 617 if(iodata->data_enum==data_enum) return iodata->data; 618 } 619 620 return NULL; 296 621 } 297 622 /*}}}*/ … … 338 663 void IoModel::DeclareIndependents(bool trace,IssmPDouble* X){/*{{{*/ 339 664 340 int i; 341 bool autodiff = false; 342 bool iscontrol = false; 665 bool autodiff,iscontrol; 343 666 int num_independent_objects; 344 667 int Xcount=0; … … 347 670 int *types = NULL; 348 671 349 int dummy;350 351 672 /*Initialize array detecting whether data[i] is an independent AD mode variable: */ 352 this->independents=xNew<bool>(MaximumNumberOfDefinitionsEnum);353 for(i=0;i<MaximumNumberOfDefinitionsEnum;i++) this->independents[i]=false;354 355 673 this->FetchData(&autodiff,AutodiffIsautodiffEnum); 356 674 this->FetchData(&iscontrol,InversionIscontrolEnum); … … 359 677 360 678 #ifdef _HAVE_ADOLC_ 361 /*build dataset made of independent objects:*/362 this->independent_objects=new DataSet();363 679 this->FetchData(&num_independent_objects,AutodiffNumIndependentObjectsEnum); 364 680 if(num_independent_objects){ 365 this->FetchData(&names, &dummy,&dummy,AutodiffIndependentObjectNamesEnum);366 this->FetchData(&types, &dummy,&dummy,AutodiffIndependentObjectTypesEnum);681 this->FetchData(&names,NULL,NULL,AutodiffIndependentObjectNamesEnum); 682 this->FetchData(&types,NULL,NULL,AutodiffIndependentObjectTypesEnum); 367 683 368 684 /*create independent objects, and at the same time, fetch the corresponding independent variables, 369 685 *and declare them as such in ADOLC: */ 370 for(i=0;i<num_independent_objects;i++){ 371 372 IndependentObject* independent_object=NULL; 373 independent_object=new IndependentObject(names[i],types[i]); 374 375 /*add to independent_objects dataset:*/ 376 this->independent_objects->AddObject(independent_object); 377 378 /*now go fetch the independent variable: */ 379 independent_object->FetchIndependent(this,&Xcount,X); //supply the pointer to iomodel. 686 for(int i=0;i<num_independent_objects;i++){ 687 688 if(types[i]==0){ 689 /*Scalar*/ 690 this->FetchIndependentConstant(&Xcount,X,names[i]); 691 } 692 else if(types[i]==1){ 693 /* vector:*/ 694 this->FetchIndependentData(&Xcount,X,names[i]); 695 } 696 else{ 697 _error_("Independent cannot be of size " << types[i]); 698 } 380 699 } 381 700 xDelete<int>(names); … … 387 706 #endif 388 707 } 389 else this->independent_objects=NULL;390 391 708 } 392 709 /*}}}*/ 393 710 void IoModel::DeleteData(int num,...){/*{{{*/ 394 711 712 /*Intermediaries*/ 395 713 va_list ap; 396 714 int dataenum; 397 398 /*Go through the entire list of enums and delete the corresponding data from the iomodel-data dataset: */ 715 vector<IoData*>::iterator iter; 716 717 /*Go through the entire list of data and delete the corresponding data from the iomodel-data dataset: */ 399 718 va_start(ap,num); 400 719 for(int i=0;i<num;i++){ 401 720 dataenum=va_arg(ap,int); 402 _assert_(dataenum<MaximumNumberOfDefinitionsEnum); 403 404 /*do not erase independent variables for the AD mode computations!: */ 405 if (!this->independents[dataenum]) xDelete<IssmDouble>(this->data[dataenum]); 721 722 for(iter=data.begin();iter<data.end();iter++){ 723 IoData* iodata=*iter; 724 if(iodata->data_enum==dataenum && !iodata->isindependent){ 725 delete *iter; 726 this->data.erase(iter); 727 break; 728 } 729 } 406 730 } 407 731 va_end(ap); 408 732 } /*}}}*/ 409 void IoModel::DeleteData(IssmDouble* vector, int dataenum){/*{{{*/ 410 411 /*do not erase independent variables for the AD mode computations!: */ 412 if(vector)if (!this->independents[dataenum]) xDelete<IssmDouble>(vector); 413 733 void IoModel::DeleteData(IssmDouble* vector_in, int dataenum){/*{{{*/ 734 735 vector<IoData*>::iterator iter; 736 737 /*do not do anything if pointer is NULL*/ 738 if(!vector_in) return; 739 740 /*do not delete if this is an independent variable*/ 741 for(iter=data.begin();iter<data.end();iter++){ 742 IoData* iodata=*iter; 743 if(iodata->data_enum==dataenum && iodata->isindependent){ 744 return; 745 } 746 } 747 748 /*Go ahead and delete*/ 749 xDelete<IssmDouble>(vector_in); 414 750 } /*}}}*/ 415 751 void IoModel::DeleteData(char*** pstringarray, int numstrings, int dataenum){/*{{{*/ … … 429 765 void IoModel::FetchConstants(void){/*{{{*/ 430 766 431 int my_rank;432 433 767 /*record descriptions; */ 434 768 int record_enum; … … 437 771 438 772 /*records: */ 439 int booleanint=0;440 int integer=0;441 IssmPDouble pscalar=0;442 IssmDouble scalar=0;443 char * string=NULL;444 int string_size;773 int booleanint = 0; 774 int integer = 0; 775 IssmPDouble pscalar = 0; 776 IssmDouble scalar = 0; 777 char *string = NULL; 778 int string_size; 445 779 446 780 /*recover my_rank:*/ 447 my_rank=IssmComm::GetRank();781 int my_rank=IssmComm::GetRank(); 448 782 449 783 /*Check that some fields have been allocated*/ 450 784 _assert_(this->fid || my_rank); 451 _assert_(this->constants);452 785 453 786 /*Go find in the binary file, the position of the data we want to fetch: */ … … 487 820 /*create BoolParam: */ 488 821 if(record_enum!=MaximumNumberOfDefinitionsEnum && record_enum!=MaximumNumberOfDefinitionsEnum+1) 489 this-> constants->AddObject(new BoolParam(record_enum,(bool)booleanint)); //cast to boolean822 this->AddConstant(new IoConstant((bool)booleanint,record_enum)); //cast to boolean 490 823 491 824 break; … … 496 829 497 830 /*create IntParam: */ 498 this-> constants->AddObject(new IntParam(record_enum,integer));831 this->AddConstant(new IoConstant(integer,record_enum)); 499 832 500 833 break; 501 834 case 3: 502 /*Read the scalar and broadcast it to other cpus. However, if this record has already 503 * been read in DeclareIndependents, we should not re-read it, but grab it from the iomodel->data 504 * slots: */ 505 if(this->independents[record_enum]){ 506 scalar=*(this->data[record_enum]); 507 } 508 else{ 509 if(fread(&pscalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar "); 510 ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 511 scalar=pscalar; 512 } 513 514 /*create DoubleParam: */ 515 this->constants->AddObject(new DoubleParam(record_enum,scalar)); 516 835 { 836 /*IssmDouble, check whether it is already there (from "declare independents")*/ 837 bool exists = false; 838 vector<IoConstant*>::iterator iter; 839 for(iter=constants.begin();iter<constants.end();iter++){ 840 IoConstant* ioconstant=*iter; 841 if(ioconstant->data_enum==record_enum){ 842 exists = true; 843 break; 844 } 845 } 846 if(!exists){ 847 if(fread(&pscalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar "); 848 ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 849 scalar=pscalar; 850 851 /*create DoubleParam: */ 852 this->AddConstant(new IoConstant(scalar,record_enum)); 853 } 854 } 517 855 break; 518 856 case 4: … … 535 873 536 874 /*Add string to parameters: */ 537 this-> constants->AddObject(new StringParam(record_enum,string));875 this->AddConstant(new IoConstant(string,record_enum)); 538 876 539 877 /*Free string*/ 540 878 xDelete<char>(string); 541 542 879 break; 543 880 case 5: 544 /*We are not interested in this record, too memory intensive. Skip it: */545 /*skip: */546 fseek(fid,-sizeof(int),SEEK_CUR); //backtrak 1 integer547 fseek(fid,record_length,SEEK_CUR);548 break;549 881 case 6: 550 /*We are not interested in this record, too memory intensive. Skip it: */551 /*skip: */552 fseek(fid,-sizeof(int),SEEK_CUR); //backtrak 1 integer553 fseek(fid,record_length,SEEK_CUR);554 break;555 882 case 7: 556 /*We are not interested in this record, too memory intensive. Skip it: */557 /*skip: */558 fseek(fid,-sizeof(int),SEEK_CUR); //backtrak 1 integer559 fseek(fid,record_length,SEEK_CUR);560 break;561 562 883 case 8: 563 /*We are not interested in this record, too memory intensive. Skip it: */564 /*skip: */565 fseek(fid,-sizeof(int),SEEK_CUR); //backtrak 1 integer566 fseek(fid,record_length,SEEK_CUR);567 break;568 569 884 case 9: 570 885 /*We are not interested in this record, too memory intensive. Skip it: */ … … 573 888 fseek(fid,record_length,SEEK_CUR); 574 889 break; 575 576 890 default: 577 891 _error_("unknown record type:" << record_code); 578 break; ;892 break; 579 893 } 580 894 } … … 597 911 /*create BoolParam: */ 598 912 if(record_enum!=MaximumNumberOfDefinitionsEnum && record_enum!=MaximumNumberOfDefinitionsEnum+1) 599 this-> constants->AddObject(new BoolParam(record_enum,(bool)booleanint)); //cast to a boolean913 this->AddConstant(new IoConstant((bool)booleanint,record_enum)); //cast to a boolean 600 914 break; 601 915 … … 605 919 606 920 /*create IntParam: */ 607 this-> constants->AddObject(new IntParam(record_enum,integer));921 this->AddConstant(new IoConstant(integer,record_enum)); 608 922 609 923 break; 610 924 case 3: 611 925 /*scalar. get it from cpu 0 */ 612 ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 613 scalar=pscalar; 614 /*create DoubleParam: */ 615 this->constants->AddObject(new DoubleParam(record_enum,scalar)); 616 926 { 927 /*IssmDouble, check whether it is already there (from "declare independents")*/ 928 bool exists = false; 929 vector<IoConstant*>::iterator iter; 930 for(iter=constants.begin();iter<constants.end();iter++){ 931 IoConstant* ioconstant=*iter; 932 if(ioconstant->data_enum==record_enum){ 933 exists = true; 934 break; 935 } 936 } 937 if(!exists){ 938 ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 939 scalar=pscalar; 940 /*create DoubleParam: */ 941 this->AddConstant(new IoConstant(scalar,record_enum)); 942 } 943 } 617 944 break; 618 945 case 4: … … 630 957 } 631 958 /*Add string to parameters: */ 632 this-> constants->AddObject(new StringParam(record_enum,string));959 this->AddConstant(new IoConstant(string,record_enum)); 633 960 634 961 /*Free string*/ … … 644 971 default: 645 972 _error_("unknown record type:" << record_code); 646 break; ;973 break; 647 974 } 648 975 … … 653 980 /*}}}*/ 654 981 void IoModel::FetchData(bool* pboolean,int data_enum){/*{{{*/ 655 656 int my_rank;657 982 658 983 /*output: */ … … 661 986 662 987 /*recover my_rank:*/ 663 my_rank=IssmComm::GetRank();988 int my_rank=IssmComm::GetRank(); 664 989 665 990 /*Set file pointer to beginning of the data: */ … … 682 1007 void IoModel::FetchData(int* pinteger,int data_enum){/*{{{*/ 683 1008 684 int my_rank;685 686 1009 /*output: */ 687 1010 int integer; … … 689 1012 690 1013 /*recover my_rank:*/ 691 my_rank=IssmComm::GetRank();1014 int my_rank=IssmComm::GetRank(); 692 1015 693 1016 /*Set file pointer to beginning of the data: */ … … 709 1032 void IoModel::FetchData(IssmDouble* pscalar,int data_enum){/*{{{*/ 710 1033 711 int my_rank;712 713 1034 /*output: */ 714 1035 IssmPDouble scalar; … … 716 1037 717 1038 /*recover my_rank:*/ 718 my_rank=IssmComm::GetRank();1039 int my_rank=IssmComm::GetRank(); 719 1040 720 1041 /*Set file pointer to beginning of the data: */ … … 735 1056 /*}}}*/ 736 1057 void IoModel::FetchData(char** pstring,int data_enum){/*{{{*/ 737 738 int my_rank;739 1058 740 1059 /*output: */ … … 744 1063 745 1064 /*recover my_rank:*/ 746 my_rank=IssmComm::GetRank();1065 int my_rank=IssmComm::GetRank(); 747 1066 748 1067 /*Set file pointer to beginning of the data: */ … … 781 1100 /*}}}*/ 782 1101 void IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){/*{{{*/ 783 784 int my_rank;785 1102 int i,j; 786 1103 … … 792 1109 793 1110 /*recover my_rank:*/ 794 my_rank=IssmComm::GetRank();1111 int my_rank=IssmComm::GetRank(); 795 1112 796 1113 /*Set file pointer to beginning of the data: */ … … 850 1167 void IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){/*{{{*/ 851 1168 852 int my_rank; 853 1169 /*First, look if has already been loaded (might be an independent variable)*/ 1170 vector<IoData*>::iterator iter; 1171 for(iter=data.begin();iter<data.end();iter++){ 1172 IoData* iodata=*iter; 1173 if(iodata->data_enum==data_enum){ 1174 *pmatrix=iodata->data; 1175 if(pM) *pM=iodata->M; 1176 if(pN) *pN=iodata->N; 1177 return; 1178 } 1179 } 1180 854 1181 /*output: */ 855 int M,N;856 IssmPDouble * matrix=NULL;857 int code=0;1182 int M,N; 1183 IssmPDouble *matrix = NULL; 1184 int code = 0; 858 1185 859 1186 /*recover my_rank:*/ 860 my_rank=IssmComm::GetRank();1187 int my_rank=IssmComm::GetRank(); 861 1188 862 1189 /*Set file pointer to beginning of the data: */ … … 868 1195 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 869 1196 /*numberofelements: */ 870 if(my_rank==0){ 1197 if(my_rank==0){ 871 1198 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 872 1199 } … … 888 1215 ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 889 1216 890 _assert_(this->independents); 891 if(this->independents[data_enum]){ 892 /*this data has already been checked out! So cancel all that we've done here, and return 893 * the data[data_enum] directly: */ 894 *pmatrix=this->data[data_enum]; 895 } 896 else{ 897 *pmatrix=xNew<IssmDouble>(M*N); 898 for(int i=0;i<M*N;++i) (*pmatrix)[i]=matrix[i]; 899 } 1217 *pmatrix=xNew<IssmDouble>(M*N); 1218 for(int i=0;i<M*N;++i) (*pmatrix)[i]=matrix[i]; 900 1219 xDelete<IssmPDouble>(matrix); 901 1220 } … … 903 1222 *pmatrix=NULL; 904 1223 /*Assign output pointers: */ 905 if (pM)*pM=M;906 if (pN)*pN=N;1224 if(pM) *pM=M; 1225 if(pN) *pN=N; 907 1226 } 908 1227 /*}}}*/ 909 1228 void IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){/*{{{*/ 910 911 int my_rank;912 1229 913 1230 int i; … … 923 1240 924 1241 /*recover my_rank:*/ 925 my_rank=IssmComm::GetRank();1242 int my_rank=IssmComm::GetRank(); 926 1243 927 1244 /*Set file pointer to beginning of the data: */ … … 975 1292 976 1293 int i; 977 978 int my_rank;979 980 1294 /*output: */ 981 1295 IssmDouble** matrices=NULL; … … 990 1304 991 1305 /*recover my_rank:*/ 992 my_rank=IssmComm::GetRank();1306 int my_rank=IssmComm::GetRank(); 993 1307 994 1308 /*Set file pointer to beginning of the data: */ … … 1105 1419 1106 1420 va_list ap; 1107 int dataenum ;1421 int dataenum,code,layout; 1108 1422 IssmDouble *matrix = NULL; 1109 1423 int M,N; 1110 int i; 1424 bool exists; 1425 vector<IoData*>::iterator iter; 1111 1426 1112 1427 /*Go through the entire list of enums and fetch the corresponding data. Add it to the iomodel->data dataset. Everything … … 1114 1429 1115 1430 va_start(ap,num); 1116 for(i =0; i<num; i++){1431 for(int i=0; i<num; i++){ 1117 1432 1118 1433 dataenum=va_arg(ap, int); 1119 _assert_(dataenum<MaximumNumberOfDefinitionsEnum); 1120 _assert_(dataenum>=0); 1121 1122 if (this->independents[dataenum]){ 1434 exists = false; 1435 1436 for(iter=data.begin();iter<data.end();iter++){ 1437 IoData* iodata=*iter; 1438 if(iodata->data_enum==dataenum){ 1439 /*Already there, no need to fetch it*/ 1440 _assert_(iodata->isindependent); 1441 exists = true; 1442 break; 1443 } 1444 } 1445 1446 if(exists){ 1123 1447 /*this data has already been checked out! Continue: */ 1124 1448 continue; 1125 1449 } 1126 1127 /*Some checks in debugging mode*/ 1128 /*{{{*/ 1129 #ifdef _ISSM_DEBUG_ 1130 _assert_(dataenum<MaximumNumberOfDefinitionsEnum); 1131 if(this->data[dataenum]){ 1132 _error_("Info: trying to fetch " << EnumToStringx(dataenum) << " but previous pointer has not been freed (DeleteData has not been called)"); 1133 } 1134 #endif 1135 /*}}}*/ 1136 1137 /*Add to this->data: */ 1138 this->FetchData(&matrix,&M,&N,dataenum); 1139 this->data[dataenum]=matrix; 1450 else{ 1451 /*Add to this->data: */ 1452 this->SetFilePointerToData(&code,&layout,dataenum); 1453 this->FetchData(&matrix,&M,&N,dataenum); 1454 this->AddData(new IoData(matrix,code,layout,M,N,dataenum)); 1455 } 1140 1456 } 1141 1457 va_end(ap); 1142 1143 1458 } 1144 1459 /*}}}*/ … … 1373 1688 ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 1374 1689 1375 _assert_(this->independents); 1376 if(this->independents[data_enum]){ 1377 /*this data has already been checked out! So cancel all that we've done here, and return 1378 * the data[data_enum] directly: */ 1379 matrix=this->data[data_enum]; 1380 } 1381 else{ 1690 //if(this->independents[data_enum]){ FIXME 1691 // /*this data has already been checked out! So cancel all that we've done here, and return 1692 // * the data[data_enum] directly: */ 1693 // matrix=this->data[data_enum]; 1694 //} 1695 //else{ 1382 1696 matrix=xNew<IssmDouble>(M*N); 1383 1697 for (int i=0;i<M*N;++i) matrix[i]=pmatrix[i]; 1384 }1698 //} 1385 1699 xDelete<IssmPDouble>(pmatrix); 1386 1700 } … … 1479 1793 ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 1480 1794 1481 _assert_(this->independents); 1482 if(this->independents[data_enum]){ 1483 /*this data has already been checked out! So cancel all that we've done here, and return 1484 * the data[data_enum] directly: */ 1485 matrix=this->data[data_enum]; 1486 for (int i=0;i<M*N;++i) integer_matrix[i]=reCast<int>(matrix[i]); 1487 } 1488 else{ 1795 //if(this->independents[data_enum]){ FIXME 1796 // /*this data has already been checked out! So cancel all that we've done here, and return 1797 // * the data[data_enum] directly: */ 1798 // matrix=this->data[data_enum]; 1799 // for (int i=0;i<M*N;++i) integer_matrix[i]=reCast<int>(matrix[i]); 1800 //} 1801 //else{ 1489 1802 for (int i=0;i<M*N;++i) integer_matrix[i]=pmatrix[i]; 1490 }1803 //} 1491 1804 xDelete<IssmPDouble>(pmatrix); 1492 1805 } … … 1525 1838 void IoModel::FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value){/*{{{*/ 1526 1839 1840 /*First, look whether it is not already loaded in this->data*/ 1841 vector<IoData*>::iterator iter; 1842 for(iter=data.begin();iter<data.end();iter++){ 1843 IoData* iodata=*iter; 1844 if(iodata->data_enum==vector_enum){ 1845 _assert_(iodata->code==7); 1846 for(int i=0;i<elements->Size();i++){ 1847 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1848 element->InputCreate(iodata->data,this,iodata->M,iodata->N,iodata->layout,vector_enum,iodata->code);//we need i to index into elements. 1849 } 1850 return; 1851 } 1852 } 1853 1527 1854 /*intermediary: */ 1528 1855 int code,vector_layout; … … 1544 1871 } 1545 1872 1546 /*Free ressources . Pay attention to not freeing an AD mode independent variable though!:*/1547 if(!this->independents[vector_enum])xDelete<IssmDouble>(doublearray);1873 /*Free ressources*/ 1874 xDelete<IssmDouble>(doublearray); 1548 1875 } 1549 1876 /*}}}*/ 1550 1877 void IoModel::FetchDataToInput(Elements* elements,int vector_enum){/*{{{*/ 1878 1879 /*First, look whether it is not already loaded in this->data*/ 1880 vector<IoData*>::iterator iter; 1881 for(iter=data.begin();iter<data.end();iter++){ 1882 IoData* iodata=*iter; 1883 if(iodata->data_enum==vector_enum){ 1884 for(int i=0;i<elements->Size();i++){ 1885 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i)); 1886 element->InputCreate(iodata->data,this,iodata->M,iodata->N,iodata->layout,vector_enum,iodata->code);//we need i to index into elements. 1887 } 1888 return; 1889 } 1890 } 1551 1891 1552 1892 /*intermediary: */ … … 1615 1955 break; 1616 1956 } 1617 /*Free ressources . Pay attention to not freeing an AD mode independent variable though!:*/1618 if (!this->independents[vector_enum])xDelete<IssmDouble>(doublearray);1957 /*Free ressources*/ 1958 xDelete<IssmDouble>(doublearray); 1619 1959 xDelete<char>(string); 1620 1960 } -
issm/trunk-jpl/src/c/classes/IoModel.h
r20645 r20653 9 9 10 10 #include "../shared/Enum/Enum.h" 11 #include <vector> 11 12 12 13 class Parameters; … … 15 16 class Option; 16 17 18 class IoConstant { /*holds single IssmDouble, int, bool and char from input*/ 19 public: 20 bool isindependent; 21 int data_enum; 22 char* name; 23 Param* constant; 24 25 ~IoConstant(); 26 IoConstant(); 27 IoConstant(bool value,int enum_in); 28 IoConstant(int value,int enum_in); 29 IoConstant(IssmDouble value,int enum_in); 30 IoConstant(char* value,int enum_in); 31 }; 32 33 class IoData { /*holds temporary data (array), memory intensive*/ 34 public: 35 bool isindependent; 36 int data_enum; 37 char* name; 38 int M,N; 39 int code; 40 int layout; 41 IssmDouble* data; 42 43 ~IoData(); 44 IoData(); 45 IoData(IssmDouble* matrix,int code,int layout_in,int M,int N,int enum_in); 46 }; 47 17 48 class IoModel { 18 49 19 50 private: 20 Parameters *constants; //this dataset holds all IssmDouble, int, bool and char from input 51 std::vector<IoConstant*> constants; //this dataset holds all IssmDouble, int, bool and char from input 52 std::vector<IoData*> data; //this dataset holds temporary data, memory intensive 53 54 /*for AD mode: to keep track of our independent variables we fetch:*/ 55 //bool *independents; 56 //DataSet *independent_objects; 21 57 22 58 public: 23 IssmDouble **data; //this dataset holds temporary data, memory intensive.24 25 59 /*pointer to input file*/ 26 60 FILE *fid; … … 55 89 int constraintcounter; //keep track of how many constraints are being created in each analysis 56 90 57 /*for AD mode: to keep track of our independent variables we fetch:*/58 bool *independents;59 DataSet *independent_objects;60 61 91 /*Methods*/ 62 92 ~IoModel(); … … 64 94 IoModel(FILE* iomodel_handle,int solution_enum_in,bool trace,IssmPDouble* X); 65 95 96 /*NEW*/ 97 void AddConstant(IoConstant* constant_in); 98 void AddConstantIndependent(IoConstant* constant_in); 99 void AddData(IoData* data_in); 100 void AddDataIndependent(IoData* data_in); 101 void FindConstant(bool* pvalue,int constant_enum); 102 void FindConstant(int* pvalue,int constant_enum); 103 void FindConstant(IssmDouble* pvalue,int constant_enum); 104 void FindConstant(char **pvalue,int constant_enum); 105 void FetchIndependentConstant(int* pXcount,IssmPDouble* X,int name); 106 void FetchIndependentData(int* pXcount,IssmPDouble* X,int name); 107 int NumIndependents(); 108 void FillIndependents(IssmDouble* xp); 109 66 110 /*Input/Output*/ 67 111 void CheckEnumSync(void); 68 void FindConstant(bool *poutput,int constant_enum);69 void FindConstant(int *poutput,int constant_enum);70 void FindConstant(IssmDouble *poutput,int constant_enum);71 void FindConstant(char **poutput,int constant_enum);72 112 Param *CopyConstantObject(int constant_enum); 73 113 IssmDouble *Data(int dataenum); -
issm/trunk-jpl/src/c/main/kriging.cpp
r18521 r20653 145 145 iomodel->fid=fid; 146 146 iomodel->CheckEnumSync(); 147 iomodel->independents=xNew<bool>(MaximumNumberOfDefinitionsEnum); for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++) iomodel->independents[i]=false;148 147 iomodel->FetchData(&x,&M,&N,0); nobs=M*N; 149 148 iomodel->FetchData(&y,&M,&N,1); _assert_(M*N==nobs); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r20645 r20653 133 133 /*Independents have already been recovered in iomodel->DeclareIndependents. Just do some more processing. 134 134 *In particular, figure out num_independents, and create the state vector xp, or size num_independents x 1 :*/ 135 num_ind=0; 136 for(i=0;i<iomodel->independent_objects->Size();i++){ 137 IndependentObject* ind=(IndependentObject*)iomodel->independent_objects->GetObjectByOffset(i); 138 num_ind+=ind->NumIndependents(); 139 } 135 num_ind=iomodel->NumIndependents(); 136 parameters->AddObject(new IntParam(AutodiffNumIndependentsEnum,num_ind)); 137 140 138 if(num_ind){ 141 139 xp=xNew<IssmDouble>(num_ind); 142 xp_backup=xp; 143 for(i=0;i<iomodel->independent_objects->Size();i++){ 144 IndependentObject* ind=(IndependentObject*)iomodel->independent_objects->GetObjectByOffset(i); 145 ind->FillIndependents(iomodel->data,xp); 146 local_num_ind=ind->NumIndependents(); xp=xp+local_num_ind; 147 } 148 xp=xp_backup; parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_ind)); 140 iomodel->FillIndependents(xp); 141 parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_ind)); 149 142 xDelete<IssmDouble>(xp); 150 143 } 151 parameters->AddObject(new IntParam(AutodiffNumIndependentsEnum,num_ind));152 153 /*Don't forget to copy iomodel->independent_objects to parameters: */154 parameters->AddObject(new DataSetParam(AutodiffIndependentObjectsEnum,iomodel->independent_objects));155 144 /*}}}*/ 156 145 }
Note:
See TracChangeset
for help on using the changeset viewer.