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

Généré le Mon May 16 17:10:22 2011 pour MED fichier par  doxygen 1.6.1