Exemple #1
0
med_geometry_type
MEDstructElementCr(const med_idt                 fid,
		   const char*             const modelname,
		   const med_int                 modeldim,
		   const char*             const supportmeshname,
		   const med_entity_type         sentitytype,
		   const med_geometry_type       sgeotype
		   )
{
  med_access_mode   _MED_ACCESS_MODE;
  med_err           _err=-1;
  med_idt           _root=0,_elemid=0;
  med_int           _ret=-1;
  char              _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
  med_size          _tmpn=0;
  med_geometry_type _stgeotype=0;
  med_int           _medintstgeotype = 0;
  med_int           _medintsgeotype  = sgeotype;
  med_int           _intentitytype   = sentitytype;
  med_int           _nnode=0,_ncell=0;
  med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;

/*   char           _entitytypename[MED_TAILLE_NOM_ENTITE+1]=""; */

  /*
   * On inhibe le gestionnaire d'erreur
   */
  _MEDmodeErreurVerrouiller();
 if (_MEDcheckVersion30(fid) < 0) goto ERROR;

  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    goto ERROR;
  }

  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    ISCRUTE_int(_MED_ACCESS_MODE);
    goto ERROR;
  }

  /*
   * Si le DataGroup /STRUCT/ n'existe pas, on le cree
   */
  if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
    if ((_root = _MEDdatagroupCrOrderCr(fid,_path)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
     goto ERROR;
    }

  NOFINALBLANK(modelname,ERROR);

  /*
   * Si le DataGroup /STRUCT/<modelname> n'existe pas, on le cree
   */
  if ((_elemid = _MEDdatagroupOpen(_root,modelname)) < 0) {
    if ((_elemid = _MEDdatagroupCreer(_root,modelname)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,modelname);
      SSCRUTE(_path);goto ERROR;
    }
  } else {
    /*
     * Lecture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
     */
    if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
      MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
      SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
      goto ERROR;
    }
    _stgeotype = _medintstgeotype;
  }
  strcat(_path,modelname);

  /*
   * Creation/Ecriture de l'attribut MED_NOM_DIM (dimension de l'�l�ment)
   */
  if ( _MEDattributeIntWr(_elemid,MED_NOM_DIM,&modeldim) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_DIM);ISCRUTE(modeldim);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NOM (nom du maillage support)
   */
  if ( _MEDattributeStringWr(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_ENT (type d'entit� support)
   */
/*   if (_MEDgetEntityTypeName(_entitytypename,sentitytype) < 0) { */
/*     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG); */
/*     ISCRUTE_int(sentitytype);SSCRUTE(_entitytypename);SSCRUTE(_path); */
/*     goto ERROR; */
/*   } */

  if ( _MEDattributeIntWr(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
    goto ERROR;
  }

  /*
    Lecture dans le maillages support du nombre de noeuds
    S'il n'y a pas de maillage support : 1
  */
  if (strlen(supportmeshname)) {
    if ( (_nnode = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
				     MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
				     &_chgt,&_trsf) )  <= 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
      ISCRUTE(_nnode);goto ERROR;
    }
  } else {
    _nnode=1;
  }

  if (strlen(supportmeshname)) {
    if ( (_ncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
				     MED_CELL,sgeotype,MED_CONNECTIVITY,MED_NODAL,
				     &_chgt,&_trsf) )  < 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
      ISCRUTE(_ncell);goto ERROR;
    }
  } else {
    _ncell=0;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_GEO (type g�om�trique des mailles support)
   */
  _medintsgeotype = sgeotype;
  if ( _MEDattributeIntWr(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
    goto ERROR;
  }

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NAV (nombre d'attributs variables associ�s � un �l�ment de structure)
   */
/*   if ( _MEDattributeIntWr(_elemid,MED_NOM_NAV,&nvariableattribute) < 0 ) { */
/*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/*     SSCRUTE(MED_NOM_NAV);ISCRUTE(nvariableattribute); */
/*     goto ERROR; */
/*   } */

  /*
   * Creation/Ecriture de l'attribut MED_NOM_NAC (nombre d'attributs constant associ�s � un �l�ment de structure)
   */
/*   if ( _MEDattributeIntWr(_elemid,MED_NOM_NAC,&nconstattribute) < 0 ) { */
/*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/*     SSCRUTE(MED_NOM_NAC);ISCRUTE(nconstattribute); */
/*     goto ERROR; */
/*   } */


  /*
   *  Nombre d'�l�ments de structure
   */
  if ( !_stgeotype ) {

    /*Si l'�l�ment de struture ne pr�-existait pas,
      il a �t� cr�e en d�but de proc�dure (il y a au moins 1 �l�ment dans le groupe) */
    if ((_err=_MEDnObjects(fid,MED_STRCT,&_tmpn)) <0) {
      MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_STRUCT,MED_STRCT);
      goto ERROR;
    }

    _stgeotype=_tmpn+MED_STRUCT_GEO_INTERNAL;
    _medintstgeotype=_stgeotype;

    /*
     * Ecriture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
     */
    if ( _MEDattributeIntWr(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
      MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
      SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
      goto ERROR;
    }
  }

  _ret = _stgeotype;

 ERROR:

  if (_elemid>0)     if (_MEDdatagroupFermer(_elemid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    ISCRUTE_id(_elemid);
  }

  if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_STRCT);
    ISCRUTE_id(_root);
  }

  return _ret;

}
Exemple #2
0
void
_MEDfieldCr31(int dummy, ...) {

  med_err _ret=-1;
  med_idt _root=0,_datagroup1=0;
  med_int _fieldtype ;
  char    _datagroupname1[MED_NAME_SIZE+1]="";
  med_access_mode _MED_ACCESS_MODE;


  MED_VARGS_DECL(const, med_idt           , , fid           );
  MED_VARGS_DECL(const, char * , const      , fieldname     );
  MED_VARGS_DECL(const, med_field_type    , , fieldtype     );
  MED_VARGS_DECL(const, med_int           , , ncomponent    );
  MED_VARGS_DECL(const, char *, const       , componentname );
  MED_VARGS_DECL(const, char *, const       , componentunit );
  MED_VARGS_DECL(const, char *, const       , dtunit        );
  MED_VARGS_DECL(const, char *, const       , meshname      );
  MED_VARGS_DECL(, med_err *              , , fret          );

  va_list params;
  va_start(params,dummy);

  MED_VARGS_DEF(const, med_idt           , , fid           );
  MED_VARGS_DEF(const, char * , const      , fieldname     );
  MED_VARGS_DEF(const, med_field_type,     , fieldtype     );
  MED_VARGS_DEF(const, med_int           , , ncomponent    );
  MED_VARGS_DEF(const, char *, const       , componentname );
  MED_VARGS_DEF(const, char *, const       , componentunit );
  MED_VARGS_DEF(const, char *, const       , dtunit        );
  MED_VARGS_DEF(const, char *, const       , meshname      );
  MED_VARGS_DEF(, med_err *              , , fret          );


 _MEDmodeErreurVerrouiller();

 _fieldtype = (med_int) fieldtype;

 if (_MEDcheckVersion30(fid) < 0) goto ERROR;

  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    goto ERROR;
  }

  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    ISCRUTE_int(_MED_ACCESS_MODE);
    goto ERROR;
  }

  /*
   * Si le DataGroup MED_FIELD_GRP n'existe pas, on le cree
   */
  if ((_root = _MEDdatagroupOuvrir(fid,MED_FIELD_GRP)) < 0)
    if ((_root = _MEDdatagroupCreer(fid,MED_FIELD_GRP)) < 0) {
     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_FIELD_GRP);
     goto ERROR;
    }

  NOFINALBLANK(fieldname,ERROR);
  /*
   * Si le Data Group "/CHA/<fieldname>" n'existe pas, on le cree
   */
  if ((_datagroup1 = _MEDdatagroupOuvrir(_root,fieldname)) < 0)
    if ((_datagroup1 = _MEDdatagroupCrOrderCr(_root,fieldname)) < 0 ) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_FIELD_GRP);
      SSCRUTE(fieldname);goto ERROR;
    }


  /*
   * Les infos sur les composantes du champ
   */
  if ( _MEDattributeIntWr(_datagroup1,MED_NOM_NCO,&ncomponent) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_NCO);
    ISCRUTE(ncomponent);goto ERROR;
  }



  
  /* Tous les types med_field_type sont autorisés dans MEDfieldCr mais :
     Avant la 3.3.0 seuls les types : MED_FLOAT64,MED_INT32 et MED_INT64 étaient autorisés dans MEDfieldValueAdvancedWr 
       et seul le type med_int et med_float64 pouvaient être utilisés en C.

      A l'écriture, si med_int=int  les champs MED_INT32 étaient stockés en interne en HDFINT32bits
      A l'écriture, si med_int=long les champs MED_INT32 étaient stockés en interne en HDFINT64bits
      A la lecture : - si med_int=int  le champ MED_INT32 est relu en en HDFINT32bit avec conversion 64->32 si necessaire
                    - si med_int=long le champ MED_INT32 est relu en en HDFINT64bit avec conversion 32->64 si necessaire
      A l'écriture, si med_int=int les champs MED_INT64 étaient interdits
      A l'écriture, si med_int=long les champs MED_INT64 étaient stockés en interne en HDFINT64bits
      A la lecture : - si med_int=int  le champ MED_INT64 ne pouvait pas être relu (pour prevenir la perte d'information)
                    - si med_int=long le champ MED_INT64 est relu sans conversion

     Depuis la 3.3.0 en plus des types MED_FLOAT64,MED_INT32 et MED_INT64 les types MED_FLOAT32 et MED_INT sont autorisés dans MEDfieldValueAdvancedWr et aux types med_int et med_float64 utilisés en C sont ajoutés les types med_float32, med_int32 et med_int64.

     MED_INT32 :
      A l'écriture :  si med_int=int  les champs MED_INT32 sont toujours  stockés en interne en HDFINT32bits   (utiliser med_int32 ou med_int(!))
                      si med_int=long les champs MED_INT32 sont désormais stockés en interne en HDFINT32bits   (utiliser le type med_int64) et désormais 
      A la lecture :  si med_int=int  les champs MED_INT32 sont toujours  relus en HDFINT32bits sans conversion (utiliser med_int32 ou med_int(!))
                      si med_int=long les champs MED_INT32 sont désormais relus en HDFINT32bits sans conversion (utiliser le type med_int32)
     MED_INT64 :
      A l'écriture :  si med_int=int  les champs MED_INT64 sont désormais autorisés et stockés en interne en HDFINT64bits  (utiliser le type med_int64)
                      si med_int=long les champs MED_INT64 sont toujours  autorisés et stockés en interne en HDFINT64bits  (utiliser le type med_int64 ou med_int(!))
      A la lecture :  si med_int=int  les champs MED_INT64 sont désormais relus en HDFINT64bits sans conversion (utiliser le type med_int64)
                      si med_int=long les champs MED_INT64 sont toujours  relus en HDFINT64bits sans conversion  (utiliser le type med_int64 ou med_int(!))
    
     MED_INT :
      A l'écriture :  si med_int=int  les champs MED_INT sont désormais acceptés et stockés en interne en HDFINT32bits    (utiliser med_int ou med_int32(!))
                      si med_int=long les champs MED_INT sont désormais acceptés et stockés en interne en HDFINT64bits    (utiliser med_int ou med_int64(!)) 
      A la lecture :  si med_int=int  les champs MED_INT sont désormais acceptés et relus en HDFINT32bits avec conversion/maxint si necessaire (utiliser med_int ou med_int32(!))
                      si med_int=long les champs MED_INT sont désormais acceptés et relus en HDFINT64bits avec conversion        si necessaire (utiliser le type med_int32)
   

     Plateforme 32 bits : TODO si la plateforme est 32 bits, il faut .... ?
  */

  if ( _MEDattributeIntWr(_datagroup1,MED_NOM_TYP,&_fieldtype) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_TYP);
    ISCRUTE(_fieldtype);goto ERROR;
  }
  if ( _MEDattributeStringWr(_datagroup1,MED_NOM_NOM,
			    MED_SNAME_SIZE*ncomponent,componentname) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_NOM);
    SSCRUTE(componentname);goto ERROR;
  }
  if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNI,
			    MED_SNAME_SIZE*ncomponent,componentunit) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_UNI);
    SSCRUTE(componentunit);goto ERROR;
  }

  /*MODEL : MED_NOM_UNI vient du niveau en dessous
    Cree ou ouvre l'attribut  MED_NOM_UNI pour écriture
  */
  if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNT,MED_SNAME_SIZE,dtunit) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_UNT);
    SSCRUTE(dtunit);goto ERROR;
  }

  /*MODEL : MED_NOM_MAI est écrit dans l'API de création de champ
   * Si c'est la première référence à un maillage, initialise l'attribut MED_MAI à ce maillage
   */
  NOFINALBLANK(meshname,ERROR);

  if (_MEDattributeStringWr(_datagroup1,MED_NOM_MAI,MED_NAME_SIZE,meshname) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_MAI);
    SSCRUTE(meshname);
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,meshname);
    goto ERROR;
  }


  /*
   * On ferme tout
   */

  _ret=0;
 ERROR:

  if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname1);
    ISCRUTE_id(_datagroup1);
  }

  if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_FIELD_GRP);
    ISCRUTE_id(_root);
  }

  va_end(params);
  *fret = _ret;
  return;
}
void
_MEDfieldCr31(int dummy, ...) {

  med_err _ret=-1;
  med_idt _root=0,_datagroup1=0;
  med_int _fieldtype ;
  char    _datagroupname1[MED_NAME_SIZE+1]="";
  med_access_mode _MED_ACCESS_MODE;


  MED_VARGS_DECL(const, med_idt           , , fid           );
  MED_VARGS_DECL(const, char * , const      , fieldname     );
  MED_VARGS_DECL(const, med_field_type    , , fieldtype     );
  MED_VARGS_DECL(const, med_int           , , ncomponent    );
  MED_VARGS_DECL(const, char *, const       , componentname );
  MED_VARGS_DECL(const, char *, const       , componentunit );
  MED_VARGS_DECL(const, char *, const       , dtunit        );
  MED_VARGS_DECL(const, char *, const       , meshname      );
  MED_VARGS_DECL(, med_err *              , , fret          );

  va_list params;
  va_start(params,dummy);

  MED_VARGS_DEF(const, med_idt           , , fid           );
  MED_VARGS_DEF(const, char * , const      , fieldname     );
  MED_VARGS_DEF(const, med_field_type,     , fieldtype     );
  MED_VARGS_DEF(const, med_int           , , ncomponent    );
  MED_VARGS_DEF(const, char *, const       , componentname );
  MED_VARGS_DEF(const, char *, const       , componentunit );
  MED_VARGS_DEF(const, char *, const       , dtunit        );
  MED_VARGS_DEF(const, char *, const       , meshname      );
  MED_VARGS_DEF(, med_err *              , , fret          );


 _MEDmodeErreurVerrouiller();

 _fieldtype = (med_int) fieldtype;

 if (_MEDcheckVersion30(fid) < 0) goto ERROR;

  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    goto ERROR;
  }

  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    ISCRUTE_int(_MED_ACCESS_MODE);
    goto ERROR;
  }

  /*
   * Si le DataGroup MED_CHA n'existe pas, on le cree
   */
  if ((_root = _MEDdatagroupOuvrir(fid,MED_CHA)) < 0)
    if ((_root = _MEDdatagroupCreer(fid,MED_CHA)) < 0) {
     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_CHA);
     goto ERROR;
    }

  NOFINALBLANK(fieldname,ERROR);
  /*
   * Si le Data Group "/CHA/<fieldname>" n'existe pas, on le cree
   */
  if ((_datagroup1 = _MEDdatagroupOuvrir(_root,fieldname)) < 0)
    if ((_datagroup1 = _MEDdatagroupCrOrderCr(_root,fieldname)) < 0 ) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_CHA);
      SSCRUTE(fieldname);goto ERROR;
    }


  /*
   * Les infos sur les composantes du champ
   */
  if ( _MEDattributeIntWr(_datagroup1,MED_NOM_NCO,&ncomponent) < 0 ) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_NCO);
    ISCRUTE(ncomponent);goto ERROR;
  }
  if ( _MEDattributeIntWr(_datagroup1,MED_NOM_TYP,&_fieldtype) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_TYP);
    ISCRUTE(_fieldtype);goto ERROR;
  }
  if ( _MEDattributeStringWr(_datagroup1,MED_NOM_NOM,
			    MED_SNAME_SIZE*ncomponent,componentname) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_NOM);
    SSCRUTE(componentname);goto ERROR;
  }
  if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNI,
			    MED_SNAME_SIZE*ncomponent,componentunit) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_UNI);
    SSCRUTE(componentunit);goto ERROR;
  }

  /*MODEL : MED_NOM_UNI vient du niveau en dessous
    Cree ou ouvre l'attribut  MED_NOM_UNI pour écriture
  */
  if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNT,MED_SNAME_SIZE,dtunit) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_UNT);
    SSCRUTE(dtunit);goto ERROR;
  }

  /*MODEL : MED_NOM_MAI est écrit dans l'API de création de champ
   * Si c'est la première référence à un maillage, initialise l'attribut MED_MAI à ce maillage
   */
  NOFINALBLANK(meshname,ERROR);

  if (_MEDattributeStringWr(_datagroup1,MED_NOM_MAI,MED_NAME_SIZE,meshname) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_MAI);
    SSCRUTE(meshname);
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,meshname);
    goto ERROR;
  }


  /*
   * On ferme tout
   */

  _ret=0;
 ERROR:

  if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname1);
    ISCRUTE_id(_datagroup1);
  }

  if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CHA);
    ISCRUTE_id(_root);
  }

  va_end(params);
  *fret = _ret;
  return;
}