2.3.6/test21.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 /******************************************************************************
00020  * - Nom du fichier : test21.c
00021  *
00022  * - Description : ecriture de valeurs scalaires numeriques dans un fichier MED
00023  *
00024  *****************************************************************************/
00025 
00026 #include <med.h>
00027 #define MESGERR 1
00028 #include <med_utils.h>
00029 
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_LECTURE_ECRITURE
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_LECTURE_AJOUT
00034 #else
00035 #define MODE_ACCES MED_CREATION
00036 #endif
00037 
00038 int main (int argc, char **argv)
00039 
00040 
00041 {
00042   med_err ret;
00043   med_idt fid;
00044   char nom_scalaire1[MED_TAILLE_NOM+1] = "VariableEntiere";
00045   char description1[MED_TAILLE_DESC+1] = "Une premiere description";
00046   char nom_scalaire2[MED_TAILLE_NOM+1] = "VariableFlottante";
00047   char description2[MED_TAILLE_DESC+1] = "Une seconde description";
00048   med_int vali1 = 56;
00049   med_int vali2 = -789;
00050   med_float valr1 = 67.98;
00051  
00052   /* Creation du fichier test21.med */
00053   if ((fid = MEDouvrir("test21.med",MODE_ACCES)) < 0) {
00054     MESSAGE("Erreur a la creation du fichier test21.med");
00055     return -1;
00056   }
00057  
00058   /* Creation d'un variable scalaire entiere */
00059   if (MEDscalaireCr(fid,nom_scalaire1,MED_INT,description1) < 0) {
00060     MESSAGE("Erreur a la creation d'une variable scalaire entière");
00061     return -1;
00062   }
00063   printf("Creation d'une variable scalaire entiere \n");
00064 
00065   /* Ecriture d'un valeur sans pas de temps et sans numero d'ordre*/
00066   if (MEDscalaireEntierEcr(fid,nom_scalaire1,vali1,MED_NOPDT,"",0.0,MED_NONOR) < 0) {
00067     MESSAGE("Erreur a l'ecriture d'une valeur entiere");
00068     return -1;
00069   }
00070   printf("Ecriture d'une valeur entiere sans pas de temps \n");
00071 
00072   /* Ecriture d'une valeur entiere avec 1 pas de temps et sans numero d'ordre */
00073   if (MEDscalaireEntierEcr(fid,nom_scalaire1,vali2,1,"ms",5.5,MED_NONOR) < 0) {
00074     MESSAGE("Erreur a l'ecriture d'une valeur entiere");
00075     return -1;
00076   }
00077   printf("Ecriture d'une valeur entiere avec pas de temps \n");
00078 
00079   /* Creation d'un variable scalaire flottante */
00080   if (MEDscalaireCr(fid,nom_scalaire2,MED_FLOAT64,description2) < 0) {
00081     MESSAGE("Erreur a la creation d'une variable scalaire flottante");
00082     return -1;
00083   }
00084   printf("Creation d'une variable scalaire flottante \n");
00085 
00086   /* Ecriture d'une valeur reelle avec 1 pas de temps et 1 numero d'ordre */
00087   if (MEDscalaireFlottantEcr(fid,nom_scalaire2,valr1,1,"ms",5.5,2) < 0) {
00088     MESSAGE("Erreur a l'ecriture d'une valeur flottante");
00089     return -1;
00090   }
00091   printf("Ecriture d'une valeur reelle avec pas de temps et numero d'ordre \n");
00092   
00093   /* Fermeture du fichier */
00094   if (MEDfermer(fid) < 0) {
00095     MESSAGE("Erreur a la fermeture du fichier");
00096     return -1;
00097   }
00098 
00099   return 0;
00100 }

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