MED23v30axesInfo.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 
00027 med_err
00028 MED23v30axesInfo(med_idt fid, char *maa, med_repere *type_rep,
00029                  char *nom, char *unit)
00030 {
00031   med_err      _ret=-1;
00032   med_idt      maaid=0, noeid=0;
00033   med_idt      dataset[3]= {0} ;
00034   char         *griddatasetname[3]={MED_NOM_IN1,MED_NOM_IN2,MED_NOM_IN3};
00035   med_int      _ndataset=1;
00036   char         chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00037   med_int      type_rep_int;
00038   med_int      _spacedim=0,_meshdim=0,_nsubstring=0;
00039   med_int      att=0;
00040   med_maillage maillage_type;
00041   med_type_grille type;
00042   int          _i=0,len=0,_p=0;
00043   char*        _ptmp=NULL;
00044   med_booleen  _nomlenwas0=MED_FAUX,_unitlenwas0=MED_FAUX;
00045   /*
00046    * On inhibe le gestionnaire d'erreur
00047    */
00048   _MEDmodeErreurVerrouiller();
00049   if (MEDcheckVersion(fid) < 0) return -1;
00050 
00051 
00052   /*
00053    * Si le maillage n'existe pas => erreur
00054    * Sinon on recupere sa dimension au passage
00055    */
00056   strcpy(chemin,MED_MAA);
00057   strcat(chemin,maa);
00058   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) { /*ICI;*/ goto ERROR;}
00059 
00060   /*
00061    * On va chercher l'attribut dimension
00062    */
00063   if ( _MEDattrEntierLire(maaid,MED_NOM_DIM,&_meshdim) < 0) { /*ICI;*/ goto ERROR;}
00064 
00065   if ( (_spacedim = MEDdimEspaceLire(fid, maa) < 0 ) ) _spacedim=_meshdim;
00066   _nsubstring = _spacedim;
00067 
00068   /*
00069    * Si le Data Group "NOE" n'existe pas => erreur
00070    */
00071   if ((noeid = _MEDdatagroupOuvrir(maaid,MED_NOM_NOE)) < 0) { /*ICI;*/ goto ERROR;}
00072 
00073   /*
00074    * Si le maillage est de type MED_NON_STRUCTURE
00075    */
00076   if ( _MEDattrEntierLire(maaid,MED_NOM_TYP,&att) < 0) { /*ICI;*/ goto ERROR;}
00077   maillage_type = (med_maillage) att;
00078 
00079   if (maillage_type == MED_NON_STRUCTURE) {
00080     /*
00081      * On Ouvre le Data Set "COO" pour y lire des attributs
00082      */
00083     if ((dataset[0] = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0) { /*ICI;*/ goto ERROR;}
00084 
00085   } else {
00086     /*
00087      * Grille  MED_GRILLE_STANDARD --> dataset==COO sinon dataset==INDx
00088      */
00089     if ( _MEDattrEntierLire(maaid,MED_NOM_GTY,&att) < 0) goto ERROR;
00090     type = (med_type_grille) att;
00091 
00092     if (type != MED_GRILLE_STANDARD) {
00093       _ndataset=_meshdim;
00094       _nsubstring = 1;
00095 
00096       for (_i= 0; _i<_ndataset; ++_i) {
00097         if ((dataset[_i] = _MEDdatasetOuvrir(noeid,griddatasetname[_i])) < 0) { /*ICI;*/goto ERROR;}
00098       }
00099     } else {
00100       /*
00101        * On Ouvre le Data Set "COO" pour y lire des attributs
00102        */
00103       if ((dataset[0] = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0) { /*ICI;*/ goto ERROR;}
00104     }
00105 
00106   }
00107 
00108 
00109   /*
00110    * L'attribut "REP"
00111    */
00112   if ( (maillage_type == MED_STRUCTURE) && (type != MED_GRILLE_STANDARD) ) {
00113     *type_rep = MED_CART;
00114   } else
00115     if (  _MEDattrEntierLire(dataset[0],MED_NOM_REP,&type_rep_int) < 0 )
00116       { /*ICI;*/ goto ERROR;}
00117     else
00118       *type_rep = (med_repere) type_rep_int;
00119 
00120   for (_i= 0; _i<_ndataset; ++_i) {
00121 
00122     /*
00123      * Attribut "NOM"
00124      */
00125     _ptmp =&nom[MED_TAILLE_PNOM*_i];
00126     if ( _MEDattrStringLire(dataset[_i],MED_NOM_NOM,_nsubstring*MED_TAILLE_PNOM,
00127                             _ptmp) < 0)
00128       { /*ICI;*/ goto ERROR;}
00129 
00130     len=strlen(_ptmp);
00131     if ( len == 0 ) _nomlenwas0=MED_VRAI;
00132     if ( (len > 0 ) && _nomlenwas0 ) {
00133       MESSAGE("Un des noms d'axes est vide et d'autres non!");
00134     }
00135     if ( (len <  MED_TAILLE_PNOM ) && (len > 0) ) {
00136       for (_p=(MED_TAILLE_PNOM-1); _p>=len; --_p) *( _ptmp + _p)=' ';
00137       *(_ptmp+MED_TAILLE_PNOM)='\0';
00138     }
00139 
00140 /*     ISCRUTE(_nsubstring); */
00141 /*     ISCRUTE(dataset[_i]); */
00142 /*     SSCRUTE(nom); */
00143 /*     SSCRUTE(&nom[MED_TAILLE_PNOM*_i]); */
00144 
00145     /*
00146      * Attribut "UNI"
00147      */
00148     _ptmp =&unit[MED_TAILLE_PNOM*_i];
00149     if ( _MEDattrStringLire(dataset[_i],MED_NOM_UNI,_nsubstring*MED_TAILLE_PNOM,
00150                             _ptmp) < 0)
00151       { /*ICI;*/ goto ERROR;}
00152 
00153     len=strlen(_ptmp);
00154     if ( len == 0 ) _unitlenwas0=MED_VRAI;
00155     if ( (len > 0 ) && _unitlenwas0 ) {
00156       MESSAGE("Un des noms d'unité d'axes est vide et d'autres non!");
00157     }
00158     if ( (len <  MED_TAILLE_PNOM) && (len > 0) ) {
00159       for (_p=(MED_TAILLE_PNOM-1); _p>=len; --_p) *( _ptmp + _p)=' ';
00160       *(_ptmp+MED_TAILLE_PNOM)='\0';
00161     }
00162 
00163   }
00164 
00165   /*
00166    * On ferme tout
00167    */
00168 
00169   _ret = 0;
00170  ERROR:
00171 
00172   for (_i= 0; _i<_ndataset; ++_i)
00173     if (dataset[_i] > 0 )
00174       if ( _MEDdatasetFermer(dataset[_i]) < 0)
00175         _ret= -1;
00176 
00177   if (noeid > 0 )
00178     if ( _MEDdatagroupFermer(noeid) < 0)
00179       _ret= -1;
00180   if (maaid > 0 )
00181     if (  _MEDdatagroupFermer(maaid) < 0)
00182       _ret= -1;
00183 
00184   return _ret;
00185 }

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