2.3.1v3.0/test2.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  * - Nom du fichier : test2.c
00020  *
00021  * - Description : exemples de creation de maillages MED.
00022  *
00023  *****************************************************************************/
00024 
00025 #include <med.h>
00026 #define MESGERR 1
00027 #include <med_utils.h>
00028 #include <string.h>
00029 
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_ACC_RDWR
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_ACC_RDEXT
00034 #else
00035 #define MODE_ACCES MED_ACC_CREAT
00036 #endif
00037 
00038 int main (int argc, char **argv)
00039 
00040 {
00041   med_err ret=0;
00042   med_idt fid=0;
00043   char des[MED_COMMENT_SIZE+1]="";
00044   med_bool hdfok=MED_FALSE, medok=MED_FALSE;
00045 
00046 
00047   /* Verification de la conformite du format med du fichier test1.med */
00048   ret = MEDfileCompatibility("test1.med",&hdfok,&medok);
00049   if (!hdfok) {
00050     MESSAGE("Format HDF non conforme ou fichier inexistant");
00051     return -1;
00052   }
00053   if (!medok) {
00054     MESSAGE("Format MED non conforme ou fichier inexistant");
00055     return -1;
00056   }
00057 
00058 /*   Ouverture en mode de lecture du fichier "test1.med"  */
00059   fid = MEDfileOpen("test1.med",MED_ACC_RDONLY);
00060   if (fid < 0) {
00061       MESSAGE("Erreur a l'ouverture du fichier test1.med en mode MED_LECTURE");
00062       return -1;
00063   }
00064 
00065 /*    Affiche de l'en-tete du fichier  */
00066   ret = MEDfileCommentRd(fid, des);
00067   if (ret == 0)
00068     printf("En-tete du fichier test1.med : %s\n",des);
00069   else {
00070     MESSAGE("Erreur a la lecture de l'en-tete du fichier test1.med");
00071     return -1;
00072   }
00073 
00074 /*   Fermeture du fichier test1.med */
00075   ret = MEDfileClose(fid);
00076   if (ret < 0) {
00077     MESSAGE("Erreur a la fermeture du fichier test1.med");
00078     return -1;
00079   }
00080 
00081   return ret;
00082 }
00083 
00084 
00085 
00086 

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