medconforme.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 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_utils.h>
00022 #include <stdlib.h>
00023 
00024 
00025 
00026 int main(int argc, char *argv[]) {
00027   med_idt fid;
00028   med_int majeur, mineur, release;
00029   med_err ret=-1;
00030   med_bool hdfok=MED_FALSE;
00031   med_bool medok=MED_FALSE;
00032 
00033   if (argc != 2) {
00034     fprintf(stdout,">> Utilisation : medconforme <nom_de_fichier_med> \n");
00035     return 0;
00036   }
00037 
00038   /*
00039    * Quelle version de la bibliotheque MED est utilisee ?
00040    */
00041   ret=MEDlibraryNumVersion(&majeur, &mineur, &release);
00042   EXIT_IF( ret<0 ,
00043            "Erreur d'appel de la routine MEDlibraryNumVersion.", NULL   );
00044   fprintf(stdout,"- Version de MED-fichier utilisée par medconforme : "IFORMAT"."IFORMAT"."IFORMAT" \n",majeur,mineur,release); 
00045 
00046   /*
00047    * Le fichier à lire est-il au bon format de fichier HDF ?
00048    */
00049 
00050   EXIT_IF(MEDfileCompatibility(argv[1],&hdfok,&medok) < 0,
00051           "Fichier non conforme.", NULL);
00052   if ( hdfok )
00053     fprintf(stdout,"- Format HDF du fichier MED [%s] conforme au format HDF utilisé par la bibliothèque \n",argv[1]);
00054   else {
00055     fprintf(stdout,"- Format HDF du fichier MED [%s] non conforme au format HDF utilisé par la bibliothèque \n",argv[1]);
00056     return -1;
00057   }
00058 
00059   /*
00060    * Le fichier à lire a-t-il été créé avec une version de la bilbiothèque MED conforme avec celle utilisée ?
00061    * (Numéros majeur et mineur identiques).
00062    */
00063   if ( medok )
00064     fprintf(stdout,"- Version MED du fichier [%s] conforme a la bibliothèque MED utilisée \n",argv[1]);
00065   else
00066     fprintf(stdout,"- Version MED du fichier [%s] non conforme avec celle de la bibliothèque utilisée \n",argv[1]);
00067 
00068   fid = MEDfileOpen(argv[1],MED_ACC_RDONLY);
00069   if (fid < 0)
00070     fprintf(stderr,">> ERREUR a l'ouverture du fichier [%s] \n",argv[1]);
00071 
00072   /*
00073    * Une fois le fichier ouvert on peut avoir acces au numero de version complet
00074    */
00075   ret = MEDfileNumVersionRd(fid, &majeur, &mineur, &release);
00076   EXIT_IF(ret < 0,"Lecture du numéro de version",NULL);
00077 
00078   fprintf(stdout,"- Ce fichier a ete créé avec MED V"IFORMAT"."IFORMAT"."IFORMAT" \n",majeur,mineur,release);
00079 
00080   ret = MEDfileClose(fid);
00081   EXIT_IF(ret < 0,"Fermeture du fichier",argv[1]);
00082 
00083   return 0;
00084 }

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