_MEDfieldnValue236.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 #include "med_versioned.h"
00025 
00026 #include <2.3.6/med23v30.h>
00027 #include <2.3.6/med23v30_proto.h>
00028 #include "2.3.6/med23v30_misc.h"
00029 
00030 
00031 void
00032 _MEDfieldnValue236(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 
00051 
00052   MED_VARGS_DECL(const, med_idt           , , fid                        );
00053   MED_VARGS_DECL(const, char * , const      , fieldname                  );
00054   MED_VARGS_DECL(const, med_int           , , numdt                      );
00055   MED_VARGS_DECL(const, med_int           , , numit                      );
00056   MED_VARGS_DECL(const, med_entity_type   , , entitytype                 );
00057   MED_VARGS_DECL(const, med_geometry_type , , geotype                    );
00058   MED_VARGS_DECL(, char *, const      , profilename                      );
00059   MED_VARGS_DECL(const, int               , , profileit                  );
00060   MED_VARGS_DECL(const, med_storage_mode  , , storagemode                );
00061   MED_VARGS_DECL(, med_int *, const   , profilesize                      );
00062   MED_VARGS_DECL(, char *, const      , localizationname                 );
00063   MED_VARGS_DECL(, med_int *, const   , nbofintegrationpoint             );
00064   MED_VARGS_DECL(, med_int *         ,, fret                             );
00065 
00066   va_list params;
00067   va_start(params,dummy);
00068 
00069   MED_VARGS_DEF(const, med_idt           , , fid                        );
00070   MED_VARGS_DEF(const, char * , const      , fieldname                  );
00071   MED_VARGS_DEF(const, med_int           , , numdt                      );
00072   MED_VARGS_DEF(const, med_int           , , numit                      );
00073   MED_VARGS_DEF(const, med_entity_type   , , entitytype                 );
00074   MED_VARGS_DEF(const, med_geometry_type , , geotype                    );
00075   MED_VARGS_DEF(, char *, const      , profilename                      );
00076   MED_VARGS_DEF(const, int               , , profileit                  );
00077   MED_VARGS_DEF(const, med_storage_mode  , , storagemode                );
00078   MED_VARGS_DEF(, med_int *, const   , profilesize                      );
00079   MED_VARGS_DEF(, char *, const      , localizationname                 );
00080   MED_VARGS_DEF(, med_int *, const   , nbofintegrationpoint             );
00081   MED_VARGS_DEF(, med_int *         ,, fret                             );
00082 
00083   /*
00084    * On inhibe le gestionnaire d'erreur HDF 5
00085    */
00086   _MEDmodeErreurVerrouiller();
00087 
00088   NOFINALBLANK(fieldname,ERROR);
00089 
00090   if ( (profileit != 1) &&  
00091        (profileit != -1)) {
00092     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_VALUE_MSG);
00093     ISCRUTE_int(profileit);goto ERROR;
00094   }
00095 
00096   /*
00097    * Cette appel effectue l'appel à _MEDfieldComputingStepCheck236
00098    */
00099   _MEDfieldnProfile236(_dummy,fid,fieldname,numdt,numit,entitytype,geotype,
00100                        &_tmpprofilename,&_localizationname,&_nbofprofile );
00101 
00102 
00103   if ( _nbofprofile  < 0 ) {
00104     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDfieldnProfile236");
00105     goto ERROR;
00106   }
00107 
00108   /* REM: MEDnVal prend en compte le nombre de points de Gauss, ce qui n'est pas le cas
00109      de MEDfieldnValue */
00110   if ( (_n = MEDnVal(fid, (char *) fieldname,entitytype,geotype,
00111                      numdt,numit,MED_NOREF,(med_mode_profil) storagemode) ) < 0 ) {
00112     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnVal");
00113     goto ERROR;
00114   }
00115 
00116   /*
00117    * Lecture de la taille du profil (eventuellement MED_ALLENTITIES_PROFILE)
00118    */
00119 
00120   /* REM:  (profileit < 0 ) signifie que l'on nous a fourni <profilename> */
00121   if ( profileit < 0 ) {
00122       if ( !strlen(profilename)) {
00123         _profilename = MED_NOPFL;
00124       }  else {
00125         if ( strcmp(_tmpprofilename,profilename) ) {
00126           MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,profilename);
00127           SSCRUTE(_tmpprofilename); goto ERROR;
00128         }
00129         _profilename=profilename;
00130         _anyprofile=MED_TRUE;
00131       }
00132   } else {
00133     strncpy(profilename,_tmpprofilename,MED_TAILLE_NOM+1);
00134     profilename[MED_TAILLE_NOM]='\0';
00135     _profilename=profilename;
00136     if ( strlen(profilename)) _anyprofile=MED_TRUE;
00137   }
00138 
00139   if ( _anyprofile ) {
00140     if ( (_profilearraysize=MEDprofileSizeByName(fid, _profilename)) < 0)  {
00141       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_FIELD_MSG);
00142       SSCRUTE(fieldname); SSCRUTE(_profilename);
00143       SSCRUTE("MEDprofileSizeByName");goto ERROR;
00144     }
00145   }
00146 
00147   /*
00148    * Lecture du nombre de points d'intégration.
00149    */
00150 
00151   strncpy(localizationname,_localizationname,MED_TAILLE_NOM+1);
00152   localizationname[MED_TAILLE_NOM]='\0';
00153 
00154   /* Vérification de la cohérence du  nombre de valeurs pas entité */
00155   if (entitytype == MED_NODE_ELEMENT ) {
00156     if ( strlen( _localizationname) ) {
00157         MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_PARAMETER,_localizationname);
00158         SSCRUTE(MED_NO_LOCALIZATION);ISCRUTE_int(entitytype);goto ERROR;
00159     }
00160     _nbofvaluesperentityfromloc = geotype % 100;
00161   } else if (! strcmp(_localizationname,MED_GAUSS_ELNO)) {
00162     /* Les points de Gauss sont d"finis sur les noeuds de l'element (mot cle) */
00163     /* le nombre de points de Gauss est egal au nombre de noeuds de l'element */
00164     _nbofvaluesperentityfromloc = geotype % 100;
00165   } else if ( strlen(_localizationname) ) {
00166 
00167     strcat(_path,_localizationname);
00168 
00169     if ( _MEDattributeNumRdByName(fid, _path, MED_NOM_NBR,MED_INTERNAL_INT,(unsigned char *) &_nbofvaluesperentityfromloc) < 0 ) {
00170       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
00171       SSCRUTE(MED_NOM_NBR);SSCRUTE(_path); ISCRUTE(_nbofvaluesperentityfromloc);goto ERROR;
00172     }
00173 
00174     if ( _MEDattributeNumRdByName(fid, _path, MED_NOM_GEO, MED_INTERNAL_INT,(unsigned char *) &_intlocgeotype) < 0 ) {
00175       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
00176       SSCRUTE(MED_NOM_GEO);SSCRUTE(_path); ISCRUTE(_intlocgeotype);goto ERROR;
00177     }
00178 
00179     _locgeotype = (med_geometry_type) _intlocgeotype;
00180 
00181     if ( _locgeotype != geotype ) {
00182       MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00183       SSCRUTE(_localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE_int(_locgeotype);ISCRUTE_int(geotype);
00184       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