2.3.6/test18.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 : test18.c
00020  *
00021  * - Description : routines de test de la conformite d'un fichier MED.
00022  *
00023  *****************************************************************************/
00024 
00025 #include <med.h>
00026 #define MESGERR 1
00027 #include <med_utils.h>
00028 
00029 #ifdef DEF_LECT_ECR
00030 #define MODE_ACCES MED_LECTURE_ECRITURE
00031 #elif DEF_LECT_AJOUT
00032 #define MODE_ACCES MED_LECTURE_AJOUT
00033 #else
00034 #define MODE_ACCES MED_CREATION
00035 #endif
00036 
00037 int main (int argc, char **argv)
00038 
00039 {
00040   med_idt fid;
00041   med_int majeur, mineur, release;
00042 
00043   /* Creation du fichier test18.med */
00044   if ((fid = MEDouvrir("test18.med",MODE_ACCES)) < 0) {
00045     MESSAGE("Erreur a la creation du fichier test18.med");
00046     return -1;
00047   }
00048   fprintf(stdout,"- Creation du fichier test18.med \n");
00049   
00050   if (MEDfermer(fid) < 0) {
00051     MESSAGE("Erreur a la fermeture du fichier");
00052     return -1;
00053   }
00054   fprintf(stdout,"- Fermeture du fichier \n");
00055 
00056   /*
00057    * Quelle version de la bibliotheque MED est utilisee ?
00058    */
00059   MEDversionDonner(&majeur, &mineur, &release);
00060   fprintf(stdout,"- Version de MED utilisee pour lire le fichier : "IFORMAT"."IFORMAT"."IFORMAT" \n",majeur,mineur,release); 
00061   /*
00062    * Le fichier à lire est-il au bon format de fichier HDF ?
00063    */
00064   if (! MEDformatConforme("test18.med"))
00065     fprintf(stdout,"- Format HDF du fichier MED conforme au format HDF utilise par la bibliotheque \n");
00066   else
00067     fprintf(stdout,"- Format HDF du fichier MED non conforme au format HDF utilise par la bibliotheque \n");
00068   
00069   /*
00070    * Le fichier a lire a-t-il été créé avec une version de la bibliothèque MED conforme avec celle utilise ?
00071    * (Numéros majeur et mineur identiques).
00072    */
00073   if (! MEDversionConforme("test18.med"))
00074     fprintf(stdout,"- Version MED du fichier conforme a la bibliotheque MED utilisee \n");
00075   else
00076     fprintf(stdout,"- Version MED du fichier non conforme a la bibliotheque MED utilisee \n");
00077 
00078   if ((fid = MEDouvrir("test18.med",MED_LECTURE)) < 0) {
00079     MESSAGE("Erreur a l'ouverture du fichier test18.med");
00080     return -1;
00081   }
00082   fprintf(stdout,"- Ouverture du fichier en lecture \n");
00083 
00084   /*
00085    * Une fois le fichier ouvert on peut avoir acces au numero de version complet
00086    */
00087   if (MEDversionLire(fid, &majeur, &mineur, &release) < 0) {
00088     MESSAGE("Erreur a la lecture du numero de version de la bibliothèque ");
00089     return -1;
00090   }
00091   fprintf(stdout,"- Ce fichier a ete cree avec MED "IFORMAT"."IFORMAT"."IFORMAT" \n",majeur,mineur,release); 
00092 
00093   if (MEDfermer(fid) < 0) {
00094     MESSAGE("Erreur a la fermeture du fichier");
00095     return -1;
00096   }
00097   fprintf(stdout,"- Fermeture du fichier \n");
00098   
00099   return 0;
00100 }

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