Changeset 16209
- Timestamp:
- 09/20/13 11:19:12 (12 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IoModel.cpp
r16208 r16209 1032 1032 } 1033 1033 /*}}}*/ 1034 /*FUNCTION IoModel::FetchDataToInput {{{*/1034 /*FUNCTION IoModel::FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value){{{*/ 1035 1035 void 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){{{*/ 1061 void IoModel::FetchDataToInput(Elements* elements,int vector_enum){ 1036 1062 1037 1063 /*intermediary: */ … … 1074 1100 case 5: //boolean vector 1075 1101 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"); 1076 1103 for(i=0;i<elements->Size();i++){ 1077 1104 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. 1081 1106 } 1082 1107 break; 1083 1108 case 6: //int vector 1084 1109 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"); 1085 1111 for(i=0;i<elements->Size();i++){ 1086 1112 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. 1090 1114 } 1091 1115 break; 1092 1116 case 7: //IssmDouble vector 1093 1117 this->FetchData(&doublearray,&M,&N,vector_enum); 1118 if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in bindary file"); 1094 1119 for(i=0;i<elements->Size();i++){ 1095 1120 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. 1099 1122 } 1100 1123 break; -
issm/trunk-jpl/src/c/classes/IoModel.h
r16208 r16209 78 78 void FetchData(Option **poption,int data_enum); 79 79 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); 81 82 void LastIndex(int *pindex); 82 83 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
Note:
See TracChangeset
for help on using the changeset viewer.