MEDequivEcr.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_outils.h>
00022 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 extern int mode_interlace; 
00027 
00028 med_err 
00029 MEDequivEcr(med_idt fid, char *maa, char *eq, med_int *corr, med_int n, 
00030             med_entite_maillage type_ent, med_geometrie_element typ_geo)
00031 {
00032   med_idt eqid, datagroup;
00033   med_err ret;
00034   char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1]; 
00035   char nomdatagroup[MED_TAILLE_NOM+1];
00036   char tmp[MED_TAILLE_NOM_ENTITE+1];
00037   med_size dimd[1];
00038   med_mode_acces MED_MODE_ACCES;
00039   med_entite_maillage _type_ent=type_ent;
00040 
00041   if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00042 
00043   if (typ_geo == MED_TETRA4 || typ_geo == MED_TETRA10 ||
00044       typ_geo == MED_HEXA8  || typ_geo == MED_HEXA20  ||
00045       typ_geo == MED_PENTA6 || typ_geo == MED_PENTA15 ||
00046       typ_geo == MED_PYRA5  || typ_geo == MED_PYRA13)
00047     return -1;
00048 
00049   /*
00050    * On inhibe le gestionnaire d'erreur HDF 5
00051    */
00052   _MEDmodeErreurVerrouiller();
00053 if (MEDcheckVersion(fid) < 0) return -1;
00054 
00055 
00056   if ( (MED_MODE_ACCES = _MEDmodeAcces(fid) ) == MED_UNDEF_MODE_ACCES ) {
00057     MESSAGE("Impossible de déterminer le mode d'acces au fichier ");
00058     return -1;
00059   }
00060 
00061   /* 
00062    * Si le Data Group de "eq" n'existe pas => erreur
00063    */
00064   strcpy(chemin,MED_MAA);
00065   strcat(chemin,maa);
00066   strcat(chemin,MED_EQS);
00067   strcat(chemin,eq);
00068   if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00069     return -1;  
00070 
00071   /*
00072    * Ecriture de l'equivalence
00073    */
00074   if ((ret = _MEDnomEntite(nomdatagroup,_type_ent)) < 0)
00075     return -1;
00076   if ((_type_ent != MED_NOEUD))
00077     {
00078       if ((ret = _MEDnomGeometrie(tmp,typ_geo)) < 0)
00079         return -1;
00080       strcat(nomdatagroup,".");
00081       strcat(nomdatagroup,tmp);
00082     }
00083   datagroup = 0;
00084   if (((datagroup = _MEDdatagroupOuvrir(eqid,nomdatagroup)) > 0) && 
00085       ( MED_MODE_ACCES == MED_LECTURE_AJOUT))
00086     return -1;
00087   else
00088     if (datagroup > 0)
00089       _MEDdatagroupFermer(datagroup);
00090 
00091   if ((datagroup = _MEDdatagroupCreer(eqid,nomdatagroup)) < 0)
00092     return -1;
00093 
00094   if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n)) < 0)
00095     return -1;
00096 
00097   dimd[0] = 2*n;
00098 
00099 #if defined(HAVE_F77INT64)
00100   if ((ret =  _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00101                                 (unsigned char*) corr)) < 0)
00102     return -1;
00103 #else
00104   if ((ret =  _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00105                                 (unsigned char*) corr)) < 0)
00106     return -1;
00107 #endif
00108 
00109   /*
00110    * On ferme tout
00111    */
00112   if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00113     return -1;
00114   if ((ret = _MEDdatagroupFermer(eqid)) < 0)
00115     return -1;
00116 
00117   return 0;
00118 }
00119 
00120 
00121 

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