00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 #ifndef MESGERR
00062 #define MESGERR 1
00063 #endif
00064 
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif
00068 
00069 #include <med.h>
00070 #include <med_config.h>
00071 #include <med_utils.h>
00072 #include <med_misc.h>
00073 #include <stdio.h>
00074 #include <string.h>
00075 #include <stdlib.h>
00076 
00077 #ifdef __cplusplus
00078 }
00079 #endif
00080 
00081 #ifdef PPRO_NT
00082 #define F_OK 0
00083 #else
00084 #include <unistd.h>
00085 #endif
00086 
00087 
00088 extern med_entity_type MED23MESH_GET_ENTITY_TYPE[MED_N_ENTITY_TYPES+2];
00089 extern const char * const MED23MESH_GET_ENTITY_TYPENAME[MED_N_ENTITY_TYPES+2];
00090 extern med_geometry_type MED23MESH_GET_CELL_GEOMETRY_TYPE[MED_N_CELL_FIXED_GEO+2];
00091 extern const char * const MED23MESH_GET_CELL_GEOMETRY_TYPENAME[MED_N_CELL_FIXED_GEO+2];
00092 extern med_geometry_type MED23MESH_GET_FACE_GEOMETRY_TYPE[MED_N_FACE_FIXED_GEO+2];
00093 extern const char * const MED23MESH_GET_FACE_GEOMETRY_TYPENAME[MED_N_FACE_FIXED_GEO+2];
00094 extern med_geometry_type MED23MESH_GET_EDGE_GEOMETRY_TYPE[MED_N_EDGE_FIXED_GEO+2];
00095 extern const char * MED23MESH_GET_EDGE_GEOMETRY_TYPENAME[MED_N_EDGE_FIXED_GEO+2];
00096 extern med_geometry_type MED23MESH_GET_NODE_GEOMETRY_TYPE[MED_N_NODE_FIXED_GEO+2];
00097 extern const char * MED23MESH_GET_NODE_GEOMETRY_TYPENAME[MED_N_NODE_FIXED_GEO+2];
00098 
00099 extern med_entity_type MED23FIELD_GET_ENTITY_TYPE[MED_N_ENTITY_TYPES+2];
00100 extern const char * const MED23FIELD_GET_ENTITY_TYPENAME[MED_N_ENTITY_TYPES+2];
00101 extern med_geometry_type MED23FIELD_GET_CELL_GEOMETRY_TYPE[MED_N_CELL_FIXED_GEO+2];
00102 extern const char * const MED23FIELD_GET_CELL_GEOMETRY_TYPENAME[MED_N_CELL_FIXED_GEO+2];
00103 extern med_geometry_type MED23FIELD_GET_FACE_GEOMETRY_TYPE[MED_N_FACE_FIXED_GEO+2];
00104 extern const char * const MED23FIELD_GET_FACE_GEOMETRY_TYPENAME[MED_N_FACE_FIXED_GEO+2];
00105 extern med_geometry_type MED23FIELD_GET_EDGE_GEOMETRY_TYPE[MED_N_EDGE_FIXED_GEO+2];
00106 extern const char * MED23FIELD_GET_EDGE_GEOMETRY_TYPENAME[MED_N_EDGE_FIXED_GEO+2];
00107 extern med_geometry_type MED23FIELD_GET_NODE_GEOMETRY_TYPE[MED_N_NODE_FIXED_GEO+2];
00108 extern const char * MED23FIELD_GET_NODE_GEOMETRY_TYPENAME[MED_N_NODE_FIXED_GEO+2];
00109 
00110 
00111 
00112 int structure = 0;
00113 
00114 
00115 const med_geometry_type * const typmai = MED23MESH_GET_CELL_GEOMETRY_TYPE+1;
00116 const med_geometry_type * const typfac = MED23MESH_GET_FACE_GEOMETRY_TYPE+1;
00117 const med_geometry_type * const typare = MED23MESH_GET_EDGE_GEOMETRY_TYPE+1;
00118 
00119 const char * const *nommai = MED23MESH_GET_CELL_GEOMETRY_TYPENAME+1;
00120 const char * const *nomfac = MED23MESH_GET_FACE_GEOMETRY_TYPENAME+1;
00121 const char * const *nomare = MED23MESH_GET_EDGE_GEOMETRY_TYPENAME+1;
00122 
00123 
00124 #define USER_MODE MED_COMPACT_STMODE
00125 
00126 #define xstr(s) str(s)
00127 #define str(s) #s
00128 
00129 med_int lecture_nombre_famille(med_idt fid,const char * const nommaa)
00130 {
00131   med_int nfam = MEDnFamily(fid,nommaa);
00132   EXIT_IF(nfam < 0,"lors de la lecture du nombre de familles",NULL);
00133   fprintf(stdout,"- Nombre de familles : %d \n",nfam);
00134 
00135   return nfam;
00136 }
00137 
00138 void lecture_famille_maillage(med_idt fid,const char * const nommaa,med_int nfam)
00139 {
00140   med_int i,j;
00141   med_int natt,ngro;
00142   char *attdes=NULL,*gro=NULL;
00143   med_int *attval=NULL,*attide=NULL;
00144   char nomfam[MED_NAME_SIZE+1];
00145   med_int numfam;
00146   char str1[MED_COMMENT_SIZE+1];
00147   char str2[MED_LNAME_SIZE+1];
00148   med_err ret = 0;
00149   int famille_0 = 0;
00150 
00151   fprintf(stdout,"\n(**************************)\n");
00152   fprintf(stdout,"(* FAMILLES DU MAILLAGE : *)\n");
00153   fprintf(stdout,"(**************************)\n");
00154 
00155   for (i=0;i<nfam;i++) {
00156 
00157     
00158     ngro = MEDnFamilyGroup(fid,nommaa,i+1);
00159     EXIT_IF(ngro < 0,"lors de la lecture du nombre de groupe d'une famille",
00160             NULL);
00161 
00162     
00163     natt = MEDnFamily23Attribute(fid,nommaa,i+1);
00164     EXIT_IF(natt < 0,"lors de la lecture du nombre d'attributs d'une famille",
00165             NULL);
00166 
00167     fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,
00168             ngro);
00169 
00170     
00171 
00172     
00173     attide = (med_int*) malloc(sizeof(med_int)*natt);
00174     EXIT_IF(attide == NULL,NULL,NULL);
00175     attval = (med_int*) malloc(sizeof(med_int)*natt);
00176     EXIT_IF(attval == NULL,NULL,NULL);
00177     attdes = (char *) malloc(MED_COMMENT_SIZE*natt+1);
00178     EXIT_IF(attdes == NULL,NULL,NULL);
00179     gro = (char*) malloc(MED_LNAME_SIZE*ngro+1);
00180     EXIT_IF(gro == NULL,NULL,NULL);
00181     ret = MEDfamily23Info(fid,nommaa,i+1,nomfam,attide,attval,
00182                           attdes,&numfam,gro);
00183     EXIT_IF(ret < 0,"lors de la lecture des informations d'une famille",
00184             NULL);
00185         if (numfam == 0)
00186           famille_0 = 1;
00187 
00188     if (!structure) {
00189     
00190     fprintf(stdout,"  - Famille de nom %s et de numero %d : \n",nomfam,numfam);
00191     fprintf(stdout,"  - Attributs : \n");
00192     for (j=0;j<natt;j++) {
00193       strncpy(str1,attdes+j*MED_COMMENT_SIZE,MED_COMMENT_SIZE);
00194       str1[MED_COMMENT_SIZE] = '\0';
00195       fprintf(stdout,"   ide = %d - val = %d - des = %s\n",*(attide+j),
00196               *(attval+j),str1);
00197     }
00198     }
00199 
00200     
00201     if (attide) {free(attide);attide=NULL;}
00202     if (attval) {free(attval);attval=NULL;}
00203     if (attdes) {free(attdes);attdes=NULL;}
00204 
00205     if (!structure) {
00206     fprintf(stdout,"  - Groupes :\n");
00207     for (j=0;j<ngro;j++) {
00208       strncpy(str2,gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
00209       str2[MED_LNAME_SIZE] = '\0';
00210       fprintf(stdout,"   gro = %s\n",str2);
00211     }
00212     }
00213 
00214     
00215     if (gro) {free(gro);gro=NULL;}
00216   }
00217 
00218   if (famille_0 != 1) {
00219     MESSAGE("Erreur : La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire. ");
00220   }
00221 
00222   return;
00223 }
00224 
00225 med_int lecture_nombre_equivalence(med_idt fid,const char * const nommaa)
00226 {
00227   med_int nequ = MEDnEquivalence(fid,nommaa);
00228   EXIT_IF(nequ < 0,"lors de la lecture du nombre d'equivalences",NULL);
00229   fprintf(stdout,"- Nombre d'equivalences : %d \n",nequ);
00230 
00231   return nequ;
00232 }
00233 
00234 
00235 void lecture_equivalence_maillage(med_idt fid,const char * const nommaa,med_int nequ)
00236 {
00237   med_int i,j,k;
00238   med_int ncor;
00239   med_int *cor;
00240   char equ[MED_NAME_SIZE+1];
00241   char des[MED_COMMENT_SIZE+1];
00242   med_err ret = 0;
00243   med_int nstep=0,nocstpncor=0;
00244   int     _cstpit=0;
00245   med_int _numdt,_numit;
00246 
00247   fprintf(stdout,"\n(******************************)\n");
00248   fprintf(stdout,"(* EQUIVALENCES DU MAILLAGE : *)\n");
00249   fprintf(stdout,"(******************************)\n");
00250 
00251   if (nequ == 0)
00252     fprintf(stdout,"- Aucune équivalence \n");
00253 
00254   
00255   for (i = 0;i<nequ;i++) {
00256     fprintf(stdout,"- Equivalence numero : %d ",i+1);
00257 
00258     
00259     ret = MEDequivalenceInfo(fid,nommaa,i+1,equ,des,&nstep,&nocstpncor);
00260     EXIT_IF(ret < 0,"lors de la lecture des informations sur une equivalence",
00261             NULL);
00262     fprintf(stdout,"\n  - Nom de l'equivalence: %s \n",equ);
00263     fprintf(stdout,"\n  - Description de l'equivalence : %s \n",des);
00264     if (nstep > 1)
00265       fprintf(stdout,"\n  - L'equivalence est définie sur "IFORMAT" étapes de calcul\n",nstep);
00266 
00267     for (_cstpit=1; _cstpit <= nstep; ++_cstpit) {
00268 
00269       ret = MEDequivalenceComputingStepInfo   (fid, nommaa, equ, _cstpit,
00270                                                & _numdt, &_numit,&nocstpncor);
00271       EXIT_IF(ret < 0,
00272               "lors de la lecture des valeurs de séquence de calcul  d'une equivalence",
00273               NULL);
00274       if ( (_numdt != MED_NO_DT) || (_numit != MED_NO_IT) )
00275         fprintf(stdout,"\n  - Séquence de calcul définie sur (numdt,numit) ("IFORMAT","IFORMAT") :\n",_numdt,_numit);
00276 
00277       
00278 
00279       
00280       ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,MED_NODE,MED_NONE,&ncor);
00281       EXIT_IF(ret < 0,
00282               "lors de la lecture du nombre de correspondances d'une equivalence",
00283               NULL);
00284       fprintf(stdout,"\n  - Il y a %d correspondances sur les noeuds \n",ncor);
00285 
00286       if (ncor > 0) {
00287 
00288         
00289         cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00290         EXIT_IF(cor == NULL,NULL,NULL);
00291         ret= MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00292                                             MED_NODE,MED_NONE,cor);
00293         EXIT_IF(ret < 0,"lors de la lecture du tableau des correspondances",
00294                 NULL);
00295         if (!structure) {
00296           for (j=0;j<ncor;j++)
00297             fprintf(stdout,"\n  - Correspondance %d : %d et %d \n",j+1,*(cor+2*j),
00298                     *(cor+2*j+1));
00299         }
00300         free(cor);
00301       }
00302 
00303       
00304       for (j=0;j<MED_N_CELL_FIXED_GEO;j++) {
00305 
00306         ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,MED_CELL,typmai[j],&ncor);
00307         EXIT_IF(ret < 0,
00308                 "lors de la lecture du nombre de correspondances dans une equivalence",
00309                 NULL);
00310         fprintf(stdout,"\n  - Il y a %d correspondances sur les mailles %s \n",ncor,
00311                 nommai[j]);
00312 
00313         if (ncor > 0) {
00314 
00315           
00316           cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00317           EXIT_IF(cor == NULL,NULL,NULL);
00318           ret = MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00319                                                MED_CELL,typmai[j],cor);
00320           EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
00321                   NULL);
00322 
00323           if (!structure) {
00324             for (k=0;k<ncor;k++)
00325               fprintf(stdout,"\n  - Correspondance %d : %d et %d \n",k+1,
00326                       *(cor+2*k),*(cor+2*k+1));
00327           }
00328           free(cor);
00329         }
00330       }
00331 
00332 
00333       
00334       for (j=0;j<MED_N_FACE_FIXED_GEO;j++) {
00335 
00336         ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,
00337                                                MED_DESCENDING_FACE,typfac[j],&ncor);
00338 
00339         EXIT_IF(ret < 0,
00340                 "lors de la lecture du nombre de correspondances dans une equivalence",
00341                 NULL);
00342         fprintf(stdout,"\n  - Il y a %d correspondances sur les faces %s\n",ncor,
00343               nomfac[j]);
00344 
00345         if (ncor > 0) {
00346 
00347           
00348           cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00349           EXIT_IF(cor == NULL,NULL,NULL);
00350           ret = MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00351                                                MED_DESCENDING_FACE,typfac[j],cor);
00352           EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
00353                   NULL);
00354 
00355           if (!structure) {
00356             for (k=0;k<ncor;k++)
00357               fprintf(stdout,"\n  - Correspondance %d : %d et %d \n",k+1,*(cor+2*k),
00358                       *(cor+2*k+1));
00359           }
00360           free(cor);
00361         }
00362       }
00363 
00364 
00365       
00366       for (j=0;j<MED_N_NODE_FIXED_GEO;j++) {
00367 
00368         ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,
00369                                              MED_DESCENDING_EDGE,typare[j],&ncor);
00370         EXIT_IF(ret < 0,"lors de la lecture du nombre de correspondances",
00371                 NULL);
00372         fprintf(stdout,"\n  - Il y a %d correspondances sur les aretes %s \n",
00373                 ncor,nomare[j]);
00374 
00375         if (ncor > 0) {
00376 
00377           
00378           cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00379           EXIT_IF(cor == NULL,NULL,NULL);
00380           ret =MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00381                                               MED_DESCENDING_EDGE,typare[j],cor);
00382           EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
00383                   NULL);
00384 
00385           if (!structure) {
00386             for (k=0;k<ncor;k++)
00387               fprintf(stdout,"\n  Correspondance %d : %d et %d \n",k+1,*(cor+2*k),
00388                       *(cor+2*k+1));
00389           }
00390 
00391           free(cor);
00392         }
00393       }
00394     }
00395   }
00396 
00397   return;
00398 }
00399 
00400 
00401 med_int lecture_nombre_joint(med_idt fid,const char * const nommaa)
00402 {
00403   med_int njnt = MEDnSubdomainJoint(fid,nommaa);
00404   EXIT_IF(njnt < 0,"lors de la lecture du nombre de joints",NULL);
00405   fprintf(stdout,"- Nombre de joints : %d \n",njnt);
00406 
00407   return njnt;
00408 }
00409 
00410 
00411 void lecture_joint_maillage(med_idt fid,const char * const nommaa,med_int njnt)
00412 {
00413   med_int i,k;
00414   char des[MED_COMMENT_SIZE+1];
00415   med_int ndom,nent;
00416   med_int typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant;
00417 
00418 
00419   char jn                  [MED_NAME_SIZE+1]="";
00420   char maa_dist            [MED_NAME_SIZE+1]="";
00421   char nom_geo_ent_local   [MED_NAME_SIZE+1]="";
00422   char nom_geo_ent_distant [MED_NAME_SIZE+1]="";
00423   med_int *cortab;
00424 
00425   med_err ret = 0;
00426   med_int njstep=0,ncor=0,nodtitncor=0;
00427   int corit=0,csit=0;
00428   med_int _numdt,_numit;
00429 
00430   fprintf(stdout,"\n(******************************)\n");
00431   fprintf(stdout,"(* JOINTS DU MAILLAGE       : *)\n");
00432   fprintf(stdout,"(******************************)\n");
00433 
00434   if (njnt == 0)
00435     fprintf(stdout,"- Aucun joint \n");
00436 
00437   
00438   for (i = 0;i<njnt;i++) {
00439     fprintf(stdout,"- Joint numero : %d ",i+1);
00440 
00441     
00442     ret = MEDsubdomainJointInfo(fid,nommaa,i+1,jn,des,&ndom,maa_dist,&njstep,&nodtitncor);
00443     EXIT_IF(ret < 0,"lors de la lecture des informations sur un joint",
00444             NULL);
00445 
00446     fprintf(stdout,"\n  - Nom du joint: %s \n",jn);
00447     fprintf(stdout,"\n  - Description du joint      : %s ",des);
00448     fprintf(stdout,"\n  - Domaine en regard         : %d ",ndom);
00449     fprintf(stdout,"\n  - Maillage distant          : %s ",maa_dist);
00450     if (njstep > 1 ) {
00451       printf("Nombre d'étapes de calcul : "IFORMAT" \n",njstep);
00452       printf("Nombre de correspondance pour (NO_DT,NO_IT) : "IFORMAT" \n",nodtitncor);
00453     }
00454 
00455     for (csit=1; csit <= njstep; ++csit) {
00456 
00457       ret = MEDsubdomainComputingStepInfo( fid, nommaa, jn, csit, &_numdt, &_numit, &ncor);
00458       EXIT_IF(ret < 0,"Erreur a la lecture des valeurs (numdt,numit) dans les joints",
00459             NULL);
00460       if ( (_numdt != MED_NO_DT) || (_numit != MED_NO_IT) ) {
00461         printf("Séquence de calcul (numdt,numit) : ("IFORMAT","IFORMAT")\n",_numdt,_numit);
00462       }
00463       corit=1;
00464       while ( corit <= ncor ) {
00465 
00466         ret = MEDsubdomainCorrespondenceSizeInfo(fid,nommaa,jn,_numdt,_numit,corit,
00467                                                  (med_entity_type *) &typ_ent_local, (med_geometry_type *) &typ_geo_local,
00468                                                  (med_entity_type *) &typ_ent_distant,(med_geometry_type *)&typ_geo_distant,
00469                                                  &nent);
00470         EXIT_IF(ret < 0,"Erreur a la lecture des infos sur le nombre d'entite en regard",
00471                 NULL);
00472         if (nent > 0) {
00473           if (typ_ent_local == MED_NODE) strcpy(nom_geo_ent_local,"MED_NOEUD");
00474           else  ret = _MEDgetExternalGeometryTypeName(nom_geo_ent_local,typ_geo_local);
00475           EXIT_IF(ret < 0,"Erreur à l'appel de _MEDgetExternalGeometryTypeName", NULL);
00476           if (typ_ent_distant == MED_NODE) strcpy(nom_geo_ent_distant,"MED_NOEUD");
00477           else ret = _MEDgetExternalGeometryTypeName(nom_geo_ent_distant,typ_geo_distant);
00478           EXIT_IF(ret < 0,"Erreur à l'appel de _MEDgetExternalGeometryTypeName", NULL);
00479           fprintf(stdout,"\n\t\t- nb de couples d'entites en regard (local,distant)=(%s,%s) : "IFORMAT" \n",
00480                   nom_geo_ent_local,nom_geo_ent_distant,  nent);
00481           
00482 
00483           cortab = (med_int*) malloc(sizeof(med_int)*nent*2);
00484           if ( (ret=MEDsubdomainCorrespondenceRd(fid,nommaa,jn,_numdt,_numit,
00485                                                  typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00486                                                  cortab)) < 0) {
00487             fprintf(stdout,"\n\t\t- Erreur a la lecture des correspondances sur (%s,%s,%s,%s)",
00488                     MED23MESH_GET_ENTITY_TYPENAME[typ_ent_local+1],nom_geo_ent_local,
00489                     MED23MESH_GET_ENTITY_TYPENAME[typ_ent_distant+1],nom_geo_ent_distant);
00490           } else {
00491             if (!structure) {
00492               for (k=0;k<nent;k++)
00493                 fprintf(stdout,"\n\t\t- Correspondance %d : "IFORMAT" et "IFORMAT" ",k+1,
00494                         *(cortab+2*k),*(cortab+2*k+1));
00495             }
00496           }
00497           free(cortab);
00498         }
00499 
00500         corit++;
00501       }
00502     }
00503   }
00504 
00505   return;
00506 }
00507 
00508 
00509 med_int lecture_nombre_noeuds_maillage_non_structure(const med_idt fid,
00510                                                      const char *  nommaa,
00511                                                      const med_int numdt,
00512                                                      const med_int numit)
00513 {
00514 
00515 
00516   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00517 
00518   med_int nnoe = MEDmeshnEntity(fid,nommaa,numdt,numit,
00519                                 MED_NODE,MED_NO_GEOTYPE,
00520                                 MED_COORDINATE,MED_NODAL,&chgt,&trsf);
00521   EXIT_IF(nnoe < 0,"lors de la lecture du nombre de noeuds",NULL);
00522   fprintf(stdout,"- Nombre de noeuds : %d \n",nnoe);
00523 
00524   return nnoe;
00525 }
00526 
00527 
00528 void lecture_noeuds_maillage_non_structure(const med_idt fid,
00529                                            const char * const nommaa,
00530                                            const med_int numdt,
00531                                            const med_int numit,
00532                                            const med_int mdim,
00533                                            const med_int edim,
00534                                            const med_int nnoe,
00535                                            const med_switch_mode mode_coo,
00536                                            const char * const nomcoo,
00537                                            const char * const unicoo,
00538                                            const med_axis_type *const rep)
00539 {
00540   med_float *coo;
00541   char *nomnoe;
00542   med_int *numnoe;
00543   med_int *nufano;
00544   med_bool inonoe,inunoe,ifano;
00545   med_err ret = 0;
00546   med_int i;
00547   char str[MED_SNAME_SIZE+1];
00548 
00549 
00550   
00551   
00552 
00553   coo = (med_float*) malloc(sizeof(med_float)*nnoe*edim);
00554   EXIT_IF(coo == NULL,NULL,NULL);
00555   
00556 
00557   numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
00558   EXIT_IF(numnoe == NULL,NULL,NULL);
00559   nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
00560   EXIT_IF(nufano == NULL,NULL,NULL);
00561   
00562 
00563   nomnoe = (char*) malloc(MED_SNAME_SIZE*nnoe+1);
00564   EXIT_IF(nomnoe == NULL,NULL,NULL);
00565 
00566   
00567 
00568 
00569 
00570 
00571   ret = MEDmeshNodeRd(fid,nommaa,numdt,numit, mode_coo, coo,
00572                       &inonoe,nomnoe,&inunoe,numnoe,&ifano,nufano);
00573 
00574 
00575   EXIT_IF(ret < 0,"lors de la lecture des noeuds du maillage \n",NULL);
00576 
00577   
00578   fprintf(stdout,"\n(************************)\n");
00579   fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
00580   fprintf(stdout,"(************************)\n");
00581   fprintf(stdout,"- Type de repere des coordonnees : %d \n",*rep);
00582   fprintf(stdout,"- Nom des coordonnees : \n");
00583   for (i=0;i<edim;i++) {
00584     strncpy(str,nomcoo+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00585     str[MED_SNAME_SIZE] = '\0';
00586     fprintf(stdout," %s ",str);
00587   }
00588   fprintf(stdout,"\n- Unites des coordonnees : \n");
00589   for (i=0;i<edim;i++) {
00590     strncpy(str,unicoo+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00591     str[MED_SNAME_SIZE] = '\0';
00592     fprintf(stdout," %s ",str);
00593   }
00594   if (!structure) {
00595   fprintf(stdout,"\n- Coordonnees des noeuds : \n");
00596   for (i=0;i<nnoe*edim;i++) {
00597     if (mode_coo == MED_FULL_INTERLACE && !(i % edim))
00598       fprintf(stdout,"\n [ %5d ] : ", (i/edim + 1) );
00599     if (mode_coo == MED_NO_INTERLACE && ! (i % nnoe))
00600       fprintf(stdout,"\n\n ");
00601     fprintf(stdout," %-+9.6f ",*(coo+i));
00602   }
00603 
00604   if (inonoe) {
00605     fprintf(stdout,"\n- Noms des noeuds : \n");
00606     for (i=0;i<nnoe;i++) {
00607       strncpy(str,nomnoe+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00608       str[MED_SNAME_SIZE] = '\0';
00609       fprintf(stdout," %s ",str);
00610     }
00611   }
00612   if (inunoe) {
00613     fprintf(stdout,"\n- Numeros des noeuds : \n");
00614     for (i=0;i<nnoe;i++)
00615       fprintf(stdout," %d ",*(numnoe+i));
00616   }
00617 
00618   fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
00619   for (i=0;i<nnoe;i++) {
00620     if (ifano)
00621       fprintf(stdout," %d ",*(nufano+i));
00622     else
00623       fprintf(stdout," %d ",0);
00624   }
00625   fprintf(stdout,"\n");
00626   }
00627 
00628 
00629   
00630   free(coo);
00631   free(nomnoe);
00632   free(numnoe);
00633   free(nufano);
00634 
00635   return;
00636 }
00637 
00638 
00639 med_int lecture_nombre_mailles_standards(const med_idt fid,
00640                                          const char * const nommaa,
00641                                          const med_int numdt,
00642                                          const med_int numit,
00643                                          const med_geometry_type typ_geo,
00644                                          const med_connectivity_mode typ_con,
00645                                          const int indice)
00646 {
00647 
00648   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00649 
00650   med_int nmailles = MEDmeshnEntity(fid,nommaa,numdt,numit,
00651                                     MED_CELL,typ_geo,
00652                                     MED_CONNECTIVITY,typ_con,&chgt,&trsf);
00653   EXIT_IF(nmailles < 0," lors de la lecture du nombre de mailles",NULL);
00654 
00655   if ( (indice < (MED_N_CELL_GEO_FIXED_CON-5) ) ||
00656        (indice >= (MED_N_CELL_GEO_FIXED_CON-5) && (nmailles > 0) ) )
00657        fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[indice],
00658                 nmailles);
00659 
00660   return nmailles;
00661 }
00662 
00663 void lecture_mailles_standards(const med_idt fid,
00664                                const char *nommaa,
00665                                const med_int numdt,
00666                                const med_int numit,
00667                                const med_int mdim,
00668                                const med_int * const nmailles,
00669                                const med_switch_mode mode_coo,
00670                                const med_connectivity_mode typ_con)
00671 {
00672   med_int  taille;
00673   med_int *connectivite;
00674   char    *nomele;
00675   med_int *numele;
00676   med_int *nufael;
00677   med_bool       inoele=MED_FALSE, inuele=MED_FALSE, inufael=MED_FALSE;
00678   med_geometry_type typgeo;
00679   med_int entdim;
00680   med_int nnodes;
00681   med_int nndes;
00682   med_int i,j;
00683   med_err ret = 0;
00684   char str[MED_SNAME_SIZE+1];
00685 
00686   fprintf(stdout,"\n(**************************)\n");
00687   fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
00688   fprintf(stdout,"(**************************)");
00689 
00690   
00691   for (i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
00692     if (nmailles[i] > 0) {
00693 
00694       ret=_MEDgetGeometricParameter(MED_CELL, typmai[i],&entdim,&nnodes,&nndes);
00695       EXIT_IF(ret < 0,"lors de la lecture des caractéristiques des mailles",NULL);
00696 
00697       switch(typ_con) {
00698       case MED_NODAL :
00699         taille = nnodes;
00700         break;
00701 
00702       case MED_DESCENDING :
00703         taille = nndes;
00704         break;
00705 
00706       default :
00707         ret = -1;
00708       }
00709 
00710       
00711       connectivite = (med_int*) malloc(sizeof(med_int)*taille*nmailles[i]);
00712       EXIT_IF(connectivite == NULL,NULL,NULL);
00713       nomele = (char*) malloc(sizeof(char)*MED_SNAME_SIZE*nmailles[i]+1);
00714       EXIT_IF(nomele == NULL,NULL,NULL);
00715       numele = (med_int*) malloc(sizeof(med_int)*nmailles[i]);
00716       EXIT_IF(numele == NULL,NULL,NULL);
00717       nufael = (med_int*) malloc(sizeof(med_int)*nmailles[i]);
00718       EXIT_IF(nufael == NULL,NULL,NULL);
00719 
00720       
00721       ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_CELL,typmai[i],
00722                               typ_con, mode_coo, connectivite,
00723                               &inoele,nomele,&inuele,numele,&inufael,nufael );
00724 
00725       EXIT_IF(ret < 0,"lors de la lecture des mailles",NULL);
00726 
00727       if (!structure) {
00728       
00729       fprintf(stdout,"\n\n- Mailles de type %s : ", nommai[i]);
00730       fprintf(stdout,"\n  - Connectivité : \n");
00731       for (j=0;j<nmailles[i]*taille;j++) {
00732             if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
00733               fprintf(stdout,"\n [ %5d ] : ", (j/taille +1) );
00734             if (mode_coo == MED_NO_INTERLACE && !(j % nmailles[i]))
00735               fprintf(stdout,"\n");
00736             fprintf(stdout," %9d ",*(connectivite+j));
00737       }
00738 
00739       if (inoele) {
00740         fprintf(stdout,"\n  - Noms : \n");
00741         for (j=0;j<nmailles[i];j++) {
00742           strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
00743           str[MED_SNAME_SIZE] = '\0';
00744           fprintf(stdout," %s ",str);
00745         }
00746       }
00747       if (inuele) {
00748         fprintf(stdout,"\n  - Numeros :\n");
00749         for (j=0;j<nmailles[i];j++)
00750           fprintf(stdout," %d ",*(numele+j));
00751       }
00752       fprintf(stdout,"\n  - Numéros de familles : \n");
00753       for (j=0;j<nmailles[i];j++)
00754         if (inufael)
00755           fprintf(stdout," %d ",*(nufael+j));
00756         else
00757           fprintf(stdout," %d ",0);
00758           }
00759 
00760       
00761       free(connectivite);
00762       free(nomele);
00763       free(numele);
00764       free(nufael);
00765     }
00766 
00767   return;
00768 }
00769 
00770 
00771 med_int lecture_nombre_mailles_polygones(const med_idt fid,
00772                                          const char * const nommaa,
00773                                          const med_int numdt,
00774                                          const med_int numit,
00775                                          const med_connectivity_mode typ_con)
00776 {
00777 
00778   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00779 
00780   med_int nmpolygones = MEDmeshnEntity(fid,nommaa,numdt,numit,
00781                                     MED_CELL,MED_POLYGON,
00782                                     MED_INDEX_NODE,typ_con,&chgt,&trsf);
00783 
00784   EXIT_IF(nmpolygones < 0,"lors de la lecture du nombre de mailles polygone\n",
00785           NULL);
00786   if (nmpolygones > 0 ) nmpolygones--; else nmpolygones=0;
00787   fprintf(stdout,"- Nombre de mailles de type MED_POLYGONE : %d \n",
00788           nmpolygones);
00789 
00790   return nmpolygones;
00791 }
00792 
00793 void lecture_mailles_polygones(const med_idt fid,
00794                                const char * const nommaa,
00795                                const med_int numdt,
00796                                const med_int numit,
00797                                const med_int nmpolygones,
00798                                const med_switch_mode mode_coo,
00799                                const med_connectivity_mode typ_con)
00800 {
00801   med_int i,j;
00802   med_err ret = 0;
00803   med_int taille;
00804   med_int *connectivite;
00805   char *nomele;
00806   med_int *numele;
00807   med_int *nufael;
00808   med_int *indexp;
00809   int ind1,ind2;
00810   char tmp[MED_NAME_SIZE+1];
00811   med_err ret1,ret2,ret3;
00812   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00813 
00814   
00815 
00816   
00817   taille=MEDmeshnEntity(fid,nommaa,numdt,numit,
00818                         MED_CELL,MED_POLYGON,MED_CONNECTIVITY,typ_con,
00819                         &chgt,&trsf);
00820   EXIT_IF(taille < 0,"lors de la lecture des parametres des mailles polygones",
00821           NULL);
00822 
00823   
00824   indexp = (med_int *) malloc(sizeof(med_int)*(nmpolygones+1));
00825   EXIT_IF(indexp == NULL,NULL,NULL);
00826   connectivite = (med_int *) malloc(sizeof(med_int)*taille);
00827   EXIT_IF(connectivite == NULL,NULL,NULL);
00828   numele = (med_int *) malloc(sizeof(med_int)*nmpolygones);
00829   EXIT_IF(numele == NULL,NULL,NULL);
00830   nufael = (med_int *) malloc(sizeof(med_int)*nmpolygones);
00831   EXIT_IF(nufael == NULL,NULL,NULL);
00832   nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*nmpolygones+1);
00833   EXIT_IF(nomele == NULL,NULL,NULL);
00834 
00835   
00836   ret = MEDmeshPolygonRd(fid,nommaa,numdt,numit,MED_CELL,typ_con,
00837                          indexp,connectivite);
00838 
00839   EXIT_IF(ret < 0,"lors de la lecture des connectivites des mailles polygones",
00840           NULL);
00841 
00842   
00843   ret1 = MEDmeshEntityNameRd(fid,nommaa,numdt,numit,
00844                              MED_CELL,MED_POLYGON, nomele);
00845 
00846   
00847   ret2 = (med_int) MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,
00848                                          MED_CELL, MED_POLYGON, numele);
00849 
00850   
00851   ret3 = MEDmeshEntityFamilyNumberRd(fid, nommaa, MED_NO_DT, MED_NO_IT,
00852                                      MED_CELL, MED_POLYGON, nufael);
00853 
00854   if (!structure) {
00855   
00856   fprintf(stdout,"\n\n- Mailles de type MED_POLYGONE : ");
00857     for (i=0;i<nmpolygones;i++) {
00858       fprintf(stdout,"\n >> Maille MED_POLYGONE %d : \n",i+1);
00859       fprintf(stdout,"\n  - Connectivité : ");
00860       ind1 = *(indexp+i)-1;
00861       ind2 = *(indexp+i+1)-1;
00862       for (j=ind1;j<ind2;j++)
00863         printf(" %d ",*(connectivite+j));
00864       if (ret1 == 0) {
00865         strncpy(tmp,nomele+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00866         tmp[MED_SNAME_SIZE] = '\0';
00867         fprintf(stdout,"\n  - Nom : %s \n",tmp);
00868       }
00869       if (ret2 == 0)
00870         fprintf(stdout,"\n  - Numero : %d \n",*(numele+i));
00871 
00872       if ( ret3 >= 0 )
00873         fprintf(stdout,"\n  - Numéro de famille : %d \n",*(nufael+i));
00874       else
00875         fprintf(stdout,"\n  - Numéro de famille : %d \n",0);
00876     }
00877   }
00878 
00879     
00880     free(indexp);
00881     free(connectivite);
00882     free(numele);
00883     free(nufael);
00884     free(nomele);
00885 
00886     return;
00887 }
00888 
00889 
00890 med_int lecture_nombre_mailles_polyedres(const med_idt fid,
00891                                          const char * const nommaa,
00892                                          const med_int numdt,
00893                                          const med_int numit,
00894                                          const med_connectivity_mode typ_con)
00895 {
00896   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00897 
00898   med_int npolyedres = MEDmeshnEntity(fid,nommaa,numdt,numit,
00899                                     MED_CELL,MED_POLYHEDRON,
00900                                     MED_INDEX_FACE,typ_con,&chgt,&trsf);
00901 
00902   EXIT_IF(npolyedres < 0,"lors de la lecture du nombre de mailles polyedre \n",
00903           NULL);
00904   if ( npolyedres > 0 ) npolyedres--; else npolyedres=0;
00905   fprintf(stdout,"- Nombre de mailles de type MED_POLYEDRE : %d \n",
00906           npolyedres);
00907 
00908   return npolyedres;
00909 }
00910 
00911 
00912 void lecture_mailles_polyedres(const med_idt         fid,
00913                                const char * const    nommaa,
00914                                const med_int         numdt,
00915                                const med_int         numit,
00916                                const med_int         npolyedres,
00917                                const med_switch_mode       mode_coo,
00918                                const med_connectivity_mode typ_con)
00919 {
00920   med_int i,j,k;
00921   med_err ret = 0;
00922   med_int taille;
00923   med_int *connectivite;
00924   char    *nomele;
00925   med_int *numele;
00926   med_int *nufael;
00927   med_int *indexf, *indexn;
00928   int ind1,ind2;
00929   char tmp[MED_SNAME_SIZE+1];
00930   med_err ret1,ret2,ret3;
00931   med_int nfa;
00932   med_int nnoe;
00933   med_int nindn;
00934   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00935 
00936 
00937   
00938   taille = MEDmeshnEntity(fid,nommaa,numdt,numit,
00939                           MED_CELL,MED_POLYHEDRON,MED_CONNECTIVITY,typ_con,
00940                           &chgt,&trsf);
00941   EXIT_IF(taille < 0,"lors de la lecture des parametres des mailles polyedres",
00942           NULL);
00943 
00944   nindn = MEDmeshnEntity(fid,nommaa,numdt,numit,
00945                          MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,typ_con,
00946                          &chgt,&trsf);
00947   EXIT_IF(nindn < 0,"lors de la lecture des parametres des mailles polyedres",
00948           NULL);
00949 
00950   
00951   
00952   indexf = (med_int *) malloc(sizeof(med_int)*(npolyedres+1));
00953   EXIT_IF(indexf == NULL,NULL,NULL);
00954   indexn = (med_int *) malloc(sizeof(med_int)*nindn);
00955   EXIT_IF(indexn == NULL,NULL,NULL);
00956   connectivite  = (med_int *) malloc(sizeof(med_int)*taille);
00957   EXIT_IF(connectivite == NULL,NULL,NULL);
00958   numele = (med_int *) malloc(sizeof(med_int)*npolyedres);
00959   EXIT_IF(numele == NULL,NULL,NULL);
00960   nufael = (med_int *) malloc(sizeof(med_int)*npolyedres);
00961   EXIT_IF(nufael == NULL,NULL,NULL);
00962   nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*npolyedres+1);
00963   EXIT_IF(nomele == NULL,NULL,NULL);
00964 
00965   ret = MEDmeshPolyhedronRd(fid,nommaa,numdt,numit,MED_CELL,typ_con,
00966                             indexf,indexn,connectivite);
00967   EXIT_IF(ret < 0,
00968           "lors de la lecture de la connectivite des mailles polyedres",
00969           NULL);
00970 
00971   
00972   ret1 = MEDmeshEntityNameRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,nomele);
00973 
00974   
00975   ret2 = MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,numele);
00976 
00977   
00978   ret3 = MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,nufael);
00979 
00980   if (!structure) {
00981   
00982   fprintf(stdout,"\n\n- Mailles de type MED_POLYEDRE : ");
00983   for (i=0;i<npolyedres;i++) {
00984     fprintf(stdout,"\n >> Maille MED_POLYEDRE %d : \n",i+1);
00985     fprintf(stdout,"\n  - Connectivité : \n");
00986     nfa  = *(indexf+i+1) - *(indexf+i);
00987     
00988     ind1 = *(indexf+i) - 1;
00989     for (j=0;j<nfa;j++) {
00990       if (typ_con == MED_NODAL) {
00991         
00992 
00993         ind2 = *(indexn+ind1+j) - 1;
00994         nnoe = *(indexn+ind1+j+1) - *(indexn+ind1+j);
00995         fprintf(stdout,"   - Face %d : [ ", j+1);
00996         for (k=0;k<nnoe;k++)
00997           printf(" %d ",*(connectivite+ind2+k));
00998         printf(" ] \n");
00999       }
01000       else {
01001         nfa  = *(indexf+i+1) - *(indexf+i);
01002         
01003 
01004         ind1 = *(indexf+i) - 1;
01005         for (j=0;j<nfa;j++)
01006           fprintf(stdout,"   - Face %d de numero : %d et de type %d \n", j+1,
01007                   *(connectivite+ind1+j),*(indexn+ind1+j));
01008       }
01009     }
01010     if (ret1 == 0) {
01011       strncpy(tmp,nomele+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01012       tmp[MED_SNAME_SIZE] = '\0';
01013       fprintf(stdout,"\n  - Nom : %s \n",tmp);
01014     }
01015     if (ret2 == 0)
01016       fprintf(stdout,"\n  - Numero : %d \n",*(numele+i));
01017     if (ret3 >= 0)
01018       fprintf(stdout,"\n  - Numéro de famille : %d \n",*(nufael+i));
01019     else
01020       fprintf(stdout,"\n  - Numéro de famille : %d \n",0);
01021 
01022   }
01023   }
01024 
01025   
01026   free(indexf);
01027   free(indexn);
01028   free(connectivite);
01029   free(numele);
01030   free(nufael);
01031   free(nomele);
01032 
01033   return;
01034 }
01035 
01036 med_int lecture_nombre_faces_standards(const med_idt fid,
01037                                        const char * const nommaa,
01038                                        const med_int numdt,
01039                                        const med_int numit,
01040                                        const med_geometry_type typ_geo,
01041                                        const med_int indice
01042                                        )
01043 {
01044 
01045   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01046 
01047   med_int nfaces = MEDmeshnEntity(fid,nommaa,numdt,numit,
01048                                     MED_DESCENDING_FACE,typ_geo,
01049                                     MED_CONNECTIVITY,MED_DESCENDING,&chgt,&trsf);
01050   EXIT_IF(nfaces < 0,"lors de la lecture du nombre de faces",NULL);
01051 
01052   if ( (indice < (MED_N_FACE_GEO_FIXED_CON-2) ) ||
01053        (indice >= (MED_N_FACE_GEO_FIXED_CON-2) && (nfaces > 0) ) )
01054     fprintf (stdout,"- Nombre de faces de type %s : %d \n",
01055              nomfac[indice],nfaces);
01056 
01057   return nfaces;
01058 }
01059 
01060 void lecture_faces_standard(const med_idt fid,
01061                             const char * const nommaa,
01062                             const med_int numdt,
01063                             const med_int numit,
01064                             const med_int mdim,
01065                             const med_int *const nfaces,
01066                             const med_switch_mode mode_coo)
01067 {
01068   med_int taille;
01069   med_int *connectivite;
01070   char *nomele;
01071   med_int *numele;
01072   med_int *nufael;
01073   med_bool inoele,inuele,inufael;
01074   med_geometry_type typgeo;
01075   med_int i,j;
01076   med_err ret = 0;
01077   char str[MED_SNAME_SIZE+1];
01078   med_int entdim;
01079   med_int nnodes;
01080 
01081   for (i=0;i<MED_N_FACE_GEO_FIXED_CON;i++)
01082     if (nfaces[i] > 0 ) {
01083 
01084       
01085         ret=_MEDgetGeometricParameter(MED_DESCENDING_FACE, typfac[i],&entdim,&nnodes,&taille);
01086       EXIT_IF(ret < 0,"lors de la lecture des caractéristiques des mailles",NULL);
01087 
01088       
01089       connectivite = (med_int*)malloc(sizeof(med_int)*taille*nfaces[i]);
01090       EXIT_IF(connectivite == NULL,NULL,NULL);
01091       nomele = (char*)malloc(sizeof(char)*MED_SNAME_SIZE*nfaces[i]+1);
01092       EXIT_IF(nomele == NULL,NULL,NULL);
01093       numele = (med_int*)malloc(sizeof(med_int)*nfaces[i]);
01094       EXIT_IF(numele == NULL,NULL,NULL);
01095       nufael = (med_int*)malloc(sizeof(med_int)*nfaces[i]);
01096       EXIT_IF(nufael == NULL,NULL,NULL);
01097 
01098       
01099      ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_DESCENDING_FACE,typmai[i],
01100                               MED_DESCENDING, mode_coo, connectivite,
01101                               &inoele,nomele,&inuele,numele,&inufael,nufael );
01102       EXIT_IF(ret < 0,"lors de la lecture des faces",NULL);
01103 
01104       if (!structure) {
01105       
01106       fprintf(stdout,"\n- Faces de type %s : ", nomfac[i]);
01107       fprintf(stdout,"\n  - Connectivité : \n");
01108       for (j=0;j<nfaces[i]*taille;j++) {
01109             if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
01110               fprintf(stdout,"\n [ %5d ] : ", (j/taille+1) );
01111             if (mode_coo == MED_NO_INTERLACE && !(j % nfaces[i]))
01112               fprintf(stdout,"\n");
01113             fprintf(stdout," %9d ",*(connectivite+j));
01114           }
01115 
01116       if (inoele) {
01117         fprintf(stdout,"\n  - Noms : \n");
01118         for (j=0;j<nfaces[i];j++) {
01119           strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01120           str[MED_SNAME_SIZE] = '\0';
01121           fprintf(stdout," %s ",str);
01122         }
01123       }
01124       if (inuele) {
01125         fprintf(stdout,"\n  - Numeros :\n");
01126         for (j=0;j<nfaces[i];j++)
01127           fprintf(stdout," %d ",*(numele+j));
01128       }
01129       fprintf(stdout,"\n  - Numéros de familles : \n");
01130       for (j=0;j<nfaces[i];j++)
01131         if ( inufael )
01132           fprintf(stdout," %d ",*(nufael+j));
01133         else
01134           fprintf(stdout," %d ",0);
01135           }
01136 
01137       
01138       free(connectivite);
01139       free(nomele);
01140       free(numele);
01141       free(nufael);
01142     }
01143 
01144   return;
01145 }
01146 
01147 med_int lecture_nombre_faces_polygones(const med_idt fid,
01148                                        const char * const nommaa,
01149                                        const med_int numdt,
01150                                        const med_int numit)
01151 {
01152 
01153   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01154 
01155   med_int nfpolygones = MEDmeshnEntity(fid,nommaa,numdt,numit,
01156                                        MED_CELL,MED_POLYGON,
01157                                        MED_INDEX_NODE,MED_DESCENDING,&chgt,&trsf);
01158 
01159   EXIT_IF(nfpolygones < 0,"lors de la lecture du nombre de faces polygone \n",
01160           NULL);
01161   nfpolygones--;
01162   fprintf(stdout,"- Nombre de faces de type MED_POLYGONE : %d \n",
01163           nfpolygones);
01164 
01165   return nfpolygones;
01166 }
01167 
01168 void lecture_faces_polygones(const med_idt fid,
01169                              const char * const nommaa,
01170                              const med_int numdt,
01171                              const med_int numit,
01172                              const med_int nfpolygones,
01173                              const med_switch_mode mode_coo)
01174 {
01175   med_int i,j;
01176   med_err ret = 0;
01177   char *nomele;
01178   med_int *numele;
01179   med_int *nufael;
01180   med_int *connectivite;
01181   med_int taille;
01182   med_int *indexp;
01183   int ind1,ind2;
01184   char tmp[MED_NAME_SIZE+1];
01185   med_err ret1,ret2,ret3;
01186   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01187 
01188   
01189   taille=MEDmeshnEntity(fid,nommaa,numdt,numit,
01190                         MED_DESCENDING_FACE,MED_POLYGON,MED_CONNECTIVITY,MED_DESCENDING,
01191                         &chgt,&trsf);
01192   EXIT_IF(taille < 0,"lors de la lecture des parametres des faces polygones",
01193             NULL);
01194 
01195   
01196   indexp = (med_int *) malloc(sizeof(med_int)*(nfpolygones+1));
01197   EXIT_IF(indexp == NULL,NULL,NULL);
01198   connectivite = (med_int *) malloc(sizeof(med_int)*taille);
01199   EXIT_IF(connectivite == NULL,NULL,NULL);
01200   numele = (med_int *) malloc(sizeof(med_int)*nfpolygones);
01201   EXIT_IF(numele == NULL,NULL,NULL);
01202   nufael = (med_int *) malloc(sizeof(med_int)*nfpolygones);
01203   EXIT_IF(nufael == NULL,NULL,NULL);
01204   nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*nfpolygones+1);
01205   EXIT_IF(nomele == NULL,NULL,NULL);
01206 
01207   
01208   ret = MEDmeshPolygonRd(fid,nommaa,numdt,numit,MED_DESCENDING_FACE,MED_DESCENDING,
01209                          indexp,connectivite);
01210   EXIT_IF(ret < 0,"lors de la lecture des connectivites des faces polygones",
01211           NULL);
01212 
01213   
01214   ret1 = MEDmeshEntityNameRd(fid,nommaa,numdt,numit,
01215                              MED_DESCENDING_FACE,MED_POLYGON, nomele);
01216 
01217   
01218   ret2 = (med_int) MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,
01219                                          MED_DESCENDING_FACE, MED_POLYGON, numele);
01220 
01221   
01222   ret3 = MEDmeshEntityFamilyNumberRd(fid, nommaa, MED_NO_DT, MED_NO_IT,
01223                                      MED_DESCENDING_FACE, MED_POLYGON, nufael);
01224 
01225   if (!structure) {
01226   
01227   fprintf(stdout,"\n\n- Faces de type MED_POLYGONE : ");
01228   for (i=0;i<nfpolygones;i++) {
01229     fprintf(stdout,"\n >> Face MED_POLYGONE %d : \n",i+1);
01230     fprintf(stdout,"\n  - Connectivité : ");
01231     ind1 = *(indexp+i)-1;
01232     ind2 = *(indexp+i+1)-1;
01233     for (j=ind1;j<ind2;j++)
01234       fprintf(stdout," %d ",*(connectivite+j));
01235     if (ret1 == 0) {
01236       strncpy(tmp,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01237       tmp[MED_SNAME_SIZE] = '\0';
01238       fprintf(stdout,"\n  - Nom : %s \n",tmp);
01239     }
01240     if (ret2 == 0)
01241       fprintf(stdout,"\n  - Numero : %d \n",*(numele+j));
01242     if ( ret3 > 0 )
01243       fprintf(stdout,"\n  - Numéro de famille : %d \n",*(nufael+i));
01244     else
01245       fprintf(stdout,"\n  - Numéro de famille : %d \n",0);
01246   }
01247   }
01248 
01249   
01250   free(indexp);
01251   free(connectivite);
01252   free(numele);
01253   free(nufael);
01254   free(nomele);
01255 
01256   return;
01257 }
01258 
01259 
01260 med_int lecture_nombre_aretes_standards(const med_idt fid,
01261                                         const char *const  nommaa,
01262                                         const med_int numdt,
01263                                         const med_int numit,
01264                                         const med_geometry_type typ_geo,
01265                                         const med_int indice)
01266 {
01267 
01268   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01269 
01270   med_int naretes = MEDmeshnEntity(fid,nommaa,numdt,numit,
01271                                    MED_DESCENDING_EDGE, typ_geo,
01272                                    MED_CONNECTIVITY,MED_DESCENDING,&chgt,&trsf);
01273   EXIT_IF(naretes < 0,"lors de la lecture du nombre d'aretes",NULL);
01274   if ( (indice < (MED_N_EDGE_GEO_FIXED_CON-1) ) ||
01275        (indice >= (MED_N_EDGE_GEO_FIXED_CON-1) && (naretes > 0) ) )
01276 
01277   fprintf (stdout,
01278            "- Nombre d'aretes de type %s : %d \n",nomare[indice],naretes);
01279 
01280   return naretes;
01281 }
01282 
01283 void lecture_aretes_standards(const med_idt fid,
01284                               const char * const nommaa,
01285                               const med_int numdt,
01286                               const med_int numit,
01287                               const med_int mdim,
01288                               const med_int * const naretes,
01289                               const med_switch_mode mode_coo)
01290 {
01291   med_int taille;
01292   med_int *connectivite;
01293   char    *nomele;
01294   med_int *numele;
01295   med_int *nufael;
01296   med_bool inoele,inuele,inufael;
01297   med_geometry_type typgeo;
01298   med_int i,j;
01299   med_err ret = 0;
01300   char str[MED_SNAME_SIZE+1];
01301   med_int entdim;
01302   med_int nnodes;
01303 
01304   for (i=0;i<MED_N_EDGE_GEO_FIXED_CON;i++)
01305     if (naretes[i] > 0) {
01306 
01307      ret=_MEDgetGeometricParameter(MED_DESCENDING_EDGE, typare[i],&entdim,&nnodes,&taille);
01308       EXIT_IF(ret < 0,"lors de la lecture des caractéristiques des mailles",NULL);
01309 
01310       
01311       connectivite = (med_int*)malloc(sizeof(med_int)*taille*naretes[i]);
01312       EXIT_IF(connectivite == NULL,NULL,NULL);
01313       nomele = (char*)malloc(sizeof(char)*MED_SNAME_SIZE*naretes[i]+1);
01314       EXIT_IF(nomele == NULL,NULL,NULL);
01315       numele = (med_int*)malloc(sizeof(med_int)*naretes[i]);
01316       EXIT_IF(numele == NULL,NULL,NULL);
01317       nufael = (med_int*)malloc(sizeof(med_int)*naretes[i]);
01318       EXIT_IF(nufael == NULL,NULL,NULL);
01319 
01320       
01321       ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_DESCENDING_EDGE,typare[i],
01322                               MED_DESCENDING, mode_coo, connectivite,
01323                               &inoele,nomele,&inuele,numele,&inufael,nufael );
01324       EXIT_IF(ret < 0,"lors de la lecture des aretes",
01325               NULL);
01326 
01327       if (!structure) {
01328       
01329       fprintf(stdout,"\n- Aretes de type %s : ", nomare[i]);
01330       fprintf(stdout,"\n  - Connectivité : \n");
01331       for (j=0;j<naretes[i]*taille;j++) {
01332             if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
01333               fprintf(stdout,"\n [ %5d ] : ", (j/taille+1) );
01334             if (mode_coo == MED_NO_INTERLACE && !(j % naretes[i]))
01335               fprintf(stdout,"\n");
01336             fprintf(stdout," %9d ",*(connectivite+j));
01337           }
01338 
01339       if (inoele) {
01340         fprintf(stdout,"\n  - Noms : \n");
01341         for (j=0;j<naretes[i];j++) {
01342           strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01343           str[MED_SNAME_SIZE] = '\0';
01344           fprintf(stdout," %s ",str);
01345         }
01346       }
01347       if (inuele) {
01348         fprintf(stdout,"\n  - Numeros :\n");
01349         for (j=0;j<naretes[i];j++)
01350           fprintf(stdout," %d ",*(numele+j));
01351       }
01352       fprintf(stdout,"\n  - Numéros de familles : \n");
01353       for (j=0;j<naretes[i];j++)
01354         if ( inufael )
01355           fprintf(stdout," %d ",*(nufael+j));
01356         else
01357           fprintf(stdout," %d ",0);
01358           }
01359 
01360       
01361       free(connectivite);
01362       free(nomele);
01363       free(numele);
01364       free(nufael);
01365     }
01366 
01367   return;
01368 }
01369 
01370 
01371 
01372 
01373 
01374 
01375 
01376 
01377 
01378 
01379 
01380 
01381 
01382 
01383 
01384 
01385 
01386 
01387 void lecture_maillage_non_structure(med_idt fid,
01388                                     const char *nommaa,
01389                                     const med_int numdt,
01390                                     const med_int numit,
01391                                     const med_int mdim,
01392                                     const med_int edim,
01393                                     const med_switch_mode mode_coo,
01394                                     const med_connectivity_mode typ_con,
01395                                     const char * const nomcoo,
01396                                     const char * const unicoo,
01397                                     const med_axis_type *const rep,
01398                                     const int lecture_en_tete_seulement)
01399 {
01400   med_int i;
01401   
01402   med_int nnoe;
01403   med_int nmailles[MED_N_CELL_GEO_FIXED_CON];
01404   med_int nfaces[MED_N_FACE_GEO_FIXED_CON];
01405   med_int naretes[MED_N_EDGE_GEO_FIXED_CON];
01406   
01407   med_int nmpolygones, npolyedres, nfpolygones;
01408   
01409   med_int nfam;
01410   
01411   med_int nequ;
01412   
01413   med_int njnt;
01414 
01415   
01416   nnoe = lecture_nombre_noeuds_maillage_non_structure(fid,nommaa,numdt,numit);
01417 
01418   
01419   
01420   
01421   for (i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
01422     nmailles[i] = lecture_nombre_mailles_standards(fid,nommaa,numdt,numit,typmai[i],
01423                                                    typ_con,i);
01424 
01425   
01426   nmpolygones = lecture_nombre_mailles_polygones(fid,nommaa,numdt,numit,typ_con);
01427 
01428   
01429   npolyedres = lecture_nombre_mailles_polyedres(fid,nommaa,numdt,numit,typ_con);
01430 
01431   
01432   if (typ_con == MED_DESCENDING) {
01433 
01434     
01435     for (i=0;i<MED_N_FACE_GEO_FIXED_CON;i++)
01436       nfaces[i] = lecture_nombre_faces_standards(fid,nommaa,numdt,numit,typfac[i],i);
01437 
01438     
01439     nfpolygones = lecture_nombre_faces_polygones(fid,nommaa,numdt,numit);
01440 
01441     
01442     for (i=0;i<MED_N_EDGE_GEO_FIXED_CON;i++)
01443       naretes[i] = lecture_nombre_aretes_standards(fid,nommaa,numdt,numit,typare[i],i);
01444   }
01445 
01446   
01447   nfam = lecture_nombre_famille(fid,nommaa);
01448 
01449   
01450   nequ = lecture_nombre_equivalence(fid,nommaa);
01451 
01452   
01453   njnt = lecture_nombre_joint(fid,nommaa);
01454 
01455   
01456   if (lecture_en_tete_seulement)
01457     return;
01458 
01459   
01460 
01461 
01462   lecture_noeuds_maillage_non_structure(fid,nommaa,numdt,numit,mdim,edim,nnoe,mode_coo,nomcoo,unicoo,rep);
01463   
01464 
01465 
01466   
01467 
01468 
01469 
01470 
01471 
01472 
01473 
01474 
01475 
01476 
01477   
01478   lecture_mailles_standards(fid,nommaa,numdt,numit,mdim,nmailles,mode_coo,typ_con);
01479   
01480 
01481   if (nmpolygones > 0)
01482     lecture_mailles_polygones(fid,nommaa,numdt,numit,nmpolygones,mode_coo,typ_con);
01483   
01484 
01485   if (npolyedres > 0)
01486     lecture_mailles_polyedres(fid,nommaa,numdt,numit,npolyedres,mode_coo,typ_con);
01487   
01488 
01489   
01490   if (typ_con == MED_DESCENDING) {
01491     lecture_faces_standard(fid,nommaa,numdt,numit,mdim,nfaces,mode_coo);
01492     if (nfpolygones > 0)
01493       lecture_faces_polygones(fid,nommaa,numdt,numit,nfpolygones,mode_coo);
01494   }
01495   
01496 
01497   
01498   if (typ_con == MED_DESCENDING)
01499     lecture_aretes_standards(fid,nommaa,numdt,numit,mdim,naretes,mode_coo);
01500   
01501 
01502   
01503 
01504 
01505   lecture_famille_maillage(fid,nommaa,nfam);
01506   
01507 
01508 
01509   
01510 
01511 
01512   lecture_equivalence_maillage(fid,nommaa,nequ);
01513   
01514 
01515 
01516   
01517 
01518 
01519   lecture_joint_maillage(fid,nommaa,njnt);
01520   
01521 
01522   return;
01523 }
01524 
01525 
01526 void lecture_caracteristiques_grille(const med_idt fid,
01527                                      const char * const nommaa,
01528                                      const med_int numdt,
01529                                      const med_int numit,
01530                                      const med_int mdim,
01531                                      med_int *nind,
01532                                      med_int *nnoe,
01533                                      med_int *nmai,
01534                                      med_grid_type *type)
01535 {
01536   med_err ret = 0;
01537   med_int axe;
01538   med_int *structure_grille;
01539   med_data_type quoi;
01540   med_int j;
01541   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01542 
01543   
01544   ret = MEDmeshGridTypeRd(fid,nommaa,type);
01545   EXIT_IF(ret < 0,"a la lecture du type d'une grille ",NULL);
01546 
01547   switch(*type) {
01548 
01549   case MED_CARTESIAN_GRID :
01550   case MED_POLAR_GRID :
01551     if (*type == MED_CARTESIAN_GRID)
01552       fprintf(stdout,"- Type de grille : MED_GRILLE_CARTESIENNE \n");
01553     else
01554       fprintf(stdout,"- Type de grille : MED_GRILLE_POLAIRE \n");
01555     for (axe=1;axe<=mdim;axe++) {
01556       switch(axe) {
01557 
01558       case 1:
01559         quoi = MED_COORDINATE_AXIS1;
01560         break;
01561 
01562       case 2:
01563         quoi = MED_COORDINATE_AXIS2;
01564         break;
01565 
01566       case 3:
01567         quoi = MED_COORDINATE_AXIS3;
01568         break;
01569       }
01570       nind[axe - 1] = MEDmeshnEntity(fid,nommaa, numdt, numit,
01571                                      MED_NODE, MED_NONE, quoi, MED_NO_CMODE, &chgt, &trsf);
01572 
01573       EXIT_IF(nind[axe - 1] < 0,
01574               "lors de la lecture de la taille d'un indice d'une grille",
01575               NULL);
01576       *nnoe = nind[axe - 1] * (*nnoe);
01577       *nmai = (nind[axe - 1] - 1) * (*nmai);
01578       fprintf(stdout,
01579               "- Taille de l'indice de l'axe %d des coordonnees : %d \n",
01580               axe,nind[axe - 1]);
01581     }
01582     break;
01583 
01584   case MED_CURVILINEAR_GRID:
01585     fprintf(stdout,"- Type de grille : MED_GRILLE_DESTRUCTUREE \n");
01586     *nnoe = MEDmeshnEntity(fid, nommaa, numdt, numit, 
01587                                MED_NODE, MED_NONE, MED_COORDINATE, MED_NO_CMODE, &chgt, &trsf);
01588     EXIT_IF(*nnoe < 0,"lors de la lecture du nombre de noeuds du maillage "
01589             ,nommaa);
01590 
01591     
01592     structure_grille = (med_int *) malloc(sizeof(med_int)*mdim);
01593     EXIT_IF(structure_grille == NULL,NULL,NULL);
01594     
01595 
01596     ret = MEDmeshGridStructRd(fid,nommaa,numdt, numit, structure_grille);
01597     EXIT_IF(ret < 0,"lors de la lecture de la structure de la grille",
01598             NULL);
01599     fprintf(stdout,"- Structure de la grille : [ ");
01600     for (j=0;j<mdim;j++) {
01601       *nmai = (*(structure_grille+j) - 1) * (*nmai);
01602       fprintf(stdout," %d ",*(structure_grille+j));
01603     }
01604     fprintf(stdout," ] \n");
01605     
01606     free(structure_grille);
01607     break;
01608 
01609   MED_UNDEF_GRID_TYPE:
01610   default:
01611     EXIT_IF(-1,"Type de grille non reconnu.",nommaa);
01612 
01613   }
01614 
01615   fprintf(stdout,"- Nombre de noeuds : %d \n",*nnoe);
01616   fprintf(stdout,"- Nombre de mailles : %d \n",*nmai);
01617 
01618   return;
01619 }
01620 
01621 
01622 void lecture_noeuds_maillage_structure(const med_idt fid,
01623                                        const char * const nommaa,
01624                                        const med_int numdt,
01625                                        const med_int numit,
01626                                        const med_int mdim,
01627                                        const med_int edim,
01628                                        const med_int * const nind,
01629                                        const med_int nnoe,
01630                                        const char * const comp,
01631                                        const char * const unit,
01632                                        const med_grid_type type,
01633                                        const med_switch_mode mode_coo)
01634 {
01635   med_err ret = 0;
01636   med_int axe,i,j;
01637   char str[MED_SNAME_SIZE+1];
01638   med_float *coo     = NULL;
01639   med_float *indices = NULL;
01640   med_int   *nufano  = NULL;
01641   med_int   *numnoe  = NULL;
01642   char      *nomnoe  = NULL;
01643   med_bool inufael=MED_FALSE;
01644 
01645   fprintf(stdout,"\n(*************************)\n");
01646   fprintf(stdout,"(* NOEUDS DE LA GRILLE : *)\n");
01647   fprintf(stdout,"(*************************)\n");
01648 
01649   switch(type) {
01650 
01651   case MED_CARTESIAN_GRID :
01652   case MED_POLAR_GRID :
01653     
01654     for (axe = 1; axe<=mdim; axe++) {
01655       
01656       indices = (med_float *) malloc(sizeof(med_float)*nind[axe - 1]);
01657       EXIT_IF(indices == NULL,NULL,NULL);
01658       
01659 
01660       ret = MEDmeshGridIndexCoordinateRd(fid,nommaa,numdt,numit, axe,indices);
01661       EXIT_IF(ret < 0,"lors de la lecture d'un tableau d'indice",
01662               NULL);
01663       fprintf(stdout,"\n - Axe %." xstr(MED_SNAME_SIZE) "s [%." xstr(MED_SNAME_SIZE) "s] : [ ",
01664               &comp[MED_SNAME_SIZE*(axe-1)],&unit[MED_SNAME_SIZE*(axe-1)]);
01665       for (j=0;j<nind[axe - 1];j++)
01666         fprintf(stdout," %f ",*(indices+j));
01667       printf(" ] \n");
01668       
01669       free(indices);
01670     }
01671     break;
01672 
01673   case MED_CURVILINEAR_GRID:
01674     
01675     coo = (med_float *) malloc(sizeof(med_float)*nnoe*edim);
01676     EXIT_IF(coo == NULL,NULL,NULL);
01677     
01678     ret = MEDmeshNodeCoordinateRd(fid,nommaa,numdt,numit, MED_FULL_INTERLACE,coo);
01679 
01680     EXIT_IF(ret < 0,"lors de la lecture des noeuds du maillage",NULL);
01681     
01682     fprintf(stdout,"- Nom des coordonnees : \n");
01683     for (i=0;i<edim;i++) {
01684       strncpy(str,comp+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01685       str[MED_SNAME_SIZE] = '\0';
01686       fprintf(stdout," %s ",str);
01687     }
01688     fprintf(stdout,"\n- Unites des coordonnees : \n");
01689     for (i=0;i<edim;i++) {
01690       strncpy(str,unit+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01691       str[MED_SNAME_SIZE] = '\0';
01692       fprintf(stdout," %s ",str);
01693     }
01694     if (!structure) {
01695     fprintf(stdout,"\n - Coordonnees des noeuds : [ ");
01696     for (j=0;j<nnoe*edim;j++)
01697       fprintf(stdout," %f ",*(coo+j));
01698     fprintf(stdout," ] \n");
01699     }
01700 
01701     
01702     free(coo);
01703     break;
01704 
01705   MED_UNDEF_GRID_TYPE:
01706   default:
01707     EXIT_IF(-1,"Type de grille non reconnu.",nommaa);
01708 
01709   }
01710 
01711   
01712 
01713 
01714 
01715 
01716   
01717   numnoe = (med_int *) malloc(sizeof(med_int)*nnoe);
01718   EXIT_IF(numnoe == NULL,NULL,NULL);
01719   nomnoe = (char*) malloc(MED_SNAME_SIZE*nnoe+1);
01720   EXIT_IF(nomnoe == NULL,NULL,NULL);
01721   nufano = (med_int *) malloc(sizeof(med_int)*nnoe);
01722   EXIT_IF(nufano == NULL,NULL,NULL);
01723 
01724   
01725   ret = MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_NODE,MED_NO_GEOTYPE,nufano);
01726   if (ret < 0) ret=0; else inufael=MED_TRUE;
01727 
01728   EXIT_IF(ret < 0,"lors de la lecture des numeros de familles des noeuds",
01729           NULL);
01730   if (!structure) {
01731   
01732   fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
01733   for (i=0;i<nnoe;i++)
01734     if (inufael)
01735       fprintf(stdout," %d ",*(nufano+i));
01736     else
01737       fprintf(stdout," %d ",0);
01738   fprintf(stdout,"\n");
01739   }
01740 
01741   
01742   if (MEDmeshEntityNameRd(fid,nommaa,numdt,numit,MED_NODE,MED_NO_GEOTYPE,nomnoe) == 0) {
01743     if (!structure) {
01744     fprintf(stdout,"\n- Noms des noeuds : \n");
01745     for (i=0;i<nnoe;i++) {
01746       strncpy(str,nomnoe+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01747       str[MED_SNAME_SIZE] = '\0';
01748       fprintf(stdout," %s ",str);
01749     }
01750     }
01751   }
01752 
01753   
01754   if (MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,MED_NODE,MED_NO_GEOTYPE,numnoe) == 0) {
01755     if (!structure) {
01756     fprintf(stdout,"\n- Numeros des noeuds : \n");
01757     for (i=0;i<nnoe;i++)
01758       fprintf(stdout," %d ",*(numnoe+i));
01759     }
01760   }
01761 
01762   
01763   free(nufano);
01764   free(numnoe);
01765   free(nomnoe);
01766 
01767   return;
01768 }
01769 
01770 
01771 void lecture_mailles_maillage_structure(const med_idt fid,
01772                                         const char * const nommaa,
01773                                         const med_int numdt,
01774                                         const med_int numit,
01775                                         const med_int mdim,
01776                                         const med_int nmai)
01777 
01778 {
01779   med_err ret = 0;
01780   med_int i;
01781   med_int *nufael = NULL;
01782   char    *nomele = NULL;
01783   med_int *numele = NULL;
01784   char str[MED_SNAME_SIZE+1];
01785   
01786   med_geometry_type typgeo;
01787 
01788   fprintf(stdout,"\n(***************************)\n");
01789   fprintf(stdout,"(* ELEMENTS DE LA GRILLE : *)\n");
01790   fprintf(stdout,"(***************************)\n");
01791 
01792   
01793   switch(mdim) {
01794   case 0 :
01795     typgeo = MED_POINT1;
01796     break;
01797   case 1 :
01798     typgeo = MED_SEG2;
01799     break;
01800   case 2 :
01801     typgeo = MED_QUAD4;
01802     break;
01803   default :
01804     typgeo = MED_HEXA8;
01805   }
01806 
01807   
01808 
01809 
01810 
01811 
01812 
01813   
01814   numele = (med_int *) malloc(sizeof(med_int)*nmai);
01815   EXIT_IF(numele == NULL,NULL,NULL);
01816   nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*nmai+1);
01817   EXIT_IF(nomele == NULL,NULL,NULL);
01818   nufael = (med_int *) malloc(sizeof(med_int)*nmai);
01819   EXIT_IF(nufael == NULL,NULL,NULL);
01820 
01821   
01822   ret = MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_CELL,typgeo,nufael);
01823   if (ret < 0)
01824     for (i=0;i<nmai;i++)
01825       *(nufael+i) = 0;
01826 
01827   if (!structure) {
01828   
01829   fprintf(stdout,"\n- Numeros des familles des mailles : \n");
01830   for (i=0;i<nmai;i++)
01831     fprintf(stdout," %d ",*(nufael+i));
01832   fprintf(stdout,"\n");
01833   }
01834 
01835   
01836   if (MEDmeshEntityNameRd(fid,nommaa,numdt,numit,MED_CELL,typgeo,nomele) == 0) {
01837     if (!structure) {
01838     fprintf(stdout,"\n  - Noms : \n");
01839     for (i=0;i<nmai;i++) {
01840           strncpy(str,nomele+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01841           str[MED_SNAME_SIZE] = '\0';
01842           fprintf(stdout," %s ",str);
01843         }
01844         }
01845   }
01846 
01847   
01848   if (MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,MED_CELL,typgeo,numele) == 0) {
01849     if (!structure) {
01850     fprintf(stdout,"\n  - Numeros :\n");
01851     for (i=0;i<nmai;i++)
01852       fprintf(stdout," %d ",*(numele+i));
01853     }
01854   }
01855 
01856   
01857   free(nufael);
01858   free(nomele);
01859   free(numele);
01860 
01861   return;
01862 }
01863 
01864 void lecture_maillage_structure(const med_idt fid,
01865                                 const char * const nommaa,
01866                                 const med_int numdt,
01867                                 const med_int numit,
01868                                 const med_int mdim,
01869                                 const med_int edim,
01870                                 const med_switch_mode mode_coo,
01871                                 const char * const comp,
01872                                 const char * const unit,
01873                                 const int lecture_en_tete_seulement)
01874 {
01875   med_err ret = 0;
01876   
01877   med_int nind[3];
01878   med_int nnoe = 1;
01879   med_int nmai = 1;
01880   
01881   med_grid_type type;
01882   
01883   med_int nfam;
01884   
01885   med_int nequ;
01886   
01887   med_int njnt;
01888 
01889   
01890 
01891 
01892 
01893 
01894   lecture_caracteristiques_grille(fid,nommaa,numdt,numit,mdim,nind,&nnoe,&nmai,&type);
01895 
01896   
01897   nfam = lecture_nombre_famille(fid,nommaa);
01898 
01899   
01900   nequ = lecture_nombre_equivalence(fid,nommaa);
01901 
01902   
01903   njnt = lecture_nombre_joint(fid,nommaa);
01904 
01905   if (lecture_en_tete_seulement)
01906     return ;
01907 
01908   
01909 
01910 
01911   lecture_noeuds_maillage_structure(fid,nommaa,numdt,numit,mdim,edim,nind,nnoe,comp,unit,type,mode_coo);
01912 
01913   
01914 
01915 
01916   lecture_mailles_maillage_structure(fid,nommaa,numdt,numit,mdim,nmai);
01917 
01918   
01919 
01920 
01921   lecture_famille_maillage(fid,nommaa,nfam);
01922 
01923   
01924 
01925 
01926   lecture_equivalence_maillage(fid,nommaa,nequ);
01927 
01928   
01929 
01930 
01931   lecture_joint_maillage(fid,nommaa,njnt);
01932 
01933   return ;
01934 }
01935 
01936 med_err getFieldsOn(const med_idt fid,
01937                     const char * const maillage,
01938                     const med_int mnumdt,
01939                     const med_int mnumit,
01940                     const char * const nomcha,
01941                     const char * const dtunit,
01942                     const med_field_type typcha,
01943                     const med_int ncomp,
01944                     const med_entity_type entite,
01945                     const med_switch_mode stockage,
01946                     const med_int ncstp) {
01947 
01948   int i,j,k,l,m,n,nb_geo=0;
01949   med_int nbpdtnor=0,pflsize,*pflval,ngauss=0,ngauss_maa_ass=0,ngroup,*vale=NULL,nval;
01950   med_int numdt=0,numo=0,_nprofile;
01951   med_int meshnumdt=0,meshnumit=0;
01952   med_float *valr=NULL,dt=0.0;
01953   med_err ret=0;
01954   char pflname [MED_NAME_SIZE+1]="";
01955   char locname [MED_NAME_SIZE+1]="";
01956   char meshname [MED_NAME_SIZE+1]="";
01957   char maa_ass [MED_NAME_SIZE+1]="";
01958   char * lien = NULL;
01959   med_bool localmesh;
01960   med_int nmesh=0;
01961   med_int lnsize=0;
01962   med_geometry_type * type_geo;
01963 
01964   const char * const * AFF;
01965   const char * const * AFF_ENT=MED23FIELD_GET_ENTITY_TYPENAME+1;
01966   switch (entite) {
01967   case MED_NODE :
01968     type_geo = MED23FIELD_GET_NODE_GEOMETRY_TYPE;
01969     nb_geo   = MED_N_NODE_FIXED_GEO;
01970     AFF      = MED23FIELD_GET_NODE_GEOMETRY_TYPENAME;
01971     break;
01972   case  MED_CELL :
01973   case  MED_NODE_ELEMENT :
01974     type_geo = MED23FIELD_GET_CELL_GEOMETRY_TYPE;
01975     nb_geo   = MED_N_CELL_FIXED_GEO;
01976     AFF      = MED23FIELD_GET_CELL_GEOMETRY_TYPENAME;
01977     break;
01978   case  MED_DESCENDING_FACE :
01979     type_geo = MED23FIELD_GET_FACE_GEOMETRY_TYPE;
01980     nb_geo   = MED_N_FACE_FIXED_GEO;
01981     AFF      = MED23FIELD_GET_FACE_GEOMETRY_TYPENAME;
01982     break;
01983   case  MED_DESCENDING_EDGE :
01984     type_geo = MED23FIELD_GET_EDGE_GEOMETRY_TYPE;
01985     nb_geo   = MED_N_EDGE_FIXED_GEO;
01986     AFF      = MED23FIELD_GET_EDGE_GEOMETRY_TYPENAME;
01987     break;
01988   }
01989 
01990   for (k=1;k<=nb_geo;k++) {
01991 
01992     
01993     nbpdtnor = ncstp;
01994     if (nbpdtnor < 1 ) continue;
01995 
01996     for (j=0;j<nbpdtnor;j++) {
01997 
01998       if ( MEDfield23ComputingStepMeshInfo(fid,nomcha,j+1, &numdt, &numo, &dt,
01999                                            &nmesh, maa_ass,&localmesh, &meshnumdt, &meshnumit ) <0) {
02000         MESSAGE("Erreur a la demande d'information sur (pdt,nor) : ");
02001         ISCRUTE(numdt); ISCRUTE(numo);ISCRUTE(nmesh);SSCRUTE(meshname);ISCRUTE_int(localmesh);
02002         ISCRUTE(meshnumdt);ISCRUTE(meshnumit);
02003         ret = -1; continue;
02004       }
02005 
02006       for (i=0;i< nmesh;++i) {
02007 
02008         if ( (_nprofile = MEDfield23nProfile(fid,nomcha,numdt,numo,entite,type_geo[k],i+1,meshname,
02009                                                 pflname,locname   ) ) < 0 ) {
02010           MESSAGE("Erreur a la demande du nombre de profils referencés par le champ : ");
02011           SSCRUTE(nomcha); ISCRUTE(numdt); ISCRUTE(numo);SSCRUTE(meshname);
02012           ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);SSCRUTE(pflname);SSCRUTE(locname);
02013           SSCRUTE(AFF_ENT[(int)entite]);SSCRUTE(AFF[k]);
02014           ret = -1; continue;
02015         };
02016 
02017         for (l=0;l<_nprofile;l++) {
02018 
02019           if ( (nval = MEDfield23nValueWithProfile(fid, nomcha, numdt, numo,  entite, type_geo[k],meshname,
02020                                                    l+1,  USER_MODE, pflname,&pflsize,
02021                                                    locname, &ngauss) ) < 0 ) {
02022             MESSAGE("Erreur a la lecture du nombre de valeurs du champ : ");
02023             SSCRUTE(nomcha);ISCRUTE(numdt);ISCRUTE(numo);SSCRUTE(meshname);
02024             ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
02025             ISCRUTE_int(USER_MODE);
02026             ret = -1; continue;
02027           };
02028           if (!strcmp(meshname,maa_ass) ) ngauss_maa_ass = ngauss;
02029 
02030           if (_nprofile > 1 )
02031             printf("\n  +Pas de Temps n."IFORMAT" (%f) [%s], n. d'ordre "IFORMAT", avec "IFORMAT" valeur(s) par entité.\n",numdt,dt,dtunit,numo,ngauss);
02032           else {
02033             printf("\n  +Pas de Temps n."IFORMAT" (%f) [%s], n. d'ordre "IFORMAT", avec "IFORMAT" pts de gauss sur le maillage par defaut.\n",numdt,dt,dtunit,numo,ngauss_maa_ass);
02034             printf("\tLe maillage par defaut est : |%s|, sur un total de : %i maillages associes\n",  maa_ass, nmesh);
02035           }
02036 
02037           if ( (!strcmp(meshname,maillage)) && (meshnumdt == mnumdt) && (meshnumit == mnumit) ) {
02038 
02039             if (_nprofile > 1 ) {
02040               printf("\t- Il y a "IFORMAT" entités qui portent des valeurs en mode %i. Chaque entite %s\
02041  de type geometrique %s associes au profile |%s| a "IFORMAT" valeurs associées \n",
02042                      nval,USER_MODE,AFF_ENT[(int)entite],AFF[k],pflname,ngauss);
02043               printf("\t- Le maillage associé est |%s|\n",meshname);
02044             } else {
02045               
02046               printf("\t- Il y a %d valeurs en mode %i. Chaque entite %s\
02047  de type geometrique %s associes au maillage |%s| a %i pts de gauss \n",
02048                      nval*ngauss,USER_MODE,AFF_ENT[(int)entite],AFF[k],
02049                      maa_ass,ngauss);
02050             }
02051 
02052             if ( (meshnumdt != MED_NO_DT) || (meshnumit != MED_NO_IT) )
02053               printf("\t- La séquence de calcul utilisée dans le maillage associé |%s| est (numdt,numit) : ("IFORMAT","IFORMAT") \n",meshname,meshnumdt,meshnumit);
02054 
02055             
02056             if ( !localmesh ) {
02057 
02058               if ( (lnsize=MEDlinkInfoByName(fid,maa_ass) ) < 0 )  {
02059               MESSAGE("Erreur a la lecture de la taille du lien : ");
02060               SSCRUTE(maa_ass);
02061               ret = -1;
02062             } else {
02063               lien = (char *)malloc(lnsize*sizeof(char) + 1);
02064               EXIT_IF(lien == NULL,NULL,NULL);
02065 
02066               if ( MEDlinkRd(fid, maa_ass, lien) < 0 )  {
02067                 MESSAGE("Erreur a la lecture du lien : ");
02068                 SSCRUTE(maa_ass);SSCRUTE(lien);
02069                 ret = -1;
02070               } else {
02071                 lien[lnsize] = '\0';
02072                 printf("\tLe maillage |%s| est porte par un fichier distant |%s|\n",maa_ass,lien);
02073               }
02074               free(lien);
02075               }
02076             }
02077 
02078             
02079             if (typcha == MED_FLOAT64) {
02080 
02081               valr = (med_float*) calloc(ncomp*nval*ngauss,sizeof(med_float));
02082               EXIT_IF(valr == NULL,NULL,NULL);
02083 
02084               if (MEDfield23ValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],meshname,
02085                                                USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
02086                                                (unsigned char*) valr) < 0 ) {
02087                 MESSAGE("Erreur a la lecture des valeurs du champ : ");
02088                 SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
02089                 ISCRUTE(numdt);ISCRUTE(numo);
02090                 ret = -1;
02091               }
02092             } else {
02093 
02094               vale = (med_int*) calloc(ncomp*nval*ngauss,sizeof(med_int));
02095               EXIT_IF(vale == NULL,NULL,NULL);
02096 
02097               if (MEDfield23ValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],meshname,
02098                                                USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
02099                                                (unsigned char*) vale) < 0 ) {
02100                 MESSAGE("Erreur a la lecture des valeurs du champ : ");
02101                 SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
02102                 ISCRUTE(numdt);ISCRUTE(numo);
02103                 ret = -1;
02104               }
02105             }
02106 
02107             if ( strlen(locname) && (_nprofile > 1) )
02108               printf("\t- Modèle de localisation des points de Gauss de nom |%s|\n",locname);
02109 
02110             if (entite == MED_NODE_ELEMENT)
02111               ngroup = (type_geo[k] % 100);
02112             else
02113               ngroup = ngauss;
02114 
02115             switch (stockage) {
02116 
02117             case MED_FULL_INTERLACE :
02118               if (!structure) {
02119                 printf("\t- Valeurs :\n\t");
02120                 for (m=0;m<(nval*ngauss)/ngroup;m++) {
02121                   printf("|");
02122                   for (n=0;n<ngroup*ncomp;n++)
02123                     if (typcha == MED_FLOAT64)
02124                       printf(" %f ",*(valr+(m*ngroup*ncomp)+n));
02125                     else
02126                       printf(" "IFORMAT" ",*(vale+(m*ngroup*ncomp)+n));
02127                 }
02128               }
02129               break;
02130 
02131               
02132             case MED_NO_INTERLACE :
02133               if (!structure) {
02134                 printf("\t- Valeurs :\n\t");
02135                 for (m=0;m<ncomp;m++) {
02136                   printf("|");
02137                   for (n=0;n<(nval*ngauss);n++)
02138                     if (typcha == MED_FLOAT64)
02139                       printf(" %f ",*(valr+(m*nval)+n));
02140                     else
02141                       printf(" "IFORMAT" ",*(vale+(m*nval)+n));
02142                 }
02143               }
02144               break;
02145             }
02146 
02147             if (!structure) {
02148               printf("|\n");
02149             }
02150 
02151             if (typcha == MED_FLOAT64) {
02152               if ( valr ) {free(valr);valr = NULL;}}
02153             else
02154               if (vale) { free(vale);vale = NULL; }
02155 
02156             
02157             if (strcmp(pflname,MED_NO_PROFILE) == 0 ) {
02158               printf("\t- Profil : MED_NOPFL\n");
02159               
02160 
02161             } else {
02162               if ( (pflsize = MEDprofileSizeByName(fid,pflname)) <0 )  {
02163                 MESSAGE("Erreur a la lecture du nombre de valeurs du profil : ");
02164                 SSCRUTE(pflname);
02165                 ret = -1; continue;
02166             }
02167 
02168               printf("\t- Profil : |%s| de taille "IFORMAT"\n",pflname,pflsize);
02169 
02170               pflval = (med_int*) malloc(sizeof(med_int)*pflsize);
02171               EXIT_IF(pflval == NULL,NULL,NULL);
02172               if ( MEDprofileRd(fid,pflname,pflval) <0) {
02173                 MESSAGE("Erreur a la lecture des valeurs du profil : ");
02174                 SSCRUTE(pflname);
02175                 ret = -1;
02176               }
02177               if (!structure) {
02178                 printf("\t");
02179                 for (m=0;m<pflsize;m++) printf(" "IFORMAT" ",*(pflval+m));
02180                 printf("\n");
02181               }
02182               free(pflval);
02183             }
02184           }
02185         }
02186       }
02187     }
02188   } 
02189 
02190   return ret;
02191 }
02192 
02193 
02194 
02195 
02196 
02197 
02198 
02199 
02200 
02201 
02202 
02203 
02204 
02205 
02206 
02207 void lecture_resultats(const med_idt fid,
02208                        const char * const    maillage,
02209                        const med_int mnumdt,
02210                        const med_int mnumit,
02211                        const med_switch_mode mode_coo,
02212                        const int lecture_en_tete_seulement)
02213 {
02214   med_err ret,lret;
02215   char pflname[MED_NAME_SIZE+1]="",nomlien[MED_NAME_SIZE+1]="";
02216   char *lien = NULL;
02217   char *comp, *unit;
02218   char nomcha  [MED_NAME_SIZE+1]="";
02219   char locname [MED_NAME_SIZE+1]="";
02220   med_int mdim,ncomp,ncha,npro,nln,pflsize,*pflval,nval,nloc,ngauss;
02221   med_field_type typcha;
02222   med_mesh_type type;
02223   int t1,t2,t3;
02224   med_geometry_type type_geo;
02225   med_float *refcoo, *gscoo, *wg;
02226   int i,j;
02227 
02228   char     nommaa[MED_NAME_SIZE+1]="";
02229   med_bool localmaa = MED_FALSE;
02230   char     dtunit[MED_SNAME_SIZE+1]="";
02231   med_int  ncstp=0;
02232 
02233   med_int locsdim=0;
02234   char    geointerpname       [MED_NAME_SIZE+1]="";
02235   char    ipointstructmeshname[MED_NAME_SIZE+1]="";
02236   med_int nsectionmeshcell = 0;
02237   med_geometry_type sectiongeotype;
02238 
02239   if (! lecture_en_tete_seulement) {
02240     fprintf(stdout,"\n(************************)\n");
02241     fprintf(stdout,"(* CHAMPS DU MAILLAGE : *)\n");
02242     fprintf(stdout,"(************************)\n");
02243   }
02244 
02245   
02246   ncha = MEDnField(fid);
02247   EXIT_IF(ncha < 0,"lors de la lecture du nombre de champs",NULL);
02248   fprintf(stdout,"- Nombre de champs : %d \n",ncha);
02249 
02250   if (lecture_en_tete_seulement)
02251     return;
02252 
02253   
02254 
02255 
02256   ret = 0;
02257 
02258   
02259   for (i =0;i<ncha;i++) {
02260     lret = 0;
02261     printf("\nChamp numero : |%d| \n",i+1);
02262 
02263     
02264     if ((ncomp = MEDfieldnComponent(fid,i+1)) < 0) {
02265       MESSAGE("Erreur à la lecture du nombre de composantes : ");
02266       ISCRUTE(ncomp);
02267       ret = -1; continue;
02268     }
02269 
02270     
02271 
02272     comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
02273     EXIT_IF(comp == NULL,NULL,NULL);
02274     unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
02275     EXIT_IF(unit == NULL,NULL,NULL);
02276 
02277     if ( MEDfieldInfo(fid, i+1, nomcha, nommaa, &localmaa,
02278                      &typcha, comp, unit, dtunit, &ncstp) < 0 ) {
02279       MESSAGE("Erreur à la demande d'information sur les champs : ");
02280       ret = -1; continue;
02281     }
02282 
02283     printf("Nom du champ : |%s| de type |%d|\n",nomcha,typcha);
02284     printf("Nom des composantes : |%s|\n",comp);
02285     printf("Unites des composantes : |%s| \n",unit);
02286     
02287 
02288 
02289 
02290 
02291 
02292     free(comp);
02293     free(unit);
02294     
02295     
02296     lret = getFieldsOn(fid, maillage, mnumdt, mnumit, nomcha, dtunit, typcha, ncomp, MED_NODE,mode_coo, ncstp);
02297     
02298     
02299     if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nomcha, dtunit, typcha, ncomp, MED_CELL,mode_coo, ncstp);
02300     else { MESSAGE("Erreur à la lecture des champs aux noeuds "); ret = -1; continue;}
02301    
02302     if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nomcha, dtunit, typcha, ncomp, MED_DESCENDING_FACE,mode_coo, ncstp);
02303     else { MESSAGE("Erreur à la lecture des champs aux mailles "); ret = -1; continue;}
02304    
02305     if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nomcha, dtunit, typcha, ncomp, MED_DESCENDING_EDGE,mode_coo, ncstp);
02306     else {MESSAGE("Erreur à la lecture des champs aux faces "); ret = -1; continue;}
02307     
02308     if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nomcha, dtunit, typcha, ncomp, MED_NODE_ELEMENT,mode_coo, ncstp);
02309     else {MESSAGE("Erreur a la lecture des champs aux aretes "); ret = -1; continue;}
02310     
02311     if  (lret != 0) {MESSAGE("Erreur a la lecture des champs aux noeuds des mailles "); ret = -1;};
02312   }
02313 
02314 
02315   
02316   npro = MEDnProfile(fid);
02317 
02318   printf("\nNombre de profils stockes : "IFORMAT"\n\n",npro);
02319   for (i=1 ; i <= npro ; i++ ) {
02320     if ( MEDprofileInfo(fid, i, pflname, &nval) < 0)  {
02321       MESSAGE("Erreur a la demande d'information sur le profil n° : "); ISCRUTE_int(i);
02322       ret = -1;continue;
02323     }
02324     printf("\t- Profil n°%i de nom |%s| et de taille "IFORMAT"\n",i,pflname,nval);
02325     pflval = (med_int*) malloc(sizeof(med_int)*nval);
02326     if ( MEDprofileRd(fid, pflname, pflval) < 0) {
02327       MESSAGE("Erreur a la lecture des valeurs du profil : ");
02328       SSCRUTE(pflname);
02329       ret = -1;
02330     } else {
02331       printf("\t");
02332       for (j=0;j<nval;j++) printf(" "IFORMAT" ",*(pflval+j));
02333       printf("\n\n");
02334     }
02335     free(pflval);
02336   }
02337 
02338   
02339   nln = MEDnLink(fid);
02340 
02341   printf("\nNombre de liens stockes : "IFORMAT"\n\n",nln);
02342   for (i=1 ; i <= nln ; i++ ) {
02343     if ( MEDlinkInfo(fid, i, nomlien, &nval) < 0)  {
02344       MESSAGE("Erreur a la demande d'information sur le lien n° : "); ISCRUTE_int(i);
02345       ret = -1;continue;
02346     }
02347     printf("\t- Lien n°%i de nom |%s| et de taille "IFORMAT"\n",i,nomlien,nval);
02348 
02349     lien = (char * ) malloc((nval+1)*sizeof(char));
02350     EXIT_IF(lien == NULL,NULL,NULL);
02351 
02352     if ( MEDlinkRd(fid, nomlien, lien ) < 0 )  {
02353       MESSAGE("Erreur a la lecture du lien : ");
02354       SSCRUTE(nomlien);SSCRUTE(lien);
02355       ret = -1;
02356     } else {
02357       lien[nval] = '\0';
02358       printf("\t\t|%s|\n\n",lien);
02359     }
02360     free(lien);
02361   }
02362 
02363   
02364   nloc = MEDnLocalization(fid);
02365 
02366   printf("\nNombre de localisations stockees : "IFORMAT"\n\n",nloc);
02367   for (i=1 ; i <= nloc ; i++ ) {
02368     if ( MEDlocalizationInfo(fid, i, locname, &type_geo, &locsdim,&ngauss,
02369                              geointerpname, ipointstructmeshname,&nsectionmeshcell,
02370                              §iongeotype) < 0)  {
02371       MESSAGE("Erreur a la demande d'information sur la localisation n° : "); ISCRUTE_int(i);
02372       ret = -1;continue;
02373     }
02374     printf("\t- Loc. n°%i de nom |%s| de dimension "IFORMAT" avec "IFORMAT" pts de GAUSS \n",i,locname,locsdim,ngauss);
02375     t1 = (type_geo%100)*(type_geo/100);
02376     t2 = ngauss*(type_geo/100);
02377     t3 = ngauss;
02378     refcoo = (med_float *) malloc(sizeof(med_float)*t1 );
02379     gscoo  = (med_float *) malloc(sizeof(med_float)*t2 );
02380     wg     = (med_float *) malloc(sizeof(med_float)*t3 );
02381 
02382     if ( MEDlocalizationRd(fid, locname, mode_coo, refcoo, gscoo, wg  ) < 0) {
02383       MESSAGE("Erreur a la lecture des valeurs de la localisation : ");
02384       SSCRUTE(locname);
02385       ret = -1;
02386     } else {
02387       printf("\t  Coordonnees de l'element de reference de type %i :\n\t\t",type_geo);
02388       for (j=0;j<t1;j++) printf(" %f ",*(refcoo+j));
02389       printf("\n");
02390       printf("\t  Localisation des points de GAUSS : \n\t\t");
02391       for (j=0;j<t2;j++) printf(" %f ",*(gscoo+j));
02392       printf("\n");
02393       printf("\t  Poids associes aux points de GAUSS :\n\t\t");
02394       for (j=0;j<t3;j++) printf(" %f ",*(wg+j));
02395       printf("\n\n");
02396     }
02397     free(refcoo);
02398     free(gscoo);
02399     free(wg);
02400   }
02401 
02402   return;
02403 }
02404 
02405 
02406 
02407 
02408 
02409 
02410 
02411 
02412 
02413 
02414 
02415 
02416 void lecture_parametres_scalaires(med_idt fid,
02417                                   int lecture_en_tete_seulement)
02418 {
02419   med_err ret = 0;
02420   char nom_scalaire[MED_NAME_SIZE+1];
02421   char description[MED_COMMENT_SIZE+1];
02422   med_int vali;
02423   med_float valr;
02424   med_int i,n,npdt,j;
02425   med_parameter_type  type;
02426   med_int numdt,numo;
02427   med_float dt;
02428   char dt_unit[MED_SNAME_SIZE+1];
02429 
02430   fprintf(stdout,"\n(*******************************)\n");
02431   fprintf(stdout,"(* VARIABLES SCALAIRES       : *)\n");
02432   fprintf(stdout,"(*******************************)\n");
02433 
02434   
02435   n = MEDnParameter(fid);
02436   EXIT_IF(n < 0,"lors de la lecture du nombre de scalaires",NULL);
02437   fprintf(stdout,"- Nombre de variables scalaires : %d\n",n);
02438 
02439   if (lecture_en_tete_seulement)
02440     return ;
02441 
02442   for (i=1;i<=n;i++) {
02443 
02444     
02445     ret = MEDparameterInfo( fid,i,nom_scalaire,&type,description,
02446                             dt_unit, &npdt );
02447     EXIT_IF(ret < 0,"lors de la lecture des parametres d'un scalaire",NULL);
02448     fprintf(stdout,"- Scalaire n°%d de nom %s \n",i,nom_scalaire);
02449     if (type == MED_FLOAT64)
02450       fprintf(stdout,"  Type flottant. \n");
02451     else
02452       fprintf(stdout,"  Type entier. \n");
02453     printf("  Description associee : [%s] \n",description);
02454 
02455     
02456 
02457     EXIT_IF(npdt < 0,
02458             "lors de la lecture du nombre de pas de temps d'un scalaire"
02459             ,NULL);
02460     fprintf(stdout,"   Nombre de valeurs stockees : %d \n",npdt);
02461 
02462     for (j=1;j<=npdt;j++) {
02463 
02464       ret = MEDparameterComputationStepInfo(fid,nom_scalaire,j, &numdt,&numo,&dt);
02465       EXIT_IF(ret < 0,
02466               "lors de la lecture des parametres d'un pas de temps d'un scalaire",
02467               NULL);
02468 
02469       if (numdt == MED_NO_DT)
02470         fprintf(stdout,"   - Aucun de pas de temps \n");
02471       else
02472         fprintf(stdout,
02473                 "   - Pas de de temps de numero %d de valeur %f [%s] \n",numdt,
02474                dt,dt_unit);
02475       if (numo == MED_NO_IT)
02476         fprintf(stdout,"   - Aucun numero d'ordre \n");
02477       else
02478         fprintf(stdout,"   - Numero d'ordre : %d \n",numo);
02479 
02480       if (type == MED_FLOAT64) {
02481         ret = MEDparameterValueRd(fid,nom_scalaire,numdt,numo,(unsigned char * ) &valr);
02482         fprintf(stdout,"   - Valeur : %f \n",valr);
02483       }
02484       else {
02485         ret = MEDparameterValueRd(fid,nom_scalaire,numdt,numo,(unsigned char * ) &vali);
02486         fprintf(stdout,"   - Valeur : %d \n",vali);
02487       }
02488       EXIT_IF(ret < 0,"lors de la lecture de la valeur d'un scalaire",NULL);
02489 
02490     }
02491   }
02492 
02493   return ;
02494 }
02495 
02496 med_idt ouverture_fichier_MED(char *fichier)
02497 {
02498   med_idt fid;
02499   med_err ret = 0;
02500   med_int majeur,mineur,release;
02501   med_bool    hdfok;
02502   med_bool    medok;
02503 
02504   
02505   ret = (int) access(fichier,F_OK);
02506   EXIT_IF(ret < 0,"Le fichier n'est pas accessible ou n'existe pas ",
02507           fichier);
02508 
02509   
02510   ret = MEDfileCompatibility (fichier,&hdfok, &medok );
02511   EXIT_IF(ret < 0,"Impossible de déterminer la compatibilité de format. ",
02512           fichier);
02513 
02514   EXIT_IF(!hdfok,"Le fichier n'est pas dans un format HDF compatible ", fichier);
02515   EXIT_IF(!medok,"Le fichier n'est pas dans un format MED compatible ", fichier);
02516 
02517   
02518   MEDlibraryNumVersion(&majeur,&mineur,&release);
02519   fprintf(stdout,
02520           "- Lecture du fichier à l'aide de la bibliotheque MED V%d.%d.%d \n",
02521           majeur,mineur,release);
02522 
02523   
02524   fid = MEDfileOpen(fichier,MED_ACC_RDONLY);
02525   EXIT_IF( fid < 0,"Ouverture du du fichier ",fichier);
02526 
02527   MEDfileNumVersionRd(fid, &majeur, &mineur, &release);
02528   EXIT_IF(( (majeur < 2) || ( (majeur == 2) && (mineur < 2)) ), "Le fichier est antérieur à la version 2.2", NULL);
02529 
02530   return fid;
02531 }
02532 
02533 void lecture_en_tete(med_idt fid,char* fichier)
02534 {
02535   char fichier_en_tete[MED_COMMENT_SIZE+1];
02536   med_err ret = 0;
02537 
02538   
02539   
02540   ret = MEDfileCommentRd(fid,fichier_en_tete);
02541 
02542   
02543   if (ret >= 0)
02544     fprintf(stdout,"- En-tete du fichier : %s \n",fichier_en_tete);
02545 
02546   return;
02547 }
02548 
02549 void parametrage(med_switch_mode *mode_coo,
02550                  med_connectivity_mode *typ_con)
02551 {
02552   int reponse;
02553 
02554   fprintf(stdout,"(*****************)\n");
02555   fprintf(stdout,"(* PARAMETRAGE : *)\n");
02556   fprintf(stdout,"(*****************)\n");
02557   fprintf(stdout,"- Mode d'affichage des coordonnées des noeuds ? \n");
02558   fprintf(stdout,"  1. Mode entrelacé : taper 1 \n");
02559   fprintf(stdout,"  2. Mode non entrelacé : taper 2 \n");
02560   reponse = 0;
02561   do {
02562     fprintf(stdout,"  Reponse : ");
02563     scanf("%d",&reponse);
02564   } while (reponse != 1 && reponse != 2);
02565   if (reponse == 1)
02566     *mode_coo = MED_FULL_INTERLACE;
02567   else
02568     *mode_coo = MED_NO_INTERLACE;
02569 
02570   fprintf(stdout,"- Connectivité des éléments ? \n");
02571   fprintf(stdout,"  1. Nodale : taper 1 \n");
02572   fprintf(stdout,"  2. Descendante : taper 2 \n");
02573   reponse = 0;
02574   do {
02575     fprintf(stdout,"  Reponse : ");
02576     scanf("%d",&reponse);
02577   } while (reponse != 1 && reponse != 2);
02578   if (reponse == 1)
02579     *typ_con = MED_NODAL;
02580   else
02581     *typ_con = MED_DESCENDING;
02582 
02583   return;
02584 }
02585 
02586 
02587 void lecture_information_maillage(const med_idt fid,
02588                                   const int numero,
02589                                   char *          nommaa,
02590                                   med_int * const mdim,
02591                                   med_int * const edim,
02592                                   med_mesh_type * const type_maillage,
02593                                   char * const maillage_description,
02594                                   med_int * const nstep,
02595                                   char    * const dtunit,
02596                                   char    * const nomcoo,
02597                                   char    * const unicoo,
02598                                   med_axis_type *const rep)
02599 {
02600   char nom_universel[MED_LNAME_SIZE+1];
02601   med_err ret = 0;
02602   med_sorting_type sortingtype;
02603 
02604   fprintf(stdout,"\n(********************************************)\n");
02605   fprintf(stdout,"(* INFORMATIONS GENERALES SUR LE MAILLAGE : *)\n");
02606   fprintf(stdout,"(********************************************)\n");
02607 
02608   
02609   ret = MEDmeshInfo(fid, numero,nommaa,edim,mdim,type_maillage,maillage_description,
02610                     dtunit,&sortingtype,nstep,rep,nomcoo,unicoo);
02611   EXIT_IF(ret < 0,"Lecture des informations sur le maillage",NULL);
02612 
02613   
02614   fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
02615   fprintf(stdout,"- Dimension du maillage : "IFORMAT"\n",*mdim);
02616   if (*edim > *mdim)
02617     fprintf(stdout,"- La dimension de l'espace est "IFORMAT" \n",*edim);
02618   if (*type_maillage == MED_UNSTRUCTURED_MESH)
02619     fprintf(stdout,"- Type du maillage : MED_NON_STRUCTURE \n");
02620   else
02621     fprintf(stdout,"- Type du maillage : MED_STRUCTURE \n");
02622   fprintf(stdout,"- Description associee au maillage : %s\n",
02623           maillage_description);
02624 
02625   if ( *nstep > 1 )
02626     fprintf(stdout,"- Nombre d'étapes de calcul associées au maillage : "IFORMAT"\n",
02627             *nstep);
02628   if (strlen(dtunit))
02629     fprintf(stdout,"- Unité des dates d'étapes de calcul associées au maillage : %s\n",
02630             dtunit);
02631 
02632  
02633   ret = MEDmeshUniversalNameRd(fid,nommaa,nom_universel);
02634   if (ret == 0)
02635    fprintf(stdout,"- Nom universel du maillage : %s \n",nom_universel);
02636 
02637  return;
02638 }
02639 
02640 
02641 
02642 
02643 
02644 
02645 
02646 
02647 
02648 
02649 
02650 int main (int argc, char **argv)
02651 {
02652   med_err ret = 0;
02653   med_idt fid;
02654   int numero;
02655   med_switch_mode mode_coo;
02656   med_connectivity_mode typ_con;
02657   int lecture_en_tete_seulement = 0;
02658   med_int mdim,nmaa;
02659   
02660   char nommaa[MED_NAME_SIZE+1];
02661   char maillage_description[MED_COMMENT_SIZE+1];
02662   med_mesh_type type_maillage;
02663   med_int edim;
02664   int decalage;
02665   char nomcoo[3*MED_SNAME_SIZE+1]="";
02666   char unicoo[3*MED_SNAME_SIZE+1]="";
02667   char dtunit[MED_SNAME_SIZE+1]="";
02668   med_int   nstep=0,numdt=MED_NO_DT,numit=MED_NO_IT;
02669   int       csit=0;
02670   med_float dt=0.0;
02671   med_axis_type  rep;
02672   
02673 
02674 
02675 
02676 
02677   structure = 0;
02678   decalage = 0;
02679   if (argc > 2 && strcmp(argv[1], "--structure") == 0) {
02680     argc--;
02681     decalage = 1;
02682     structure = 1;
02683   }
02684 
02685   EXIT_IF(argc != 2 && argc != 5,"nombre de parametres incorrects\n",NULL);
02686 
02687 
02688   
02689 
02690 
02691   fid = ouverture_fichier_MED(argv[1 + decalage]);
02692 
02693 
02694   
02695 
02696 
02697 
02698 
02699   fprintf(stdout,"\n >>>>>> DUMP DU FICHIER %s >>>>>>\n",argv[1 + decalage]);
02700 
02701   
02702   lecture_en_tete(fid,argv[1 + decalage]);
02703 
02704 
02705   if (argc == 2)
02706     parametrage(&mode_coo,&typ_con);
02707   else {
02708     if (! strcmp(argv[3 + decalage],"NODALE"))
02709       typ_con = MED_NODAL;
02710     if (! strcmp(argv[3 + decalage],"DESCENDANTE"))
02711       typ_con = MED_DESCENDING;
02712 
02713     if (!strcmp(argv[4 + decalage],"NO_INTERLACE"))
02714       mode_coo = MED_NO_INTERLACE;
02715     if (!strcmp(argv[4 + decalage],"FULL_INTERLACE"))
02716       mode_coo = MED_FULL_INTERLACE;
02717     if (! strcmp(argv[4 + decalage],"LECTURE_EN_TETE_SEULEMENT"))
02718       lecture_en_tete_seulement = 1;
02719   }
02720 
02721 
02722   
02723 
02724 
02725   nmaa = MEDnMesh(fid);
02726 
02727 
02728   EXIT_IF(nmaa < 0,"lors de la lecture du nombre de maillages",NULL);
02729 
02730   
02731   if (argc == 2) {
02732     fprintf(stdout,"- Il y a %d maillages dans ce fichier \n",nmaa);
02733     fprintf(stdout,"  Lequel voulez-vous lire (1|2|3|...|n) ?\n");
02734     do {
02735       fprintf(stdout,"  Reponse : ");
02736       scanf("%d",&numero);
02737     } while ( (numero > nmaa) || (numero <= 0) );
02738   }
02739   else {
02740     numero = atoi(argv[2 + decalage]);
02741     EXIT_IF(numero > nmaa || numero <= 0,"ce numero de maillage n'existe pas",
02742             NULL);
02743   }
02744 
02745   
02746 
02747 
02748 
02749   
02750   lecture_parametres_scalaires(fid,lecture_en_tete_seulement);
02751 
02752 
02753   
02754 
02755 
02756   lecture_information_maillage(fid,numero,nommaa,&mdim,&edim,&type_maillage,
02757                                maillage_description,&nstep,dtunit,nomcoo,unicoo,&rep);
02758 
02759 
02760   for (csit=1; csit <= nstep; ++csit) {
02761 
02762     ret = MEDmeshComputationStepInfo(fid, nommaa, csit, &numdt, &numit, &dt);
02763     EXIT_IF(ret < 0,"lors de l'appel à MEDmeshComputationStepInfo",NULL);
02764 
02765  
02766 
02767 
02768 
02769 
02770       if (type_maillage == MED_UNSTRUCTURED_MESH)
02771         lecture_maillage_non_structure(fid,nommaa,numdt,numit,mdim,edim,mode_coo,typ_con,
02772                                        nomcoo,unicoo,&rep,lecture_en_tete_seulement);
02773       else {
02774         lecture_maillage_structure(fid,nommaa,numdt,numit,mdim,edim,mode_coo,
02775                                    nomcoo,unicoo,lecture_en_tete_seulement);
02776 
02777       }
02778 
02779       
02780       lecture_resultats(fid,nommaa,numdt,numit,mode_coo,lecture_en_tete_seulement);
02781 
02782 
02783   }
02784 
02785  
02786 
02787 
02788  ret = MEDfileClose(fid);
02789  EXIT_IF(ret < 0,"lors de la fermeture du fichier",argv[1 + decalage]);
02790 
02791  fprintf(stdout,"\n >>>>>> FIN DU DUMP DU FICHIER %s >>>>>>\n",argv[1 + decalage]);
02792 
02793  return EXIT_SUCCESS;
02794 }