2.3.6/test3.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 /******************************************************************************
00020  * - Nom du fichier : test3.c
00021  *
00022  * - Description : lecture des informations sur les maillages d'un fichier MED.
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_LECTURE_ECRITURE
00033 #elif DEF_LECT_AJOUT
00034 #define MODE_ACCES MED_LECTURE_AJOUT
00035 #else
00036 #define MODE_ACCES MED_CREATION
00037 #endif
00038 
00039 int main (int argc, char **argv)
00040 
00041 
00042 {
00043   med_err ret = 0;
00044   med_idt fid;
00045   med_int nmaa,i,mdim,edim;
00046   char maa[MED_TAILLE_NOM+1];
00047   char nomu[MED_TAILLE_LNOM+1];
00048   char desc[MED_TAILLE_DESC+1];
00049   med_maillage type;
00050   med_err inomu;
00051 
00052   /* Ouverture du fichier "test2.med" en lecture seule */
00053   fid = MEDouvrir("test2.med",MED_LECTURE);
00054   if (fid < 0) {
00055     MESSAGE("Erreur a l'ouverture du fichier test2.med");
00056     return -1;
00057   }
00058 
00059   /* Lecture du nombre de maillage dans le fichier */
00060   nmaa = MEDnMaa(fid);
00061   if (nmaa < 0) {
00062     MESSAGE("Erreur a la lecture du nombre de maillage");
00063     ret = -1;
00064   } 
00065   if (ret == 0)
00066     printf("- Nombre de maillage dans test2.med = "IFORMAT"\n",nmaa);
00067 
00068   /* Boucle sur tous les maillages, pour chaque maillage, on lit :
00069      - Le nom.
00070      - Le type
00071      - La dimension
00072      - La description
00073      - La dimension de l'espace si elle existe
00074      - Le nom universel s'il existe 
00075      */
00076   if (ret == 0)
00077     for (i=0;i<nmaa;i++) {
00078       /* lecture des informations */
00079       if (MEDmaaInfo(fid,i+1,maa,&mdim,&type,desc) < 0) {
00080         MESSAGE("Erreur a la lecture des informations du maillage :"); SSCRUTE(maa);
00081         ret = -1;
00082       }
00083       /* lecture de la dimension de l'espace */
00084       edim = MEDdimEspaceLire(fid,maa);
00085       /* lecture du nom universel */
00086       inomu = MEDunvLire(fid,maa,nomu);
00087       /* affichage des donnees lues */
00088       if (inomu < 0)
00089         printf("maillage "IFORMAT" de nom %s, de dimension "IFORMAT" \n",i+1,maa,mdim);
00090       else
00091         printf("maillage "IFORMAT" de nom %s, de dimension "IFORMAT" et de nom univ. %s\n",i+1,maa,mdim,nomu);  
00092       if (edim > 0)
00093         printf("La dimension de l'espace est "IFORMAT" \n",edim);
00094       else
00095         printf("La dimension de l'espace est "IFORMAT" \n",mdim);
00096       if (type == MED_STRUCTURE)
00097         printf("Il s'agit d'un maillage structure \n");
00098       else
00099         printf("Il s'agit d'un maillage non structure \n");
00100       printf("Description associee au maillage : %s \n\n",desc);
00101     }
00102 
00103   /* Fermeture du fichier */
00104   ret = MEDfermer(fid);
00105   if (ret < 0) {
00106     MESSAGE("Erreur a la fermeture du fichier test2.med");
00107     return -1;
00108   }
00109   
00110   return ret;
00111 }
00112 
00113 
00114 
00115 

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1