Salome HOME
Update to match the changes in SMDS
[modules/smesh.git] / src / DriverMED / DriverMED_R_SMDS_Mesh.cxx
1 //  SMESH DriverMED : driver to read and write 'med' files
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DriverMED_R_SMDS_Mesh.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "DriverMED_R_SMDS_Mesh.h"
29 #include "utilities.h"
30
31 DriverMED_R_SMDS_Mesh::DriverMED_R_SMDS_Mesh()
32 {
33 }
34
35 DriverMED_R_SMDS_Mesh::~DriverMED_R_SMDS_Mesh()
36 {
37         ;
38 }
39
40 void DriverMED_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
41 {
42         myMesh = aMesh;
43 }
44
45 void DriverMED_R_SMDS_Mesh::SetFile(string aFile)
46 {
47         myFileId = -1;
48         myFile = aFile;
49 }
50
51 void DriverMED_R_SMDS_Mesh::SetFileId(med_idt aFileId)
52 {
53         myFileId = aFileId;
54 }
55
56 void DriverMED_R_SMDS_Mesh::SetMeshId(int aMeshId)
57 {
58         myMeshId = aMeshId;
59 }
60
61 void DriverMED_R_SMDS_Mesh::Add()
62 {
63         ;
64 }
65
66 void DriverMED_R_SMDS_Mesh::Read()
67 {
68
69         med_err ret = 0;
70         int i, j, k, l;
71         int numero;
72         char message[200];
73         bool ok;
74         /* nombre d'objets MED */
75         char nom_universel[MED_TAILLE_LNOM + 1];
76         med_int long_fichier_en_tete;
77         char *fichier_en_tete;
78         char version_hdf[10];
79         char version_med[10];
80         med_int nmaa, mdim, nnoe;
81         med_int nmai[MED_NBR_GEOMETRIE_MAILLE], nfac[MED_NBR_GEOMETRIE_FACE];
82         med_int nare[MED_NBR_GEOMETRIE_ARETE];
83         /* nom du maillage */
84         char nommaa[MED_TAILLE_NOM + 1];
85         /* noeuds */
86         med_float *coo;
87         char nomcoo[3 * MED_TAILLE_PNOM + 1];
88         char unicoo[3 * MED_TAILLE_PNOM + 1];
89         char *nomnoe;
90         med_int *numnoe;
91         med_int *nufano;
92         med_repere rep;
93         med_booleen inonoe, inunoe;
94         med_mode_switch mode_coo;
95         char str[MED_TAILLE_PNOM + 1];
96         /* elements */
97         med_int nsup;
98         med_int edim;
99         med_int taille;
100         med_int elem_id;
101         med_int cmpt = 0;
102         med_int *connectivite;
103         char *nomele;
104         med_int *numele;
105         med_int *nufael;
106         med_booleen inoele, inuele;
107         med_connectivite typ_con;
108         med_geometrie_element typgeo;
109         med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
110                 { MED_POINT1, MED_SEG2,
111                 MED_SEG3, MED_TRIA3,
112                 MED_TRIA6, MED_QUAD4,
113                 MED_QUAD8, MED_TETRA4,
114                 MED_TETRA10, MED_HEXA8,
115                 MED_HEXA20, MED_PENTA6,
116                 MED_PENTA15, MED_PYRA5,
117                 MED_PYRA13
118         };
119         med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
120                 { 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
121         med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
122         char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
123                 "MED_SEG2",
124                 "MED_SEG3",
125                 "MED_TRIA3",
126                 "MED_TRIA6",
127                 "MED_QUAD4",
128                 "MED_QUAD8",
129                 "MED_TETRA4",
130                 "MED_TETRA10",
131                 "MED_HEXA8",
132                 "MED_HEXA20",
133                 "MED_PENTA6",
134                 "MED_PENTA15",
135                 "MED_PYRA5",
136                 "MED_PYRA13"
137         };
138         med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
139                 { MED_TRIA3, MED_TRIA6,
140                 MED_QUAD4, MED_QUAD8
141         };
142         med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
143         med_int nfaces[MED_NBR_GEOMETRIE_FACE];
144         char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
145                 { "MED_TRIA3", "MED_TRIA6",
146                 "MED_QUAD4", "MED_QUAD8"
147         };
148         med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
149                 { MED_SEG2, MED_SEG3 };
150         med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
151         med_int naretes[MED_NBR_GEOMETRIE_ARETE];
152         char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
153                 { "MED_SEG2", "MED_SEG3" };
154         /* familles */
155         med_int nfam;
156         med_int natt, ngro;
157         char *attdes, *gro;
158         med_int *attval, *attide;
159         char nomfam[MED_TAILLE_NOM + 1];
160         med_int numfam;
161         char str1[MED_TAILLE_DESC + 1];
162         char str2[MED_TAILLE_LNOM + 1];
163
164         char *file2Read;
165         bool locally_managed;
166         SCRUTE(myFileId);
167         if (myFileId == -1)
168                 locally_managed = true;
169         else
170                 locally_managed = false;
171
172         if (locally_managed)
173         {
174                 file2Read = (char *)myFile.c_str();
175                 myFileId = MEDouvrir(file2Read, MED_LECT);
176                 if (myFileId < 0)
177                 {
178                         fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n",
179                                 file2Read);
180                         exit(EXIT_FAILURE);
181                 }
182                 numero = 1;
183         }
184         else
185                 numero = myMeshId;
186
187         typ_con = MED_NOD;
188         mode_coo = MED_FULL_INTERLACE;
189
190   /****************************************************************************
191   *                       NOMBRES D'OBJETS MED                                *
192   ****************************************************************************/
193         fprintf(stdout, "\n(****************************)\n");
194         fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n");
195         fprintf(stdout, "(****************************)\n");
196
197         /* lecture du nom et de la dimension du maillage */
198         fprintf(stdout, "%d %d\n", myFileId, numero);
199         ret = MEDmaaInfo(myFileId, numero, nommaa, &mdim);
200         fprintf(stdout, "%d\n", ret);
201         if (ret < 0)
202         {
203                 fprintf(stderr, ">> ERREUR : lecture du nom du maillage \n");
204                 exit(EXIT_FAILURE);
205         }
206         fprintf(stdout, "- Nom du maillage : <<%s>>\n", nommaa);
207         fprintf(stdout, "- Dimension du maillage : %d\n", mdim);
208
209         /* Combien de noeuds ? */
210         nnoe =
211                 MEDnEntMaa(myFileId, nommaa, MED_COOR, MED_NOEUD, MED_POINT1, typ_con);
212         if (nnoe < 0)
213         {
214                 fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n");
215                 exit(EXIT_FAILURE);
216         }
217         fprintf(stdout, "- Nombre de noeuds : %d \n", nnoe);
218
219         /* Combien de mailles, faces ou aretes ? */
220         for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
221         {
222                 nmailles[i] =
223                         MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_MAILLE, typmai[i],
224                         typ_con);
225                 if (nmailles[i] < 0)
226                 {
227                         fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n");
228                         exit(EXIT_FAILURE);
229                 }
230                 fprintf(stdout, "- Nombre de mailles de type %s : %d \n", nommai[i],
231                         nmailles[i]);
232         }
233
234         for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++)
235         {
236                 nfaces[i] = MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_FACE, typfac[i],
237                         typ_con);
238                 if (nfaces[i] < 0)
239                 {
240                         fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n");
241                         exit(EXIT_FAILURE);
242                 }
243                 fprintf(stdout, "- Nombre de faces de type %s : %d \n", nomfac[i],
244                         nfaces[i]);
245         }
246
247         for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++)
248         {
249                 naretes[i] =
250                         MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_ARETE, typare[i],
251                         typ_con);
252                 if (naretes[i] < 0)
253                 {
254                         fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n");
255                         exit(EXIT_FAILURE);
256                 }
257                 fprintf(stdout, "- Nombre d'aretes de type %s : %d \n", nomare[i],
258                         naretes[i]);
259         }
260
261         /* nombre de familles */
262         nfam = MEDnFam(myFileId, nommaa, 0, MED_FAMILLE);
263         if (nfam < 0)
264         {
265                 fprintf(stderr, ">> ERREUR : lecture du nombre de familles \n");
266                 exit(EXIT_FAILURE);
267         }
268         fprintf(stdout, "- Nombre de familles : %d \n", nfam);
269
270   /****************************************************************************
271   *                       LECTURE DES NOEUDS                                  *
272   ****************************************************************************/
273         fprintf(stdout, "\n(************************)\n");
274         fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
275         fprintf(stdout, "(************************)\n");
276
277         /* Allocations memoires */
278         /* table des coordonnees 
279          * profil : (dimension * nombre de noeuds ) */
280         coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
281         /* table  des numeros, des numeros de familles des noeuds
282          * profil : (nombre de noeuds) */
283         numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
284         nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
285         /* table des noms des noeuds 
286          * profil : (nnoe*MED_TAILLE_PNOM+1) */
287         nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1);
288
289         /* lecture des noeuds : 
290          * - coordonnees
291          * - noms (optionnel dans un fichier MED) 
292          * - numeros (optionnel dans un fichier MED) 
293          * - numeros des familles */
294         ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep,
295                 nomcoo, unicoo, nomnoe, &inonoe, numnoe, &inunoe, nufano, nnoe);
296         if (ret < 0)
297                 strcpy(message, ">> ERREUR : lecture des noeuds \n");
298
299         if (inunoe)
300         {
301                 for (int i = 0; i < nnoe; i++)
302                 {
303                         ok = myMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
304                                 coo[i * 3 + 2], numnoe[i]);
305                         //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
306                 }
307         }
308         else
309         {
310                 for (int i = 0; i < nnoe; i++)
311                 {
312                         ok = myMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
313                                 coo[i * 3 + 2], i + 1);
314                         //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
315                 }
316         }
317
318         //fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
319         //for (i=0;i<nnoe;i++)
320         //fprintf(stdout," %d ",*(nufano+i));
321         //fprintf(stdout,"\n");
322
323         SCRUTE(myMesh->NbNodes());
324
325         /* liberation memoire */
326         free(coo);
327         free(nomnoe);
328         free(numnoe);
329         free(nufano);
330
331   /****************************************************************************
332   *                       LECTURE DES ELEMENTS                                *
333   ****************************************************************************/
334         fprintf(stdout, "\n(**************************)\n");
335         fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
336         fprintf(stdout, "(**************************)");
337         //fprintf(Out,"CELLS\n");
338         /* Lecture des connectivites, noms, numeros des mailles */
339         //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]);
340
341         if (ret == 0)
342                 for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
343                 {
344                         if (nmailles[i] > 0 && ret == 0)
345                         {
346                                 /* dimension de la maille */
347                                 edim = typmai[i] / 100;
348                                 nsup = 0;
349                                 if (mdim == 2 || mdim == 3)
350                                         if (edim == 1)
351                                                 nsup = 1;
352                                 if (mdim == 3)
353                                         if (edim == 2)
354                                                 nsup = 1;
355
356                                 taille = nsup + typmai[i] % 100;
357                                 //taille = typmai[i]%100;
358
359                                 /* allocation memoire */
360                                 connectivite = (med_int *) malloc(sizeof(med_int) *
361                                         taille * nmailles[i]);
362                                 nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
363                                         nmailles[i] + 1);
364                                 numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
365                                 nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
366
367                                 /* lecture des données */
368                                 ret =
369                                         MEDelementsLire(myFileId, nommaa, mdim, connectivite,
370                                         mode_coo, nomele, &inoele, numele, &inuele, nufael,
371                                         nmailles[i], MED_MAILLE, typmai[i], typ_con);
372                                 SCRUTE(typmai[i]);
373                                 switch (typmai[i])
374                                 {
375                                 case MED_SEG2:
376                                 {
377                                         if (inuele)
378                                         {
379                                                 for (j = 0; j < nmailles[i]; j++)
380                                                 {
381                                                         elem_id = *(numele + j);
382                                                         ok = myMesh->AddEdgeWithID(*(connectivite +
383                                                                         j * (taille)),
384                                                                 *(connectivite + j * (taille) + 1), elem_id);
385                                                 }
386                                         }
387                                         else
388                                         {
389                                                 for (j = 0; j < nmailles[i]; j++)
390                                                 {
391                                                         cmpt++;
392                                                         ok = myMesh->AddEdgeWithID(*(connectivite +
393                                                                         j * (taille)),
394                                                                 *(connectivite + j * (taille) + 1), cmpt);
395                                                 }
396                                         }
397
398                                         break;
399                                 }
400                                 case MED_TRIA3:
401                                 {
402                                         if (inuele)
403                                         {
404                                                 for (j = 0; j < nmailles[i]; j++)
405                                                 {
406                                                         elem_id = *(numele + j);
407                                                         ok = myMesh->AddFaceWithID(*(connectivite +
408                                                                         j * (taille)),
409                                                                 *(connectivite + j * (taille) + 1),
410                                                                 *(connectivite + j * (taille) + 2), elem_id);
411                                                         //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
412                                                 }
413                                         }
414                                         else
415                                         {
416                                                 for (j = 0; j < nmailles[i]; j++)
417                                                 {
418                                                         cmpt++;
419                                                         ok = myMesh->AddFaceWithID(*(connectivite +
420                                                                         j * (taille)),
421                                                                 *(connectivite + j * (taille) + 1),
422                                                                 *(connectivite + j * (taille) + 2), cmpt);
423                                                         //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
424                                                 }
425                                         }
426
427                                         break;
428                                 }
429                                 case MED_QUAD4:
430                                 {
431                                         if (inuele)
432                                         {
433                                                 for (j = 0; j < nmailles[i]; j++)
434                                                 {
435                                                         elem_id = *(numele + j);
436                                                         ok = myMesh->AddFaceWithID(*(connectivite +
437                                                                         j * (taille)),
438                                                                 *(connectivite + j * (taille) + 1),
439                                                                 *(connectivite + j * (taille) + 2),
440                                                                 *(connectivite + j * (taille) + 3), elem_id);
441                                                         //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
442                                                 }
443                                         }
444                                         else
445                                         {
446                                                 for (j = 0; j < nmailles[i]; j++)
447                                                 {
448                                                         cmpt++;
449                                                         ok = myMesh->AddFaceWithID(*(connectivite +
450                                                                         j * (taille)),
451                                                                 *(connectivite + j * (taille) + 1),
452                                                                 *(connectivite + j * (taille) + 2),
453                                                                 *(connectivite + j * (taille) + 3), cmpt);
454                                                         //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
455                                                 }
456                                         }
457                                         break;
458                                 }
459                                 case MED_HEXA8:
460                                 {
461                                         if (inuele)
462                                         {
463                                                 for (j = 0; j < nmailles[i]; j++)
464                                                 {
465                                                         elem_id = *(numele + j);
466                                                         ok = myMesh->AddVolumeWithID(*(connectivite +
467                                                                         j * (taille)),
468                                                                 *(connectivite + j * (taille) + 1),
469                                                                 *(connectivite + j * (taille) + 2),
470                                                                 *(connectivite + j * (taille) + 3),
471                                                                 *(connectivite + j * (taille) + 4),
472                                                                 *(connectivite + j * (taille) + 5),
473                                                                 *(connectivite + j * (taille) + 6),
474                                                                 *(connectivite + j * (taille) + 7), elem_id);
475                                                         //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
476                                                 }
477                                         }
478                                         else
479                                         {
480                                                 for (j = 0; j < nmailles[i]; j++)
481                                                 {
482                                                         cmpt++;
483                                                         ok = myMesh->AddVolumeWithID(*(connectivite +
484                                                                         j * (taille)),
485                                                                 *(connectivite + j * (taille) + 1),
486                                                                 *(connectivite + j * (taille) + 2),
487                                                                 *(connectivite + j * (taille) + 3),
488                                                                 *(connectivite + j * (taille) + 4),
489                                                                 *(connectivite + j * (taille) + 5),
490                                                                 *(connectivite + j * (taille) + 6),
491                                                                 *(connectivite + j * (taille) + 7), cmpt);
492                                                         //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
493                                                 }
494                                         }
495                                         break;
496                                 }
497                                 default:
498                                 {
499                                         break;
500                                 }
501                                 }
502
503                                 //fprintf(stdout,"\n  - Numéros de familles : \n");
504                                 //for (j=0;j<nmailles[i];j++)
505                                 //fprintf(stdout," %d ",*(nufael+j));
506
507                                 /* liberation memoire */
508                                 free(connectivite);
509                                 free(nomele);
510                                 free(numele);
511                                 free(nufael);
512                         }
513                 }
514
515         SCRUTE(myMesh->NbEdges());
516         SCRUTE(myMesh->NbFaces());
517   /****************************************************************************
518    *                       LECTURE DES FAMILLES                                *
519    ****************************************************************************/
520         printf("\n(*************************)\n");
521         printf("(* FAMILLES DU MAILLAGE : *)\n");
522         printf("(*************************)\n");
523         if (ret == 0)
524                 for (i = 0; i < nfam; i++)
525                 {
526
527                         /* nombre de groupes */
528                         ngro = MEDnFam(myFileId, nommaa, i + 1, MED_GROUPE);
529                         if (ngro < 0)
530                         {
531                                 ret = -1;
532                                 strcpy(message,
533                                         ">> ERREUR : lecture du nombre de groupes d'une famille \n");
534                         }
535
536                         /* nombre d'attributs */
537                         if (ret == 0)
538                         {
539                                 natt = MEDnFam(myFileId, nommaa, i + 1, MED_ATTR);
540                                 if (natt < 0)
541                                 {
542                                         ret = -1;
543                                         strcpy(message,
544                                                 ">> ERREUR : lecture du nombre d'attributs d'une famille\n");
545                                 }
546                         }
547
548                         if (ret == 0)
549                                 fprintf(stdout, "- Famille %d a %d attributs et %d groupes \n",
550                                         i + 1, natt, ngro);
551
552                         /* nom,numero,attributs,groupes */
553                         if (ret == 0)
554                         {
555                                 attide = (med_int *) malloc(sizeof(med_int) * natt);
556                                 attval = (med_int *) malloc(sizeof(med_int) * natt);
557                                 attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1);
558                                 gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1);
559                                 ret =
560                                         MEDfamInfo(myFileId, nommaa, i + 1, nomfam, &numfam, attide,
561                                         attval, attdes, &natt, gro, &ngro);
562                                 fprintf(stdout, "  - Famille de nom %s et de numero %d : \n",
563                                         nomfam, numfam);
564                                 fprintf(stdout, "  - Attributs : \n");
565                                 for (j = 0; j < natt; j++)
566                                 {
567                                         strncpy(str1, attdes + j * MED_TAILLE_DESC,
568                                                 MED_TAILLE_DESC);
569                                         str1[MED_TAILLE_DESC] = '\0';
570                                         fprintf(stdout, "   ide = %d - val = %d - des = %s\n",
571                                                 *(attide + j), *(attval + j), str1);
572                                 }
573                                 free(attide);
574                                 free(attval);
575                                 free(attdes);
576                                 fprintf(stdout, "  - Groupes :\n");
577                                 for (j = 0; j < ngro; j++)
578                                 {
579                                         strncpy(str2, gro + j * MED_TAILLE_LNOM, MED_TAILLE_LNOM);
580                                         str2[MED_TAILLE_LNOM] = '\0';
581                                         fprintf(stdout, "   gro = %s\n", str2);
582                                 }
583                                 free(gro);
584                         }
585                 }
586
587         if (locally_managed)
588                 ret = MEDfermer(myFileId);
589
590 }