Changeset 18879
- Timestamp:
- 11/28/14 09:50:51 (10 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IoModel.cpp
r18806 r18879 50 50 } 51 51 /*}}}*/ 52 IoModel::IoModel(FILE* iomodel_handle){/*{{{*/ 53 52 IoModel::IoModel(FILE* iomodel_handle,bool trace,IssmPDouble* X){/*{{{*/ 53 54 bool autodiff=false; 55 bool iscontrol=false; 56 54 57 /*First, keep track of the file handle: */ 55 58 this->fid=iomodel_handle; … … 65 68 *and prevent them from being erased during successive calls to iomodel->FetchConstants, iomodel->FetchData and 66 69 iomodel->DeleteData:*/ 67 this->StartTrace( );68 this->DeclareIndependents( );70 this->StartTrace(trace); 71 this->DeclareIndependents(trace,X); 69 72 70 73 /*Initialize and read constants:*/ 71 74 this->constants=new Parameters(); 72 75 this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/ 76 77 /*Now some very specific piece of logic. We want to know whether we are going to carry out an autodiff run. There are 78 *several cases: either trace is true (which bypasses the isautodiff choice), or trace is false but isautodiff is on, in which 79 *case two cases are possible: are we running a control method or not? To make things simpler, we are going to pin down everyting 80 *on isautodiff. By the way, we could not do this before we had the constants dataset initialized! {{{*/ 81 this->constants->FindParam(&autodiff,AutodiffIsautodiffEnum); 82 this->constants->FindParam(&iscontrol,InversionIscontrolEnum); 83 84 if(trace)autodiff=true; 85 else{ 86 if(autodiff && !iscontrol) autodiff=true; 87 else autodiff=false; 88 } 89 this->constants->SetParam(autodiff,AutodiffIsautodiffEnum); 90 /*}}}*/ 73 91 74 92 /*Initialize permanent data: */ … … 108 126 109 127 /*checks in debugging mode*/ 110 #if def _ISSM_DEBUG_128 #if defined(_ISSM_DEBUG_) && !defined(_HAVE_ADOLC_) 111 129 if(this->data){ 112 130 for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++){ … … 273 291 } 274 292 /*}}}*/ 275 void IoModel::StartTrace( void){/*{{{*/293 void IoModel::StartTrace(bool trace){/*{{{*/ 276 294 277 295 bool autodiff = false; 296 bool iscontrol = false; 278 297 bool keep=false; 279 298 IssmDouble gcTriggerRatio; … … 287 306 288 307 this->FetchData(&autodiff,AutodiffIsautodiffEnum); 289 if(autodiff){ 290 308 this->FetchData(&iscontrol,InversionIscontrolEnum); 309 310 if(trace || (autodiff && !iscontrol)){ 291 311 #ifdef _HAVE_ADOLC_ 292 312 /*Retrieve parameters: */ … … 311 331 } 312 332 /*}}}*/ 313 void IoModel::DeclareIndependents( void){/*{{{*/333 void IoModel::DeclareIndependents(bool trace,IssmPDouble* X){/*{{{*/ 314 334 315 335 int i; 316 336 bool autodiff = false; 337 bool iscontrol = false; 317 338 int num_independent_objects; 339 int Xcount=0; 318 340 319 341 int *names = NULL; … … 327 349 328 350 this->FetchData(&autodiff,AutodiffIsautodiffEnum); 329 if(autodiff){ 351 this->FetchData(&iscontrol,InversionIscontrolEnum); 352 353 if(trace || (autodiff && !iscontrol)){ 330 354 331 355 #ifdef _HAVE_ADOLC_ … … 348 372 349 373 /*now go fetch the independent variable: */ 350 independent_object->FetchIndependent(this ); //supply the pointer to iomodel.374 independent_object->FetchIndependent(this,&Xcount,X); //supply the pointer to iomodel. 351 375 } 352 376 xDelete<int>(names); -
issm/trunk-jpl/src/c/classes/IoModel.h
r18813 r18879 59 59 ~IoModel(); 60 60 IoModel(); 61 IoModel(FILE* iomodel_handle );61 IoModel(FILE* iomodel_handle,bool trace,IssmPDouble* X); 62 62 63 63 /*Input/Output*/ … … 93 93 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 94 94 fpos_t* SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum); 95 void DeclareIndependents( void);96 void StartTrace( void);95 void DeclareIndependents(bool trace,IssmPDouble* X); 96 void StartTrace(bool trace); 97 97 void FetchIndependent(int dependent_enum); 98 98 };
Note:
See TracChangeset
for help on using the changeset viewer.