2.3.6/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 
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_err ret=0;
00041   med_idt fid;
00042   char des[MED_TAILLE_DESC+1]="";
00043 
00044   /* Verification de la conformite du format med du fichier test1.med */
00045   ret = MEDformatConforme("test1.med");
00046   if (ret < 0) {
00047     MESSAGE("Format HDF non conforme ou fichier inexistant");
00048     return -1;
00049   }
00050 
00051   /* Ouverture en mode de lecture du fichier "test1.med" */
00052   fid = MEDouvrir("test1.med",MED_LECTURE);
00053   if (fid < 0) {
00054       MESSAGE("Erreur a l'ouverture du fichier test1.med en mode MED_LECTURE");
00055       return -1;
00056   }
00057   
00058   /* Affiche de l'en-tete du fichier */
00059   ret = MEDfichEntete(fid,MED_FICH_DES, des);
00060   if (ret == 0) 
00061     printf("En-tete du fichier test1.med : %s\n",des);
00062   else {
00063     MESSAGE("Erreur a la lecture de l'en-tete du fichier test1.med");
00064     ret = -1;
00065   }
00066   
00067   /* Fermeture du fichier test1.med */
00068   ret = MEDfermer(fid); 
00069   if (ret < 0) {
00070     MESSAGE("Erreur a la fermeture du fichier test1.med");
00071     return -1;
00072   }
00073   
00074   /* Ouverture en mode creation du fichier test2.med */
00075   fid = MEDouvrir("test2.med",MODE_ACCES);
00076   if (fid < 0) {
00077     MESSAGE("Erreur a la creation du fichier test2.med");
00078     return -1;
00079   }
00080   
00081   /* Creation du maillage "maa1" de type MED_NON_STRUCTURE
00082      et de dimension 3 */
00083   if (MEDmaaCr(fid,"maa1",3,MED_NON_STRUCTURE,
00084                       "un premier maillage") < 0) {
00085     MESSAGE("Erreur a la creation du maillage maa1");
00086     ret = -1;
00087   }
00088 
00089   /* Ecriture du nom universel pour "maa1" */
00090   if (MEDunvCr(fid,"maa1") < 0) {
00091     MESSAGE("Erreur a la creation du nom universel de maa1");
00092     ret = -1;
00093   }
00094 
00095   /* Creation du maillage "maa2" de type MED_NON_STRUCTURE
00096      et de dimension 2 */
00097   if (MEDmaaCr(fid,"maa2",2,MED_NON_STRUCTURE,
00098                       "un second maillage") < 0) {
00099     MESSAGE("Erreur a la creation du maillage maa2");
00100     ret = -1;
00101   }
00102 
00103   /* Ecriture de la dimension de l'espace : Maillage de 
00104      dimension 2 dans un espace de dimension 3 */
00105   if (MEDdimEspaceCr(fid,"maa2",3) < 0) {
00106     MESSAGE("Erreur a l'ecriture de la dimension de l'espace"); 
00107     ret = -1; 
00108   }  
00109 
00110   /* Creation du maillage "maa3" de type MED_STRUCTURE
00111      et de dimension 1 */
00112   if (MEDmaaCr(fid,"maa3",1,MED_STRUCTURE,
00113                       "un troisieme maillage") < 0) {
00114     MESSAGE("Erreur a la creation du maillage maa3");
00115     ret = -1;
00116   }
00117 
00118   /* Fermeture du fichier */
00119   if ((ret = MEDfermer(fid))  < 0) {
00120     MESSAGE("Erreur a la fermeture du fichier");
00121     return -1;
00122   }
00123   
00124   return ret;
00125 }
00126 
00127 
00128 
00129 

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