Beispiel #1
0
med_int
MEDfieldnComponent(const med_idt fid, 
		   const int ind)
{
  med_err _ret       = -1;
  char    _fieldname[MED_NAME_SIZE+1]="";
  int     _num       = ind-1;
  char    _path        [MED_TAILLE_CHA+MED_NAME_SIZE+1]=MED_CHA;
  /*
   * On inhibe le gestionnaire d'erreur HDF
   */
  _MEDmodeErreurVerrouiller();


  /*
   * On recupere le nom du champ
   */
  if ( _MEDobjectGetName(fid, _path ,_num, _fieldname) < 0 ) {
    MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);ISCRUTE_int(_num);
    goto ERROR;
  }

  if ( (_ret=MEDfieldnComponentByName( fid, _fieldname )) < 0) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_FIELD_MSG);
    SSCRUTE(_fieldname);SSCRUTE(_path);SSCRUTE("MEDfieldnComponentbyName");
    goto ERROR;
  }

 ERROR:
  return _ret;
}
Beispiel #2
0
med_err
MEDfileCommentWr(const med_idt fid,
		 const char* const comment)
{
  med_idt _rootId=0;
  med_err _ret=-1;

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

  /* the root data group is open */
  if ((_rootId = _MEDdatagroupOuvrir(fid,"/")) < 0) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP," : '/'");
    goto ERROR;
  }

  /* The comment is stored in a HDF attribute */
  if (_MEDattributeStringWr(_rootId,MED_COMMENT_NAME,MED_COMMENT_SIZE,(char*)comment) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_COMMENT_NAME);
    SSCRUTE(comment);
    goto ERROR;
  }

  _ret = 0;
 ERROR:

  /* the "/" group has to be closed */
  if (_rootId > 0)
    if (_MEDdatagroupFermer(_rootId) < 0) {
      MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP," : '/'");
    }
  return _ret;
}
Beispiel #3
0
med_err _MEDsoftlinkDel(const med_idt               id,
			const char * const          softlinkname,
			med_bool                    linkmustexist
			) {

  med_err         _ret=-1;
  H5L_info_t      _linkinfo;


  if ( H5Lget_info( id, softlinkname,  &_linkinfo, H5P_DEFAULT ) >= 0 ) {
    if ( _linkinfo.type == H5L_TYPE_SOFT ) {
      if ( H5Ldelete(id,softlinkname,H5P_DEFAULT) < 0 ) {
	MED_ERR_(_ret,MED_ERR_DELETE,MED_ERR_LINK,softlinkname);
	goto ERROR;
      }
    } else if (linkmustexist) {
      MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_LINK,softlinkname);
      goto ERROR;
    }
  } else if (linkmustexist) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_LINK,softlinkname);
    goto ERROR;
  }

  _ret=0;
 ERROR:
  return _ret;
}
Beispiel #4
0
med_err
MEDstructElementInfo(const med_idt             fid,
		     const int                 mit,
		     char *              const modelname,
		     med_geometry_type * const mgeotype,
		     med_int*            const modeldim,
		     char*               const supportmeshname,
		     med_entity_type*    const sentitytype,
		     med_int*            const snnode,
		     med_int*            const sncell,
		     med_geometry_type*  const sgeotype,
		     med_int*            const nconstantattribute,
		     med_bool*           const anyprofile,
		     med_int*            const nvariableattribute
			   )
{

  med_err  _ret=-1;
  char     _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
  int      _num = mit -1;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

  /*
   * On recupere le nom de l'élément de structure
   */
  if ( _MEDobjectGetName(fid, _path ,_num, modelname) < 0 ) {
    MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);ISCRUTE_int(mit);
    goto ERROR;
  }
  strcat(_path,modelname);

  if (
      MEDstructElementInfoByName(fid,
				 modelname,
				 mgeotype,
				 modeldim,
				 supportmeshname,
				 sentitytype,
				 snnode,
				 sncell,
				 sgeotype,
				 nconstantattribute,
				 anyprofile,
				 nvariableattribute
				 ) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_STRUCT_MSG);
    SSCRUTE(modelname);SSCRUTE(_path);SSCRUTE("MEDstructElementInfoByName");
    goto ERROR;
  }

  _ret = 0;

 ERROR:

  return _ret;
}
med_err _MEDdatagroupExist(const med_idt        gid,
			   const char * const   datagroupname,
			   med_bool *   const   datagroupexist,
			   med_bool *   const   isasoftlink )
/*Pour l'instant, dans le modèle interne les liens sont uniquement des liens vers
  des datasets*/

{
  med_err        _ret=-1;
  H5L_info_t     _linkinfo;
  H5O_info_t     _oinfo;

  if ( H5Lget_info( gid, datagroupname,  &_linkinfo, H5P_DEFAULT ) >= 0 ) {

    switch ( _linkinfo.type ) {

    case H5L_TYPE_SOFT:
      *isasoftlink=MED_TRUE;
      _oinfo.type=H5G_LINK;
      break;

    case H5L_TYPE_HARD:
      *isasoftlink  = MED_FALSE;
      if ( H5Oget_info_by_name( gid, datagroupname, &_oinfo, H5P_DEFAULT ) <0) {
	MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"H5Oget_info_by_name");
	SSCRUTE( datagroupname);
      }
      break;

    case H5L_TYPE_EXTERNAL:
    case H5L_TYPE_ERROR:
    default:
      MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_HDFTYPE, datagroupname);
      ISCRUTE( _linkinfo.type);
      goto ERROR;
      break;
    }

    /*TODO : A vérifier sur un lien de datagroup, à mon avis ne fonctionne pas */
    switch ( _oinfo.type ) {
    case H5G_GROUP:
    case H5G_LINK:
      *datagroupexist = MED_TRUE;
      break;
    default:
      *datagroupexist = MED_FALSE;
    }

  } else {
      *datagroupexist = MED_FALSE;
      *isasoftlink    = MED_FALSE;
  }

  _ret = 0;
 ERROR:

  return _ret;
}
Beispiel #6
0
/**\ingroup MEDfile
  \brief \MEDfileObjectExistBrief
  \param fid \fid
  \param medclass \medclass
  \param objectname \objectname
  \param objectexist \objectexist
  \retval med_err  \error
  \details \MEDfileObjectExistDetails
  \par Remarques
*/
med_err
MEDfileObjectExist(const med_idt           fid,
		   const med_class         medclass,
		   const char      * const objectname,
		         med_bool  * const objectexist )
{
  med_idt _fid = 0;
  med_err _ret = -1;
  char    _link[2*MED_NAME_SIZE+1]="";
  med_bool _datagroupexist=MED_FALSE,_isasoftlink=MED_FALSE;
  int _objsize = 0;

  /* 
   * On inhibe le gestionnaire d'erreur HDF
   */
  _MEDmodeErreurVerrouiller();

  *objectexist = MED_FALSE;
  /*
   * Give access to the class object in the local file
   */
  switch(medclass) {

    MY_CASE(MESH);
    MY_CASE(MESH_SUPPORT);
    MY_CASE(ELSTRUCT);
    MY_CASE(FAMILY);
    MY_CASE(EQUIVALENCE);
    MY_CASE(JOINT);
    MY_CASE(FIELD);
    MY_CASE(LOCALIZATION);
    MY_CASE(PROFILE);
    MY_CASE(INTERPOLATION);
    MY_CASE(NUMERICAL_DATA);

  default :
    MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_CLASS,_link);
   goto ERROR;
  }

  strncpy(_link+_objsize,objectname,MED_NAME_SIZE+1);
  _link[2*MED_NAME_SIZE]='\0';
	 
  if( _MEDdatagroupExist(fid,_link,&_datagroupexist,&_isasoftlink) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
    SSCRUTE(_link);goto ERROR;
  }

  if ( _datagroupexist ) *objectexist = MED_TRUE;

  _ret=0;
 ERROR:

  return _ret;
}
void
_MEDmeshUniversalNameRd30(int dummy, ...)
{


  med_err _ret=-1;
  med_idt _meshid;
  char    _path [MED_TAILLE_MAA+MED_NAME_SIZE+1]=MED_MAA;


  MED_VARGS_DECL(const, med_idt      , , fid       );
  MED_VARGS_DECL(const, char * , const , meshname  );
  MED_VARGS_DECL(, char *, const , univname        );
  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 , meshname  );
  MED_VARGS_DEF(, char *, const , univname        );
  MED_VARGS_DEF(, med_err *    ,, fret            );

  /*
   * On inhibe le gestionnaire d'erreur
   */
  _MEDmodeErreurVerrouiller();


  /*
   * Si le maillage n'existe pas => erreur
   */
  strcat(_path,meshname);
  if ((_meshid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
    ISCRUTE_id(_meshid);goto ERROR;
  }

  if ( _MEDattrStringLire(_meshid,MED_NOM_UNV,MED_LNAME_SIZE,univname) < 0) {
    _ret = MED_ERR_READ + MED_ERR_ATTRIBUTE;
    goto ERROR;
  }

  _ret = 0;
 ERROR:

  if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    ISCRUTE_id(_meshid);
  }
  va_end(params);
  *fret = _ret;
  return;
}
Beispiel #8
0
/**\ingroup MEDinterp
  \brief \MEDinterpInfoBrief
  \param fid           \fid
  \param interpit      \interpit
  \param interpname    \interpname
  \param geotype       \geotype
  \param cellnode      \cellnode
  \param nbasisfunc \nbasisfunc
  \param nvariable  \nvariable
  \param maxdegree     \maxdegree
  \param nmaxcoef      \nmaxcoef

  \return \error
  \details \MEDinterpInfoDetails
  \see     MEDinterpInfoByName

 */
med_err
MEDinterpInfo(const med_idt                 fid,
	      const int                      interpit,
	            char*              const interpname,
	            med_geometry_type* const geotype,
	            med_bool*          const cellnode,
	            med_int*           const nbasisfunc,
	            med_int*           const nvariable,
	            med_int*           const maxdegree,
	            med_int*           const nmaxcoef
	      )
{
  med_err  _ret=-1;
  char     _interppath[MED_TAILLE_INTERP+MED_NAME_SIZE+1]=MED_INTERP;
  int      _num = interpit -1;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

  /*
   * On recupere le nom de l'interpolation
   */
  if ( _MEDobjectGetName(fid, _interppath ,_num, interpname) < 0 ) {
    MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_interppath);ISCRUTE_int(interpit);
    goto ERROR;
  }
  strcat(_interppath,interpname);

  if (  MEDinterpInfoByName(fid,
			    interpname,
			    geotype,
			    cellnode,
			    nbasisfunc,
			    nvariable,
			    maxdegree,
			    nmaxcoef
			    )    < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_INTERP_MSG);
    SSCRUTE(interpname);SSCRUTE(_interppath);SSCRUTE("MEDinterpInfoByName");
    goto ERROR;
  }

  _ret = 0;

 ERROR:

  return _ret;
}
Beispiel #9
0
med_int
MEDnInterp(const med_idt fid) {

  med_int        _ret=-1,_err=-1;
  char           _path[MED_INTERPOLATION_GRP_SIZE+1]=MED_INTERPOLATION_GRP;
  med_size       _tmpn=0;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

  /*
   *  nombre de link
   */
  if ((_err=_MEDnObjects(fid,_path,&_tmpn)) <0)
    if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
      MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_INTERP,_path);
      goto ERROR;
    }

  _ret = (med_int) _tmpn;
 ERROR:
  return _ret;

}
med_int
MEDfieldnValueWithProfileByName(const med_idt fid,
				const char * const fieldname,
				const med_int numdt,
				const med_int numit,
				const med_entity_type entitype, 
				const med_geometry_type geotype,
				const char * const profilename,
				const med_storage_mode storagemode,
				med_int * const profilesize,
				char * const localizationname, 
				med_int * const nintegrationpoint)
{
  med_int  _ret=-1;

  if ( (_ret = _MEDfieldnValue(fid,  fieldname, numdt, numit,
			      entitype,  geotype,
			      (char * const) profilename,-1,
			      storagemode, profilesize,
			      localizationname, nintegrationpoint)) < 0) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_FIELD_MSG);
    SSCRUTE(fieldname);SSCRUTE("_MEDfieldnValue");
    goto ERROR;
  }

 ERROR:

  return _ret;
}
med_err
_MEDgetComputationStepName(const med_sorting_type sortingtype, const med_int numdt,
			   const med_int numit, char * const datagroupname)
{

  med_err    _ret=-1;
  long _numdt = numdt;
  long _numit = numit;

  switch (sortingtype) {
  case MED_SORT_DTIT:
    sprintf(datagroupname,"%0*li%0*li",MED_MAX_PARA, _numdt,MED_MAX_PARA, _numit);
    break;
  case MED_SORT_ITDT:
    sprintf(datagroupname,"%0*li%0*li",MED_MAX_PARA, _numit,MED_MAX_PARA, _numdt);
    break;
  default:
    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_PARAMETER,"");
    ISCRUTE_int(sortingtype);
    goto ERROR;
  }
  _ret=0;
 ERROR:
  return _ret;

}
Beispiel #12
0
med_int
MEDnSupportMesh(const med_idt fid)
{
  med_size _n=0;
  med_int  _ret=-1,_err=-1;

  /*
   * On inhibe le gestionnaire d'erreur HDF
   */
  _MEDmodeErreurVerrouiller();


  /*
   *  nombre de champs
   */
  if ((_err=_MEDnObjects(fid,MED_SUP_MAA,&_n)) <0)
    if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
      MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_MESH,MED_MAA);
      goto ERROR;
    }


  _ret = (med_int) _n;
 ERROR:
  return _ret;
}
Beispiel #13
0
/*
 * - Nom de la fonction : _MED1cstring
 * - Description : convertit une chaine de caracteres FORTRAN
 *                 en une nouvelle chaine de caracteres C
 *                 dont la longueur est passee en parametre.
 *                 Les caracteres completes sont des blancs
 * Cette routine est utile au les paramètres chaînes f77 au format chaînes de taille fixe de l'API C.
 * - Parametres :
 *     - chaine (IN)          : la chaine FORTRAN
 *     - longueur_reelle (IN) : la longueur de la chaine FORTRAN
 *     - longueur_fixee (IN)  : longueur de la chaine C a construire
 * - Resultat : la nouvelle chaine C en cas de succes, NULL sinon
 */
char *_MED1cstring(char *chaine,int longueur_reelle,int longueur_fixee)
{
  char *nouvelle;
  int i;
  med_err _ret = 0;

  if (longueur_reelle > longueur_fixee) {
    fprintf(stderr,"Erreur n°1 ds _MED1cstring\n");
    return NULL;
  }
  if ((nouvelle = (char *) malloc(sizeof(char)*(longueur_fixee+1))) == NULL) {
    fprintf(stderr,"Erreur n°2 ds _MED1cstring : longueur_reelle %d, longueur_fixee %d\n",longueur_reelle,longueur_fixee);
    MED_ERR_(_ret,MED_ERR_NOTNULL,MED_ERR_API,MED_ERR_NAME_MSG"malloc");
    return NULL;
  }

  for (i=0;i<longueur_reelle;i++)
    *(nouvelle+i) = *(chaine+i);

  for (i=longueur_reelle;i<longueur_fixee;i++)
    *(nouvelle+i) = ' ';

  *(nouvelle+longueur_fixee) = '\0';

  return nouvelle;
}
Beispiel #14
0
med_int
MEDmeshnEntity(const med_idt fid,
	       const char * const meshname,
	       const med_int numdt,
	       const med_int numit,
	       const med_entity_type entitype,
	       const med_geometry_type geotype,
	       const med_data_type datatype,
	       const med_connectivity_mode cmode,
	       med_bool * const changement,
	       med_bool * const transformation )
{

  char                   _profilename[MED_NAME_SIZE+1]="";
  med_int                _profilesize=0;
  med_int                _ret=-1;


  _ret = _MEDmeshnEntity(fid,  meshname, numdt, numit,entitype,  geotype,
		       datatype, cmode, MED_GLOBAL_PFLMODE,_profilename, &_profilesize,
		       changement, transformation );

  if ( strlen(_profilename) || (_profilesize > 0) ) {
    MED_ERR_(_ret,MED_ERR_EXIST,MED_ERR_PROFILE,_profilename);
    goto ERROR;
  }

 ERROR:
  return _ret;
}
Beispiel #15
0
void _MEDnFamily236(int dummy, ...)
{


  med_int       _ret=-1;
  med_int       _n=0;
  
  MED_VARGS_DECL(const, med_idt      , , fid      );
  MED_VARGS_DECL(const, char * , const , meshname );
  MED_VARGS_DECL(, med_int *          ,, fret     );

  va_list params;
  va_start(params,dummy);

  MED_VARGS_DEF(const, med_idt      , , fid      );
  MED_VARGS_DEF(const, char * , const , meshname );
  MED_VARGS_DEF(, med_int *          ,, fret     );


  if ( ( _n = MEDnFam(fid,(char *) meshname) ) < 0) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnFam");
    SSCRUTE(meshname);
    goto ERROR;
  }

  _ret =  _n;
 ERROR:
  va_end(params);
  *fret = _ret;

  return;
}
Beispiel #16
0
med_err
MEDlocalizationInfo(const med_idt             fid,
		    const int                 localizationit,
		    char              * const localizationname,
		    med_geometry_type * const geotype,
		    med_int           * const spacedimension,
		    med_int           * const nipoint,
		    char *              const geointerpname,
		    char *              const sectionmeshname,
		    med_int           * const nsectionmeshcell,
		    med_geometry_type * const sectiongeotype)
{
  med_err _ret=-1;
  char    _path[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
  int     _num=localizationit-1;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

  /*
   * ouverture du groupe /GAUSS/"nom"
   */
  if ( _MEDobjectGetName(fid, _path ,_num, localizationname) < 0 ) {
    MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);
    ISCRUTE_int(localizationit);
    goto ERROR;
  }

  if ( MEDlocalizationInfoByName(fid, localizationname, geotype, spacedimension,
				 nipoint,geointerpname, 
				 sectionmeshname, nsectionmeshcell,sectiongeotype ) < 0) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDlocalizationInfoByName");
    SSCRUTE(localizationname);
    goto ERROR;
  }

  _ret = 0;
 ERROR:

  return _ret;
}
med_err
MEDparameterComputationStepInfo(const med_idt      fid,
				const char * const paramname,
				const int          csit,
				med_int * const    numdt,
				med_int * const    numit,
				med_float * const  dt )
{
  med_err _ret = -1, _err = -1;
  med_idt _cpstidt = 0;
  char    _path[(MED_TAILLE_NUM_DATA+MED_NAME_SIZE+1)+2*MED_MAX_PARA+1]=MED_NUM_DATA;
  int     _num=csit-1;
  char    _cstpname[2*MED_MAX_PARA+1]="";

  _MEDmodeErreurVerrouiller();
  
  /* On recupere le nom du pas de temps */
  strcat(_path, paramname);
  if ( _MEDobjectGetName(fid, _path ,_num, _cstpname) < 0 ) {
    MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);ISCRUTE_int(_num);
    goto ERROR;
  }

  /* on ouvre le groupe HDF correspondant */
  strcat(_path,"/");
  strcat(_path,_cstpname);
  if ((_cpstidt = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
    goto ERROR;
  }

  /* Lecture des attributs */
  if (_MEDattrEntierLire(_cpstidt, MED_NOM_NDT, (med_int*) numdt) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT);
    SSCRUTE(_path);ISCRUTE(*numdt);goto ERROR;
  }
  if (_MEDattrFloatLire(_cpstidt, MED_NOM_PDT, (med_float*) dt) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_PDT);
    SSCRUTE(_path);RSCRUTE(*dt);goto ERROR;
  }
  if (_MEDattrEntierLire(_cpstidt, MED_NOM_NOR, (med_int*) numit) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NOR);
    SSCRUTE(_path);ISCRUTE(*numit);goto ERROR;
  }

  _ret = 0;
 ERROR:

  /* on ferme tout */
  if (_cpstidt > 0)            
    if (_MEDdatagroupFermer(_cpstidt) < 0) {
      MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
      ISCRUTE_id(_cpstidt);
    }

  return _ret;
}
med_err MEDmeshEntityAttributeAdvancedWr(const med_idt               fid,
					 const char*  const          meshname,
					 const med_data_type         datatype,
					 const med_int               numdt,
					 const med_int               numit,
					 const med_entity_type       entitype,
					 const med_geometry_type     geotype,
					 const med_filter * const    filter,
					 const void * const          attval)
{

  med_err _ret=-1;

  switch (datatype) {
  case MED_NAME:
  case MED_NUMBER:
  case MED_FAMILY_NUMBER:
    break;
  default:
    MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_PARAMETER,"");
    ISCRUTE_int(datatype);
    goto ERROR;
  }

  _ret= _MEDmeshAdvancedWr(fid,
			   meshname,
			   datatype,
			   MED_NO_NAME,
			   MED_INTERNAL_UNDEF,
			   numdt,
			   numit,
			   MED_UNDEF_DT, /*Si la séquence de calcul n'existe pas, ce champ sera initialisé correctement par d'autres appels.*/
			   entitype,
			   geotype,
			   MED_NODAL,
			   MED_UNDEF_PFLMODE,
			   MED_NO_PROFILE,
			   MED_UNDEF_INTERLACE,
			   MED_ALL_CONSTITUENT,
			   filter,
			   MED_UNDEF_SIZE,
			   attval);
 ERROR:
  return _ret;

}
Beispiel #19
0
med_err
MEDlibraryClose(void)
{
  med_err _ret = -1;

  _MEDmodeErreurVerrouiller();

  if ( H5close() < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_LIBRARY,"");
    goto ERROR;
  }

  _ret = 0;
 ERROR:

  return _ret;
}
void
_MEDequivalenceCorrespondenceRd236(int dummy, ...) {

  med_err _ret=-1;

  MED_VARGS_DECL(const, med_idt            , , fid            );
  MED_VARGS_DECL(const, char * , const       , meshname       );
  MED_VARGS_DECL(const, char * , const       , equivname      );
  MED_VARGS_DECL(const, med_int            , , numdt          );
  MED_VARGS_DECL(const, med_int            , , numit          );
  MED_VARGS_DECL(const, med_entity_type    , , entitype       );
  MED_VARGS_DECL(const, med_geometry_type  , , geotype        );
  MED_VARGS_DECL(, med_int *, const          , correspondence );
  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       , meshname       );
  MED_VARGS_DEF(const, char * , const       , equivname      );
  MED_VARGS_DEF(const, med_int            , , numdt          );
  MED_VARGS_DEF(const, med_int            , , numit          );
  MED_VARGS_DEF(const, med_entity_type    , , entitype       );
  MED_VARGS_DEF(const, med_geometry_type  , , geotype        );
  MED_VARGS_DEF(, med_int *, const          , correspondence );
  MED_VARGS_DEF(, med_err *                ,, fret           );


  if ( MEDequivLire(fid, (char *) meshname, (char *) equivname, correspondence, -1 ,
		    entitype, geotype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDequivLire");
    SSCRUTE(meshname); SSCRUTE(equivname); 
    ISCRUTE_int(entitype);ISCRUTE_int(geotype);goto ERROR;

  }

  _ret=0;
 ERROR:

  va_end(params);
  *fret = _ret;

  return;
}
Beispiel #21
0
void _MEDnEquivalence30(int dummy, ...) {


  char             _path[MED_EQUIVALENCE_GRP_SIZE+MED_NAME_SIZE+1]=MED_EQUIVALENCE_GRP;
  med_int          _ret=-1,_err=-1;
  med_size         _tmpn=0;


  MED_VARGS_DECL(const, med_idt      , , fid       );
  MED_VARGS_DECL(const, char * , const , meshname  );
  MED_VARGS_DECL(, med_int *          ,, fret      );

  va_list params;
  va_start(params,dummy);

  MED_VARGS_DEF(const, med_idt      , , fid       );
  MED_VARGS_DEF(const, char * , const , meshname  );
  MED_VARGS_DEF(, med_int *          ,, fret      );

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();


  strcat(_path,meshname);

  /*
   *  nombre d'équivalence
   */
  if ( (_err=_MEDnObjects(fid,_path,&_tmpn)) <0)
    if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
      MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_path);
      goto ERROR;
   }

  _ret = (med_int) _tmpn;
 ERROR:

  va_end(params);
  *fret = _ret;
  return;
}
med_err _MEDattributeStringRdByName(med_idt pid,
				    const char * const path,
				    const char * const attname,
				    const med_size attsize,
				    char * const val)
{
  med_err _ret=-1;
  med_idt _attid=0;
  int     type_hdf=0;

  if ( (type_hdf = H5Tcopy(H5T_C_S1)) < 0) {
    MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_HDFTYPE, MED_ERR_NAME_MSG );
    SSCRUTE("H5T_C_S1"); goto ERROR;
  }

  if ( H5Tset_size(type_hdf,attsize+1) < 0) {
    MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_HDFTYPE, MED_ERR_NAME_MSG );
    SSCRUTE("H5T_C_S1"); goto ERROR;
  }

  if ( (_attid=H5Aopen_by_name( pid, path, attname, H5P_DEFAULT, H5P_DEFAULT )) < 0 ) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
    SSCRUTE(attname); SSCRUTE(path);goto ERROR;
  }

  if ( H5Aread(_attid,type_hdf,val) < 0 ) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE, MED_ERR_NAME_MSG );
    SSCRUTE(attname); SSCRUTE(path);goto ERROR;
  }

  _ret=0;

 ERROR:

  if (type_hdf >0) if ( H5Tclose(type_hdf) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_HDFTYPE, MED_ERR_ID_MSG );
    ISCRUTE_int(type_hdf);
  }

  if (_attid >0) if ( H5Aclose(_attid) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_ATTRIBUTE, MED_ERR_ID_MSG );
    ISCRUTE_id(_attid);
  }

  return _ret;
}
Beispiel #23
0
void _MEDprofileRd236(int dummy, ...) {


  med_idt        _pfid=0;
  med_err        _ret=-1;
  char           _path[MED_TAILLE_PROFILS+MED_NAME_SIZE+1]=MED_PROFILS;
  med_filter     _filter        = MED_FILTER_INIT;
  med_int        _nentity=0;
  
  MED_VARGS_DECL(const, med_idt         , , fid          );
  MED_VARGS_DECL(const, char    * , const , profilename  );
  MED_VARGS_DECL(, med_int *, const , profilearray       );
  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 , profilename  );
  MED_VARGS_DEF(, med_int *, const , profilearray       );
  MED_VARGS_DEF(, med_err *       ,, fret               );


  if ( MEDprofilLire( fid,profilearray, (char *) profilename) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDprofilLire");
    SSCRUTE(profilename);
    goto ERROR;
  }

  _ret = 0;
 ERROR:

  va_end(params);
  *fret = _ret;

  return;
}
med_err
MEDsupportMeshInfoByName(const med_idt         fid,
			 const char *    const supportmeshname,
			 med_int *       const spacedim,
			 med_int *       const meshdim,
			 char *          const description,
			 med_axis_type * const axistype,
			 char *          const axisname,
			 char *          const axisunit)
{
  med_err          _ret=-1;
  char             _dtunit[MED_SNAME_SIZE+1]="";
  med_sorting_type _sortingtype=MED_SORT_UNDEF;
  med_mesh_type    _meshtype = MED_UNDEF_MESH_TYPE;
  med_int          _nstep=0;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();


  if ( _MEDmeshInfoByName(fid, MED_MESH_SUPPORT_GRP, supportmeshname, spacedim, meshdim, &_meshtype,
			  description, _dtunit, &_sortingtype, &_nstep,
			  axistype,  axisname, axisunit)  < 0) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_MESH_MSG);
    SSCRUTE(supportmeshname);SSCRUTE("MEDmeshInfoByName");
    goto ERROR;
  }

  _ret = 0;

 ERROR:

  return _ret;
}
Beispiel #25
0
med_err
MEDprofileWr(const med_idt        fid,
	     const char* const    profilename,
	     const med_int        profilesize,
	     const med_int* const profilearray)
{
  med_access_mode _MED_ACCESS_MODE;
  med_idt        _root=0,_pfid=0;
  med_err        _ret=-1;
  char           _path[MED_TAILLE_PROFILS+MED_NAME_SIZE+1]=MED_PROFILS;
  med_filter     _filter        = MED_FILTER_INIT;

  /*
   * 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 /PROFILS/ n'existe pas, on le cree
   */
  if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0)
    if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
     goto ERROR;
    }

  NOFINALBLANK(profilename,ERROR);
  /*
   * Si le DataGroup /PROFILS/<profilename> n'existe pas, on le cree
   */
  if ((_pfid = _MEDdatagroupOuvrir(_root,profilename)) < 0)
    if ((_pfid = _MEDdatagroupCreer(_root,profilename)) < 0) {
      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,profilename);
      SSCRUTE(_path);goto ERROR;
    }

  strcat(_path,profilename);


  /*
   * On stocke "profilesize" sous forme d'attribut
   */
  if (_MEDattributeIntWr(_pfid,MED_NOM_NBR,&profilesize) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_PROFILE_MSG);
    SSCRUTE(profilename);SSCRUTE(MED_NOM_NBR);ISCRUTE(profilesize);
    goto ERROR;
  }

  /*
   * On stocke le profil dans un dataset
   */
  if ( MEDfilterEntityCr(fid, profilesize, 1, 1, MED_ALL_CONSTITUENT,
			 MED_NO_INTERLACE,MED_UNDEF_PFLMODE,
			 MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
    goto ERROR;
  }

  if ( _MEDdatasetWr(_pfid,MED_NOM_PFL,MED_INTERNAL_INT,&_filter, profilearray) < 0) {
    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_PFL);SSCRUTE(_path);
    goto ERROR;
  }

  if ( MEDfilterClose(&_filter) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_PROFILE_MSG); SSCRUTE(_path);
    goto ERROR;
  }

  _ret = 0;

 ERROR:

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

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

  return _ret;
}
void _MEDsubdomainCorrespondenceSize30(int dummy, ...) {


  med_err  _ret=-1;
  med_idt  _eqid=0,_datagroup1=0,_dataset=0;
  char     _path[MED_JOINT_GRP_SIZE+2*MED_NAME_SIZE+2+2*MED_MAX_PARA+1+4*MED_TAILLE_NOM_ENTITE+4]=MED_JOINT_GRP;
  char     _datagroupname1[2*MED_TAILLE_NOM_ENTITE+2]="";
  char     _cstpname[2*MED_MAX_PARA+1]="";
  med_size          _njointarray=0;
  med_sorting_type  _sortingtype=0;
  med_int           _intlocalentitype;
  med_int           _intlocalgeotype;
  char              _localgeotypename [MED_TAILLE_NOM_ENTITE+1]="";
  char              _remotegeotypename  [MED_TAILLE_NOM_ENTITE+1]="";


  MED_VARGS_DECL(const, med_idt              , , fid             );
  MED_VARGS_DECL(const, char * , const         , meshname        );
  MED_VARGS_DECL(const, char * , const         , jointname       );
  MED_VARGS_DECL(const, med_int              , , numdt           );
  MED_VARGS_DECL(const, med_int              , , numit           );
  MED_VARGS_DECL(const, med_entity_type      , , localentitype   );
  MED_VARGS_DECL(const, med_geometry_type    , , localgeotype    );
  MED_VARGS_DECL(const, med_entity_type      , , remoteentitype  );
  MED_VARGS_DECL(const, med_geometry_type    , , remotegeotype   );
  MED_VARGS_DECL(, med_int *, const            , nentitycor      );
  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         , meshname        );
  MED_VARGS_DEF(const, char * , const         , jointname       );
  MED_VARGS_DEF(const, med_int              , , numdt           );
  MED_VARGS_DEF(const, med_int              , , numit           );
  MED_VARGS_DEF(const, med_entity_type      , , localentitype   );
  MED_VARGS_DEF(const, med_geometry_type    , , localgeotype    );
  MED_VARGS_DEF(const, med_entity_type      , , remoteentitype  );
  MED_VARGS_DEF(const, med_geometry_type    , , remotegeotype   );
  MED_VARGS_DEF(, med_int *, const            , nentitycor      );
  MED_VARGS_DEF(, med_err *                  ,, fret            );

  /*
   * On inhibe le gestionnaire d'erreur
   */

  _MEDmodeErreurVerrouiller();


  if ( MEDmeshSortingTypeRd(fid,meshname,&_sortingtype) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API," MEDmeshSortingTypeRd");
    SSCRUTE(meshname);ISCRUTE_int(_sortingtype);goto ERROR;
  }


  strcat( _path, meshname);
  strcat( _path, "/");
  strcat( _path, jointname);
  strcat( _path, "/");
  _MEDgetComputationStepName(_sortingtype,numdt,numit,&_path[strlen(_path)]);
  strcat( _path, "/");

  /*
   *  Construction du nom de  datagroup <localentitype>[.<localgeotype>].<remoteentitype>[.<remotegeotype>]
   */
  if (_MEDgetEntityTypeName(&_path[strlen(_path)],localentitype) < 0) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
    ISCRUTE_int(localentitype);SSCRUTE(jointname);goto ERROR;
  }
  if ( localentitype != MED_NODE ) {
    if ( _MEDgetInternalGeometryTypeName(0,_localgeotypename,localgeotype) < 0) {
      MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
      ISCRUTE_int(localgeotype);SSCRUTE(jointname);goto ERROR;
    }
      strcat(_path,".");
      strcat(_path,_localgeotypename);
  }

  strcat(_path,".");

  if (_MEDgetEntityTypeName(&_path[strlen(_path)],remoteentitype) < 0) {
    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
    ISCRUTE_int(remoteentitype);SSCRUTE(jointname);goto ERROR;
  }
  if ( remoteentitype != MED_NODE ) {
    if ( _MEDgetInternalGeometryTypeName(fid,_remotegeotypename,remotegeotype) < 0) {
      MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
      ISCRUTE_int(remotegeotype);SSCRUTE(jointname);goto ERROR;
    }
      strcat(_path,".");
      strcat(_path,_remotegeotypename);
  }


  if ( (_datagroup1 = _MEDdatagroupOuvrir(fid,_path)) < 0 ) {
    *nentitycor=0;
    goto SORTIE;
  }

  if ((_dataset = _MEDdatasetOuvrir(_datagroup1,MED_NOM_COR)) < 0) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATASET,MED_NOM_COR);
    SSCRUTE(_path);
    goto ERROR;
  }

  if ( _MEDattrEntierLire(_dataset,MED_NOM_NBR,nentitycor) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
    SSCRUTE(_path);SSCRUTE(MED_NOM_NBR);ISCRUTE(*nentitycor);
    goto ERROR;
  }

 SORTIE:
  _ret = 0;
 ERROR:

  if (_dataset>0)     if (_MEDdatasetFermer(_dataset) < 0) {
    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATASET,MED_NOM_COR);
    ISCRUTE_id(_dataset);
  }

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

  va_end(params);
  *fret = _ret;
  return;
}
Beispiel #27
0
int main(int argc, char *argv[]) {
  med_idt  fid    =0;
  med_int  majeur =0, mineur=0, release=0;
  med_err  ret    =-1;
  med_bool hdfok     =MED_FALSE;
  med_bool medok     =MED_FALSE;
  med_bool fileexist =MED_FALSE;
  med_bool accessok  =MED_FALSE;

  if (argc != 2) {
    fprintf(stdout,">> Utilisation : medconforme <nom_de_fichier_med> \n");
    return 0;
  }

  /*
   * Quelle version de la bibliotheque MED est utilisee ?
   */
  ret=MEDlibraryNumVersion(&majeur, &mineur, &release);
  EXIT_IF( ret<0 , "Erreur d'appel de la routine MEDlibraryNumVersion.", NULL);
  fprintf(stdout,"- Version de MED-fichier utilisée par medconforme : "IFORMAT"."IFORMAT"."IFORMAT" \n",majeur,mineur,release); 

  /*
   * Le fichier à lire est-il accessible ?
   */
  ret = MEDfileExist(argv[1],MED_ACC_RDONLY,&fileexist,&accessok );
  MED_ERR_EXIT_IF(ret < 0 , MED_ERR_CALL,MED_ERR_API,"MEDfileExist");
  if ( !fileexist ) {  fprintf(stdout,"- Le fichier [%s] n'existe pas \n",argv[1]); goto SORTIE; }
  if ( !accessok  ) {  fprintf(stdout,"- Le fichier [%s] n'est pas accessible en lecture \n",argv[1]); goto SORTIE; }
  
  /*
   * Le fichier à lire est-il au bon format de fichier HDF ?
   */
  ret=MEDfileCompatibility(argv[1],&hdfok,&medok);
  MED_ERR_EXIT_IF(ret < 0 , MED_ERR_CALL,MED_ERR_API,"MEDfileCompatibility");
  if ( hdfok ) fprintf(stdout,"- Format HDF du fichier MED [%s] conforme au format HDF utilisé par la bibliothèque \n",argv[1]);
  else       { fprintf(stdout,"- Format HDF du fichier MED [%s] non conforme au format HDF utilisé par la bibliothèque \n",argv[1]); goto SORTIE; }

  /*
   * Le fichier à lire a-t-il été créé avec une version de la bilbiothèque MED conforme avec celle utilisée ?
   * (Numéros majeur identique et mineur de la bibliothèque supérieur à celui du fichier).
   */
  if ( medok ) {
    fprintf(stdout,"- Version MED du fichier [%s] conforme a la bibliothèque MED utilisée \n",argv[1]);

    if ((fid = MEDfileOpen(argv[1],MED_ACC_RDONLY)) < 0) {
      MED_ERR_(ret,MED_ERR_OPEN,MED_ERR_FILE,argv[1]);
      goto ERROR;
    }
    
    /*
     * Une fois le fichier ouvert on peut avoir acces au numero de version complet
     */
    if ( MEDfileNumVersionRd(fid, &majeur, &mineur, &release) < 0 ) {
      MED_ERR_(ret,MED_ERR_CALL,MED_ERR_API,"MEDfileNumVersionRd");
      goto ERROR;
    }
    fprintf(stdout,"- Ce fichier a ete créé avec MED-fichier V"IFORMAT"."IFORMAT"."IFORMAT" \n",majeur,mineur,release);

  }
  else
    fprintf(stdout,"- Version MED du fichier [%s] non conforme avec celle de la bibliothèque utilisée \n",argv[1]); 

 SORTIE:
  ret = 0;
 ERROR:
  
  if (fid > 0)
    if (MEDfileClose(fid) < 0) {
      MED_ERR_(ret,MED_ERR_CLOSE,MED_ERR_FILE,argv[1]);
      ret = -1;
    }

  return ret;
}
void
_MEDlocalizationInfoByName30(int dummy, ...) {


  med_idt           _lzid =  0;
  med_err           _ret  = -1;
  char              _path[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
  char              _sectiongeotypename[MED_TAILLE_NOM_ENTITE+1]="";
  med_int           _intgeotype      = -1,_nsectiongeotype=0, _nsectionmeshcell=0;
  med_entity_type   _sectionentitype = MED_CELL;
  med_geometry_type _sectiongeotype  = MED_UNDEF_GEOTYPE;
  med_data_type     _conorcoo        = MED_CONNECTIVITY;
  med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;


  MED_VARGS_DECL(const, med_idt                   , , fid                  );
  MED_VARGS_DECL(const, char        * , const       , localizationname     );
  MED_VARGS_DECL(, med_geometry_type *, const , geotype                    );
  MED_VARGS_DECL(, med_int           *, const , spacedimension             );
  MED_VARGS_DECL(, med_int           *, const , nipoint                 );
  MED_VARGS_DECL(, char        *, const       , geointerpname              );
  MED_VARGS_DECL(, char        *, const       , sectionmeshname            );
  MED_VARGS_DECL(, med_int     *, const       , nsectionmeshcell           );
  MED_VARGS_DECL(, med_geometry_type *, const , sectiongeotype             );
  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       , localizationname     );
  MED_VARGS_DEF(, med_geometry_type *, const , geotype                    );
  MED_VARGS_DEF(, med_int           *, const , spacedimension             );
  MED_VARGS_DEF(, med_int           *, const , nipoint                 );
  MED_VARGS_DEF(, char        *, const       , geointerpname              );
  MED_VARGS_DEF(, char        *, const       , sectionmeshname            );
  MED_VARGS_DEF(, med_int     *, const       , nsectionmeshcell           );
  MED_VARGS_DEF(, med_geometry_type *, const , sectiongeotype             );
  MED_VARGS_DEF(, med_err *                 ,, fret                       );

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

  /*
   * ouverture du groupe /GAUSS/"nom"
   */
  strcat(_path,localizationname);
  if ((_lzid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(_path);
    goto ERROR;
  }

  /*
   * Lecture de l'attribut MED_NOM_NBR
   */
  if (_MEDattrEntierLire(_lzid,MED_NOM_NBR,nipoint) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(_path);SSCRUTE(MED_NOM_NBR);ISCRUTE(*nipoint);
    goto ERROR;
  }


  /*
   * On lit <typgeo> sous forme d'attribut
   */
  /* sizeof(enum) tjrs = sizeof(int) en C, or
     sur machines 64 bits par défaut med_int==long,
     du coup sur  machines 64 bits _MEDattributeIntWr utilise 
     le type hdf NATIVE_LONG, ce qui pose un problème qd on passe
     un enum.
  */
  if (_MEDattrEntierLire(_lzid,MED_NOM_GEO,&_intgeotype) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intgeotype);
    goto ERROR;
  };
  *geotype = (med_geometry_type) _intgeotype;

  /*
   * On lit <spacedimension>
   */
  if (_MEDattrEntierLire(_lzid,MED_NOM_DIM,spacedimension) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(localizationname);SSCRUTE(MED_NOM_DIM);ISCRUTE(*spacedimension);
    goto ERROR;
  };

  /*
   * Lecture de l'attribut MED_NOM_NOM (nom du maillage de section)
   */
  if ( _MEDattrStringLire(_lzid,MED_NOM_NOM,MED_NAME_SIZE,sectionmeshname) < 0) {
    sectionmeshname[0]='\0';
  }

  if ( strlen(sectionmeshname) &&
       ( _intgeotype > MED_STRUCT_GEO_INTERNAL) &&
       ( _intgeotype < MED_STRUCT_GEO_SUP_INTERNAL) ) {

    if ( _MEDgetSupportMeshNbOfEntities(fid,sectionmeshname,&_sectionentitype,
					&_sectiongeotype,NULL,&_nsectionmeshcell) < 0) {
      MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDgetSupportMeshNbOfEntities");
      SSCRUTE(sectionmeshname);ISCRUTE_int(_sectionentitype);
      ISCRUTE(_sectiongeotype);ISCRUTE(_nsectionmeshcell);goto ERROR;
    }
  }
  *sectiongeotype= _sectiongeotype;
  *nsectionmeshcell= _nsectionmeshcell;


  if ( _MEDattrStringLire(_lzid,MED_NOM_INM,MED_NAME_SIZE,geointerpname) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(localizationname);SSCRUTE(MED_NOM_INM);SSCRUTE(geointerpname);
    goto ERROR;
  }

  _ret = 0;
 ERROR:

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

  va_end(params);
  *fret = _ret;
  return;
  }
Beispiel #29
0
med_err
MEDmeshPolygon2Rd(const med_idt               fid,
		 const char*  const          meshname,
		 const med_int               numdt,
		 const med_int               numit,
		 const med_entity_type       entitype,
		 const med_geometry_type     polytype,
		 const med_connectivity_mode cmode,
		 med_int * const             polyindex,
		 med_int * const             connectivity )
{
  med_access_mode _MED_ACCESS_MODE;
  med_idt         _meshid=0;
  med_err         _ret         = -1;
  med_data_type   _datatype    = MED_UNDEF_DATATYPE;
  med_entity_type _entitytype=entitype;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

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

  /* Tester le type d'entité ?
   * MAILLE Ok
   * FACE   OK
   * ARETE  ?
   * NOEUD  KO
   * NOEUD_MAILLE  ?
   */
  if (entitype == MED_NODE_ELEMENT ) _entitytype=MED_NODE ;

  switch(polytype)
    {
    case MED_POLYGON:
    case MED_POLYGON2:
      break;
    default:
      MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
      ISCRUTE_int(polytype);
      goto ERROR;
    }


  if (_MEDmeshAdvancedRd(fid,
			 meshname,
			 MED_CONNECTIVITY,
			 MED_NO_NAME,
			 MED_INTERNAL_UNDEF,
			 numdt,
			 numit,
			 _entitytype,
			 polytype,
			 cmode,
			 MED_UNDEF_PFLMODE,
			 MED_NO_PROFILE,
			 MED_FULL_INTERLACE,
			 MED_ALL_CONSTITUENT,
			 NULL,
			 (unsigned char * const)connectivity) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedRd (MED_CONNECTIVITY) ");
    goto ERROR;
  }

  if (_MEDmeshAdvancedRd(fid,
			 meshname,
			 MED_INDEX_NODE,
			 MED_NO_NAME,
			 MED_INTERNAL_UNDEF,
			 numdt,
			 numit,
			 _entitytype,
			 polytype,
			 cmode,
			 MED_UNDEF_PFLMODE,
			 MED_NO_PROFILE,
			 MED_FULL_INTERLACE,
			 MED_ALL_CONSTITUENT,
			 NULL,
			 (unsigned char * const)polyindex) < 0 ) {
    MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedRd (MED_INDEX_NODE) ");
    goto ERROR;
  }

  _ret = 0;

 ERROR:

  return _ret;

}
void
_MEDlocalizationInfoByName236(int dummy, ...) {


  med_idt _lzid=0;
  med_err _ret=-1;
  char    _path[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
  med_int _intgeotype = -1;


  MED_VARGS_DECL(const, med_idt                   , , fid                 );
  MED_VARGS_DECL(const, char        * , const       , localizationname    );
  MED_VARGS_DECL(, med_geometry_type *, const , geotype                   );
  MED_VARGS_DECL(, med_int           *, const , spacedimension            );
  MED_VARGS_DECL(, med_int           *, const , nipoint                );
  MED_VARGS_DECL(, char        *, const       , geointerpname             );
  MED_VARGS_DECL(, char        *, const       , sectionmeshname           );
  MED_VARGS_DECL(, med_int     *, const       , nsectionmeshcell          );
  MED_VARGS_DECL(, med_geometry_type *, const , sectiongeotype            );
  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       , localizationname    );
  MED_VARGS_DEF(, med_geometry_type *, const , geotype                   );
  MED_VARGS_DEF(, med_int           *, const , spacedimension            );
  MED_VARGS_DEF(, med_int           *, const , nipoint                );
  MED_VARGS_DEF(, char        *, const       , geointerpname             );
  MED_VARGS_DEF(, char        *, const       , sectionmeshname           );
  MED_VARGS_DEF(, med_int     *, const       , nsectionmeshcell          );
  MED_VARGS_DEF(, med_geometry_type *, const , sectiongeotype            );
  MED_VARGS_DEF(, med_err *                 ,, fret                      );

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();


  /*
   * ouverture du groupe /GAUSS/"nom"
   */
  strcat(_path,localizationname);
  if ((_lzid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(_path);
    goto ERROR;
  }

  /*
   * Lecture de l'attribut MED_NOM_NBR
   */
  if (_MEDattrEntierLire(_lzid,MED_NOM_NBR,nipoint) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(_path);SSCRUTE(MED_NOM_NBR);ISCRUTE(*nipoint);
    goto ERROR;
  }


  /*
   * On lit <typgeo> sous forme d'attribut
   */
  /* sizeof(enum) tjrs = sizeof(int) en C, or
     sur machines 64 bits par défaut med_int==long,
     du coup sur  machines 64 bits _MEDattributeIntWr utilise
     le type hdf NATIVE_LONG, ce qui pose un problème qd on passe
     un enum.
  */
  if (_MEDattrEntierLire(_lzid,MED_NOM_GEO,&_intgeotype) < 0) {
    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
    SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intgeotype);
    goto ERROR;
  };
  *geotype = (med_geometry_type) _intgeotype;

  *spacedimension = (_intgeotype/100);

  sectionmeshname[0]='\0';
  geointerpname[0]='\0';
  *nsectionmeshcell=0;
  *sectiongeotype=MED_UNDEF_GEOTYPE;

  _ret = 0;
 ERROR:

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

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