source: issm/oecreview/Archive/16133-16554/ISSM-16498-16499.diff@ 16556

Last change on this file since 16556 was 16556, checked in by Mathieu Morlighem, 11 years ago

NEW: added Archive/16133-16554

File size: 6.8 KB
RevLine 
[16556]1Index: ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
2===================================================================
3--- ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp (revision 16498)
4+++ ../trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp (revision 16499)
5@@ -21,12 +21,15 @@
6
7 definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i));
8
9- if (strcmp(definition->Name(),output_string)==0){
10+ char* name = definition->Name();
11+ if (strcmp(name,output_string)==0){
12 /*This is the object that we have been chasing for. compute the response and return: */
13 return_value=definition->Response(femmodel);
14 delete output_definitions;
15+ xDelete<char>(name);
16 return return_value;
17 }
18+ xDelete<char>(name);
19 }
20 /*If we are here, did not find the definition for this response, not good!: */
21 _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!");
22Index: ../trunk-jpl/src/c/classes/IoModel.cpp
23===================================================================
24--- ../trunk-jpl/src/c/classes/IoModel.cpp (revision 16498)
25+++ ../trunk-jpl/src/c/classes/IoModel.cpp (revision 16499)
26@@ -1087,14 +1087,14 @@
27 int* codes=NULL;
28
29 /*output: */
30- int numstrings=0;
31- char** strings=NULL;
32+ int numstrings = 0;
33+ char **strings = NULL;
34
35 /*intermediary: */
36- char* string=NULL;
37- int string_size;
38- int* code=NULL;
39- fpos_t* file_positions=NULL;
40+ char *string = NULL;
41+ int string_size;
42+ int *code = NULL;
43+ fpos_t *file_positions = NULL;
44
45 /*recover my_rank:*/
46 my_rank=IssmComm::GetRank();
47@@ -1103,12 +1103,10 @@
48 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum);
49
50 if(num_instances){
51-
52 strings=xNew<char*>(num_instances);
53
54 for(i=0;i<num_instances;i++){
55
56-
57 if(my_rank==0){
58 /*check we are indeed finding a string, not something else: */
59 if(codes[i]!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum));
60@@ -1137,7 +1135,6 @@
61 }
62 strings[i]=string;
63 }
64-
65 }
66 /*Free ressources:*/
67 xDelete<int>(codes);
68@@ -1152,24 +1149,22 @@
69
70 int i;
71 int num_instances;
72- int my_rank;
73-
74 fpos_t* file_positions=NULL;
75
76 /*output: */
77- IssmDouble** matrices=NULL;
78- int* mdims=NULL;
79- int* ndims=NULL;
80+ IssmDouble **matrices = NULL;
81+ int *mdims = NULL;
82+ int *ndims = NULL;
83
84 /*intermediary: */
85- int M, N;
86+ int M, N;
87 IssmPDouble *pmatrix = NULL;
88- IssmDouble *matrix = NULL;
89- int* codes=NULL;
90- int code;
91+ IssmDouble *matrix = NULL;
92+ int *codes = NULL;
93+ int code;
94
95 /*recover my_rank:*/
96- my_rank=IssmComm::GetRank();
97+ int my_rank=IssmComm::GetRank();
98
99 /*Get file pointers to beginning of the data (multiple instances of it): */
100 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum);
101@@ -1181,7 +1176,7 @@
102 mdims=xNew<int>(num_instances);
103 ndims=xNew<int>(num_instances);
104
105- for(i=0;i<num_instances;i++){
106+ for(int i=0;i<num_instances;i++){
107
108 if(my_rank==0){
109 code=codes[i];
110@@ -1212,7 +1207,7 @@
111 ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
112
113 _assert_(this->independents);
114- if (this->independents[data_enum]){
115+ if(this->independents[data_enum]){
116 /*this data has already been checked out! So cancel all that we've done here, and return
117 * the data[data_enum] directly: */
118 matrix=this->data[data_enum];
119@@ -1239,8 +1234,18 @@
120
121 /*Assign output pointers: */
122 *pmatrices=matrices;
123- if(pmdims)*pmdims=mdims;
124- if(pndims)*pndims=ndims;
125+ if(pmdims){
126+ *pmdims=mdims;
127+ }
128+ else{
129+ xDelete<int>(mdims);
130+ }
131+ if(pndims){
132+ *pndims=ndims;
133+ }
134+ else{
135+ xDelete<int>(ndims);
136+ }
137 *pnumrecords=num_instances;
138 }
139 /*}}}*/
140@@ -1447,20 +1452,19 @@
141 /*FUNCTION IoModel::SetFilePointersToData{{{*/
142 fpos_t* IoModel::SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum){
143
144- int my_rank;
145- int found = 0;
146- int record_enum;
147- int record_length;
148- int record_code; //1 to 7 number
149- int vector_type; //1 to 7 number
150- int* vector_types = NULL;
151- int* codes= NULL;
152- int num_instances = 0;
153- int counter;
154- fpos_t* file_positions=NULL;
155+ int found = 0;
156+ int record_enum;
157+ int record_length;
158+ int record_code; //1 to 7 number
159+ int vector_type; //1 to 7 number
160+ int *vector_types = NULL;
161+ int *codes = NULL;
162+ int num_instances = 0;
163+ int counter;
164+ fpos_t *file_positions = NULL;
165
166 /*recover my_rank:*/
167- my_rank=IssmComm::GetRank();
168+ int my_rank=IssmComm::GetRank();
169
170 /*Go find in the binary file, the data we want to fetch and count the number of
171 * instances it appears: */
172@@ -1488,10 +1492,9 @@
173 /*Ok, initialize the number of file handles we are going to return: */
174 if(num_instances){
175 file_positions = xNew<fpos_t>(num_instances);
176- codes = xNew<int>(num_instances);
177- vector_types = xNew<int>(num_instances);
178+ codes = xNew<int>(num_instances);
179+ vector_types = xNew<int>(num_instances);
180 }
181-
182
183 /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information
184 * as we find it: */
185@@ -1515,8 +1518,8 @@
186 if(5<=record_code && record_code<=7){
187 if(fread(&vector_type,sizeof(int),1,fid)!=1) _error_("Could not read vector_type");
188 }
189- codes[counter]=record_code;
190- vector_types[counter]=vector_type;
191+ codes[counter] = record_code;
192+ vector_types[counter] = vector_type;
193 fgetpos(fid,file_positions+counter);
194
195 /*backup and skip over the record, as we have more work to do: */
196@@ -1539,9 +1542,14 @@
197 ISSM_MPI_Bcast(&num_instances,1,ISSM_MPI_INT,0,IssmComm::GetComm());
198
199 /*Assign output pointers:*/
200- *pcodes=codes;
201- *pnum_instances=num_instances;
202- if(pvector_types)*pvector_types=vector_types;
203+ *pcodes = codes;
204+ *pnum_instances = num_instances;
205+ if(pvector_types){
206+ *pvector_types=vector_types;
207+ }
208+ else{
209+ xDelete<int>(vector_types);
210+ }
211 return file_positions;
212 }
213 /*}}}*/
214Index: ../trunk-jpl/src/c/classes/Massfluxatgate.h
215===================================================================
216--- ../trunk-jpl/src/c/classes/Massfluxatgate.h (revision 16498)
217+++ ../trunk-jpl/src/c/classes/Massfluxatgate.h (revision 16499)
218@@ -126,10 +126,9 @@
219 /*}}}*/
220 /*Definition virtual function resolutoin: */
221 /*FUNCTION char* Name() {{{*/
222- char* Name(){
223- char* name2=NULL;
224+ char* Name(){
225
226- name2=xNew<char>(strlen(this->name)+1);
227+ char* name2=xNew<char>(strlen(this->name)+1);
228 xMemCpy(name2,this->name,strlen(this->name)+1);
229
230 return name2;
Note: See TracBrowser for help on using the repository browser.