# _MEDfieldnProfile236.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  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 #include <string.h>
    00023
    00024 #include <2.3.6/med23v30.h>
    00025 #include <2.3.6/med23v30_proto.h>
    00026 #include "2.3.6/med23v30_misc.h"
    00027
    00028 void
    00029 _MEDfieldnProfile236(int dummy, ...) {
    00030
    00031
    00032   med_int  _ret=-1,_err=-1;
    00033   med_idt  _gid=0,_datagroup1=0;
    00034   char     _path[(MED_TAILLE_CHA+MED_NAME_SIZE+1)+(2*MED_MAX_PARA+1)+1]=MED_CHA;
    00035   char     _datagroupname1  [2*MED_TAILLE_NOM_ENTITE+2]="";
    00036   char     _nomdatagroup2   [2*MED_MAX_PARA+1]         ="";
    00037   char     _geotype         [MED_TAILLE_NOM_ENTITE+1]  ="";
    00038   char     _profilename     [MED_NAME_SIZE+1]          ="";
    00039   char     _meshname        [MED_NAME_SIZE+1]          ="";
    00040   char     _localizationname[MED_NAME_SIZE+1]          ="";
    00041   med_int  _numdt=0, _numit=0;
    00042   med_size _n=0,_ncpst=0;
    00043   med_bool _checkmultiplemesh=MED_TRUE, _multiplemesh        =MED_FALSE;
    00044   med_bool _checkmeshname    =MED_TRUE,  _samedefaultmeshname=MED_FALSE;
    00045   char     _tmp1         [MED_TAILLE_NOM_ENTITE+1]="";
    00046 /*   med_size _rank; */
    00047
    00048
    00049   MED_VARGS_DECL(const, med_idt           , , fid                     );
    00050   MED_VARGS_DECL(const, char * , const      , fieldname               );
    00051   MED_VARGS_DECL(const, med_int           , , numdt                   );
    00052   MED_VARGS_DECL(const, med_int           , , numit                   );
    00053   MED_VARGS_DECL(const, med_entity_type   , , entitype                );
    00054   MED_VARGS_DECL(const, med_geometry_type , , geotype                 );
    00055   MED_VARGS_DECL(, char *, const      , defaultprofilename            );
    00056   MED_VARGS_DECL(, char *, const      , defaultlocalizationname       );
    00057   MED_VARGS_DECL(, med_int *         ,, fret                          );
    00058
    00059   va_list params;
    00060   va_start(params,dummy);
    00061
    00062   MED_VARGS_DEF(const, med_idt           , , fid                     );
    00063   MED_VARGS_DEF(const, char * , const      , fieldname               );
    00064   MED_VARGS_DEF(const, med_int           , , numdt                   );
    00065   MED_VARGS_DEF(const, med_int           , , numit                   );
    00066   MED_VARGS_DEF(const, med_entity_type   , , entitype                );
    00067   MED_VARGS_DEF(const, med_geometry_type , , geotype                 );
    00068   MED_VARGS_DEF(, char *, const      , defaultprofilename            );
    00069   MED_VARGS_DEF(, char *, const      , defaultlocalizationname       );
    00070   MED_VARGS_DEF(, med_int *         ,, fret                          );
    00071
    00072   /*
    00073    * On inhibe le gestionnaire d'erreur HDF 5
    00074    */
    00075   _MEDmodeErreurVerrouiller();
    00076
    00077   NOFINALBLANK(fieldname,ERROR);
    00078
    00079   /*
    00080    * Autorise la lecture du profile et de la localisation des points d'intégration
    00081    * s'il n'y a qu'un même maillage sur tous les pas de temps de tous les couples
    00082    * (typent,typgeo)
    00083    */
    00084   if ( _MEDfieldComputingStepCheck236(fid,  fieldname,
    00085                                       &_ncpst,
    00086                                       _checkmultiplemesh, &_multiplemesh,
    00087                                       _checkmeshname,     &_samedefaultmeshname) < 0) {
    00088     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_FIELD,fieldname);
    00089     goto ERROR;
    00090   }
    00091
    00092   strcat(_path,fieldname);
    00093   strcat(_path,"/");
    00094
    00095   if (_MEDnomEntite(_datagroupname1,entitype) < 0) {
    00096     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
    00097     ISCRUTE_int(entitype);SSCRUTE(_path);goto ERROR;
    00098   };
    00099
    00100   if ((entitype != MED_NOEUD)) {
    00101     if (_MEDnomGeometrie30(_tmp1,geotype) < 0) {
    00102       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
    00103       ISCRUTE_int(geotype);SSCRUTE(_path);goto ERROR;
    00104     }
    00105     strcat(_datagroupname1,".");
    00106     strcat(_datagroupname1,_tmp1);
    00107   }
    00108   strcat(_path,_datagroupname1);
    00109
    00110   if ((_datagroup1 = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    00111     _ret = 0;
    00112     goto ERROR;
    00113   }
    00114
    00115   strcat(_path,"/");
    00116
    00117   /*TODO : Vérifier IFORMAT */
    00118   sprintf(_nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numit);
    00119
    00120   strcat(_path,_nomdatagroup2);
    00121
    00122 /*   if (  _MEDobjectGetRank(fid, */
    00123 /*                        _path, */
    00124 /*                        _rank ) < 0 ) { */
    00125 /*     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDobjectGetRank"); */
    00126 /*     goto ERROR; */
    00127 /*   } */
    00128
    00129   if ((_gid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    00130     _ret = 0;
    00131     goto ERROR;
    00132   }
    00133   strcat(_path,"/");
    00134
    00135   /*Lit l'attribut MED_NOM_NDT  */
    00136   if ( _MEDattrEntierLire(_gid,MED_NOM_NDT, &_numdt) < 0) {
    00137     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00138     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NDT);
    00139     ISCRUTE(_numdt);goto ERROR;
    00140   }
    00141
    00142   if ( _numdt != numdt) {
    00143     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00144     SSCRUTE(fieldname);ISCRUTE(_numdt);ISCRUTE(numdt);goto ERROR;
    00145   }
    00146
    00147   /*Lit l'attribut MED_NOM_NOR */
    00148   if ( _MEDattrEntierLire(_gid,MED_NOM_NOR, &_numit) < 0) {
    00149     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00150     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_NOR);
    00151     ISCRUTE(_numit); goto ERROR;
    00152   }
    00153
    00154   if ( _numit != numit) {
    00155     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00156     SSCRUTE(fieldname);ISCRUTE(_numit);ISCRUTE(numit);goto ERROR;
    00157   }
    00158
    00159
    00160   /*Pas d'info maillage local ou distant*/
    00161   if (_MEDattrStringLire(_gid,MED_NOM_MAI,MED_TAILLE_NOM,_meshname) < 0) {
    00162     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    00163     SSCRUTE(fieldname);SSCRUTE(_path);SSCRUTE(MED_NOM_MAI);
    00164     SSCRUTE(_meshname); goto ERROR;
    00165   };
    00166
    00167   strcat(_path,_meshname);
    00168
    00169   if ( _MEDattributeStringRdByName(fid, _path, MED_NOM_GAU, MED_TAILLE_NOM, _localizationname) < 0 ) {
    00170     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
    00171     SSCRUTE(MED_NOM_GAU);SSCRUTE(_localizationname);goto ERROR;
    00172   }
    00173
    00174   if ( ! strcmp(_localizationname,MED_NOGAUSSi))
    00175     strcpy(defaultlocalizationname,MED_NO_LOCALIZATION);
    00176   else
    00177     strcpy(defaultlocalizationname,_localizationname);
    00178
    00179   if ( _MEDattributeStringRdByName(fid, _path, MED_NOM_PFL, MED_TAILLE_NOM, _profilename) < 0 ) {
    00180     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
    00181     SSCRUTE(MED_NOM_PFL);SSCRUTE(_profilename);goto ERROR;
    00182   }
    00183
    00184   if ( strcmp(_profilename,MED_NOPFLi) &&
    00185        strcmp(_profilename,"") ) /* le test MED_NOPFLi pour des raisons de compatibilité */
    00186     {
    00187       strcpy(defaultprofilename,_profilename);
    00188     }  else {
    00189     strcpy(defaultprofilename, MED_NO_PROFILE);
    00190   }
    00191
    00192
    00193   _ret = (med_int) 1;
    00194
    00195  ERROR:
    00196
    00197
    00198   if (_datagroup1>0)            if (_MEDdatagroupFermer(_datagroup1) < 0) {
    00199     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00200     SSCRUTE(_datagroupname1); ISCRUTE_id(_datagroup1);
    00201   }
    00202
    00203   if (_gid>0)            if (_MEDdatagroupFermer(_gid) < 0) {
    00204     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00205     ISCRUTE_id(_gid);
    00206   }
    00207
    00208   va_end(params);
    00209   *fret = _ret;
    00210   return;
    00211 }