test3.c
Aller à la documentation de ce fichier.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 #include <med.h>
00027 #define MESGERR 1
00028 #include "med_utils.h"
00029 #include <string.h>
00030 
00031 #ifdef DEF_LECT_ECR
00032 #define MODE_ACCES MED_ACC_RDWR
00033 #elif DEF_LECT_AJOUT
00034 #define MODE_ACCES MED_ACC_RDEXT
00035 #else
00036 #define MODE_ACCES MED_ACC_CREAT
00037 #endif
00038 
00039 int main (int argc, char **argv)
00040 
00041 
00042 {
00043   med_err ret = 0;
00044   med_idt fid = 0;
00045   med_int nmaa=0,mdim=0,sdim=0,nstep=0;
00046   int i=0;
00047   
00048 
00049 
00050 
00051 
00052   char *maa   ;
00053   char *nomu  ;
00054   char *des   ;
00055   char *dtunit;
00056   char *axisname=0,*axisunit=0;
00057   med_mesh_type     meshtype;
00058   med_err           inomu;
00059   med_sorting_type  sortingtype;
00060   med_axis_type     axistype;
00061 
00062   
00063   maa    = (char *) malloc(sizeof(char)*(MED_NAME_SIZE+1   ));
00064   nomu   = (char *) malloc(sizeof(char)*(MED_LNAME_SIZE+1  ));
00065   des    = (char *) malloc(sizeof(char)*(MED_COMMENT_SIZE+1));
00066   dtunit = (char *) malloc(sizeof(char)*(MED_SNAME_SIZE+1  ));
00067 
00068   
00069   fid = MEDfileOpen("test2.med",MED_ACC_RDONLY);
00070   if (fid < 0) {
00071     MESSAGE("Erreur a l'ouverture du fichier test2.med");
00072     return -1;
00073   }
00074 
00075   
00076   nmaa = MEDnMesh(fid);
00077   if (nmaa < 0) {
00078     MESSAGE("Erreur a la lecture du nombre de maillage");
00079     return  -1;
00080   }
00081 
00082 
00083   
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091   printf("- Nombre de maillage dans test2.med = "IFORMAT"\n",nmaa);
00092 
00093   for (i=0;i< nmaa;i++) {
00094     
00095 
00096     if ((sdim=MEDmeshnAxis(fid, i+1)) <0) {
00097       MESSAGE("Erreur a la lecture de la dimension de l'espace du maillage :");
00098       SSCRUTE(maa);
00099       ret = -1;
00100     }
00101     axisname  = (char*) malloc(MED_SNAME_SIZE*sdim+1);
00102     axisunit  = (char*) malloc(MED_SNAME_SIZE*sdim+1);
00103 
00104     if (MEDmeshInfo(fid,i+1, maa, &sdim, &mdim,  &meshtype, des, dtunit, &sortingtype, &nstep,
00105                     &axistype, axisname, axisunit) < 0) {
00106       MESSAGE("Erreur a la lecture des informations du maillage :"); SSCRUTE(maa);
00107       ret = -1;
00108     }
00109     
00110     inomu = MEDmeshUniversalNameRd(fid,maa,nomu);
00111     
00112     if (inomu < 0)
00113       printf("maillage %d de nom %s, de dimension "IFORMAT" \n",i+1,maa,mdim);
00114     else
00115       printf("maillage %d de nom %s, de dimension "IFORMAT" et de nom univ. %s\n",i+1,maa,mdim,nomu);
00116 
00117     printf("La dimension de l'espace est "IFORMAT" \n",sdim);
00118     if (meshtype == MED_STRUCTURED_MESH)
00119       printf("Il s'agit d'un maillage structure \n");
00120     else
00121       printf("Il s'agit d'un maillage non structure \n");
00122     printf("Description associee au maillage : %s \n\n",des);
00123     printf("\t -Noms des axes : %s\n",  axisname);
00124     printf("\t -Unités des axes : %s\n",axisunit);
00125     printf("\t -Type de repère : %d\n", axistype);
00126     printf("\t -Nombre d'étape de calcul : "IFORMAT"\n",nstep);
00127     printf("\t -Unité des dates : %s\n",dtunit);
00128 
00129     free(axisname);
00130     free(axisunit);
00131   }
00132 
00133   free(  maa    );
00134   free(  nomu   );
00135   free(  des    );
00136   free(  dtunit );
00137 
00138 
00139   
00140   if ( MEDfileClose(fid) < 0) {
00141     MESSAGE("Erreur a la fermeture du fichier test2.med");
00142     return -1;
00143   }
00144 
00145   return ret;
00146 }
00147 
00148 
00149 
00150