1 #include <cstdlib> // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE
3 #include "MEDMEM_Array.hxx"
5 int main (int argc, char ** argv)
8 int SpaceDimension = 3;
10 MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ;
11 ASSERT(myArray != NULL);
13 int * value = myArray->get(MED_FULL_INTERLACE) ;
16 for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
22 leadingValue = myArray->getLeadingValue() ;
23 ASSERT (leadingValue == SpaceDimension);
25 catch ( const std::exception &e )
27 cout << "-------------------------------" << endl;
28 cout << " Pb au getLeadingValue() " << endl;
29 cout << "-------------------------------" << endl;
30 MESSAGE( "catched exception : " << e.what() ) ;
35 cout << "-------------------------------" << endl;
36 cout << " Pb au getLeadingValue() " << endl;
37 cout << "-------------------------------" << endl;
44 lengthValue = myArray->getLengthValue() ;
45 ASSERT(lengthValue == NumberOfNodes)
47 catch ( const std::exception &e )
49 cout << "-------------------------------" << endl;
50 cout << " Pb au getLengthValue() " << endl;
51 cout << "-------------------------------" << endl;
52 MESSAGE( "catched exception : " << e.what() ) ;
57 cout << "-------------------------------" << endl;
58 cout << " Pb au getLengthValue() " << endl;
59 cout << "-------------------------------" << endl;
63 cout << "Show all using getI and full interlace :" << endl;
64 for (int i=1; i<=lengthValue; i++)
68 int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
70 for (int j=0;j<leadingValue;j++)
71 cout << node[j] << " " ;
74 catch ( const std::exception &e )
76 cout << "-------------------------------" << endl;
77 cout << " Pb au getI() valeur de i " << i << endl;
78 cout << "-------------------------------" << endl;
79 MESSAGE( "catched exception : " << e.what() ) ;
84 cout << "-------------------------------" << endl;
85 cout << " Pb au getI() valeur de i " << i << endl;
86 cout << "-------------------------------" << endl;
91 cout << "Show all using getI and no interlace :" << endl;
92 for (int i=1; i<=leadingValue; i++)
96 int * node = myArray->getI(MED_NO_INTERLACE,i) ;
98 for (int j=0;j<lengthValue;j++)
99 cout << node[j] << " " ;
102 catch ( const std::exception &e )
104 cout << "-------------------------------" << endl;
105 cout << " Pb au getI() valeur de i " << i << endl;
106 cout << "-------------------------------" << endl;
107 MESSAGE( "catched exception : " << e.what() ) ;
108 return EXIT_FAILURE ;
112 cout << "-------------------------------" << endl;
113 cout << " Pb au getI() valeur de i " << i << endl;
114 cout << "-------------------------------" << endl;
115 return EXIT_FAILURE ;
119 cout << "Show all using getIJ :" << endl;
120 for (int i=1; i<=lengthValue ; i++)
126 for (j=1;j<leadingValue+1;j++)
127 cout << myArray->getIJ(i,j) << " " ;
130 catch ( const std::exception &e )
132 cout << "-------------------------------" << endl;
133 cout << " Pb au getIJ() i " << i << " j " << j << endl;
134 cout << "-------------------------------" << endl;
135 MESSAGE( "catched exception : " << e.what() ) ;
136 return EXIT_FAILURE ;
140 cout << "-------------------------------" << endl;
141 cout << " Pb au getIJ() i " << i << " j " << j << endl;
142 cout << "-------------------------------" << endl;
143 return EXIT_FAILURE ;
147 cout << "Show all using get and MED_NO_INTERLACE :" << endl;
150 int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
151 for (int i=0; i<lengthValue ; i++)
154 for (int j=0;j<leadingValue;j++)
155 cout << NoInterlaceArray[j*lengthValue+i] << " " ;
159 catch ( const std::exception &e )
161 cout << "-------------------------------" << endl;
162 cout << " Pb au get " << endl;
163 cout << "-------------------------------" << endl;
164 MESSAGE( "catched exception : " << e.what() ) ;
165 return EXIT_FAILURE ;
169 cout << "---------------" << endl;
170 cout << " Pb au get " << endl;
171 cout << "---------------" << endl;
172 return EXIT_FAILURE ;
176 cout << endl << endl << "Tests des fonctions Set " << endl;
178 int * myNewInt = new int[SpaceDimension*NumberOfNodes];
179 for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
186 myArray->set(MED_FULL_INTERLACE, myNewInt);
188 catch ( const std::exception &e )
190 cout << "-------------------------------" << endl;
191 cout << " Pb au set " << endl;
192 cout << "-------------------------------" << endl;
193 MESSAGE( "catched exception : " << e.what() ) ;
194 return EXIT_FAILURE ;
198 cout << "---------------" << endl;
199 cout << " Pb au set " << endl;
200 cout << "---------------" << endl;
201 return EXIT_FAILURE ;
205 cout << "Nouvelles valeurs (x10) : get avec Full interlace : " << endl;
209 myNewValue = myArray->get(MED_FULL_INTERLACE) ;
210 ASSERT(myNewValue!= NULL);
212 catch ( const std::exception &e )
214 cout << "-----------------" << endl;
215 cout << " Pb au get " << endl;
216 cout << "-----------------" << endl;
217 MESSAGE( "catched exception : " << e.what() ) ;
218 return EXIT_FAILURE ;
222 cout << "---------------" << endl;
223 cout << " Pb au get " << endl;
224 cout << "---------------" << endl;
228 for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
229 cout << myNewValue[i]<< " " ;
233 int * myNewLine = new int[SpaceDimension];
234 for (int i = 0; i < SpaceDimension; i++)
235 myNewLine[i] = i * 100;
239 myArray->setI(MED_FULL_INTERLACE, 1, myNewLine);
241 catch ( const std::exception &e )
243 cout << "-------------------------------" << endl;
244 cout << " Pb au getLengthValue() " << endl;
245 cout << "-------------------------------" << endl;
246 MESSAGE( "catched exception : " << e.what() ) ;
247 return EXIT_FAILURE ;
251 cout << "---------------" << endl;
252 cout << " Pb au setI " << endl;
253 cout << "---------------" << endl;
259 myNewValue = myArray->getI(MED_FULL_INTERLACE,1) ;
260 ASSERT(myNewValue!= NULL);
262 catch ( const std::exception &e )
264 cout << "-------------------------------" << endl;
265 cout << " Pb au getLengthValue() " << endl;
266 cout << "-------------------------------" << endl;
267 MESSAGE( "catched exception : " << e.what() ) ;
268 return EXIT_FAILURE ;
272 cout << "---------------" << endl;
273 cout << " Pb au getI " << endl;
274 cout << "---------------" << endl;
277 cout << endl << " Nouvelles valeurs (x100) sur la 1ere ligne: get avec Full interlace : ";
278 cout << endl << " - ";
279 for (int i=0; i<SpaceDimension; i++)
280 cout << myNewValue[i]<< " " ;
285 myArray->setIJ(1,1,1992);
287 catch ( const std::exception &e )
289 cout << "---------------------------" << endl;
290 cout << " Pb au setIJ() de 1 , 1 " << endl;
291 cout << "---------------------------" << endl;
292 MESSAGE( "catched exception : " << e.what() ) ;
293 return EXIT_FAILURE ;
297 cout << "-----------------------------" << endl;
298 cout << " Pb au setIJ() de 1 , 1 " << endl;
299 cout << "-----------------------------" << endl;
302 cout << "Nouvelle valeur avec setIJ et getIJ" << endl;
303 cout << " - " << myArray->getIJ(1,1) << endl;
306 return EXIT_SUCCESS ;
310 inline medModeSwitch getMode() const ;