2.3.6/test31.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 : test31.c
00020  *
00021  * - Description : ecriture d'une numerotation globale dans un maillage 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 {
00041   med_err ret = 0;
00042   med_idt fid;
00043   /* la dimension du maillage */
00044   med_int mdim;
00045   /* nom du maillage de longueur maxi MED_TAILLE_NOM */
00046   char maa[MED_TAILLE_NOM+1];
00047   /* le nombre de noeuds */
00048   med_int nnoe = 0;
00049   /* table des numeros global */
00050   med_int *numglobalnoe;
00051 
00052   /* variable de stockage pour reperer le maillage */
00053   med_int i;
00054   char desc[MED_TAILLE_DESC+1];
00055   med_maillage type;
00056 
00057 
00058 
00059   if (argc != 2) {
00060     MESSAGE("Il faut passer un fichier MED en paramètre");
00061     return -1;
00062   }
00063 
00064   /* Ouverture du fichier passe en argument */
00065   if ((fid = MEDouvrir(argv[1],MED_LECTURE_ECRITURE)) < 0) {
00066     MESSAGE("Erreur a l'ouverture du fichier : "); SSCRUTE(argv[1]);
00067     return -1;
00068   }
00069   
00070 
00071   /* Lecture des infos concernant le premier maillage */
00072   if (MEDmaaInfo(fid,1,maa,&mdim,&type,desc) < 0) {
00073     MESSAGE("Erreur a la lecture des informations du 1er maillage");
00074     return -1;
00075   }
00076   printf("Maillage de nom : %s et de dimension : "IFORMAT" \n",maa,mdim);
00077 
00078   /* Lecture du nombre de noeuds */
00079   if ((nnoe = MEDnEntMaa(fid,maa,MED_COOR,MED_NOEUD,0,0)) < 0) {
00080     MESSAGE("Erreur a la lecture du nombre de noeuds ");
00081     return -1;
00082   }
00083   printf("Nombre de noeuds : "IFORMAT" \n",nnoe);
00084 
00085   /* Allocations memoires */
00086 
00087   /* table de la numerotation globale
00088      profil : (nombre de noeuds ) */
00089   if (nnoe > 0) {
00090     numglobalnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
00091     for (i=0;i<nnoe;i++) {
00092       numglobalnoe[i]=i+100;
00093     }
00094   }
00095 
00096   /* ecriture de la numerotation globale */
00097   
00098   if (MEDglobalNumEcr(fid,maa,numglobalnoe,nnoe,MED_NOEUD,0)<0) {
00099     MESSAGE("Erreur a l''ecriture de la numerotation globale");
00100     return -1;
00101   }
00102 
00103   free(numglobalnoe);
00104 
00105   /* Fermeture du fichier */
00106   if (MEDfermer(fid) < 0) {
00107     MESSAGE("Erreur a la fermeture du fichier");
00108     return -1;
00109   }
00110 
00111   return 0;
00112 }
00113 
00114 
00115 
00116 

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