Changeset 1271
- Timestamp:
- 07/08/09 21:06:26 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Result.cpp
r823 r1271 37 37 VecDuplicatePatch(&field,result.field); 38 38 dfield=NULL; 39 cfield=NULL; 39 40 } 40 41 if(result.dfield){ … … 42 43 memcpy(dfield,result.dfield,result.size*sizeof(double)); 43 44 field=NULL; 45 cfield=NULL; 46 } 47 if(result.cfield){ 48 cfield=(char*)xmalloc((strlen(result.cfield)+1)*sizeof(char)); 49 strcpy(cfield,result.cfield); 50 field=NULL; 51 dfield=NULL; 44 52 } 45 53 } … … 63 71 field=result_field; //do not copy, as the results are large in memory size. 64 72 dfield=NULL; 73 cfield=NULL; 65 74 } 66 75 … … 84 93 size=result_size; 85 94 field=NULL; 86 } 87 95 cfield=NULL; 96 } 97 98 #undef __FUNCT__ 99 #define __FUNCT__ "Result::Result" 100 Result::Result(int result_id,double result_time,int result_step,char* result_fieldname,char* result_field){ 101 102 id=result_id; 103 time=result_time; 104 step=result_step; 105 106 if(!result_fieldname){ 107 throw ErrorException(__FUNCT__," NULL fieldname in constructor argument"); 108 } 109 else{ 110 fieldname=(char*)xmalloc((strlen(result_fieldname)+1)*sizeof(char)); 111 strcpy(fieldname,result_fieldname); 112 } 113 cfield=(char*)xmalloc((strlen(result_field)+1)*sizeof(char)); 114 strcpy(cfield,result_field); 115 116 field=NULL; 117 dfield=NULL; 118 } 88 119 89 120 Result::~Result(){ … … 91 122 VecFree(&field); 92 123 xfree((void**)&dfield); 124 xfree((void**)&cfield); 93 125 } 94 126 … … 103 135 printf(" field pointer %p\n",field); 104 136 } 105 else{137 if(dfield){ 106 138 printf(" field pointer %p\n",dfield); 107 139 printf(" field size %i\n",size); 140 } 141 if(cfield){ 142 printf(" field pointer %p\n",cfield); 143 printf(" field string %s\n",cfield); 108 144 } 109 145 } … … 119 155 printf(" field pointer %p\n",field); 120 156 } 121 else{157 if(dfield){ 122 158 printf(" field pointer %p\n",dfield); 123 159 printf(" field size %i\n",size); 124 160 } 161 if(cfield){ 162 printf(" field pointer %p\n",cfield); 163 printf(" field string %s\n",cfield); 164 } 125 165 } 166 126 167 #undef __FUNCT__ 127 168 #define __FUNCT__ "Result::Marshall" … … 179 220 180 221 int length; 222 int type; 181 223 182 224 /*First write field name :*/ … … 190 232 191 233 /*Now write field: */ 192 fwrite(&size,sizeof(int),1,fid); 193 fwrite(dfield,size*sizeof(double),1,fid); 234 if(dfield){ 235 type=1; 236 fwrite(&type,sizeof(int),1,fid); 237 fwrite(&size,sizeof(int),1,fid); 238 fwrite(dfield,size*sizeof(double),1,fid); 239 } 240 if(cfield){ 241 type=2; 242 fwrite(&type,sizeof(int),1,fid); 243 length=(strlen(cfield)+1)*sizeof(char); 244 fwrite(&length,sizeof(int),1,fid); 245 fwrite(cfield,length,1,fid); 246 } 194 247 } 195 248 … … 200 253 201 254 } 202 255 256 void Result::GetField(char** pcfield){ 257 258 char* string=NULL; 259 260 string=(char*)xmalloc((strlen(cfield)+1)*sizeof(char)); 261 strcpy(string,cfield); 262 263 *pcfield=string; 264 } 265 203 266 void Result::GetField(double** pfield){ 204 267 *pfield=(double*)xmalloc(size*sizeof(double)); -
issm/trunk/src/c/objects/Result.h
r803 r1271 19 19 Vec field; 20 20 double* dfield; 21 char* cfield; 21 22 int size; 22 23 … … 27 28 Result(int result_id,double result_time,int result_step,char* result_fieldname,Vec result_field); 28 29 Result(int result_id,double result_time,int result_step,char* result_fieldname,double* result_field,int result_size); 30 Result(int result_id,double result_time,int result_step,char* result_fieldname,char* result_field); 29 31 ~Result(); 30 32 … … 43 45 void GetField(Vec* pfield); 44 46 void GetField(double** pfield); 47 void GetField(char** pcfield); 45 48 int GetStep(); 46 49 void WriteData(FILE* fid); -
issm/trunk/src/c/parallel/control.cpp
r1265 r1271 24 24 int numberofnodes; 25 25 int qmu_analysis=0; 26 char* control_type=NULL; 26 27 27 28 /*Fem models : */ … … 30 31 /*Results: */ 31 32 DataSet* results=NULL; 33 Result* result=NULL; 32 34 33 35 ParameterInputs* inputs=NULL; … … 117 119 } 118 120 121 /*Add analysis_type and control_type to results: */ 122 result=new Result(results->Size()+1,0,1,"analysis_type","control"); 123 results->AddObject(result); 124 125 femmodels[0].parameters->FindParam((void*)&control_type,"control_type"); 126 result=new Result(results->Size()+1,0,1,"control_type",control_type); 127 results->AddObject(result); 128 119 129 _printf_("process results:\n"); 120 130 ProcessResults(&results,&femmodels[0],ControlAnalysisEnum()); -
issm/trunk/src/c/parallel/diagnostic.cpp
r962 r1271 31 31 /*Results: */ 32 32 DataSet* results=NULL; 33 Result* result=NULL; 33 34 34 35 ParameterInputs* inputs=NULL; … … 105 106 } 106 107 108 /*Add analysis_type to results: */ 109 result=new Result(results->Size()+1,0,1,"analysis_type","diagnostic"); 110 results->AddObject(result); 111 107 112 _printf_("process results:\n"); 108 113 ProcessResults(&results,&femmodels[0],DiagnosticAnalysisEnum()); -
issm/trunk/src/c/parallel/prognostic.cpp
r962 r1271 39 39 /*Results: */ 40 40 DataSet* results=NULL; 41 Result* result=NULL; 41 42 42 43 ParameterInputs* inputs=NULL; … … 106 107 } 107 108 109 /*Add analysis_type to results: */ 110 result=new Result(results->Size()+1,0,1,"analysis_type","prognostic"); 111 results->AddObject(result); 112 108 113 _printf_("process results:\n"); 109 114 ProcessResults(&results,&fem,PrognosticAnalysisEnum()); -
issm/trunk/src/c/parallel/thermal.cpp
r962 r1271 36 36 /*Results: */ 37 37 DataSet* results=NULL; 38 Result* result=NULL; 38 39 39 40 ParameterInputs* inputs=NULL; … … 113 114 #endif 114 115 } 115 116 117 /*Add analysis_type to results: */ 118 result=new Result(results->Size()+1,0,1,"analysis_type","thermal"); 119 results->AddObject(result); 120 116 121 _printf_("process results:\n"); 117 122 ProcessResults(&results,&femmodels[0],ThermalAnalysisEnum()); -
issm/trunk/src/c/parallel/transient.cpp
r962 r1271 32 32 /*Results: */ 33 33 DataSet* results=NULL; 34 Result* result=NULL; 34 35 35 36 ParameterInputs* inputs=NULL; … … 124 125 } 125 126 127 /*Add analysis_type to results: */ 128 result=new Result(results->Size()+1,0,1,"analysis_type","transient"); 129 results->AddObject(result); 130 126 131 _printf_("process results:\n"); 127 132 ProcessResults(&results,&femmodels[0],TransientAnalysisEnum()); -
issm/trunk/src/m/classes/public/ReadData.m
r643 r1271 17 17 time=fread(fid,1,'double'); 18 18 step=fread(fid,1,'int'); 19 20 type=fread(fid,1,'int'); 19 21 ssize=fread(fid,1,'int'); 20 field=fread(fid,ssize,'double'); 22 if type==1, 23 field=fread(fid,ssize,'double'); 24 else 25 field=fread(fid,ssize,'char'); 26 field=char(field(1:end-1)'); 27 end 21 28 22 29 result.fieldname=fieldname; -
issm/trunk/src/m/classes/public/loadresultsfromdisk.m
r965 r1271 15 15 md.results=struct(); 16 16 end 17 eval(['md.results.' md.analysis_type '=parseresultsfromdisk(filename);']); 17 18 structure=parseresultsfromdisk(filename); 19 eval(['md.results.' structure.analysis_type '=structure;']); 18 20 19 21 %Check result is consistent, only if it exists -
issm/trunk/src/m/classes/public/parseresultsfromdisk.m
r802 r1271 10 10 error(['loadresultsfromdisk error message: could not open ',filename,' for binary reading']); 11 11 end 12 13 12 results=struct(); 14 13 -
issm/trunk/src/m/solutions/cielo/diagnostic.m
r972 r1271 37 37 if ~models.dh.parameters.qmu_analysis, 38 38 %launch core of diagnostic solution. 39 results=diagnostic_core(models,inputs) ;39 results=diagnostic_core(models,inputs) 40 40 41 41 %process results
Note:
See TracChangeset
for help on using the changeset viewer.