c/test3.c
#include <med.h>
#define MESGERR 1
#include "med_utils.h"
#include <string.h>
#ifdef DEF_LECT_ECR
#define MODE_ACCES MED_ACC_RDWR
#elif DEF_LECT_AJOUT
#define MODE_ACCES MED_ACC_RDEXT
#else
#define MODE_ACCES MED_ACC_CREAT
#endif
int main (int argc, char **argv)
{
  med_err ret = 0;
  med_idt fid = 0;
  med_int nmaa=0,mdim=0,sdim=0,nstep=0;
  int i=0;
  
  char *maa   ;
  char *nomu  ;
  char *des   ;
  char *dtunit;
  char *axisname=0,*axisunit=0;
  med_mesh_type     meshtype;
  med_err           inomu;
  med_sorting_type  sortingtype;
  med_axis_type     axistype;
  
  maa    = (char *) malloc(sizeof(char)*(MED_NAME_SIZE+1   ));
  nomu   = (char *) malloc(sizeof(char)*(MED_LNAME_SIZE+1  ));
  des    = (char *) malloc(sizeof(char)*(MED_COMMENT_SIZE+1));
  dtunit = (char *) malloc(sizeof(char)*(MED_SNAME_SIZE+1  ));
  
  fid = MEDfileOpen("test2.med",MED_ACC_RDONLY);
  if (fid < 0) {
    MESSAGE("Erreur a l'ouverture du fichier test2.med");
    return -1;
  }
  
  nmaa = MEDnMesh(fid);
  if (nmaa < 0) {
    MESSAGE("Erreur a la lecture du nombre de maillage");
    return  -1;
  }
  
  printf("- Nombre de maillage dans test2.med = "IFORMAT"\n",nmaa);
  for (i=0;i< nmaa;i++) {
    
    if ((sdim=MEDmeshnAxis(fid, i+1)) <0) {
      MESSAGE("Erreur a la lecture de la dimension de l'espace du maillage :");
      SSCRUTE(maa);
      ret = -1;
    }
    axisname  = (char*) malloc(MED_SNAME_SIZE*sdim+1);
    axisunit  = (char*) malloc(MED_SNAME_SIZE*sdim+1);
    if (MEDmeshInfo(fid,i+1, maa, &sdim, &mdim,  &meshtype, des, dtunit, &sortingtype, &nstep,
                    &axistype, axisname, axisunit) < 0) {
      MESSAGE("Erreur a la lecture des informations du maillage :"); SSCRUTE(maa);
      ret = -1;
    }
    
    inomu = MEDmeshUniversalNameRd(fid,maa,nomu);
    
    if (inomu < 0)
      printf("maillage %d de nom %s, de dimension "IFORMAT" \n",i+1,maa,mdim);
    else
      printf("maillage %d de nom %s, de dimension "IFORMAT" et de nom univ. %s\n",i+1,maa,mdim,nomu);
    printf("La dimension de l'espace est "IFORMAT" \n",sdim);
    if (meshtype == MED_STRUCTURED_MESH)
      printf("Il s'agit d'un maillage structure \n");
    else
      printf("Il s'agit d'un maillage non structure \n");
    printf("Description associee au maillage : %s \n\n",des);
    printf("\t -Noms des axes : %s\n",  axisname);
    printf("\t -Unités des axes : %s\n",axisunit);
    printf("\t -Type de repère : %d\n", axistype);
    printf("\t -Nombre d'étape de calcul : "IFORMAT"\n",nstep);
    printf("\t -Unité des dates : %s\n",dtunit);
    free(axisname);
    free(axisunit);
  }
  free(  maa    );
  free(  nomu   );
  free(  des    );
  free(  dtunit );
  
  if ( MEDfileClose(fid) < 0) {
    MESSAGE("Erreur a la fermeture du fichier test2.med");
    return -1;
  }
  return ret;
}