1 /************************************************************************* 2 * COPYRIGHT (C) 1999 - 2003 EDF R&D 3 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY 4 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE 5 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 6 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 7 * 8 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT 9 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF 10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU 11 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS. 12 * 13 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE 14 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION, 15 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA 16 * 17 *************************************************************************/ 18 19 20 /****************************************************************************** 21 * - Nom du fichier : test3.c 22 * 23 * - Description : lecture des informations sur les maillages d'un fichier MED. 24 * 25 *****************************************************************************/ 26 27 #include <med.h> 28 #include <med_utils.h> 29 #include <string.h> 30 31 int main (int argc, char **argv) 32 { 33 med_err ret = 0; 34 med_idt fid; 35 med_int nmaa,i,mdim,edim; 36 char maa[MED_TAILLE_NOM+1]; 37 char nomu[MED_TAILLE_LNOM+1]; 38 char desc[MED_TAILLE_DESC+1]; 39 med_maillage type; 40 med_err inomu; 41 42 /* Ouverture du fichier "test2.med" en lecture seule */ 43 fid = MEDouvrir("test2.med",MED_LECTURE); 44 if (fid < 0) { 45 MESSAGE("Erreur a l'ouverture du fichier test2.med"); 46 return -1; 47 } 48 49 /* Lecture du nombre de maillage dans le fichier */ 50 nmaa = MEDnMaa(fid); 51 if (nmaa < 0) { 52 MESSAGE("Erreur a la lecture du nombre de maillage"); 53 ret = -1; 54 } 55 if (ret == 0) 56 printf("- Nombre de maillage dans test2.med = %d\n",nmaa); 57 58 /* Boucle sur tous les maillages, pour chaque maillage, on lit : 59 - Le nom. 60 - Le type 61 - La dimension 62 - La description 63 - La dimension de l'espace si elle existe 64 - Le nom universel s'il existe 65 */ 66 if (ret == 0) 67 for (i=0;i<nmaa;i++) { 68 /* lecture des informations */ 69 if (MEDmaaInfo(fid,i+1,maa,&mdim,&type,desc) < 0) { 70 MESSAGE("Erreur a la lecture des informations du maillage :"); SSCRUTE(maa); 71 ret = -1; 72 } 73 /* lecture de la dimension de l'espace */ 74 edim = MEDdimEspaceLire(fid,maa); 75 /* lecture du nom universel */ 76 inomu = MEDunvLire(fid,maa,nomu); 77 /* affichage des donnees lues */ 78 if (inomu < 0) 79 printf("maillage %d de nom %s, de dimension %d \n",i+1,maa,mdim); 80 else 81 printf("maillage %d de nom %s, de dimension %d et de nom univ. %s\n",i+1,maa,mdim,nomu); 82 if (edim > 0) 83 printf("La dimension de l'espace est %d \n",edim); 84 else 85 printf("La dimension de l'espace est %d \n",mdim); 86 if (type == MED_STRUCTURE) 87 printf("Il s'agit d'un maillage structure \n"); 88 else 89 printf("Il s'agit d'un maillage non structure \n"); 90 printf("Description associee au maillage : %s \n\n",desc); 91 } 92 93 /* Fermeture du fichier */ 94 ret = MEDfermer(fid); 95 if (ret < 0) { 96 MESSAGE("Erreur a la fermeture du fichier test2.med"); 97 return -1; 98 } 99 100 return ret; 101 } 102 103 104 105