Changeset 25523


Ignore:
Timestamp:
09/03/20 10:48:33 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: working on better marshalling for AD

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

Legend:

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

    r25508 r25523  
    7575
    7676        /*preliminary, before marshall starts: */
    77         if(marshallhandle->OperationNumber()==MARSHALLING_WRITE || marshallhandle->OperationNumber()==MARSHALLING_SIZE){
     77        if(marshallhandle->OperationNumber()!=MARSHALLING_LOAD){
    7878                if(this->hneighbors)hneighbors_null=false;
    7979                if(this->hnodes){
  • issm/trunk-jpl/src/c/classes/ExternalResults/GenericExternalResult.h

    r25508 r25523  
    6363                        /*Marshal result name*/
    6464                        int size = 0;
    65                         if(marshallhandle->OperationNumber()==MARSHALLING_WRITE || marshallhandle->OperationNumber() == MARSHALLING_SIZE) size=strlen(result_name)+1;
     65                        if(marshallhandle->OperationNumber()!=MARSHALLING_LOAD) size=strlen(result_name)+1;
    6666                        marshallhandle->call(size);
    6767                        marshallhandle->call(this->result_name,size);
     
    7070                        this->value=0;
    7171                        bool isnull=true;
    72                         if(marshallhandle->OperationNumber()==MARSHALLING_WRITE || marshallhandle->OperationNumber() == MARSHALLING_SIZE){
     72                        if(marshallhandle->OperationNumber()!=MARSHALLING_LOAD){
    7373                                if(value) isnull=false;
    7474                        }
     
    168168                } /*}}}*/
    169169                int ObjectEnum(void){ /*{{{*/
    170                         _error_("template ObjectEnum not implemented for this ResultType\n");
     170                        return GenericExternalResultEnum;
    171171                } /*}}}*/
    172172                void Marshall(MarshallHandle* marshallhandle){/*{{{*/
    173                         _error_("not implemented yet!");
     173                        _printf_("   WARNING: result "<<this->result_name<<" is a GenericExternalResult and cannot be marshalled (need overload)\n");
     174                        /*Nothing for now*/
    174175                }
    175176                /*}}}*/
     
    239240} /*}}}*/
    240241template <> inline void GenericExternalResult<bool>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
    241 
     242        printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);
    242243        this->GenericMarshall(marshallhandle);
    243244
     
    256257} /*}}}*/
    257258template <> inline void GenericExternalResult<int>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
     259        printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);
    258260        this->GenericMarshall(marshallhandle);
    259261}  /*}}}*/
     
    274276} /*}}}*/
    275277template <> inline void GenericExternalResult<double>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
     278        printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);
    276279        this->GenericMarshall(marshallhandle);
    277280}  /*}}}*/
     
    343346} /*}}}*/
    344347template <> inline void GenericExternalResult<char*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
    345 
    346         int size = 0;
    347 
    348         if(marshallhandle->OperationNumber()==MARSHALLING_WRITE || marshallhandle->OperationNumber() == MARSHALLING_SIZE)size=strlen(value)+1;
    349 
     348        printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);
    350349        marshallhandle->call(this->id);
    351350        marshallhandle->call(this->result_name);
    352         marshallhandle->call(size);
    353         marshallhandle->call(this->value,size);
     351        marshallhandle->call(this->value);
    354352        marshallhandle->call(this->step);
    355353        marshallhandle->call(this->time);
     
    473471} /*}}}*/
    474472template <> inline void GenericExternalResult<int*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
     473        printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);
    475474
    476475        int object_enum = this->ObjectEnum();
     
    606605} /*}}}*/
    607606template <> inline void GenericExternalResult<IssmPDouble*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
     607        printf("-------------- file: GenericExternalResult.h line: %i\n",__LINE__);
    608608
    609609        int object_enum = this->ObjectEnum();
     
    829829        /*}}}*/
    830830        template <> inline void GenericExternalResult<Vector<IssmDouble>*>::Marshall(MarshallHandle* marshallhandle){/*{{{*/
    831 
    832831                _error_("GenericExternalResult instantiated for type Vector<IssmDouble>* called " << result_name << " not implemented yet");
    833 
    834832        }  /*}}}*/
    835833
  • issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp

    r25508 r25523  
    122122        int object_enum = ControlInputEnum;
    123123   marshallhandle->call(object_enum);
    124         _error_("Not implemented");
     124
     125   marshallhandle->call(this->control_id);
     126        marshallhandle->call(this->enum_type);
     127        marshallhandle->call(this->layout_enum);
     128
     129        /*Allocate memory*/
     130        if(marshallhandle->OperationNumber()==MARSHALLING_LOAD){
     131                switch(this->layout_enum){
     132                        case TriaInputEnum:
     133                                this->values     =new TriaInput();
     134                                this->savedvalues=new TriaInput();
     135                                this->minvalues  =new TriaInput();
     136                                this->maxvalues  =new TriaInput();
     137                                this->gradient   =new TriaInput();
     138                                break;
     139                        case PentaInputEnum:
     140                                this->values     =new PentaInput();
     141                                this->savedvalues=new PentaInput();
     142                                this->minvalues  =new PentaInput();
     143                                this->maxvalues  =new PentaInput();
     144                                this->gradient   =new PentaInput();
     145                                break;
     146                        case TransientInputEnum:
     147                                this->values     =new TransientInput();
     148                                this->savedvalues=new TransientInput();
     149                                this->minvalues  =new TransientInput();
     150                                this->maxvalues  =new TransientInput();
     151                                this->gradient   =new TransientInput();
     152                                break;
     153                        default:
     154                                _error_("Input of Enum \"" << EnumToStringx(this->layout_enum) << "\" not supported yet");
     155                }
     156        }
     157
     158        this->values->Marshall(marshallhandle);
     159        this->savedvalues->Marshall(marshallhandle);
     160        this->minvalues->Marshall(marshallhandle);
     161        this->maxvalues->Marshall(marshallhandle);
     162        this->gradient->Marshall(marshallhandle);
    125163}
    126164/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp

    r25508 r25523  
    8787   marshallhandle->call(object_enum);
    8888
    89         if(marshallhandle->OperationNumber()==MARSHALLING_WRITE || marshallhandle->OperationNumber()==MARSHALLING_SIZE){
     89        if(marshallhandle->OperationNumber()!=MARSHALLING_LOAD){
    9090
    9191                /*Marshall num_inputs first*/
     
    137137                                this->inputs[index]=pentainput2;
    138138                        }
     139                        else if(object_enum==ControlInputEnum){
     140                                ControlInput* input=new ControlInput();
     141                                input->Marshall(marshallhandle);
     142                                this->inputs[index]=input;
     143                        }
    139144                        else{
    140145                                _error_("input "<<EnumToStringx(object_enum)<<" not supported");
Note: See TracChangeset for help on using the changeset viewer.