Ejemplo n.º 1
0
med_int 
nmfdfnpf(med_int *fid, char*fname, med_int *fnamelen,
	 med_int *numdt, med_int *numit, med_int *etype, med_int *gtype,
	 char *dpname, char *dlname)
#endif
{
  med_int _ret;
  char *_fn1;
  char _fs2[MED_NAME_SIZE+1]="";
  char _fs3[MED_NAME_SIZE+1]="";
  med_geometry_type _gtype = (med_geometry_type) *gtype;
  med_entity_type _etype = (med_entity_type) *etype;

  _fn1 = _MED2cstring((char *) fname, (int) *fnamelen);
  if (!_fn1)
    return(-1);

  _ret = (med_int) MEDfieldnProfile((const med_idt) *fid,
				    _fn1,
				    (med_int) *numdt,
				    (med_int) *numit,
				    _etype,
				    _gtype,
				    _fs2,
				    _fs3);

  _MEDc2fString(_fs2,dpname,MED_NAME_SIZE);
  _MEDc2fString(_fs3,dlname,MED_NAME_SIZE);

  _MEDcstringFree(_fn1);

  return(_ret);
}
Ejemplo n.º 2
0
med_err getFieldsOn(med_idt fid, char * nomcha, med_field_type typcha, med_int ncomp,
		    med_entity_type entite, med_switch_mode stockage, med_int ncstp) {

  int j,k,l,m,n,nb_geo=0;
  med_int nbpdtnor=0,pflsize,*pflval,ngauss=0,ngroup,*vale=NULL,nval;
  med_int numdt=0,numo=0,_nprofile;
  med_float *valr=NULL,dt=0.0;
  med_err ret=0;
  char pflname [MED_NAME_SIZE+1]="";
  char locname [MED_NAME_SIZE+1]="";
  char * lien = NULL;
  char dt_unit [MED_SNAME_SIZE+1]="unknown";


  med_geometry_type * type_geo;

  const char * const * AFF;
  const char * const * AFF_ENT=MED_GET_ENTITY_TYPENAME+1;
  switch (entite) {
  case MED_NODE :
    type_geo = MED_GET_NODE_GEOMETRY_TYPE;
    nb_geo   = MED_N_NODE_FIXED_GEO;
    AFF      = MED_GET_NODE_GEOMETRY_TYPENAME;
    break;
  case  MED_CELL :
  case  MED_NODE_ELEMENT :
    type_geo = MED_GET_CELL_GEOMETRY_TYPE;
    nb_geo   = MED_N_CELL_FIXED_GEO;
    AFF      = MED_GET_CELL_GEOMETRY_TYPENAME;
    break;
  case  MED_DESCENDING_FACE :
    type_geo = MED_GET_FACE_GEOMETRY_TYPE;
    nb_geo   = MED_N_FACE_FIXED_GEO;
    AFF      = MED_GET_FACE_GEOMETRY_TYPENAME;
    break;
  case  MED_DESCENDING_EDGE :
    type_geo = MED_GET_EDGE_GEOMETRY_TYPE;
    nb_geo   = MED_N_EDGE_FIXED_GEO;
    AFF      = MED_GET_EDGE_GEOMETRY_TYPENAME;
    break;
  }

  for (k=1;k<=nb_geo;k++) {

    /* Combien de (PDT,NOR) a lire */
    nbpdtnor = ncstp;
    if (nbpdtnor < 1 ) continue;

    for (j=0;j<nbpdtnor;j++) {

      if ( MEDfieldComputingStepInfo(fid,nomcha,j+1, &numdt, &numo, &dt ) <0) {
	MESSAGE("Erreur a la demande d'information sur (pdt,nor) : ");
	ISCRUTE(numdt); ISCRUTE(numo);
	ret = -1; continue;
      }

      if ( (_nprofile = MEDfieldnProfile(fid,nomcha,numdt,numo,entite,type_geo[k],
					    pflname,locname   ) ) < 0 ) {
	MESSAGE("Erreur a la demande du nombre de profils referencés par le champ : ");
	SSCRUTE(nomcha);
	ISCRUTE(numdt); ISCRUTE(numo);
	ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
	SSCRUTE(AFF_ENT[(int)entite]);SSCRUTE(AFF[k]);
	ret = -1; continue;
      };

      for (l=0;l<_nprofile;l++) {


	if ( (nval = MEDfieldnValueWithProfile(fid, nomcha, numdt, numo, entite, type_geo[k],
					       l+1,  USER_MODE, pflname,&pflsize,
					       locname, &ngauss) ) < 0 ) {
	  MESSAGE("Erreur a la lecture du nombre de valeurs du champ : ");
	  SSCRUTE(nomcha);ISCRUTE(numdt);ISCRUTE(numo);
	  ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
	  ISCRUTE_int(USER_MODE);
	  ret = -1; continue;
	};

	printf("\n  +Pas de Temps n."IFORMAT" (%f) [%s], n. d'ordre "IFORMAT", avec "IFORMAT" valeur(s) par entité.\n",numdt,dt,dt_unit,numo,ngauss);
	printf("\t- Il y a "IFORMAT" entités qui portent des valeurs en mode %i. Chaque entite %s\
 de type geometrique %s associes au profile |%s| a "IFORMAT" valeurs associées \n",
	       nval,USER_MODE,AFF_ENT[(int)entite],AFF[k],pflname,ngauss);

	/*Lecture des valeurs du champ */
	if (typcha == MED_FLOAT64) {


	  valr = (med_float*) calloc(ncomp*nval*ngauss,sizeof(med_float));
	  EXIT_IF(valr == NULL,NULL,NULL);

	  if (MEDfieldValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],
					 USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
					 (unsigned char*) valr) < 0 ) {
	    MESSAGE("Erreur a la lecture des valeurs du champ : ");
	    SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
	    ISCRUTE(numdt);ISCRUTE(numo);
	    ret = -1;
	  }

	} else {

	  vale = (med_int*) calloc(ncomp*nval*ngauss,sizeof(med_int));
	  EXIT_IF(vale == NULL,NULL,NULL);

	  if (MEDfieldValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],
					 USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
					 (unsigned char*) vale) < 0 ) {
	    MESSAGE("Erreur a la lecture des valeurs du champ : ");
	    SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
	    ISCRUTE(numdt);ISCRUTE(numo);
	    ret = -1;
	  };


	}

	if ( strlen(locname) )
	  printf("\t- Modèle de localisation des points de Gauss de nom |%s|\n",locname);

	if (entite == MED_NODE_ELEMENT)
	  ngroup = (type_geo[k] % 100);
	else
	  ngroup = ngauss;

	switch (stockage) {

	case MED_FULL_INTERLACE :
	  printf("\t- Valeurs :\n\t");
	  for (m=0;m<(nval*ngauss)/ngroup;m++) {
	    printf("|");
	    for (n=0;n<ngroup*ncomp;n++)
	      if (typcha == MED_FLOAT64)
		printf(" %f ",*(valr+(m*ngroup*ncomp)+n));
	      else
		printf(" "IFORMAT" ",*(vale+(m*ngroup*ncomp)+n));

	  }
	  break;

	  /*Affichage en fonction du profil à traiter*/
	case MED_NO_INTERLACE :
	  printf("\t- Valeurs :\n\t");
	  for (m=0;m<ncomp;m++) {
	    printf("|");
	    for (n=0;n<(nval*ngauss);n++)
	      if (typcha == MED_FLOAT64)
		printf(" %f ",*(valr+(m*nval)+n));
	      else
		printf(" "IFORMAT" ",*(vale+(m*nval)+n));
	  }
	  break;
	}

	printf("|\n");
	if (typcha == MED_FLOAT64) {
	  if ( valr ) {free(valr);valr = NULL;}}
	else
	  if (vale) { free(vale);vale = NULL; }

	/*Lecture du profil associe */
	if (strcmp(pflname,MED_NO_PROFILE) == 0 )
	  printf("\t- Profil : MED_NO_PROFILE\n");
	else {

	  if ( (pflsize = MEDprofileSizeByName(fid,pflname)) <0 )  {
	    MESSAGE("Erreur a la lecture du nombre de valeurs du profil : ");
	    SSCRUTE(pflname);
	    ret = -1; continue;
	  }

	  printf("\t- Profil : |%s| de taille "IFORMAT"\n",pflname,pflsize);

	  pflval = (med_int*) malloc(sizeof(med_int)*pflsize);
	  EXIT_IF(pflval == NULL,NULL,NULL);
	  if ( MEDprofileRd(fid,pflname,pflval) <0) {
	    MESSAGE("Erreur a la lecture des valeurs du profil : ");
	    SSCRUTE(pflname);
	    ret = -1;
	  }
	  printf("\t");
	  for (m=0;m<pflsize;m++) printf(" "IFORMAT" ",*(pflval+m));
	  printf("\n");
	  free(pflval);

	}

      }
    }
  } /* fin for sur les mailles*/

  return ret;
}