_MEDfieldValueAdvancedWr30.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 #include <stdlib.h>
00024 
00025 
00026 void  _MEDfieldValueAdvancedWr30(int dummy,...) {
00027 
00028   med_access_mode       _MED_ACCESS_MODE;
00029   med_err               _ret=-1;
00030   med_idt               _gid=0,_locgid=0,_datagroup1=0,_datagroup2=0,_datagroup3=0;
00031   med_int               _nbofconstituentpervalue=0, _profilearraysize=0;
00032   med_bool              _defaultprofileexist=MED_FALSE,_defaultlocalizationexist=MED_FALSE;
00033   med_bool              _attexist=MED_FALSE;
00034 /*   med_bool              _profilparameterexist=MED_FALSE; */
00035   med_bool              _profilehaschanged=MED_FALSE,_filterparameterexist=MED_FALSE;
00036   med_int               _nbofvaluesperentity=0,_nbofsectiongeotype=0,_nbofsectioncell=1;
00037   med_field_type        _fieldtype=0;
00038   med_int               _intfieldtype=0;
00039   med_geometry_type     _locgeotype=0,_sectiongeotype=0;
00040   med_int               _intlocgeotype=0;
00041   char _gidname           [MED_TAILLE_CHA+MED_NAME_SIZE+1]="";
00042   char _datagroupname1    [2*MED_MAX_PARA+1]="";
00043   char _datagroupname2    [2*MED_TAILLE_NOM_ENTITE+2]="";
00044   char _profilename       [MED_NAME_SIZE+1]="";
00045   char _locgidname        [MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
00046   char _sectionmeshname      [MED_NAME_SIZE+1]="";
00047   char _sectiongeotypename   [MED_NAME_SIZE+1]="";
00048   char _geotypename       [MED_TAILLE_NOM_ENTITE+1]="";
00049   char _defaultprofilename[MED_NAME_SIZE+1]=MED_NO_PROFILE;
00050   char _defaultlocalizationname[MED_NAME_SIZE+1]=MED_NO_LOCALIZATION;
00051   med_filter *               _filter           = NULL;
00052   med_filter                 _tmpfilter        = MED_FILTER_INIT;
00053   med_filter                 _paramfilter      = MED_FILTER_INIT;
00054   med_int                    _MED_NO_DT = MED_NO_DT;
00055   med_int                    _MED_NO_IT = MED_NO_IT;
00056   med_bool                   _chgt=MED_FALSE,_trsf=MED_FALSE;
00057 
00058 
00059   MED_VARGS_DECL(const, med_idt               , , fid              );
00060   MED_VARGS_DECL(const, char * , const          , fieldname        );
00061   MED_VARGS_DECL(const, med_int               , , numdt            );
00062   MED_VARGS_DECL(const, med_int               , , numit            );
00063   MED_VARGS_DECL(const, med_float             , , dt               );
00064   MED_VARGS_DECL(const, med_entity_type       , , entitytype       );
00065   MED_VARGS_DECL(const, med_geometry_type     , , geotype          );
00066   MED_VARGS_DECL(const, med_storage_mode      , , storagemode      );
00067   MED_VARGS_DECL(const, char * , const          , profilename      );
00068   MED_VARGS_DECL(const, char * , const          , localizationname );
00069   MED_VARGS_DECL(const, med_switch_mode       , , switchmode       );
00070   MED_VARGS_DECL(const, med_int               , , componentselect  );
00071   MED_VARGS_DECL(const, med_filter* , const     , filter           );
00072   MED_VARGS_DECL(const, med_int               , , nbofentity       );
00073   MED_VARGS_DECL(const, unsigned char*, const   , value            );
00074   MED_VARGS_DECL(, med_err *                   ,, fret             );
00075 
00076   va_list params;
00077   va_start(params,dummy);
00078 
00079   MED_VARGS_DEF(const, med_idt               , , fid              );
00080   MED_VARGS_DEF(const, char * , const          , fieldname        );
00081   MED_VARGS_DEF(const, med_int               , , numdt            );
00082   MED_VARGS_DEF(const, med_int               , , numit            );
00083   MED_VARGS_DEF(const, med_float             , , dt               );
00084   MED_VARGS_DEF(const, med_entity_type       , , entitytype       );
00085   MED_VARGS_DEF(const, med_geometry_type     , , geotype          );
00086   MED_VARGS_DEF(const, med_storage_mode      , , storagemode      );
00087   MED_VARGS_DEF(const, char * , const          , profilename      );
00088   MED_VARGS_DEF(const, char * , const          , localizationname );
00089   MED_VARGS_DEF(const, med_switch_mode       , , switchmode       );
00090   MED_VARGS_DEF(const, med_int               , , componentselect  );
00091   MED_VARGS_DEF(const, med_filter* , const     , filter           );
00092   MED_VARGS_DEF(const, med_int               , , nbofentity       );
00093   MED_VARGS_DEF(const, unsigned char*, const   , value            );
00094   MED_VARGS_DEF(, med_err *                   ,, fret             );
00095 
00096 
00097 
00098 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00099 
00100   if (filter) {
00101     _filter=(med_filter*)(filter); _filterparameterexist=MED_TRUE;
00102   }
00103   else {
00104     _filter=&_tmpfilter;
00105     (*_filter).nbofentity              = nbofentity;
00106 /*   (*_filter).nbofvaluesperentity     = nbofvaluesperentity; */
00107 /*   (*_filter).nbofconstituentpervalue = nbofconstituentpervalue; */
00108     (*_filter).constituentselect       = componentselect;
00109     (*_filter).switchmode              = switchmode;
00110     (*_filter).storagemode             = storagemode;
00111     strcpy((*_filter).profilename,profilename);
00112 /*   (*_filter).profilearraysize        = profilearraysize; */
00113   }
00114 
00115   /*
00116    * On inhibe le gestionnaire d'erreur HDF 5
00117    */
00118   _MEDmodeErreurVerrouiller();
00119 
00120   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00121     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00122     goto ERROR;
00123   }
00124 
00125   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
00126     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00127     ISCRUTE_int(_MED_ACCESS_MODE);
00128     goto ERROR;
00129   }
00130 
00131   /*
00132    * Si le DataGroup MED_CHA n'existe pas => erreur
00133    */
00134   NOFINALBLANK(fieldname,ERROR);
00135 
00136   strcpy(_gidname,MED_CHA);
00137   strcat(_gidname,fieldname);
00138   if ((_gid = _MEDdatagroupOuvrir(fid,_gidname)) < 0) {
00139     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
00140     SSCRUTE(fieldname);SSCRUTE(_gidname); goto ERROR;
00141   }
00142 
00143 
00144   /* Lecture de l'attribut MED_NOM_NCO */
00145   /* Cohérence de l'attribut MED_NOM_NCO avec le filtre*/
00146   if (_MEDattrEntierLire(_gid,MED_NOM_NCO,&_nbofconstituentpervalue) < 0) {
00147     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00148     SSCRUTE(fieldname);SSCRUTE(MED_NOM_NCO);goto ERROR;
00149   }
00150 
00151   if (_filterparameterexist) {
00152     if ((*_filter).nbofconstituentpervalue != _nbofconstituentpervalue ) {
00153       MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_VALUE_MSG);
00154       ISCRUTE((*_filter).nbofconstituentpervalue); ISCRUTE(_nbofconstituentpervalue );
00155       goto ERROR;
00156     }
00157   } else {
00158     (*_filter).nbofconstituentpervalue = _nbofconstituentpervalue;
00159   }
00160 
00161 
00162 
00163   /* Lecture de l'attribut MED_NOM_TYP */
00164   if ( _MEDattrEntierLire(_gid,MED_NOM_TYP,&_intfieldtype) < 0) {
00165     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00166     SSCRUTE(fieldname);SSCRUTE(MED_NOM_TYP);
00167     goto ERROR;
00168   }
00169   _fieldtype = (med_field_type) (_intfieldtype);
00170 
00171 
00172   /* MODEL : Remontée du datagroup2 en datagroup1 */
00173   /*
00174    * Creation/Ouverture du datagroup de niveau 2 <numdt>.<numit>
00175    */
00176   _MEDgetComputationStepName(MED_SORT_DTIT,numdt,numit,_datagroupname1);
00177 
00178   _datagroup1 = 0;
00179   if ( (_datagroup1 = _MEDdatagroupOuvrir(_gid,_datagroupname1)) < 0 )
00180     if ((_datagroup1 = _MEDdatagroupCreer(_gid,_datagroupname1)) < 0 ) {
00181       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_ERR_FIELD_MSG);
00182       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);goto ERROR;
00183     }
00184 
00185   /*Cree ou ouvre l'attribut MED_NOM_NDT pour écriture */
00186   if ( _MEDattributeIntWr(_datagroup1,MED_NOM_NDT,&numdt) < 0) {
00187     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00188     SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_NDT);
00189     ISCRUTE(numdt);goto ERROR;
00190   }
00191 
00192   /*Cree ou ouvre l'attribut MED_NOM_PDT pour écriture */
00193   if ( _MEDattrFloatEcrire(_datagroup1,MED_NOM_PDT,&dt) < 0) {
00194     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00195     SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_PDT);
00196     RSCRUTE(dt);goto ERROR;
00197   }
00198 
00199   /*Cree ou ouvre l'attribut MED_NOM_NOR pour écriture */
00200   if ( _MEDattributeIntWr(_datagroup1,MED_NOM_NOR,&numit) < 0) {
00201     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00202     SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_NOR);
00203     ISCRUTE(numit); goto ERROR;
00204   }
00205 
00206   /*Cree l'attribut MED_NOM_RDT s'il n'exite pas déjà*/
00207   _MEDattributeExist(_datagroup1,".",MED_NOM_RDT,&_attexist);
00208   if (!_attexist )
00209     if ( _MEDattributeIntWr(_datagroup1,MED_NOM_RDT,&_MED_NO_DT) < 0) {
00210       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00211       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_RDT);
00212       ISCRUTE_int(MED_NO_DT);goto ERROR;
00213     }
00214 
00215   /*Cree l'attribut MED_NOM_ROR s'il n'exite pas déjà*/
00216   _MEDattributeExist(_datagroup1,".",MED_NOM_ROR,&_attexist);
00217   if (!_attexist )
00218     if ( _MEDattributeIntWr(_datagroup1,MED_NOM_ROR,&_MED_NO_IT) < 0) {
00219       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00220       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_ROR);
00221       ISCRUTE_int(MED_NO_IT);goto ERROR;
00222     }
00223 
00224   /*MODEL : MED_NOM_UNI est remonte à la création du champ  */
00225   /*Cree ou ouvre l'attribut  MED_NOM_UNI pour écriture */
00226 /*   if ( numdt == MED_NO_DT ) { */
00227 /*     if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNI,MED_SNAME_SIZE,MED_PNOM_BLANC) < 0) { */
00228 /*       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_UNI); */
00229 /*       goto ERROR; */
00230 /*     } */
00231 /*   } else */
00232 /*     if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNI,MED_SNAME_SIZE,dt_unit) < 0) { */
00233 /*       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_UNI); */
00234 /*       SSCRUTE(dt_unit); */
00235 /*       goto ERROR; */
00236 /*     } */
00237 
00238   /* MODEL : Descente du datagroup1 en datagroup2 */
00239   /*
00240    *  Creation/Ouverture du datagroup de niveau 2 <entitytype>[.<geotype>]
00241    */
00242 
00243   if (_MEDgetEntityTypeName(_datagroupname2,entitytype) < 0) {
00244     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
00245     ISCRUTE_int(entitytype);SSCRUTE(fieldname);goto ERROR;
00246   }
00247 
00248 
00249   if ( entitytype != MED_NODE ) {
00250 
00251     if ( entitytype == MED_STRUCT_ELEMENT ) {
00252       if ( MEDstructElementName(fid, geotype,_geotypename) < 0 ) {
00253         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDstructElementName");
00254         ISCRUTE_int(geotype);goto ERROR;
00255       }
00256     } else {
00257       if ( _MEDgetInternalGeometryTypeName(_geotypename,geotype) < 0) {
00258         MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
00259         ISCRUTE_int(geotype);SSCRUTE(fieldname);goto ERROR;
00260       }
00261     }
00262     strcat(_datagroupname2,".");
00263     strcat(_datagroupname2,_geotypename);
00264   }
00265 
00266   _datagroup2 = 0;
00267   if ( (_datagroup2 = _MEDdatagroupOuvrir(_datagroup1,_datagroupname2)) < 0)
00268     if ((_datagroup2 = _MEDdatagroupCreer(_datagroup1,_datagroupname2)) < 0) {
00269       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_datagroupname2);
00270       SSCRUTE(fieldname);goto ERROR;
00271     }
00272 
00273   /* MODEL : déplacement de l'attribut MED_NOM_PFL */
00274 
00275   /*Cree ou ouvre  l'attribut MED_NOM_PFL   */
00276   /* Lit le nom du profil associé s'il en existe déjà un */
00277   if ( _MEDattrStringLire(_datagroup2,MED_NOM_PFL,MED_NAME_SIZE,_defaultprofilename) < 0 ) {
00278     strncpy(_defaultprofilename,MED_NO_PROFILE,MED_NAME_SIZE+1);
00279     _defaultprofileexist = MED_FALSE;
00280   } else
00281     _defaultprofileexist = MED_TRUE;
00282 
00283   NOFINALBLANK(profilename,ERROR);
00284 
00285   if ( strlen((*_filter).profilename) == 0 ) {  /* idem MED_NOPFL*/
00286     /*Ecriture de MED_NO_PROFILE_INTERNAL car un datagroup ne peut pas être de nom ""*/
00287     strncpy(_profilename,MED_NO_PROFILE_INTERNAL,MED_NAME_SIZE+1);
00288 /*     strncpy(_profilename,MED_NO_PROFILE,MED_NAME_SIZE+1); */
00289 /*     _profilparameterexist=MED_FALSE; */
00290     _profilearraysize = MED_UNDEF_SIZE;
00291   } else {
00292     strncpy(_profilename,(*_filter).profilename,MED_NAME_SIZE+1);
00293     _profilename[MED_NAME_SIZE]='\0'; /*On tronque les eventuels noms trop long*/
00294 /*     _profilparameterexist=MED_TRUE; */
00295     if ( ( _profilearraysize = MEDprofileSizeByName( fid,_profilename) ) < 0 ) {
00296       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_FIELD_MSG);
00297       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);
00298       SSCRUTE(_profilename);SSCRUTE("MEDprofileSizeByName");goto ERROR;
00299     }
00300   }
00301 
00302   /*INUTILE : le paramètre est positionné dans  MEDfilterEntityCr */
00303   if (!_filterparameterexist) (*_filter).profilearraysize =  _profilearraysize;
00304 
00305 
00306   /*Cree ou ouvre  l'attribut MED_NOM_GAU   */
00307   /* Lit le nom de la localisation associée s'il en existe déjà une */
00308   if ( _MEDattrStringLire(_datagroup2,MED_NOM_GAU,MED_NAME_SIZE,_defaultlocalizationname) < 0 ) {
00309     strncpy(_defaultlocalizationname,MED_NO_LOCALIZATION,MED_NAME_SIZE+1);
00310     _defaultlocalizationexist = MED_FALSE;
00311   } else {
00312     _defaultlocalizationexist = MED_TRUE;
00313   }
00314   NOFINALBLANK(localizationname,ERROR);
00315 
00316 
00317   /*
00318    * Cree ou ouvre le _datagroup de niveau 3 <profilename>
00319    */
00320 
00321   _datagroup3 = 0;
00322   if (((_datagroup3 = _MEDdatagroupOuvrir(_datagroup2,_profilename)) > 0)
00323       && ( _MED_ACCESS_MODE == MED_ACC_RDEXT )) {
00324     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_DATAGROUP_MSG);
00325     SSCRUTE(_profilename);
00326     ISCRUTE_int(_MED_ACCESS_MODE);
00327     goto ERROR;
00328   } else
00329     if ( _datagroup3 < 0)
00330       if ((_datagroup3 = _MEDdatagroupCreer(_datagroup2,_profilename)) < 0) {
00331         MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_profilename);
00332         SSCRUTE(fieldname);SSCRUTE(_profilename);goto ERROR;
00333       }
00334 
00335   /*L'attribut MED_NOM_PFL du datagroup2 est crée après le datagroup profilename
00336    en cas d'erreur de création */
00337   /*TODO: IL faudra gérer la suppression d'un profil si nbofentity==0 et *val=0
00338     TODO: Vérifier alors qu'il n'est pas le profil par défaut sinon proposer une API
00339     TODO: pour changer le profil par défaut.*/
00340   if ( !_defaultprofileexist )
00341     if ( _MEDattributeStringWr(_datagroup2,MED_NOM_PFL,MED_NAME_SIZE,_profilename) < 0) {
00342       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00343       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);
00344       SSCRUTE(MED_NOM_PFL);SSCRUTE(_profilename);goto ERROR;
00345     }
00346 
00347   if ( !_defaultlocalizationexist ) {
00348     if ( _MEDattributeStringWr(_datagroup2,MED_NOM_GAU,MED_NAME_SIZE,localizationname) < 0) {
00349       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00350       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);
00351       SSCRUTE(MED_NOM_GAU);SSCRUTE(localizationname);goto ERROR;
00352     }
00353   }
00354   /*Cree ou ouvre l'attribut MED_NOM_NBR */
00355   if ( _MEDattributeIntWr(_datagroup3,MED_NOM_NBR,&((*_filter).nbofentity)) < 0) {
00356     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00357     SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00358     SSCRUTE(MED_NOM_NBR);ISCRUTE((*_filter).nbofentity);goto ERROR;
00359   }
00360 
00361   /* Lit le nombre de points d'intégation et vérifie   */
00362   /* que la localisation porte sur le meme type géométrique  */
00363 
00364   /* Dans le cas de champs aux noeuds par element, on stocke
00365    * une localisation vide, et le nombre de noeuds dans l'attribut NGA
00366    */
00367   /*
00368     TODO : ? SYMETRISATION MED_NODE_ELEMENT POUR MAILLAGE ?
00369     TODO : DEUX MT CLES RESERVES POUR DES LOCALISATIONS PARTICULIERES
00370     TODO : MED_NODESOFCELL_WITHOUTWEIGHT sans élément de réf & sans poids
00371     TODO : MED_NODESOFCELL_WITHWEIGHT ?
00372   */
00373   if (entitytype == MED_NODE_ELEMENT ) {
00374     if ( strlen(localizationname) != 0) {
00375       MED_ERR_(_ret,MED_ERR_NOTNULL,MED_ERR_PARAMETER,localizationname);
00376       ISCRUTE_int(entitytype);goto ERROR;
00377     }
00378     _nbofvaluesperentity = geotype % 100;
00379   } else if (! strcmp(localizationname,MED_GAUSS_ELNO)) {
00380     /* TODO: générer une erreur si on est en présence d'un élément de structure.*/
00381     /* Les points de Gauss sont définis sur les noeuds de l'element (mot cle) */
00382     /* le nombre de points de Gauss est egal au nombre de noeuds de l'element */
00383     _nbofvaluesperentity = geotype % 100;
00384     /*Impose t'on une localisation, sinon test si "" ?*/
00385   } else if (strlen(localizationname))  {
00386     strcat(_locgidname,localizationname);
00387 
00388     if ((_locgid = _MEDdatagroupOuvrir(fid,_locgidname)) < 0) {
00389       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_locgidname);
00390       goto ERROR;
00391     }
00392 
00393     if (_MEDattrEntierLire(_locgid,MED_NOM_NBR,&_nbofvaluesperentity) < 0) {
00394       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00395       SSCRUTE(localizationname);SSCRUTE(MED_NOM_NBR);ISCRUTE(_nbofvaluesperentity);goto ERROR;
00396     }
00397 
00398 
00399     if ( entitytype == MED_STRUCT_ELEMENT ) {
00400 
00401       /*
00402        * Lecture de l'attribut MED_NOM_NOM (nom du maillage support de section)
00403        */
00404       if ( _MEDattrStringLire(_locgid,MED_NOM_NOM,MED_NAME_SIZE,_sectionmeshname) < 0) {
00405         MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_locgidname);
00406         SSCRUTE(MED_NOM_NOM);SSCRUTE(_sectionmeshname);
00407         goto ERROR;
00408       }
00409 
00410       if (strlen(_sectionmeshname) ) {
00411 
00412         if ( (_nbofsectiongeotype = MEDmeshnEntity(fid,_sectionmeshname,MED_NO_DT,MED_NO_IT,
00413                                             MED_CELL,MED_ALL_GEOTYPE,MED_CONNECTIVITY,MED_NODAL,
00414                                             &_chgt,&_trsf) )  < 0) {
00415           MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00416           ISCRUTE(_nbofsectiongeotype);goto ERROR;
00417         }
00418 
00419         if ( (_nbofsectiongeotype != 1 ) ) {
00420           MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_RANGE,""); ISCRUTE(_nbofsectiongeotype); goto ERROR;
00421         }
00422 
00423 
00424         if ( MEDmeshEntityInfo( fid,_sectionmeshname,MED_NO_DT,MED_NO_IT,
00425                                 MED_CELL, 1, _sectiongeotypename,
00426                                 &_sectiongeotype ) < 0 ) {
00427           MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshEntityInfo");
00428           SSCRUTE(_sectiongeotypename);ISCRUTE_int(_sectiongeotype);goto ERROR;
00429         }
00430 
00431         if ( (_nbofsectioncell = MEDmeshnEntity(fid,_sectionmeshname,MED_NO_DT,MED_NO_IT,
00432                                                MED_CELL,_sectiongeotype,MED_CONNECTIVITY,MED_NODAL,
00433                                                &_chgt,&_trsf) )  < 0) {
00434           MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00435           ISCRUTE(_nbofsectioncell);goto ERROR;
00436         }
00437       }
00438     }
00439 
00440     _nbofvaluesperentity*=_nbofsectioncell;
00441 
00442     if (_MEDattrEntierLire(_locgid,MED_NOM_GEO,&_intlocgeotype) < 0) {
00443       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00444       SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE_int(_locgeotype);goto ERROR;
00445     }
00446     _locgeotype = (med_geometry_type) _intlocgeotype;
00447 
00448     if ( _locgeotype != geotype ) {
00449       MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00450       SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE_int(_locgeotype);
00451       ISCRUTE_int(geotype);goto ERROR;
00452     }
00453   }  else  {
00454     _nbofvaluesperentity = MED_NO_IPOINT_INTERNAL ;
00455   }
00456 /*   strcpy(_localizationname,localizationname); */
00457 
00458   if (!_filterparameterexist) (*_filter).nbofvaluesperentity=_nbofvaluesperentity;
00459 
00460 
00461 
00462   /* Cree ou ouvre l'attribut MED_NOM_GAU         */
00463   /* Ecriture de la localisation des pts de gauss  */
00464   if ( _MEDattributeStringWr(_datagroup3,MED_NOM_GAU,MED_NAME_SIZE,localizationname) < 0) {
00465       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00466       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00467       SSCRUTE(MED_NOM_GAU);SSCRUTE(localizationname);goto ERROR;
00468   }
00469 
00470   /* Cree ou ouvre l'attribut MED_NOM_NGA         */
00471   /* Ecriture de l'attribut portant le nombre de points de gauss  */
00472   if ( _MEDattributeIntWr(_datagroup3,MED_NOM_NGA,&_nbofvaluesperentity) < 0) {
00473     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00474     SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00475     SSCRUTE(MED_NOM_NGA);ISCRUTE(_nbofvaluesperentity);goto ERROR;
00476   }
00477 
00478   /* TODO : ?MODE ECRASEMENT ?*/
00479   /* Si une localisation par défaut existe déjà <=> Un profil par défaut existe déjà :
00480      Si le profil courant est le profil par défaut met à jour la localisation par défaut */
00481   if ( _defaultprofileexist && !strcmp((*_filter).profilename,_defaultprofilename) ) {
00482     if ( _MEDattributeStringWr(_datagroup2,MED_NOM_GAU,MED_NAME_SIZE,localizationname) < 0) {
00483           MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
00484           SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00485           SSCRUTE(MED_NOM_GAU);SSCRUTE(localizationname);goto ERROR;
00486         }
00487       }
00488 
00489   if (!_filterparameterexist) {
00490 
00491 #ifdef _DEBUG_
00492     ISCRUTE((*_filter).nbofentity              );
00493     ISCRUTE((*_filter).nbofvaluesperentity     );
00494     ISCRUTE((*_filter).nbofconstituentpervalue );
00495     ISCRUTE((*_filter).constituentselect       );
00496     ISCRUTE_int((*_filter).switchmode              );
00497     ISCRUTE((*_filter).filterarraysize         );
00498     ISCRUTE((*_filter).profilearraysize        );
00499     ISCRUTE_int((*_filter).storagemode             );
00500     SSCRUTE((*_filter).profilename             );
00501 #endif
00502 
00503     if ( MEDfilterEntityCr(fid, (*_filter).nbofentity,         (*_filter).nbofvaluesperentity,
00504                            (*_filter).nbofconstituentpervalue, (*_filter).constituentselect,
00505                            (*_filter).switchmode,              (*_filter).storagemode, 
00506                            (*_filter).profilename, MED_UNDEF_SIZE, NULL, &_paramfilter) < 0 ) {
00507       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00508       goto ERROR;
00509     }
00510     _filter = &_paramfilter;
00511   }
00512 
00513   /*CELA N'A PLUS DE SENS AVEC LE MODELE INTERNE 3.0*/
00514   /* Vérifie si le profil a changé (l'API MED ne permet pas de modifier un profil existant) */
00515   /*   if (strcmp(_profilename, _defaultprofilename)) */
00516   /*     _profilehaschanged = 1;               le profil a changé*/
00517   /*   else */
00518   /*     _profilehaschanged = 0;               le profil n'a pas changé*/
00519 
00520 
00521   /*
00522    * Ecriture du champ
00523    */
00524 
00525   switch(_fieldtype)
00526     {
00527     case MED_FLOAT64 :
00528       if ( _MEDdatasetWr(_datagroup3,MED_NOM_CO,MED_FLOAT64,_filter,value) < 0) {
00529         MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_CO);
00530         SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00531         goto ERROR;
00532       }
00533       break;
00534 
00535     case MED_INT32 :
00536 #if defined(HAVE_F77INT64)
00537       if ( _MEDdatasetWr(_datagroup3,MED_NOM_CO,MED_INT64,_filter,value) < 0) {
00538         MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_CO);
00539         SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00540         goto ERROR;
00541       }
00542 #else
00543       if ( _MEDdatasetWr(_datagroup3,MED_NOM_CO,MED_INT32,_filter,value) < 0){
00544         MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_CO);
00545         SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00546         goto ERROR;
00547       }
00548 #endif
00549       break;
00550 
00551     case MED_INT64 :
00552 #if defined(HAVE_F77INT64)
00553       if ( _MEDdatasetWr(_datagroup3,MED_NOM_CO,MED_INT64,_filter,value) < 0){
00554         MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_CO);
00555         SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00556         goto ERROR;
00557       }
00558 #else
00559       MESSAGE("Impossible d'ecrire le dataset de type MED_INT64 sur une plateforme dépourvue de int64 !");
00560       goto ERROR;
00561 #endif
00562       break;
00563 
00564     default :
00565       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_RANGE,MED_ERR_FIELD_MSG);
00566       SSCRUTE(fieldname);ISCRUTE_int(_fieldtype);
00567       goto ERROR;
00568     }
00569 
00570 
00571   /*
00572    * On ferme tout
00573    */
00574 
00575   _ret = 0;
00576 
00577  ERROR:
00578 
00579 /*   if ( _defaultprofileexist ) { free(pfltab); free(pfltabtmp);} */
00580 
00581   if (!_filterparameterexist) {
00582     if ( MEDfilterClose(_filter) < 0 ) {
00583       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_FIELD_MSG);
00584       SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(_datagroupname2);SSCRUTE(_profilename);
00585       goto ERROR;
00586     }
00587   }
00588 
00589   if (_datagroup3>0)     if (_MEDdatagroupFermer(_datagroup3) < 0) {
00590     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_profilename);
00591     ISCRUTE_id(_datagroup3);
00592   }
00593 
00594   if (_datagroup2>0)     if (_MEDdatagroupFermer(_datagroup2) < 0) {
00595     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname2);
00596     ISCRUTE_id(_datagroup2);
00597   }
00598 
00599   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00600     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname1);
00601     ISCRUTE_id(_datagroup1);
00602   }
00603 
00604   if (_gid>0)            if (_MEDdatagroupFermer(_gid) < 0) {
00605     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_gidname);
00606     ISCRUTE_id(_gid);
00607   }
00608 
00609   if (_locgid>0)     if (_MEDdatagroupFermer(_locgid) < 0) {
00610     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_locgidname);
00611     ISCRUTE_id(_locgid);
00612   }
00613 
00614   va_end(params);
00615   *fret = _ret;
00616   return;
00617 }
00618 

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