Beispiel #1
0
med_int 
nmsefiaw(med_int *fid, char *mname, med_int *mnamelen, 
	 char *aname, med_int *anamelen,
	 med_int *atype, med_int *anc,
	 med_int *setype, med_int *val)
#endif
{
  med_int _ret;
  char *_fn1, *_fn2;
  med_attribute_type _atype = (med_attribute_type) *atype;
  med_entity_type _setype = (med_entity_type) *setype;

  _fn1 = _MED2cstring((char *) mname, (int) *mnamelen);
  if (!_fn1)
    return(-1);

  _fn2 = _MED2cstring((char *) aname, (int) *anamelen);
  if (!_fn2)
    return(-1);

  _ret = (med_int) MEDstructElementConstAttWr((const med_idt) *fid, 
					      _fn1, 
					      _fn2, 
					      _atype,
					      (med_int) *anc,
					      _setype,
					      (void *) val);

  _MEDcstringFree(_fn1);
  _MEDcstringFree(_fn2);

  return _ret;
}
int main (int argc, char **argv)

{
  med_err           _ret=0;
  med_idt           _fid=0;
  med_geometry_type _geotype=MED_NONE;

  const char        _elementname1[]="MED_BILLE";
  med_int           _elementdim1=3;
  const char        _supportmeshname1[]="MED_BILLE_SUPPORT";
  med_entity_type   _entitytype1=MED_NODE;
  med_int           _nnode1=1;
  med_int           _ncell1=0;
  med_int           _geocelltype1=MED_NONE;

  const char                _constattname1_1[MED_NAME_SIZE+1]="MED_FOO_ATR1_1";
  const med_attribute_type  _constatttype1_1=MED_ATT_INT;
  const med_int             _ncomponent1_1=2;
  const char                _profilename1_1[MED_NAME_SIZE+1]=MED_NO_PROFILE;
  const med_int             _cstatrvalue1_1[2]={ 20 , 21 };

  const char                _constattname1_2[MED_NAME_SIZE+1]="MED_FOO_ATR1_2";
  const med_attribute_type  _constatttype1_2=MED_ATT_FLOAT64;
  const med_int             _ncomponent1_2=2;
  const char                _profilename1_2[MED_NAME_SIZE+1]=MED_NO_PROFILE;
  const med_float             _cstatrvalue1_2[2]={ 20.1 , 21.2 };

  const char                _constattname1_3[MED_NAME_SIZE+1]="MED_FOO_ATR1_3";
  const med_attribute_type  _constatttype1_3=MED_ATT_NAME;
  const med_int             _ncomponent1_3=2;
  const char                _profilename1_3[MED_NAME_SIZE+1]=MED_NO_PROFILE;
  /*0123456789012345678901234567890123456789012345678901234567890123*/
  const char                _cstatrvalue1_3[2*MED_NAME_SIZE+1]={ "MED_FOO_ATR1_3_________________________________________________1" \
								 "MED_FOO_ATR1_3_________________________________________________2" };

  /*TODO : Tester avec un profil sur un maillage support*/


  /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
  _fid = MEDfileOpen("current.med",MODE_ACCES);
  if (_fid < 0) {
    MESSAGE("Erreur à la lecture du fichier current.med");
    return -1;
  }

  if ( (_ret = MEDstructElementConstAttWr(_fid,
					  _elementname1,
					  _constattname1_1,
					  _constatttype1_1,
					  _ncomponent1_1,
					  _entitytype1,
					  _cstatrvalue1_1 )) < 0 ) {
    return _ret;
  }

  if ( (_ret = MEDstructElementConstAttWr(_fid,
					  _elementname1,
					  _constattname1_2,
					  _constatttype1_2,
					  _ncomponent1_2,
					  _entitytype1,
					  _cstatrvalue1_2 )) < 0 ) {
    return _ret;
  }

  if ( (_ret = MEDstructElementConstAttWr(_fid,
					  _elementname1,
					  _constattname1_3,
					  _constatttype1_3,
					  _ncomponent1_3,
					  _entitytype1,
					  _cstatrvalue1_3 )) < 0 ) {
    return _ret;
  }

  if (MEDfileClose(_fid) < 0) {
    MESSAGE("ERROR : file closing");
    return -1;
  }

  return _ret;
}
Beispiel #3
0
med_int 
nmsefsaw(med_int *fid, char *mname, med_int *mnamelen, 
	 char *aname, med_int *anamelen,
	 med_int *atype, med_int *anc, med_int *setype,
	 char *val, med_int *vallen)
#endif
{
  med_int _ret;
  char *_fn1, *_fn2,*_fn3;
  med_attribute_type _atype = (med_attribute_type) *atype;
  med_entity_type _setype = (med_entity_type) *setype;
  int _nentity=0; 
  med_geometry_type _geotype=0;
  med_int _modeldim=0;
  char _supportmeshname[MED_NAME_SIZE+1]="";
  med_entity_type _entitytype=0;
  med_int _nnode=0;
  med_int _ncell=0; 
  med_geometry_type _sgeotype=0; 
  med_int _nconstatt=0; 
  med_bool _anyprofile=0;
  med_int _nvaratt=0;
  med_bool _coordinatechangement=MED_FALSE;
  med_bool _geotransformation=MED_FALSE;

  _fn1 = _MED2cstring((char *) mname, (int) *mnamelen);
  if (!_fn1)
    return(-1);

  _fn2 = _MED2cstring((char *) aname, (int) *anamelen);
  if (!_fn2)
    return(-1);

  /* on recupere le nom du maillage support */
  _ret = MEDstructElementInfoByName((med_idt) *fid,
				    _fn1,
				    &_geotype, 
				    &_modeldim,
                                    _supportmeshname, 
				    &_entitytype, 
				    &_nnode, 
				    &_ncell,
                                    &_sgeotype, 
				    &_nconstatt, 
				    &_anyprofile, 
				    &_nvaratt);
  if (_ret < 0)
    return (-1);
  
  /* on recupere le nombre d'entite dans le maillage support :
     MED_NODE ou MED_CELL */
  _nentity = MEDmeshnEntity((med_idt) *fid, 
			    _supportmeshname, 
			    MED_NO_DT, 
			    MED_NO_IT, 
			    _setype, 
			    _sgeotype,
			    MED_COORDINATE, 
			    MED_NO_CMODE,
			    &_coordinatechangement,
			    &_geotransformation);
  if (_nentity < 0)
    return (-1); 
  
  _fn3 = _MED1cstring((char *) val, (int) *vallen*_nentity, (int) *anc*_nentity*MED_NAME_SIZE);
  if (!_fn3)
    return(-1);
  
  _ret = (med_int) MEDstructElementConstAttWr((const med_idt) *fid, 
					      _fn1, 
					      _fn2, 
					      _atype,
					      (med_int) *anc,
					      _setype,
					      (void *) _fn3);

  _MEDcstringFree(_fn1);
  _MEDcstringFree(_fn2);
  _MEDcstringFree(_fn3);

  return _ret;
}