source:
issm/oecreview/Archive/16133-16554/ISSM-16498-16499.diff@
16556
Last change on this file since 16556 was 16556, checked in by , 11 years ago | |
---|---|
File size: 6.8 KB |
-
TabularUnified ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
21 21 22 22 definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i)); 23 23 24 if (strcmp(definition->Name(),output_string)==0){ 24 char* name = definition->Name(); 25 if (strcmp(name,output_string)==0){ 25 26 /*This is the object that we have been chasing for. compute the response and return: */ 26 27 return_value=definition->Response(femmodel); 27 28 delete output_definitions; 29 xDelete<char>(name); 28 30 return return_value; 29 31 } 32 xDelete<char>(name); 30 33 } 31 34 /*If we are here, did not find the definition for this response, not good!: */ 32 35 _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!"); -
TabularUnified ../trunk-jpl/src/c/classes/IoModel.cpp
1087 1087 int* codes=NULL; 1088 1088 1089 1089 /*output: */ 1090 int numstrings=0;1091 char ** strings=NULL;1090 int numstrings = 0; 1091 char **strings = NULL; 1092 1092 1093 1093 /*intermediary: */ 1094 char * string=NULL;1095 int string_size;1096 int * code=NULL;1097 fpos_t * file_positions=NULL;1094 char *string = NULL; 1095 int string_size; 1096 int *code = NULL; 1097 fpos_t *file_positions = NULL; 1098 1098 1099 1099 /*recover my_rank:*/ 1100 1100 my_rank=IssmComm::GetRank(); … … 1103 1103 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum); 1104 1104 1105 1105 if(num_instances){ 1106 1107 1106 strings=xNew<char*>(num_instances); 1108 1107 1109 1108 for(i=0;i<num_instances;i++){ 1110 1109 1111 1112 1110 if(my_rank==0){ 1113 1111 /*check we are indeed finding a string, not something else: */ 1114 1112 if(codes[i]!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum)); … … 1137 1135 } 1138 1136 strings[i]=string; 1139 1137 } 1140 1141 1138 } 1142 1139 /*Free ressources:*/ 1143 1140 xDelete<int>(codes); … … 1152 1149 1153 1150 int i; 1154 1151 int num_instances; 1155 int my_rank;1156 1157 1152 fpos_t* file_positions=NULL; 1158 1153 1159 1154 /*output: */ 1160 IssmDouble ** matrices=NULL;1161 int * mdims=NULL;1162 int * ndims=NULL;1155 IssmDouble **matrices = NULL; 1156 int *mdims = NULL; 1157 int *ndims = NULL; 1163 1158 1164 1159 /*intermediary: */ 1165 int M, N;1160 int M, N; 1166 1161 IssmPDouble *pmatrix = NULL; 1167 IssmDouble *matrix= NULL;1168 int * codes=NULL;1169 int code;1162 IssmDouble *matrix = NULL; 1163 int *codes = NULL; 1164 int code; 1170 1165 1171 1166 /*recover my_rank:*/ 1172 my_rank=IssmComm::GetRank();1167 int my_rank=IssmComm::GetRank(); 1173 1168 1174 1169 /*Get file pointers to beginning of the data (multiple instances of it): */ 1175 1170 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum); … … 1181 1176 mdims=xNew<int>(num_instances); 1182 1177 ndims=xNew<int>(num_instances); 1183 1178 1184 for(i =0;i<num_instances;i++){1179 for(int i=0;i<num_instances;i++){ 1185 1180 1186 1181 if(my_rank==0){ 1187 1182 code=codes[i]; … … 1212 1207 ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 1213 1208 1214 1209 _assert_(this->independents); 1215 if 1210 if(this->independents[data_enum]){ 1216 1211 /*this data has already been checked out! So cancel all that we've done here, and return 1217 1212 * the data[data_enum] directly: */ 1218 1213 matrix=this->data[data_enum]; … … 1239 1234 1240 1235 /*Assign output pointers: */ 1241 1236 *pmatrices=matrices; 1242 if(pmdims)*pmdims=mdims; 1243 if(pndims)*pndims=ndims; 1237 if(pmdims){ 1238 *pmdims=mdims; 1239 } 1240 else{ 1241 xDelete<int>(mdims); 1242 } 1243 if(pndims){ 1244 *pndims=ndims; 1245 } 1246 else{ 1247 xDelete<int>(ndims); 1248 } 1244 1249 *pnumrecords=num_instances; 1245 1250 } 1246 1251 /*}}}*/ … … 1447 1452 /*FUNCTION IoModel::SetFilePointersToData{{{*/ 1448 1453 fpos_t* IoModel::SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum){ 1449 1454 1450 int my_rank; 1451 int found = 0; 1452 int record_enum; 1453 int record_length; 1454 int record_code; //1 to 7 number 1455 int vector_type; //1 to 7 number 1456 int* vector_types = NULL; 1457 int* codes= NULL; 1458 int num_instances = 0; 1459 int counter; 1460 fpos_t* file_positions=NULL; 1455 int found = 0; 1456 int record_enum; 1457 int record_length; 1458 int record_code; //1 to 7 number 1459 int vector_type; //1 to 7 number 1460 int *vector_types = NULL; 1461 int *codes = NULL; 1462 int num_instances = 0; 1463 int counter; 1464 fpos_t *file_positions = NULL; 1461 1465 1462 1466 /*recover my_rank:*/ 1463 my_rank=IssmComm::GetRank();1467 int my_rank=IssmComm::GetRank(); 1464 1468 1465 1469 /*Go find in the binary file, the data we want to fetch and count the number of 1466 1470 * instances it appears: */ … … 1488 1492 /*Ok, initialize the number of file handles we are going to return: */ 1489 1493 if(num_instances){ 1490 1494 file_positions = xNew<fpos_t>(num_instances); 1491 codes = xNew<int>(num_instances);1492 vector_types = xNew<int>(num_instances);1495 codes = xNew<int>(num_instances); 1496 vector_types = xNew<int>(num_instances); 1493 1497 } 1494 1495 1498 1496 1499 /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information 1497 1500 * as we find it: */ … … 1515 1518 if(5<=record_code && record_code<=7){ 1516 1519 if(fread(&vector_type,sizeof(int),1,fid)!=1) _error_("Could not read vector_type"); 1517 1520 } 1518 codes[counter] =record_code;1519 vector_types[counter] =vector_type;1521 codes[counter] = record_code; 1522 vector_types[counter] = vector_type; 1520 1523 fgetpos(fid,file_positions+counter); 1521 1524 1522 1525 /*backup and skip over the record, as we have more work to do: */ … … 1539 1542 ISSM_MPI_Bcast(&num_instances,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1540 1543 1541 1544 /*Assign output pointers:*/ 1542 *pcodes=codes; 1543 *pnum_instances=num_instances; 1544 if(pvector_types)*pvector_types=vector_types; 1545 *pcodes = codes; 1546 *pnum_instances = num_instances; 1547 if(pvector_types){ 1548 *pvector_types=vector_types; 1549 } 1550 else{ 1551 xDelete<int>(vector_types); 1552 } 1545 1553 return file_positions; 1546 1554 } 1547 1555 /*}}}*/ -
TabularUnified ../trunk-jpl/src/c/classes/Massfluxatgate.h
126 126 /*}}}*/ 127 127 /*Definition virtual function resolutoin: */ 128 128 /*FUNCTION char* Name() {{{*/ 129 char* Name(){ 130 char* name2=NULL; 129 char* Name(){ 131 130 132 name2=xNew<char>(strlen(this->name)+1);131 char* name2=xNew<char>(strlen(this->name)+1); 133 132 xMemCpy(name2,this->name,strlen(this->name)+1); 134 133 135 134 return name2;
Note:
See TracBrowser
for help on using the repository browser.