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

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