MEDjointEcr.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 MEDjointEcr   (med_idt fid, char *maa, char *jn, med_int *corrtab, med_int n,
00030                med_entite_maillage type_ent_local,   med_geometrie_element typ_geo_local,
00031                med_entite_maillage type_ent_distant, med_geometrie_element typ_geo_distant)
00032               
00033 {
00034   med_entite_maillage _type_ent_local   = (med_entite_maillage) ( (int)(type_ent_local) % 10 );
00035   med_entite_maillage _type_ent_distant = (med_entite_maillage) ( (int)(type_ent_distant) % 10 );
00036 
00037   med_idt corrid, datagroup;
00038   med_err ret;
00039   char chemin[MED_TAILLE_MAA+MED_TAILLE_JNT+2*MED_TAILLE_NOM+1]; 
00040   char nomdatagroup[MED_TAILLE_NOM+1+MED_TAILLE_NOM+1];
00041   char tmp[MED_TAILLE_NOM_ENTITE+1];
00042   med_size dimd[1];
00043   med_mode_acces MED_MODE_ACCES;
00044 
00045 /*   if (typ_geo_local   == MED_TETRA4 || typ_geo_local    == MED_TETRA10 || */
00046 /*       typ_geo_local   == MED_HEXA8  || typ_geo_local    == MED_HEXA20  || */
00047 /*       typ_geo_local   == MED_PENTA6 || typ_geo_local    == MED_PENTA15 || */
00048 /*       typ_geo_local   == MED_PYRA5  || typ_geo_local    == MED_PYRA13  || */
00049 /*       typ_geo_distant == MED_TETRA4 || typ_geo_distant == MED_TETRA10 || */
00050 /*       typ_geo_distant == MED_HEXA8  || typ_geo_distant == MED_HEXA20  || */
00051 /*       typ_geo_distant == MED_PENTA6 || typ_geo_distant == MED_PENTA15 || */
00052 /*       typ_geo_distant == MED_PYRA5  || typ_geo_distant == MED_PYRA13) */
00053 /*     return -1; */
00054 
00055   /*
00056    * On inhibe le gestionnaire d'erreur HDF 5
00057    */
00058   _MEDmodeErreurVerrouiller();
00059 if (MEDcheckVersion(fid) < 0) return -1;
00060 
00061 
00062   if ( (MED_MODE_ACCES = _MEDmodeAcces(fid) ) == MED_UNDEF_MODE_ACCES ) {
00063     MESSAGE("Impossible de déterminer le mode d'acces au fichier ");
00064     return -1;
00065   }
00066 
00067   /* 
00068    * Si le Data Group de "JNT" n'existe pas => erreur
00069    */
00070   strcpy(chemin,MED_MAA);
00071   strcat(chemin,maa);
00072   strcat(chemin,MED_JNT);
00073   strcat(chemin,jn);
00074   if ((corrid = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
00075     MESSAGE(chemin);
00076     return -1;  
00077   }
00078   /*
00079    * Ecriture de la correspondance
00080    *   construction du tag HDF "reperant" la correspondance 
00081    *   
00082    */
00083   if ((ret = _MEDnomEntite(nomdatagroup,_type_ent_local)) < 0)
00084     return -1;
00085   if ((_type_ent_local != MED_NOEUD))
00086     {
00087       if ((ret = _MEDnomGeometrie(tmp,typ_geo_local)) < 0)
00088         return -1;
00089       strcat(nomdatagroup,".");
00090       strcat(nomdatagroup,tmp);
00091     }
00092 
00093 
00094 
00095   if ((ret = _MEDnomEntite(tmp,_type_ent_distant)) < 0)
00096     return -1;
00097   strcat(nomdatagroup,".");
00098   strcat(nomdatagroup,tmp);
00099   if ((_type_ent_distant != MED_NOEUD))
00100     {
00101       if ((ret = _MEDnomGeometrie(tmp,typ_geo_distant)) < 0)
00102         return -1;
00103       strcat(nomdatagroup,".");
00104       strcat(nomdatagroup,tmp);
00105     }
00106 
00107   datagroup = 0;
00108 
00109 
00110   /* 
00111    * Si la correspondance existe, on passe en mode
00112    * ajout ?????????
00113    */
00114 
00115   if (((datagroup = _MEDdatagroupOuvrir(corrid,nomdatagroup)) > 0) && 
00116       ( MED_MODE_ACCES == MED_LECTURE_AJOUT))
00117     return -1;
00118   else
00119     if (datagroup > 0)
00120       _MEDdatagroupFermer(datagroup);
00121 
00122   if ((datagroup = _MEDdatagroupCreer(corrid,nomdatagroup)) < 0)
00123     return -1;
00124 
00125 
00126   /*
00127    * L'attribut "NBR"
00128    */
00129   if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n)) < 0)
00130     return -1;
00131 
00132 
00133   dimd[0] = 2*n;
00134 
00135 #if defined(HAVE_F77INT64)
00136   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,
00137                                 (unsigned char*) corrtab)) < 0)
00138     return -1;
00139 #else
00140   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,
00141                                 (unsigned char*) corrtab)) < 0)
00142     return -1;
00143 #endif
00144 
00145   /*
00146    * On ferme tout 
00147    */
00148   if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00149     return -1;
00150   if ((ret = _MEDdatagroupFermer(corrid)) < 0)
00151     return -1;
00152 
00153   return 0; 
00154 }
00155 
00156 
00157 

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