Beispiel #1
0
med_err
MEDgaussInfo(med_idt fid, int indice, char * locname, med_geometrie_element * type_geo,
	     med_int * ngauss )
{
  int numero=0;
  med_idt locid=0;
  med_err ret=-1;
  char chemin[MED_TAILLE_GAUSS+MED_TAILLE_NOM+1]="";
  med_int typegeo;

  /*
   * On inhibe le gestionnaire d'erreur
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  /*
   * On recupere le nom du groupe de rang "indice"
   */ 
  numero = indice-1;
  if ( _MEDobjetIdentifier(fid,MED_GAUSS,numero,locname) < 0)
    goto ERROR;

  /*
   * On va chercher l'attribut ngauss 
   */
  strcpy(chemin,MED_GAUSS);
  strcat(chemin,locname);
  if ((locid = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
    MESSAGE("Impossible d'ouvrir le datagroup : ");
    SSCRUTE(chemin); goto ERROR;
  }

  /* Lecture de  <ngauss> */
  if (_MEDattrEntierLire(locid,MED_NOM_NBR,ngauss) < 0) {
    MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NBR : ");
    ISCRUTE(*ngauss);goto ERROR;
  };
  
  /* Lecture <type_geo> sous forme d'attribut */
  if (_MEDattrEntierLire(locid,MED_NOM_GEO,&typegeo) < 0) {
    MESSAGE("Erreur à la lecture de l'attribut MED_NOM_GEO : ");
    ISCRUTE(*type_geo);goto ERROR;
  };
  *type_geo = ( med_geometrie_element ) typegeo;

  ret = 0;

 ERROR:
  if ( locid > 0 ) if (_MEDdatagroupFermer(locid) < 0)
    goto ERROR;
  
  return 0;
}
med_err 
MEDscalairePasdetempsInfo(med_idt fid,char *scalaire,int indice, 
			  med_int * numdt, char * dt_unit, med_float * dt,med_int * numo)
{
  med_err ret=0;
  med_idt gid;
  char chemin[MED_TAILLE_NUM_DATA+MED_TAILLE_NOM+1+2*MED_MAX_PARA+1];
  int num;
  char nomdatagroup[2*MED_MAX_PARA+1];

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  /*
   * On construit le chemine d'acces 
   */
  strcpy(chemin,MED_NUM_DATA);
  strcat(chemin,scalaire);
  strcat(chemin,"/");
  num = indice - 1;
  if ((ret = _MEDobjetIdentifier(fid,chemin,num,nomdatagroup)) < 0)
    return -1;
  strcat(chemin,nomdatagroup);
  if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    return -1;

  /*
   * La liste des attributs
   */
 if ((ret = _MEDattrEntierLire(gid,MED_NOM_NDT,(med_int*) numdt)) < 0)
   return -1;

 if ((ret = _MEDattrFloatLire(gid,MED_NOM_PDT,(med_float*) dt)) < 0)
   return -1;

 if ((ret = _MEDattrStringLire(gid,MED_NOM_UNI,MED_TAILLE_PNOM,dt_unit)) < 0)
   return -1;
 
 if ((ret = _MEDattrEntierLire(gid,MED_NOM_NOR,(med_int*) numo)) < 0)
   return -1;

 /*
  * On ferme tout
  */
 if ((ret = _MEDdatagroupFermer(gid)) < 0)
   return -1;
 
 return ret; 
}
Beispiel #3
0
med_err 
MEDscalaireInfo(med_idt fid,int indice,char *scalaire,
		med_type_champ *type,char *desc)
{
  med_err ret=0;
  med_idt gid;
  char chemin[MED_TAILLE_NUM_DATA+MED_TAILLE_NOM+1];
  int num;
  med_int typechamp;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  /*
   * On recupere le nom du scalaire
   */
  num = indice - 1;
  strcpy(chemin,MED_NUM_DATA);
  if ((ret = _MEDobjetIdentifier(fid,chemin,num,scalaire)) < 0)
    return -1;


  /* 
   * Si le Groupe HDF "scalaire" n'existe pas => erreur
   */
  strcat(chemin,scalaire);
  if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    return -1;


  /*
   * La liste des attributs
   */
  if ((ret = _MEDattrEntierLire(gid,MED_NOM_TYP, & typechamp)) < 0)
    return -1;
  *type = (med_type_champ) typechamp;

  if ((ret = _MEDattrStringLire(gid,MED_NOM_DES,MED_TAILLE_DESC,
				desc)) < 0)
    return -1;

  /*
   * On ferme tout
   */
  if ((ret = _MEDdatagroupFermer(gid)) < 0)
    return -1; 

  return ret;
}
Beispiel #4
0
int
MEDequivInfo(int fid, char *maa, int ind, char *eq, char *des)
{
  med_idt eqid;
  med_err ret;
  char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1];
  int num;
  int idx;

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  /*
   * On recupere le nom de l'equivalence
   */
  num = ind - 1;
  strcpy(chemin,MED_MAA);
  strcat(chemin,maa);
  strcat(chemin,MED_EQS); 
  if ((idx = _MEDobjetIdentifier(fid,chemin,num,eq)) < 0)
    return -1;

  /* 
   * Si le Data Group eq n'existe pas => erreur
   */
  strcat(chemin,eq);
  if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
      return -1;

  /*
   * L'attribut "DES"
   */
  if ((ret = _MEDattrStringLire(eqid,MED_NOM_DES,MED_TAILLE_DESC,des)) < 0)
    return -1;

  /*
   * On ferme tout 
   */
  if ((ret = _MEDdatagroupFermer(eqid)) < 0)
    return -1;

  return 0;
}
Beispiel #5
0
med_err 
MEDprofilInfo(med_idt fid, int indice, char *profilname, med_int *n)
{
  int numero=0;
  med_idt proid=0;
  med_err ret=-1;
  char chemin[MED_TAILLE_PROFILS+MED_TAILLE_NOM+1]="";

  /*
   * On inhibe le gestionnaire d'erreur
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  /*
   * On recupere le nom du groupe de rang "indice"
   */ 
  numero = indice-1;
  if ( _MEDobjetIdentifier(fid,MED_PROFILS,numero,profilname) < 0)
    goto ERROR;

  /*
   * On va chercher l'attribut taille du profil 
   */
  strcpy(chemin,MED_PROFILS);
  strcat(chemin,profilname);
  if ((proid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    goto ERROR;   
  if (_MEDattrEntierLire(proid,MED_NOM_NBR,n) < 0)
    goto ERROR;
 
  ret = 0;

 ERROR:
  if ( proid > 0 ) if (_MEDdatagroupFermer(proid) < 0)
    goto ERROR;
  
  return 0;
}
med_err
MED231champRefInfoEtRenMaa(med_idt fid,char *champ,
		med_entite_maillage type_ent, med_geometrie_element type_geo,
		int indice, med_int numdt, med_int numo,
		char * maa, med_booleen * local, med_int *ngauss)
{

  med_err ret=-1;
  int num;
  med_idt datagroup2=0,datagroup3=0,gid_maa=0,gid_lien=0;
  char chemin[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";
  char chemini[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";
  char chemin_maa[MED_TAILLE_MAA+MED_TAILLE_NOM+1]="";
  char chemin_lien[MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=""; 
  char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2]="";
  char nomdatagroup2[2*MED_MAX_PARA+1]="";
  char tmp1         [MED_TAILLE_NOM_ENTITE+1]="";
  char maai         [MED_TAILLE_NOM+1];
  char maaf         [MED_TAILLE_NOM+1]="";
  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();

  /*
   * On construit le nom du datagroup
   */
  strcpy(chemin,MED_CHA);
  strcat(chemin,champ);
  strcat(chemin,"/");

  /* 
   * Si le Data Group  de niveau 1 <type_ent>[.<type_geo>] n'existe pas => erreur
   */
  /* modif pour la version 2.3.3 */
  
  if (_MEDnomEntite(nomdatagroup1,type_ent) < 0)
    goto ERROR;
  if ((type_ent != MED_NOEUD)) {
    if (_MEDnomGeometrie(tmp1,type_geo) < 0)
      goto ERROR;
    strcat(nomdatagroup1,".");
    strcat(nomdatagroup1,tmp1);
  }
  strcat(chemin,nomdatagroup1);
  strcat(chemin,"/");

  /*
   * Si le Data Group de niveau 2 <numdtt>.<numoo> n'existe pas => erreur
   */
  sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
  strcat(chemin,nomdatagroup2);

  /*
   * Modifie le nom de la  première référence à un maillage
   * si besoin est
   */  
  if ( (datagroup2 = _MEDdatagroupOuvrir(fid,chemin)) < 0 ) {
    MESSAGE("Erreur à l'ouverture du datagroup : ");
    SSCRUTE(chemin); goto ERROR;
  }
  if ( _MEDattrStringLire(datagroup2,MED_NOM_MAI,MED_TAILLE_NOM,maai) < 0 ) {
    MESSAGE("Erreur de lecture de l'attribut MED_NOM_MAI : ");
    SSCRUTE(maai); goto ERROR;
  }
  if ( MAJ_231_232_chaine(maai,maaf) ) {
    fprintf(stdout,"  >>> Normalisation du nom de maillage par défaut [%s] associé au champ [%s] pour (n°dt,n°it) ("IFORMAT","IFORMAT")\n",maai,champ,numdt,numo);
    ret = _MEDattrStringEcrire(datagroup2,MED_NOM_MAI,MED_TAILLE_NOM,maaf);
    EXIT_IF(ret < 0,"Renommage du maillage en",maaf);
    fprintf(stdout,"  >>> Normalisation du nom du maillage par défaut [%s] ... OK ... \n",maaf);
  }
  if (_MEDdatagroupFermer(datagroup2) < 0) {
    MESSAGE("Impossible de fermer le datagroup : ");
    ISCRUTE_int(datagroup2); goto ERROR; 
  }


  strcat(chemin,"/");


  /*
   * Cherche le datagroup de niveau 3 <maa> correspondant à l'indice <num>
   */
  num = indice - 1;
  if (_MEDobjetIdentifier(fid,chemin,num,maa) < 0) {
    MESSAGE("Impossible de trouver un groupe à l'indice spécifié : ");
    SSCRUTE(chemin); ISCRUTE_int(num); goto ERROR;
  };
  
  if ( MAJ_231_232_chaine(maa,maaf) ) {
  
    fprintf(stdout,"  >>> Normalisation du nom de maillage [%s] associé au champ [%s] pour (n°dt,n°it) ("IFORMAT","IFORMAT")\n",maa,champ,numdt,numo);
    /* on accede au maillage */
    strcpy(chemini,chemin);
    strcat(chemini,maa);
    strcat(chemin,maaf);

    ret = H5Gmove(fid, chemini, chemin );
    EXIT_IF(ret < 0,"Renommage du maillage en",maaf);
    fprintf(stdout,"  >>> Normalisation du nom du maillage [%s] ... OK ... \n",maaf);
  }  else
    strcat(chemin,maa);

  
  /*
   * Si le Data Group de niveau 3 <maa> n'existe pas => erreur
   */
 
  if ((datagroup3 = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
    MESSAGE("Erreur d'ouverture du datagroup lien au maillage : ");
    SSCRUTE(chemin); goto ERROR;
  };


  /* Lire le nbre des points de GAUSS*/
  if (_MEDattrEntierLire(datagroup3,MED_NOM_NGA,ngauss) < 0) {
    MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NGA : ");
    ISCRUTE(*ngauss);goto ERROR;
  };


  /* Maillage local ou distant */
  /* Les noms de maillages n'ayant pas encore été mis à jour
     on garde l'ancien nom pour le test local/distant */
  strcpy(chemin_maa,MED_MAA);
  strcat(chemin_maa,maa);
  /* Le maillage est il distant */
  if ( (gid_maa = _MEDdatagroupOuvrir(fid,chemin_maa)) < 0)  {
    
    /* Verifie que le maillage est bien référencé comme distant */  
    strcpy(chemin_lien,MED_LIENS);
    strcat(chemin_lien,maa); 
    if ((gid_lien = _MEDdatagroupOuvrir(fid,chemin_lien)) < 0) {
/*       MESSAGE("Le maillage n'est ni local, ni distant : "); */
/*        SSCRUTE(chemin_maa);SSCRUTE(chemin_lien); goto ERROR; */
      *local = MED_FAUX;
    }
  
    *local = MED_FAUX;
    
  } else  
    *local = MED_VRAI;
    
  /*On retourne le nouveau nom de maillage*/
  if ( strlen(maaf) ) strcpy(maa,maaf);
  /*
   * On ferme tout 
   */

  ret = 0;

 ERROR:
  
  if (datagroup3>0)     if (_MEDdatagroupFermer(datagroup3) < 0) {
      MESSAGE("Impossible de fermer le datagroup : ");
      ISCRUTE_int(datagroup3); ret = -1; 
  }
  
  if (gid_maa>0)  if (_MEDdatagroupFermer(gid_maa) < 0) {
      MESSAGE("Impossible de fermer le datagroup : ");
      ISCRUTE_id(gid_maa); ret = -1; 
  }
  
  if (gid_lien>0) if (_MEDdatagroupFermer(gid_lien) < 0) {
      MESSAGE("Impossible de fermer le datagroup : ");
      SSCRUTE(chemin_lien); ret = -1; 
  }

  return ret; 
}
Beispiel #7
0
med_int 
MEDnChamp(med_idt fid, int indice)
{
  int n1;
  med_int n2;
  med_idt datagroup;
  med_err ret;
  char nomdatagroup[MED_TAILLE_NOM+1];
  int num;
  char chemin[MED_TAILLE_CHA+MED_TAILLE_NOM+1];

  if (indice < 0)
    return -1;

  /*
   * On inhibe le gestionnaire d'erreur HDF 
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;

  
  /* 
   * Si le Data Group cha n'existe pas et indice == 0 => 0
   * sinon erreur => erreur
   */
  strcpy(chemin,MED_CHA);

  /*
   * Si indice == 0 => nombre de champs
   */
  if (indice == 0)
    {
      n1 = 0;
      _MEDnObjets(fid,chemin,&n1);
      n2 = n1;
    }

  /*
   * Si indice > 0 => nbre de composants
   */
  if (indice > 0)
    {
      /*
       * On recupere le nom du champ 
       */
      num = indice-1;
      if ((ret = _MEDobjetIdentifier(fid,chemin,num,nomdatagroup)) < 0)
	return -1;
      strcat(chemin,nomdatagroup);
      /*
       * On recupere le nombre de composants
       */
      if ((datagroup = _MEDdatagroupOuvrir(fid,chemin)) < 0) 
	return -1;
      if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NCO,&n2)) < 0)
	return -1;
      if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
	return -1;
    }

  return n2;
}
Beispiel #8
0
med_err
MED231champInfoEtRen(med_idt fid,int indice,char *champ,
		     med_type_champ *type,char *comp,char *unit, 
		     med_int ncomp)
{
  med_err ret=0;
  med_idt gid;
  char chemin [MED_TAILLE_CHA+MED_TAILLE_NOM+1];
  char chemini[MED_TAILLE_CHA+MED_TAILLE_NOM+1];
  char champf [MED_TAILLE_NOM+1];
  int num;
  med_int typechamp;

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

  /*
   * On recupere le nom du champ
   */
  num = indice - 1;
  strcpy(chemin,MED_CHA);
  if ((ret = _MEDobjetIdentifier(fid,chemin,num,champ)) < 0)
    return -1;

  /* 
   * Si le Data Group cha n'existe pas => erreur
   */
  if ( MAJ_231_232_chaine(champ,champf) ) {
    
    fprintf(stdout,"  >>> Normalisation du nom de champ [%s] \n",champ);
    /* on accede au maillage */
    strcpy(chemini,chemin);
    strcat(chemini,champ);
    strcat(chemin,champf);
    
    ret = H5Gmove(fid, chemini, chemin );
    EXIT_IF(ret < 0,"Renommage du champ en",champf);
    strcpy(champ,champf);
    fprintf(stdout,"  >>> Normalisation du nom du champ [%s] ... OK ... \n",champf);
  } else {
    strcat(chemin,champ);
  }

  if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    return -1;


  /*
   * La liste des attributs
   */
  if ((ret = _MEDattrEntierLire(gid,MED_NOM_TYP,&typechamp)) < 0)
    return -1;
  *type = (med_type_champ) (typechamp);

  if ((ret = _MEDattrStringLire(gid,MED_NOM_NOM,ncomp*MED_TAILLE_PNOM,
				comp)) < 0)
    return -1;
  if ((ret = _MEDattrStringLire(gid,MED_NOM_UNI,ncomp*MED_TAILLE_PNOM,
				unit)) < 0)
    return -1;

  /*
   * On ferme tout
   */
  if ((ret = _MEDdatagroupFermer(gid)) < 0)
    return -1; 

  return 0;
}
Beispiel #9
0
med_int
MEDnGroupe(med_idt fid,char *maa, int indice)
{
  med_idt datagroup,famid;
  med_err ret;
  char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_FAS_ENTITE+2*MED_TAILLE_NOM+1];
  char stockage[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_FAS_ENTITE+2*MED_TAILLE_NOM+1];
  med_int n;
  int n_tmp;
  int num;
  char famille[MED_TAILLE_NOM+1];
  int nfamnoe,nfammai;

  /*
   * On inhibe le gestionnaire d'erreur HDF
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  strcpy(chemin,MED_MAA);
  strcat(chemin,maa);
  strcat(chemin,MED_FAS);

  num = indice - 1;
  
  /* Acces a la famille :
   * nfam = nfamnoe + 1 + nfammai
   * Repartition selon l'indice "num" dans le datagroup :
   *    - 0..nfammai - 1 : familles des mailles/faces/aretes
   *    - nfamai : famille 0
   *    - (nfamai + 1)..(nfammai+nfamnoe) : familles de noeuds 
   */

  /* On va compter les familles de mailles/faces/aretes */
  strcpy(stockage,chemin);
  strcat(stockage,MED_FAS_ELEME_NOM);
  nfammai = 0;
  n_tmp = 0;
  if ((ret =_MEDnObjets(fid,stockage,&n_tmp)) == 0) 
    nfammai = (med_int ) n_tmp;
  strcat(stockage,"/");
  
  /* Pour la famille 0 */
  if (num == nfammai) 
    return 0;

  if (num > nfammai) {
    /* C'est une famille de noeuds */
    strcpy(stockage,chemin);
    strcat(stockage,MED_FAS_NOEUD_NOM);
    strcat(stockage,"/");
    num = num - nfammai - 1;
  }
      
  /* 
   * Si le Data Group de la famille n'existe pas => erreur
   */
  if ((ret = _MEDobjetIdentifier(fid,stockage,num,
				 famille)) < 0)
    return -1;
  strcat(stockage,famille);
  
  if ((famid = _MEDdatagroupOuvrir(fid,stockage)) < 0)
    return -1;
  
  if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_GRO)) < 0)
    n = 0;
  else
    {
      if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,&n)) < 0)
	return -1;
      if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
	return -1;
    }

  if ((ret = _MEDdatagroupFermer(famid)) < 0)
    return -1;

  return (med_int) n;
}
void MAJ_21_22_maillages(med_idt fid)
{
  med_idt gid;
  med_err ret;
  int n,i;
  char nom[MED_TAILLE_NOM+1];
  char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
  char description[MED_TAILLE_DESC+1] = "Maillage converti au format MED V2.2";
  med_int type = (med_int) MED_NON_STRUCTURE;
  med_int dimension;
  
  /* Lecture du nombre de maillages */
  n = 0;
  _MEDnObjets(fid,(char *) MED_MAA,&n);
  EXIT_IF(n < 0,"Erreur a la lecture du nombre de maillage",NULL);

  /* 
   * Mise a jour des maillages :
   *  - type : MED_NON_STRUCTURE
   *  - description : "Maillage converti au format V2.2"
   */
  for (i=0;i<n;i++) {
    /* on recupere le nom du maillage */
    ret = _MEDobjetIdentifier(fid,(char *) MED_MAA,i,nom);
    EXIT_IF(ret < 0,"Identification d'un maillage",NULL);
    fprintf(stdout,"  >>> Normalisation du maillage [%s] \n",nom);

    /* on accede au maillage */
    strcpy(chemin,MED_MAA);
    strcat(chemin,nom);
    gid = _MEDdatagroupOuvrir(fid,chemin); 
    EXIT_IF(gid < 0,"Accès au maillage",nom);

    /* lecture de la dimension du maillage */
    ret = _MEDattrEntierLire(gid,(char *)(MED_NOM_DIM),&dimension);
    EXIT_IF(ret < 0,"Lecture de la dimension du maillage",nom);

    /* Ecriture du type et de la description */
    ret = _MEDattrStringEcrire(gid,(char *)(MED_NOM_DES),MED_TAILLE_DESC,description);
    EXIT_IF(ret < 0,"Ecriture de la description du maillage ",nom);
    ret = _MEDattrEntierEcrire(gid,(char *)(MED_NOM_TYP),&type);
    EXIT_IF(ret < 0,"Ecriture de la dimension du maillage ",nom);
    
    /* Mise a jour des noeuds du maillage */ 
    MAJ_21_22_noeuds_maillage(gid,dimension);  
    fprintf(stdout,"  ... Normalisation des noeuds effectuée ... \n");
    
    /* Mise a jour des éléments du maillage */ 
    MAJ_21_22_elements_maillage(gid,dimension);  
    fprintf(stdout,"  ... Normalisation des éléments effectuée ... \n");
    
    /* Mise a jour des familles du maillage */
    MAJ_21_22_familles_maillage(gid);
    fprintf(stdout,"  ... Normalisation des familles effectuée ... \n");
    
    /* On ferme tout */
    ret = _MEDdatagroupFermer(gid);
    EXIT_IF(ret < 0,"Fermeture de l'accès au maillage",NULL);

    fprintf(stdout,"  >>> Normalisation du maillage [%s] ... OK ... \n",nom);
  }
}
Beispiel #11
0
med_err 
MEDchampRefInfo(med_idt fid,char *champ,
		med_entite_maillage type_ent, med_geometrie_element type_geo,
		int indice, med_int numdt, med_int numo,
		char * maa, med_booleen * local, med_int *ngauss)
{

  med_err ret=-1;
  int num;
  med_idt datagroup3=0,gid_maa=0,gid_lien=0;
  char chemin[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";
  char chemin_maa[MED_TAILLE_MAA+MED_TAILLE_NOM+1]="";
  char chemin_lien[MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=""; 
  char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2]="";
  char nomdatagroup2[2*MED_MAX_PARA+1]="";
  char tmp1         [MED_TAILLE_NOM_ENTITE+1]="";

  /*
   * On inhibe le gestionnaire d'erreur HDF 5
   */
  _MEDmodeErreurVerrouiller();
if (MEDcheckVersion(fid) < 0) return -1;


  /*
   * On construit le nom du datagroup
   */
  strcpy(chemin,MED_CHA);
  strcat(chemin,champ);
  strcat(chemin,"/");

  /* 
   * Si le Data Group  de niveau 1 <type_ent>[.<type_geo>] n'existe pas => erreur
   */
  /* modif pour la version 2.3.3 */
  
  if (_MEDnomEntite(nomdatagroup1,type_ent) < 0)
    goto ERROR;
  if ((type_ent != MED_NOEUD)) {
    if (_MEDnomGeometrie30(tmp1,type_geo) < 0)
      goto ERROR;
    strcat(nomdatagroup1,".");
    strcat(nomdatagroup1,tmp1);
  }
  strcat(chemin,nomdatagroup1);
  strcat(chemin,"/");

  /*
   * Si le Data Group de niveau 2 <numdtt>.<numoo> n'existe pas => erreur
   */
  sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
  
  strcat(chemin,nomdatagroup2);
  strcat(chemin,"/");


  /*
   * Cherche le datagroup de niveau 3 <maa> correspondant à l'indice <num>
   */
  num = indice - 1;
  if (_MEDobjetIdentifier(fid,chemin,num,maa) < 0) {
    MESSAGE("Impossible de trouver un groupe à l'indice spécifié : ");
    SSCRUTE(chemin); ISCRUTE_int(num); goto ERROR;
  };
  strcat(chemin,maa);
 

  /*
   * Si le Data Group de niveau 3 <maa> n'existe pas => erreur
   */
 
  if ((datagroup3 = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
    MESSAGE("Erreur d'ouverture du datagroup lien au maillage : ");
    SSCRUTE(chemin); goto ERROR;
  };


  /* Lire le nbre des points de GAUSS*/
  if (_MEDattrEntierLire(datagroup3,MED_NOM_NGA,ngauss) < 0) {
    MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NGA : ");
    ISCRUTE(*ngauss);goto ERROR;
  };


  /* Maillage local ou distant */
  strcpy(chemin_maa,MED_MAA);
  strcat(chemin_maa,maa);
  /* Le maillage est il distant */
  if ( (gid_maa = _MEDdatagroupOuvrir(fid,chemin_maa)) < 0)  {
    
    /* Verifie que le maillage est bien référencé comme distant */  
    strcpy(chemin_lien,MED_LIENS);
    strcat(chemin_lien,maa); 
    if ((gid_lien = _MEDdatagroupOuvrir(fid,chemin_lien)) < 0) {
/*       MESSAGE("Le maillage n'est ni local, ni distant : "); */
/*        SSCRUTE(chemin_maa);SSCRUTE(chemin_lien); goto ERROR; */
      *local = MED_FAUX;
    }
  
    *local = MED_FAUX;
    
  } else  
    *local = MED_VRAI;
    
  
  /*
   * On ferme tout 
   */

  ret = 0;

 ERROR:
  
  if (datagroup3>0)     if (_MEDdatagroupFermer(datagroup3) < 0) {
      MESSAGE("Impossible de fermer le datagroup : ");
      ISCRUTE_int(datagroup3); ret = -1; 
  }
  
  if (gid_maa>0)  if (_MEDdatagroupFermer(gid_maa) < 0) {
      MESSAGE("Impossible de fermer le datagroup : ");
      ISCRUTE_id(gid_maa); ret = -1; 
  }
  
  if (gid_lien>0) if (_MEDdatagroupFermer(gid_lien) < 0) {
      MESSAGE("Impossible de fermer le datagroup : ");
      SSCRUTE(chemin_lien); ret = -1; 
  }

  return ret; 
}