Changeset 16209


Ignore:
Timestamp:
09/20/13 11:19:12 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: defaulting in InputCreate is now explicit, to avoid default 0. values if not found

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

Legend:

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

    r16208 r16209  
    10321032}
    10331033/*}}}*/
    1034 /*FUNCTION IoModel::FetchDataToInput{{{*/
     1034/*FUNCTION IoModel::FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value){{{*/
    10351035void IoModel::FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value){
     1036
     1037        /*intermediary: */
     1038        int         code,vector_layout;
     1039        IssmDouble *doublearray = NULL;
     1040        int         M,N;
     1041
     1042        /*First of, find the record for the enum, and get code  of data type: */
     1043        this->SetFilePointerToData(&code, &vector_layout,vector_enum);
     1044
     1045        /*Defaulting only supported for double arrays*/
     1046        if(code!=7) _error_(EnumToStringx(vector_enum)<<" is not a double array");
     1047
     1048        this->FetchData(&doublearray,&M,&N,vector_enum);
     1049
     1050        for(int i=0;i<elements->Size();i++){
     1051                Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
     1052                if(!doublearray) element->InputUpdateFromConstant(default_value,vector_enum);
     1053                else             element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
     1054        }
     1055
     1056        /*Free ressources. Pay attention to not freeing an AD mode independent variable though!:*/
     1057        if(!this->independents[vector_enum]) xDelete<IssmDouble>(doublearray);
     1058}
     1059/*}}}*/
     1060/*FUNCTION IoModel::FetchDataToInput(Elements* elements,int vector_enum){{{*/
     1061void IoModel::FetchDataToInput(Elements* elements,int vector_enum){
    10361062
    10371063        /*intermediary: */
     
    10741100                case 5: //boolean vector
    10751101                        this->FetchData(&doublearray,&M,&N,vector_enum); //we still have a doublearray, because it might include times in transient mode
     1102                        if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in bindary file");
    10761103                        for(i=0;i<elements->Size();i++){
    10771104                                Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
    1078                                 if(!doublearray) element->InputUpdateFromConstant(reCast<bool>(default_value),vector_enum);
    1079                                 else             element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    1080                                 element->InputUpdateFromConstant(boolean,vector_enum);
     1105                                element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    10811106                        }
    10821107                        break;
    10831108                case 6: //int vector
    10841109                        this->FetchData(&doublearray,&M,&N,vector_enum); //we still have a doublearray, because it might include times in transient mode
     1110                        if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in bindary file");
    10851111                        for(i=0;i<elements->Size();i++){
    10861112                                Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
    1087                                 if(!doublearray) element->InputUpdateFromConstant(reCast<int>(default_value),vector_enum);
    1088                                 else             element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    1089                                 element->InputUpdateFromConstant(boolean,vector_enum);
     1113                                element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    10901114                        }
    10911115                        break;
    10921116                case 7: //IssmDouble vector
    10931117                        this->FetchData(&doublearray,&M,&N,vector_enum);
     1118                        if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in bindary file");
    10941119                        for(i=0;i<elements->Size();i++){
    10951120                                Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
    1096                                 if(!doublearray) element->InputUpdateFromConstant(default_value,vector_enum);
    1097                                 else             element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    1098                                 element->InputUpdateFromConstant(boolean,vector_enum);
     1121                                element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
    10991122                        }
    11001123                        break;
  • issm/trunk-jpl/src/c/classes/IoModel.h

    r16208 r16209  
    7878                void        FetchData(Option **poption,int data_enum);
    7979                void        FetchData(int num,...);
    80                 void        FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value=0.);
     80                void        FetchDataToInput(Elements* elements,int vector_enum);
     81                void        FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value);
    8182                void        LastIndex(int *pindex);
    8283                FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
Note: See TracChangeset for help on using the changeset viewer.