_MEDfield23nValue236.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 <string.h>
00022 #include <stdlib.h>
00023 #include <med_outils.h>
00024 
00025 #include <2.3.6/med23v30.h>
00026 #include <2.3.6/med23v30_proto.h>
00027 #include "2.3.6/med23v30_misc.h"
00028 
00029 #include "med_versioned.h"
00030 
00031 void
00032 _MEDfield23nValue236(int dummy, ...)
00033 {
00034 
00035 
00036   med_int               _ret                 =-1;
00037   med_int               _nbofprofile         = 0;
00038   med_int               _n                   = 0;
00039   med_int               _profilearraysize    = 0,_nbofvaluesperentity=0;
00040   med_int               _nbofintegrationpoint= 0;
00041   med_bool              _anyprofile          = MED_FALSE;
00042   med_geometrie_element _locgeotype          = 0;
00043   med_int               _intlocgeotype       = 0;
00044   med_int               _nbofvaluesperentityfromloc=0;
00045   int                   _dummy                     =0;
00046   char     _localizationname  [MED_TAILLE_NOM+1]                 = "";
00047   char     _tmpprofilename    [MED_NAME_SIZE+1]                  = "", *_profilename=0;
00048   char     _path              [MED_TAILLE_GAUSS+MED_TAILLE_NOM+1]= MED_GAUSS;
00049   char     _geotype           [MED_TAILLE_NOM_ENTITE+1]          = "";
00050   int      _meshit =-1;
00051 
00052 
00053   MED_VARGS_DECL(const, med_idt           , , fid                        );
00054   MED_VARGS_DECL(const, char * , const      , fieldname                  );
00055   MED_VARGS_DECL(const, med_int           , , numdt                      );
00056   MED_VARGS_DECL(const, med_int           , , numit                      );
00057   MED_VARGS_DECL(const, med_entity_type   , , entitytype                 );
00058   MED_VARGS_DECL(const, med_geometry_type , , geotype                    );
00059   MED_VARGS_DECL(const, char * , const      , meshname                   );
00060   MED_VARGS_DECL(, char *, const      , profilename                      );
00061   MED_VARGS_DECL(const, int               , , profileit                  );
00062   MED_VARGS_DECL(const, med_storage_mode  , , storagemode                );
00063   MED_VARGS_DECL(, med_int *, const   , profilesize                      );
00064   MED_VARGS_DECL(, char *, const      , localizationname                 );
00065   MED_VARGS_DECL(, med_int *, const   , nbofintegrationpoint             );
00066   MED_VARGS_DECL(, med_int *         ,, fret                             );
00067 
00068   va_list params;
00069   va_start(params,dummy);
00070 
00071   MED_VARGS_DEF(const, med_idt           , , fid                        );
00072   MED_VARGS_DEF(const, char * , const      , fieldname                  );
00073   MED_VARGS_DEF(const, med_int           , , numdt                      );
00074   MED_VARGS_DEF(const, med_int           , , numit                      );
00075   MED_VARGS_DEF(const, med_entity_type   , , entitytype                 );
00076   MED_VARGS_DEF(const, med_geometry_type , , geotype                    );
00077   MED_VARGS_DEF(const, char * , const      , meshname                   );
00078   MED_VARGS_DEF(, char *, const      , profilename                      );
00079   MED_VARGS_DEF(const, int               , , profileit                  );
00080   MED_VARGS_DEF(const, med_storage_mode  , , storagemode                );
00081   MED_VARGS_DEF(, med_int *, const   , profilesize                      );
00082   MED_VARGS_DEF(, char *, const      , localizationname                 );
00083   MED_VARGS_DEF(, med_int *, const   , nbofintegrationpoint             );
00084   MED_VARGS_DEF(, med_int *         ,, fret                             );
00085 
00086   /*
00087    * On inhibe le gestionnaire d'erreur HDF 5
00088    */
00089   _MEDmodeErreurVerrouiller();
00090 
00091   NOFINALBLANK(fieldname,ERROR);
00092 
00093   if ( profileit != 1 ) {
00094     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_VALUE_MSG);
00095     ISCRUTE_int(profileit);goto ERROR;
00096   }
00097 
00098   /*
00099    * Cette appel n'effectue pas l'appel à _MEDfieldComputingStepCheck236
00100    */
00101   _MEDfield23nProfile236(_dummy,fid,fieldname,numdt,numit,entitytype,geotype,
00102                          _meshit,meshname,_tmpprofilename,_localizationname,&_nbofprofile );
00103 
00104   if ( _nbofprofile  < 0 ) {
00105     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDfieldnProfile236");
00106     goto ERROR;
00107   }
00108 
00109   /* REM: MEDnVal prend en compte le nombre de points de Gauss, ce qui n'est pas le cas
00110      de MEDfieldnValue */
00111   if ( (_n = MEDnVal(fid, (char *) fieldname,entitytype,geotype,
00112                      numdt,numit,(char *) meshname,(med_mode_profil) storagemode) ) < 0 ) {
00113     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnVal");
00114     goto ERROR;
00115   }
00116 
00117   /*
00118    * Lecture de la taille du profil (eventuellement MED_ALLENTITIES_PROFILE)
00119    */
00120 
00121   /* REM:  (profileit < 0 ) signifie que l'on nous a fourni <profilename> */
00122   if ( profileit < 0 ) {
00123       if ( !strlen(profilename)) {
00124         _profilename = MED_NOPFL;
00125       }  else {
00126         if ( strcmp(_tmpprofilename,profilename) ) {
00127           MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,profilename);
00128           SSCRUTE(_tmpprofilename); goto ERROR;
00129         }
00130         _profilename=profilename;
00131         _anyprofile=MED_TRUE;
00132       }
00133   } else {
00134     strncpy(profilename,_tmpprofilename,MED_TAILLE_NOM+1);
00135     profilename[MED_TAILLE_NOM]='\0';
00136     _profilename=profilename;
00137     if ( strlen(profilename)) _anyprofile=MED_TRUE;
00138   }
00139 
00140   if ( _anyprofile ) {
00141     if ( (_profilearraysize=MEDprofileSizeByName(fid, _profilename)) < 0)  {
00142       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_FIELD_MSG);
00143       SSCRUTE(fieldname); SSCRUTE(_profilename);
00144       SSCRUTE("MEDprofileSizeByName");goto ERROR;
00145     }
00146   }
00147 
00148   /*
00149    * Lecture du nombre de points d'intégration.
00150    */
00151 
00152   strncpy(localizationname,_localizationname,MED_TAILLE_NOM+1);
00153   localizationname[MED_TAILLE_NOM]='\0';
00154 
00155   /* Vérification de la cohérence du  nombre de valeurs pas entité */
00156   if (entitytype == MED_NODE_ELEMENT ) {
00157     if ( strlen( _localizationname) ) {
00158         MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_PARAMETER,_localizationname);
00159         SSCRUTE(MED_NO_LOCALIZATION);ISCRUTE_int(entitytype);goto ERROR;
00160     }
00161     _nbofvaluesperentityfromloc = geotype % 100;
00162   } else if (! strcmp(_localizationname,MED_GAUSS_ELNO)) {
00163     /* Les points de Gauss sont définis sur les noeuds de l'element (mot cle) */
00164     /* le nombre de points de Gauss est egal au nombre de noeuds de l'element */
00165     _nbofvaluesperentityfromloc = geotype % 100;
00166   } else if ( strlen(_localizationname) ) {
00167 
00168     strcat(_path,_localizationname);
00169 
00170     if ( _MEDattributeNumRdByName(fid, _path, MED_NOM_NBR,MED_INTERNAL_INT,(unsigned char *) &_nbofvaluesperentityfromloc) < 0 ) {
00171       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
00172       SSCRUTE(MED_NOM_NBR);SSCRUTE(_path); ISCRUTE(_nbofvaluesperentityfromloc);goto ERROR;
00173     }
00174 
00175     if ( _MEDattributeNumRdByName(fid, _path, MED_NOM_GEO, MED_INTERNAL_INT,(unsigned char *) &_intlocgeotype) < 0 ) {
00176       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
00177       SSCRUTE(MED_NOM_GEO);SSCRUTE(_path); ISCRUTE(_intlocgeotype);goto ERROR;
00178     }
00179 
00180     _locgeotype = (med_geometry_type) _intlocgeotype;
00181 
00182     if ( _locgeotype != geotype ) {
00183       MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00184       SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE_int(_locgeotype);ISCRUTE_int(geotype);goto ERROR;
00185     }
00186 
00187   } else {
00188     _nbofvaluesperentityfromloc = 1;
00189   }
00190 
00191   /* Pour effectuer la vérification suivante (incohérence dans le fichier suite à une 
00192      maj de la localisation ou du champ  sans prise en compte d'un nombre de points d'intégration différent),
00193      il faudrait lire l'attribut MED_NOM_NGA sur le maillage par défaut du champ*/
00194   /* Pour celà il faut soit developper une nouvelle routine soit utiliser MEDpasdetempsInfo mais qui
00195      est itérative*/
00196 /*   if ( _nbofvaluesperentityfromloc != _nbofvaluesperentity ) { */
00197 /*     MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG); */
00198 /*     SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_nbofvaluesperentityfromloc); */
00199 /*     ISCRUTE(_nbofvaluesperentity);goto ERROR; */
00200 /*   } */
00201 
00202   *nbofintegrationpoint = _nbofvaluesperentityfromloc;
00203 
00204   _n/=_nbofvaluesperentityfromloc;
00205 
00206   /*Rectification de la valeur 2.3.6 qui prend en compte le nombre de points d'intégration*/
00207   if (_anyprofile)
00208     *profilesize=_profilearraysize;
00209   else
00210     *profilesize=_n;
00211 
00212 
00213   _ret = _n;
00214  ERROR:
00215 
00216   va_end(params);
00217   *fret = _ret;
00218 
00219   return;
00220 }

Généré le Mon Nov 7 16:21:23 2011 pour MED fichier par  doxygen 1.6.1