# MEDjointLire.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  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 MEDjointLire  (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   med_idt corrid, datagroup;
    00037   med_err ret;
    00038   char chemin[MED_TAILLE_MAA+MED_TAILLE_JNT+2*MED_TAILLE_NOM+1];
    00039   char nomdatagroup[MED_TAILLE_NOM+1+MED_TAILLE_NOM+1];
    00040   char tmp[MED_TAILLE_NOM_ENTITE+1];
    00041   med_size dimd[1];
    00042
    00043 /*   if (typ_geo_local   == MED_TETRA4 || typ_geo_local    == MED_TETRA10 || */
    00044 /*       typ_geo_local   == MED_HEXA8  || typ_geo_local    == MED_HEXA20  || */
    00045 /*       typ_geo_local   == MED_PENTA6 || typ_geo_local    == MED_PENTA15 || */
    00046 /*       typ_geo_local   == MED_PYRA5  || typ_geo_local    == MED_PYRA13  || */
    00047 /*       typ_geo_distant == MED_TETRA4 || typ_geo_distant == MED_TETRA10 || */
    00048 /*       typ_geo_distant == MED_HEXA8  || typ_geo_distant == MED_HEXA20  || */
    00049 /*       typ_geo_distant == MED_PENTA6 || typ_geo_distant == MED_PENTA15 || */
    00050 /*       typ_geo_distant == MED_PYRA5  || typ_geo_distant == MED_PYRA13) */
    00051 /*     return -1; */
    00052
    00053   /*
    00054    * On inhibe le gestionnaire d'erreur HDF 5
    00055    */
    00056   _MEDmodeErreurVerrouiller();
    00057 if (MEDcheckVersion(fid) < 0) return -1;
    00058
    00059
    00060   /*
    00061    * Si le Data Group de "JNT/corr" n'existe pas => erreur
    00062    */
    00063   strcpy(chemin,MED_MAA);
    00064   strcat(chemin,maa);
    00065   strcat(chemin,MED_JNT);
    00066   strcat(chemin,jn);
    00067   if ((corrid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    00068     return -1;
    00069
    00070   /*
    00071    * lecture de la correspondance
    00072    *   construction du tag HDF "reperant" la correspondance
    00073    *
    00074    */
    00075   if ((ret = _MEDnomEntite(nomdatagroup,_type_ent_local)) < 0)
    00076     return -1;
    00077   if ((_type_ent_local != MED_NOEUD))
    00078     {
    00079       if ((ret = _MEDnomGeometrie30(tmp,typ_geo_local)) < 0)
    00080         return -1;
    00081       strcat(nomdatagroup,".");
    00082       strcat(nomdatagroup,tmp);
    00083     }
    00084
    00085
    00086
    00087   if ((ret = _MEDnomEntite(tmp,_type_ent_distant)) < 0)
    00088     return -1;
    00089   strcat(nomdatagroup,".");
    00090   strcat(nomdatagroup,tmp);
    00091   if ((_type_ent_distant != MED_NOEUD))
    00092     {
    00093       if ((ret = _MEDnomGeometrie30(tmp,typ_geo_distant)) < 0)
    00094         return -1;
    00095       strcat(nomdatagroup,".");
    00096       strcat(nomdatagroup,tmp);
    00097     }
    00098
    00099
    00100   /*
    00101    * Lecture de la correspondance
    00102    */
    00103
    00104   if (((datagroup = _MEDdatagroupOuvrir(corrid,nomdatagroup)) < 0) )
    00105     return -1;
    00106
    00107
    00108 #if defined(HAVE_F77INT64)
    00109   if ((ret =  _MEDdatasetNumLire(datagroup,MED_NOM_COR,MED_INT64,
    00110                                  MED_NO_INTERLACE,1,MED_ALL,
    00111                                  MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
    00112                                  (unsigned char *) corrtab)) < 0)
    00113     return -1;
    00114 #else
    00115   if ((ret =  _MEDdatasetNumLire(datagroup,MED_NOM_COR,MED_INT32,
    00116                                  MED_NO_INTERLACE,1,MED_ALL,
    00117                                  MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
    00118                                  (unsigned char *) corrtab)) < 0)
    00119     return -1;
    00120 #endif
    00121
    00122
    00123   /*
    00124    * On ferme tout
    00125    */
    00126   if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
    00127     return -1;
    00128   if ((ret = _MEDdatagroupFermer(corrid)) < 0)
    00129     return -1;
    00130
    00131   return 0;
    00132 }
    00133
    00134
    00135