Changeset 18879


Ignore:
Timestamp:
11/28/14 09:50:51 (10 years ago)
Author:
Eric.Larour
Message:

CHG: new overloading to feed in trace (boolean which determines whether we should trace using AD or not) and
corresponding X (state parameters, or number of indepenets) down into the FetchIndependent routines, where we
bypass the disk I/O and instead use X to initialize the independents. This is useful for ad control core, which
does not update the control inputs the same way as the standard m1qn3controlcore.

Location:
issm/trunk-jpl/src/c/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/IoModel.cpp

    r18806 r18879  
    5050}
    5151/*}}}*/
    52 IoModel::IoModel(FILE* iomodel_handle){/*{{{*/
    53 
     52IoModel::IoModel(FILE* iomodel_handle,bool trace,IssmPDouble* X){/*{{{*/
     53
     54        bool autodiff=false;
     55        bool iscontrol=false;
     56       
    5457        /*First, keep track of the file handle: */
    5558        this->fid=iomodel_handle;
     
    6568         *and prevent them from being erased during successive calls to iomodel->FetchConstants, iomodel->FetchData and
    6669         iomodel->DeleteData:*/
    67         this->StartTrace();
    68         this->DeclareIndependents();
     70        this->StartTrace(trace);
     71        this->DeclareIndependents(trace,X);
    6972
    7073        /*Initialize and read constants:*/
    7174        this->constants=new Parameters();
    7275        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        /*}}}*/
    7391
    7492        /*Initialize permanent data: */
     
    108126
    109127        /*checks in debugging mode*/
    110         #ifdef _ISSM_DEBUG_
     128        #if defined(_ISSM_DEBUG_) && !defined(_HAVE_ADOLC_)
    111129        if(this->data){
    112130                for(int i=0;i<MaximumNumberOfDefinitionsEnum;i++){
     
    273291}
    274292/*}}}*/
    275 void IoModel::StartTrace(void){/*{{{*/
     293void IoModel::StartTrace(bool trace){/*{{{*/
    276294
    277295        bool autodiff = false;
     296        bool iscontrol = false;
    278297        bool keep=false;
    279298        IssmDouble gcTriggerRatio;
     
    287306
    288307        this->FetchData(&autodiff,AutodiffIsautodiffEnum);
    289         if(autodiff){
    290 
     308        this->FetchData(&iscontrol,InversionIscontrolEnum);
     309
     310        if(trace || (autodiff && !iscontrol)){
    291311                #ifdef _HAVE_ADOLC_
    292312                /*Retrieve parameters: */
     
    311331}
    312332/*}}}*/
    313 void IoModel::DeclareIndependents(void){/*{{{*/
     333void IoModel::DeclareIndependents(bool trace,IssmPDouble* X){/*{{{*/
    314334
    315335        int  i;
    316336        bool autodiff = false;
     337        bool iscontrol = false;
    317338        int  num_independent_objects;
     339        int  Xcount=0;
    318340
    319341        int *names = NULL;
     
    327349
    328350        this->FetchData(&autodiff,AutodiffIsautodiffEnum);
    329         if(autodiff){
     351        this->FetchData(&iscontrol,InversionIscontrolEnum);
     352       
     353        if(trace || (autodiff && !iscontrol)){
    330354
    331355                #ifdef _HAVE_ADOLC_
     
    348372
    349373                                /*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.
    351375                        }
    352376                        xDelete<int>(names);
  • issm/trunk-jpl/src/c/classes/IoModel.h

    r18813 r18879  
    5959                ~IoModel();
    6060                IoModel();
    61                 IoModel(FILE* iomodel_handle);
     61                IoModel(FILE* iomodel_handle,bool trace,IssmPDouble* X);
    6262
    6363                /*Input/Output*/
     
    9393                FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
    9494                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);
    9797                void        FetchIndependent(int dependent_enum);
    9898};
Note: See TracChangeset for help on using the changeset viewer.