[med-fichier] 02/03: Fix FTBFS with clang. (Closes: #751174)

Anton Gladky gladk at moszumanska.debian.org
Thu Sep 11 19:52:06 UTC 2014


This is an automated email from the git hooks/post-receive script.

gladk pushed a commit to branch master
in repository med-fichier.

commit ff1dec0c47dae9dd3c541d235c98ad6cdccead72
Author: Arthur Marble <arthur at info9.net>
Date:   Thu Sep 11 21:39:26 2014 +0200

    Fix FTBFS with clang. (Closes: #751174)
---
 debian/patches/clang-ftbfs.diff | 652 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 652 insertions(+)

diff --git a/debian/patches/clang-ftbfs.diff b/debian/patches/clang-ftbfs.diff
new file mode 100644
index 0000000..27bfe15
--- /dev/null
+++ b/debian/patches/clang-ftbfs.diff
@@ -0,0 +1,652 @@
+Description:  Fix FTBFS with clang:
+  - Fixed "function declaration not allowed" in
+    tests/parallel/filterBlockOfentities.c
+    tests/parallel/generateDatas.c
+Author: Arthur Marble <arthur at info9.net>
+Reviewed-by: Anton Gladky <gladk at debian.org> 
+Last-Update: 2014-09-11
+
+--- a/tests/parallel/filterBlockOfentities.c
++++ b/tests/parallel/filterBlockOfentities.c
+@@ -77,324 +77,323 @@
+ /* #define USER_MODE MED_COMPACT */
+ 
+ 
+-int main (int argc, char **argv)
+-
+-
+-{
+-  med_err _ret=0;
+-  med_idt _fid;
++med_err generateFieldFile( const med_size nentities, const med_size nvaluesperentity, const med_size nconstituentpervalue,
++			   const med_switch_mode constituentmode,GetBlocksOfEntitiesType getBlockOfEntities, const med_int nbblocksperproc,
++			   GenerateDataType generateDatas,
++			   const med_storage_mode storagemode, const med_size profilearraysize,  const char * const fieldnameprefix,
++			   int mpi_size, med_idt _fid, MPI_Comm comm, int mpi_rank, med_int *_filterarray,
++                           med_int    _nentitiesfiltered, MPI_Info info) {
++
++/*   static int   _fileno=0; */
++  med_err      _ret=-1;
++  char         _filename   [255]="";
++  char         _meshname[MED_NAME_SIZE+1]="Empty mesh";
++  med_int      _meshdim=3;
++  char         _meshcomponentname[3*MED_SNAME_SIZE+1] = "x               y               z               ";
++  char         _meshcomponentunit[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
++  char         _fieldname  [MED_NAME_SIZE+1]="";
++  char         *componentname,*componentunit;
++  char         _profilename[MED_NAME_SIZE+1]=MED_NO_PROFILE;
++  med_int       *_profilearray=0;
++  int          _i=0,_j=0,_k=0, _lastusedrank=0;
++  med_size     _blocksize=0,_lastblocksize=0,_count=0,_stride=0,_start=0,_index=0;
++  med_float    *_arrayvalues;
++  med_filter   filter = MED_FILTER_INIT;
++  med_size     _nusedentities        = nentities;
++  med_size     _io_count                = nbblocksperproc;
++  med_idt      _fidseq;
++
++  /*TODO : EXTERNALISER CES DEFINITIONS ET GENERALISER LE PRINCIPE */
++  char         *_MED_MODE_SWITCH_MSG[3]={"MED_FULL_INTERLACE", "MED_NO_INTERLACE","MED_UNDEF_INTERLACE",};
++  char         *_MED_STORAGE_MODE_MSG[3]={"MED_NO_PFLMODE","MED_GLOBAL_PFLMODE", "MED_COMPACT_PFLMODE"};
++
++  med_geometry_type     _geotype       = MED_TRIA6;
++  med_int               _geodim        = _geotype/100;
++  med_int               _geonnodes  = _geotype%100;
++  char       _ipointname[MED_NAME_SIZE+1];
++  med_float* _ipointrefcoo = 0;
++  med_int    _ipoint       = nvaluesperentity;
++  med_float* _ipointcoo    = 0;
++  med_float* _ipointwg     = 0;
++
++  sprintf(_filename,"%s_CPU-%03d_ at _%s_%s.med",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
++/*   SSCRUTE(_filename); */
++  /* Ouverture du fichier en mode parallel */
++  if ((_fid = MEDparFileOpen(_filename, MODE_ACCES ,comm, info)) < 0){
++    MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
++    goto ERROR;
++  }
+ 
+-  int mpi_size, mpi_rank;
+-  MPI_Comm comm = MPI_COMM_WORLD;
+-  MPI_Info info = MPI_INFO_NULL;
++/*   SSCRUTE(_meshname); */
++  if (MEDmeshCr( _fid,_meshname,_meshdim,_meshdim, MED_UNSTRUCTURED_MESH,
++		 "Un maillage pour le test parallel","s", MED_SORT_DTIT,
++		 MED_CARTESIAN, _meshcomponentname, _meshcomponentunit) < 0) {
++    MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MESH,_meshname);
++    goto ERROR;
++  };
+ 
+-  med_int    _nentitiesfiltered=0;
+-  med_int    *_filterarray=NULL;
++  componentname = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
++  componentunit = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
++  /*TODO : Compléter le nom */
++  strcpy(componentname,"");
++  strcpy(componentunit,"");
++  strcpy(_fieldname,fieldnameprefix);
++  if ( MEDfieldCr(_fid,_fieldname,MED_FLOAT64,nconstituentpervalue,componentname,componentunit,"s",_meshname ) < 0) {
++    MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FIELD,_fieldname);
++    goto ERROR;
++  };
++  free(componentname);
++  free(componentunit);
++
++
++  if ( _ipoint > 1 ) {
++
++    MESSAGE("Creating a localization of integration points...");
++    strcpy(_ipointname,_fieldname);
++    strcat(_ipointname,"_loc");
++
++    /*Attention ancienne spec*/
++    _ipointrefcoo = (med_float *) calloc(_geodim*_geonnodes,sizeof(med_float));
++    _ipointcoo    = (med_float *) calloc(_ipoint*_geodim,sizeof(med_float));
++    _ipointwg     = (med_float *) calloc(_ipoint,sizeof(med_float));
++
++    if (MEDlocalizationWr(_fid, _ipointname, _geotype, _geotype/100, _ipointrefcoo, constituentmode,
++			  _ipoint, _ipointcoo, _ipointwg, MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT ) < 0) {
++      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_LOCALIZATION,_ipointname);
++      ISCRUTE_int(constituentmode);
++      goto ERROR;
++    }
++    free(_ipointrefcoo );
++    free(_ipointcoo    );
++    free(_ipointwg     );
+ 
++  } else {
++    strcpy(_ipointname,MED_NO_LOCALIZATION);
++  }
+ 
+-  MPI_Init(&argc, &argv);
+-  MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+-  MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
++  if (profilearraysize) {
++    MESSAGE("Creating a profile...");
+ 
++    strcpy(_profilename,_fieldname);strcat(_profilename,"_profile");
+ 
+-  med_err generateFieldFile( const med_size nentities, const med_size nvaluesperentity, const med_size nconstituentpervalue,
+-			     const med_switch_mode constituentmode,GetBlocksOfEntitiesType getBlockOfEntities, const med_int nbblocksperproc,
+-			     GenerateDataType generateDatas,
+-			     const med_storage_mode storagemode, const med_size profilearraysize,  const char * const fieldnameprefix ) {
+-
+-/*     static int   _fileno=0; */
+-    med_err      _ret=-1;
+-    char         _filename   [255]="";
+-    char         _meshname[MED_NAME_SIZE+1]="Empty mesh";
+-    med_int      _meshdim=3;
+-    char         _meshcomponentname[3*MED_SNAME_SIZE+1] = "x               y               z               ";
+-    char         _meshcomponentunit[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
+-    char         _fieldname  [MED_NAME_SIZE+1]="";
+-    char         *componentname,*componentunit;
+-    char         _profilename[MED_NAME_SIZE+1]=MED_NO_PROFILE;
+-    med_int       *_profilearray=0;
+-    int          _i=0,_j=0,_k=0, _lastusedrank=0;
+-    med_size     _blocksize=0,_lastblocksize=0,_count=0,_stride=0,_start=0,_index=0;
+-    med_float    *_arrayvalues;
+-    med_filter   filter = MED_FILTER_INIT;
+-    med_size     _nusedentities        = nentities;
+-    med_size     _io_count                = nbblocksperproc;
+-    med_idt      _fidseq;
+-
+-    /*TODO : EXTERNALISER CES DEFINITIONS ET GENERALISER LE PRINCIPE */
+-    char         *_MED_MODE_SWITCH_MSG[3]={"MED_FULL_INTERLACE", "MED_NO_INTERLACE","MED_UNDEF_INTERLACE",};
+-    char         *_MED_STORAGE_MODE_MSG[3]={"MED_NO_PFLMODE","MED_GLOBAL_PFLMODE", "MED_COMPACT_PFLMODE"};
+-
+-    med_geometry_type     _geotype       = MED_TRIA6;
+-    med_int               _geodim        = _geotype/100;
+-    med_int               _geonnodes  = _geotype%100;
+-    char       _ipointname[MED_NAME_SIZE+1];
+-    med_float* _ipointrefcoo = 0;
+-    med_int    _ipoint       = nvaluesperentity;
+-    med_float* _ipointcoo    = 0;
+-    med_float* _ipointwg     = 0;
+-
+-    sprintf(_filename,"%s_CPU-%03d_ at _%s_%s.med",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
+-/*     SSCRUTE(_filename); */
+-    /* Ouverture du fichier en mode parallel */
+-    if ((_fid = MEDparFileOpen(_filename, MODE_ACCES ,comm, info)) < 0){
+-      MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
+-      goto ERROR;
+-    }
++    _profilearray = (med_int*) calloc(profilearraysize,sizeof(med_int));
+ 
+-/*     SSCRUTE(_meshname); */
+-    if (MEDmeshCr( _fid,_meshname,_meshdim,_meshdim, MED_UNSTRUCTURED_MESH,
+-		   "Un maillage pour le test parallel","s", MED_SORT_DTIT,
+-		   MED_CARTESIAN, _meshcomponentname, _meshcomponentunit) < 0) {
+-      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MESH,_meshname);
++    for (_i=0; _i < profilearraysize; ++_i) _profilearray[_i]=_i;
++    if ( MEDprofileWr(_fid,_profilename,profilearraysize,_profilearray) < 0) {
++      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_PROFILE,_profilename);
+       goto ERROR;
+     };
++    _nusedentities = profilearraysize;
++  } else {
++    strcpy(_profilename,MED_NO_PROFILE);
++  }
++
+ 
+-    componentname = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
+-    componentunit = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
+-    /*TODO : Compléter le nom */
+-    strcpy(componentname,"");
+-    strcpy(componentunit,"");
+-    strcpy(_fieldname,fieldnameprefix);
+-    if ( MEDfieldCr(_fid,_fieldname,MED_FLOAT64,nconstituentpervalue,componentname,componentunit,"s",_meshname ) < 0) {
+-      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FIELD,_fieldname);
++  MESSAGE("Generating partition...");
++  getBlockOfEntities ( mpi_rank , mpi_size, _nusedentities,
++		       &_start, &_stride, &_io_count, &_blocksize,
++		       &_lastusedrank, &_lastblocksize);
++
++  _count=_io_count;
++  MESSAGE("Generating filter...");
++  if ( MEDfilterBlockOfEntityCr(_fid, nentities, nvaluesperentity, nconstituentpervalue,
++				MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
++				_start,_stride,_count,_blocksize,_lastblocksize,  &filter) < 0 ) {
++      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
+       goto ERROR;
+-    };
+-    free(componentname);
+-    free(componentunit);
++  }
+ 
++  MESSAGE("Generating datas...");
++  generateDatas(mpi_rank, _lastusedrank, sizeof(med_float),
++		storagemode, profilearraysize, _profilearray,
++		_start, _stride, _count, _blocksize, _lastblocksize,
++		nentities, nvaluesperentity, nconstituentpervalue,
++		&_arrayvalues );
++
++  MESSAGE("Writing field...");
++  if ( MEDfieldValueAdvancedWr(_fid,_fieldname,MED_NO_DT,MED_NO_IT,0.0, MED_CELL, _geotype,
++			       _ipointname, &filter, (unsigned char*)_arrayvalues ) < 0) {
++    MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldname);
++    ISCRUTE(mpi_rank);
++    goto ERROR;
++  }
+ 
+-    if ( _ipoint > 1 ) {
++  /* Test de lecture du même fichier avec filtre simple par un seul processeur */
++  /* TODO : Créer MEDflush */
++  H5Fflush(_fid, H5F_SCOPE_GLOBAL );
+ 
+-      MESSAGE("Creating a localization of integration points...");
+-      strcpy(_ipointname,_fieldname);
+-      strcat(_ipointname,"_loc");
++  /*Le flush suffit pas besoin de synchroniser les processus : MPI_Barrier(MPI_COMM_WORLD); */
++  if (mpi_rank == 0 ) {
++    MESSAGE("Reading field...");
+ 
+-      /*Attention ancienne spec*/
+-      _ipointrefcoo = (med_float *) calloc(_geodim*_geonnodes,sizeof(med_float));
+-      _ipointcoo    = (med_float *) calloc(_ipoint*_geodim,sizeof(med_float));
+-      _ipointwg     = (med_float *) calloc(_ipoint,sizeof(med_float));
+ 
+-      if (MEDlocalizationWr(_fid, _ipointname, _geotype, _geotype/100, _ipointrefcoo, constituentmode,
+-			    _ipoint, _ipointcoo, _ipointwg, MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT ) < 0) {
+-	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_LOCALIZATION,_ipointname);
+-	ISCRUTE_int(constituentmode);
+-	goto ERROR;
+-      }
+-      free(_ipointrefcoo );
+-      free(_ipointcoo    );
+-      free(_ipointwg     );
++    med_int    _nentitiesarrayvalues=0;
++    med_float  *_filteredarrayvalues=NULL;
++    med_filter filter2=MED_FILTER_INIT;
++    int        _ind=0;
++    FILE *     _asciifile;
++    char       _asciifilename[255]="";
+ 
+-    } else {
+-      strcpy(_ipointname,MED_NO_LOCALIZATION);
++
++    if ((_fidseq = MEDfileOpen(_filename, MED_ACC_RDONLY )) < 0){
++      MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
++      goto ERROR;
+     }
+ 
+-    if (profilearraysize) {
+-      MESSAGE("Creating a profile...");
++    sprintf(_asciifilename,"%s_CPU-%03d_ at _%s_%s.ascii",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
++    _asciifile=fopen(_asciifilename, "w");
+ 
+-      strcpy(_profilename,_fieldname);strcat(_profilename,"_profile");
++    /*Génère un filtre de selection simple s'il n'a pas déjà été généré lors d'un précédent appel */
++    /*TODO : Déplacer cette appel dans le main après avoir externaliser la génération du profile */
++    if (!_filterarray)
++      if ( generateFilterArray(  nentities,  nvaluesperentity, nconstituentpervalue,
++				 profilearraysize, _profilearray,
++				 &_nentitiesfiltered, &_filterarray ) < 0 ) {
++	goto ERROR;
++      }
+ 
+-      _profilearray = (med_int*) calloc(profilearraysize,sizeof(med_int));
++    ISCRUTE(_nentitiesfiltered);
++    /*Stocke le filtre utilisé dans le fichier .ascii*/
++    for (_i=0; _i < _nentitiesfiltered; ++_i ) {
++/*    ISCRUTE(_filterarray[_i]); */
++      fprintf(_asciifile,"%d ",_filterarray[_i]) ;
++    }
++    fprintf(_asciifile,"\n") ;
+ 
+-      for (_i=0; _i < profilearraysize; ++_i) _profilearray[_i]=_i;
+-      if ( MEDprofileWr(_fid,_profilename,profilearraysize,_profilearray) < 0) {
+-	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_PROFILE,_profilename);
+-	goto ERROR;
+-      };
+-      _nusedentities = profilearraysize;
++
++    /*Pas de profile possible (profilearraysize == 0) en MED_GLOBAL_PFLMODE sur un fichier géré en parallel */
++    if ( profilearraysize ) {
++      _nentitiesarrayvalues = profilearraysize;
+     } else {
+-      strcpy(_profilename,MED_NO_PROFILE);
++      _nentitiesarrayvalues = nentities;
+     }
+ 
+-
+-    MESSAGE("Generating partition...");
+-    getBlockOfEntities ( mpi_rank , mpi_size, _nusedentities,
+-			 &_start, &_stride, &_io_count, &_blocksize,
+-			 &_lastusedrank, &_lastblocksize);
+-
+-    _count=_io_count;
+-    MESSAGE("Generating filter...");
+-    if ( MEDfilterBlockOfEntityCr(_fid, nentities, nvaluesperentity, nconstituentpervalue,
+-				  MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
+-				  _start,_stride,_count,_blocksize,_lastblocksize,  &filter) < 0 ) {
+-	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
+-	goto ERROR;
++    /*Attention allocation mémoire potentiellement grosse car réalisée uniquement par le processus 0
++      qui rassemble les données.*/
++    _filteredarrayvalues = (med_float*) malloc(_nentitiesarrayvalues*
++					       nvaluesperentity*
++					       nconstituentpervalue*sizeof(med_float));
++
++    /* Permet de vérifier une erreur d'indiçage après la lecture */
++    for (_i=0;_i<_nentitiesarrayvalues*nvaluesperentity*nconstituentpervalue; ++_i)
++      _filteredarrayvalues[_i]=-_i;
++
++
++    /*Création d'un filtre de sélection simple, pour une lecture séquentielle par le processys 0*/
++    if ( MEDfilterEntityCr(_fidseq, nentities, nvaluesperentity, nconstituentpervalue,
++			   MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
++			   _nentitiesfiltered,_filterarray, &filter2) < 0 ) {
++      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
++      goto ERROR;
+     }
+ 
+-    MESSAGE("Generating datas...");
+-    generateDatas(mpi_rank, _lastusedrank, sizeof(med_float),
+-		  storagemode, profilearraysize, _profilearray,
+-		  _start, _stride, _count, _blocksize, _lastblocksize,
+-		  nentities, nvaluesperentity, nconstituentpervalue,
+-		  &_arrayvalues );
+-
+-    MESSAGE("Writing field...");
+-    if ( MEDfieldValueAdvancedWr(_fid,_fieldname,MED_NO_DT,MED_NO_IT,0.0, MED_CELL, _geotype,
+-				 _ipointname, &filter, (unsigned char*)_arrayvalues ) < 0) {
+-      MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldname);
++    if ( MEDfieldValueAdvancedRd(_fidseq,_fieldname,MED_NO_DT,MED_NO_IT, MED_CELL, _geotype,
++				 &filter2, (unsigned char*)_filteredarrayvalues ) < 0) {
++      MED_ERR_(_ret,MED_ERR_READ,MED_ERR_FIELD,_fieldname);
+       ISCRUTE(mpi_rank);
+       goto ERROR;
+     }
+ 
+-    /* Test de lecture du même fichier avec filtre simple par un seul processeur */
+-    /* TODO : Créer MEDflush */
+-    H5Fflush(_fid, H5F_SCOPE_GLOBAL );
+-
+-    /*Le flush suffit pas besoin de synchroniser les processus : MPI_Barrier(MPI_COMM_WORLD); */
+-    if (mpi_rank == 0 ) {
+-      MESSAGE("Reading field...");
+-
+-
+-      med_int    _nentitiesarrayvalues=0;
+-      med_float  *_filteredarrayvalues=NULL;
+-      med_filter filter2=MED_FILTER_INIT;
+-      int        _ind=0;
+-      FILE *     _asciifile;
+-      char       _asciifilename[255]="";
+-
+-
+-      if ((_fidseq = MEDfileOpen(_filename, MED_ACC_RDONLY )) < 0){
+-	MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
+-	goto ERROR;
++    /*AFFICHAGE TOUJOURS EN FULL INTERLACE QUELQUES SOIENT LES COMBINAISONS*/
++    /*TODO : Externaliser l'affichage*/
++    if ( storagemode == MED_GLOBAL_PFLMODE ) {
++      switch (constituentmode) {
++      case MED_FULL_INTERLACE:
++        for (_i=0; _i < _nentitiesfiltered; ++_i)
++          for (_j=0; _j < nvaluesperentity; ++_j)
++            for (_k=0; _k < nconstituentpervalue; ++_k) {
++	     _ind = (_filterarray[_i]-1)*nvaluesperentity*nconstituentpervalue+ _j*nconstituentpervalue+_k;
++/* 	      fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLGLB[",_ind,"]",_filteredarrayvalues[_ind]) ; */
++	      fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
++	    }
++	break;
++      case MED_NO_INTERLACE:
++        for (_j=0; _j < _nentitiesfiltered; ++_j)
++	  for (_k=0; _k < nvaluesperentity; ++_k)
++	    for (_i=0; _i < nconstituentpervalue; ++_i) {
++	      _ind =_i*nentities*nvaluesperentity+ (_filterarray[_j]-1)*nvaluesperentity +_k;
++/* 	      fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOGLB[",_ind,"]",_filteredarrayvalues[_ind]); */
++	      fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
++	    }
++	break;
+       }
+-
+-      sprintf(_asciifilename,"%s_CPU-%03d_ at _%s_%s.ascii",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
+-      _asciifile=fopen(_asciifilename, "w");
+-
+-      /*Génère un filtre de selection simple s'il n'a pas déjà été généré lors d'un précédent appel */
+-      /*TODO : Déplacer cette appel dans le main après avoir externaliser la génération du profile */
+-      if (!_filterarray)
+-	if ( generateFilterArray(  nentities,  nvaluesperentity, nconstituentpervalue,
+-				   profilearraysize, _profilearray,
+-				   &_nentitiesfiltered, &_filterarray ) < 0 ) {
+-	  goto ERROR;
++    }  else
++      switch (constituentmode) {
++      case MED_FULL_INTERLACE:
++        for (_i=0; _i < _nentitiesfiltered; ++_i )
++          for (_j=0; _j < nvaluesperentity; ++_j)
++            for (_k=0; _k < nconstituentpervalue; ++_k) {
++	      _ind = (_filterarray[_i]-1)*nvaluesperentity*nconstituentpervalue+_j*nconstituentpervalue+_k;
++/* 	      fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLCP[",_ind,"]",_filteredarrayvalues[_ind]) ; */
++	      fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
+ 	}
+-
+-      ISCRUTE(_nentitiesfiltered);
+-      /*Stocke le filtre utilisé dans le fichier .ascii*/
+-      for (_i=0; _i < _nentitiesfiltered; ++_i ) {
+-/* 	ISCRUTE(_filterarray[_i]); */
+-	fprintf(_asciifile,"%d ",_filterarray[_i]) ;
++	break;
++      case MED_NO_INTERLACE:
++	for (_j=0; _j < _nentitiesfiltered; ++_j)
++	  for (_k=0; _k < nvaluesperentity; ++_k)
++	    for (_i=0; _i < nconstituentpervalue; ++_i) {
++	      _ind =_i*_nentitiesarrayvalues*nvaluesperentity+ (_filterarray[_j]-1)*nvaluesperentity +_k;
++/* 	      fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOCP[",_ind,"]",_filteredarrayvalues[_ind]); */
++	      fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
++	    }
++	break;
+       }
+-      fprintf(_asciifile,"\n") ;
+ 
+ 
+-      /*Pas de profile possible (profilearraysize == 0) en MED_GLOBAL_PFLMODE sur un fichier géré en parallel */
+-      if ( profilearraysize ) {
+-	_nentitiesarrayvalues = profilearraysize;
+-      } else {
+-	_nentitiesarrayvalues = nentities;
+-      }
++    free(_filteredarrayvalues);
+ 
+-      /*Attention allocation mémoire potentiellement grosse car réalisée uniquement par le processus 0
+-       qui rassemble les données.*/
+-      _filteredarrayvalues = (med_float*) malloc(_nentitiesarrayvalues*
+-						 nvaluesperentity*
+-						 nconstituentpervalue*sizeof(med_float));
+-
+-      /* Permet de vérifier une erreur d'indiçage après la lecture */
+-      for (_i=0;_i<_nentitiesarrayvalues*nvaluesperentity*nconstituentpervalue; ++_i)
+-	_filteredarrayvalues[_i]=-_i;
+-
+-
+-      /*Création d'un filtre de sélection simple, pour une lecture séquentielle par le processys 0*/
+-      if ( MEDfilterEntityCr(_fidseq, nentities, nvaluesperentity, nconstituentpervalue,
+-			     MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
+-			     _nentitiesfiltered,_filterarray, &filter2) < 0 ) {
+-	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
+-	goto ERROR;
+-      }
+-
+-      if ( MEDfieldValueAdvancedRd(_fidseq,_fieldname,MED_NO_DT,MED_NO_IT, MED_CELL, _geotype,
+-				   &filter2, (unsigned char*)_filteredarrayvalues ) < 0) {
+-	MED_ERR_(_ret,MED_ERR_READ,MED_ERR_FIELD,_fieldname);
+-	ISCRUTE(mpi_rank);
+-	goto ERROR;
+-      }
++    fclose(_asciifile);
+ 
+-      /*AFFICHAGE TOUJOURS EN FULL INTERLACE QUELQUES SOIENT LES COMBINAISONS*/
+-      /*TODO : Externaliser l'affichage*/
+-      if ( storagemode == MED_GLOBAL_PFLMODE ) {
+-	switch (constituentmode) {
+-	case MED_FULL_INTERLACE:
+-	  for (_i=0; _i < _nentitiesfiltered; ++_i)
+-	    for (_j=0; _j < nvaluesperentity; ++_j)
+-	      for (_k=0; _k < nconstituentpervalue; ++_k) {
+-		_ind = (_filterarray[_i]-1)*nvaluesperentity*nconstituentpervalue+ _j*nconstituentpervalue+_k;
+-/* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLGLB[",_ind,"]",_filteredarrayvalues[_ind]) ; */
+-		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
+-	      }
+-	  break;
+-	case MED_NO_INTERLACE:
+-	  for (_j=0; _j < _nentitiesfiltered; ++_j)
+-	    for (_k=0; _k < nvaluesperentity; ++_k)
+-	      for (_i=0; _i < nconstituentpervalue; ++_i) {
+-		_ind =_i*nentities*nvaluesperentity+ (_filterarray[_j]-1)*nvaluesperentity +_k;
+-/* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOGLB[",_ind,"]",_filteredarrayvalues[_ind]); */
+-		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
+-	      }
+-	  break;
+-	}
+-      }  else
+-	switch (constituentmode) {
+-	case MED_FULL_INTERLACE:
+-	  for (_i=0; _i < _nentitiesfiltered; ++_i )
+-	    for (_j=0; _j < nvaluesperentity; ++_j)
+-	      for (_k=0; _k < nconstituentpervalue; ++_k) {
+-		_ind = (_filterarray[_i]-1)*nvaluesperentity*nconstituentpervalue+_j*nconstituentpervalue+_k;
+-/* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLCP[",_ind,"]",_filteredarrayvalues[_ind]) ; */
+-		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
+-	  }
+-	  break;
+-	case MED_NO_INTERLACE:
+-	  for (_j=0; _j < _nentitiesfiltered; ++_j)
+-	    for (_k=0; _k < nvaluesperentity; ++_k)
+-	      for (_i=0; _i < nconstituentpervalue; ++_i) {
+-		_ind =_i*_nentitiesarrayvalues*nvaluesperentity+ (_filterarray[_j]-1)*nvaluesperentity +_k;
+-/* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOCP[",_ind,"]",_filteredarrayvalues[_ind]); */
+-		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
+-	      }
+-	  break;
+-	}
++    if ( MEDfilterClose(&filter2) < 0 ) {
++      MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
++      goto ERROR;
++    }
+ 
++  } /*fin if (mpi_rank == 0) */
+ 
+-      free(_filteredarrayvalues);
++if ( MEDfilterClose(&filter) < 0 ) {
++  MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
++  goto ERROR;
++}
+ 
+-      fclose(_asciifile);
+ 
+-      if ( MEDfilterClose(&filter2) < 0 ) {
+-	MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
+-	goto ERROR;
+-      }
++  _ret=0;
++ERROR:
++  if (_arrayvalues)     free(_arrayvalues);
++  if (profilearraysize) free(_profilearray);
+ 
+-    } /*fin if (mpi_rank == 0) */
++  if (  MEDfileClose(_fid) < 0) {
++    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
++  }
+ 
+-  if ( MEDfilterClose(&filter) < 0 ) {
+-    MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
+-    goto ERROR;
++  if (mpi_rank == 0 ) {
++    if (  MEDfileClose(_fidseq) < 0) {
++      MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
++    }
+   }
+ 
++  return _ret;
++}
+ 
+-    _ret=0;
+-  ERROR:
+-    if (_arrayvalues)     free(_arrayvalues);
+-    if (profilearraysize) free(_profilearray);
+ 
+-    if (  MEDfileClose(_fid) < 0) {
+-      MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
+-    }
++int main (int argc, char **argv)
+ 
+-    if (mpi_rank == 0 ) {
+-      if (  MEDfileClose(_fidseq) < 0) {
+-	MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
+-      }
+-    }
+ 
+-    return _ret;
+-  }
++{
++  med_err _ret=0;
++  med_idt _fid;
+ 
++  int mpi_size, mpi_rank;
++  MPI_Comm comm = MPI_COMM_WORLD;
++  MPI_Info info = MPI_INFO_NULL;
++
++  med_int    _nentitiesfiltered=0;
++  med_int    *_filterarray=NULL;
+ 
+ 
++  MPI_Init(&argc, &argv);
++  MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
++  MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+ 
+   /* MAIN */
+   med_size            _nbblocksperproc    = 0;
+@@ -458,7 +457,8 @@ int main (int argc, char **argv)
+ 
+       if ( generateFieldFile( _nentities,  _nvaluesperentity, _nconstituentpervalue,
+ 			      _switchmode, getCyclicBlocksOfEntities, _nbblocksperproc, generateDatas,
+-			      _storagemode, _profilearraysize,  _fieldnameprefix ) < 0 ) {
++			      _storagemode, _profilearraysize,  _fieldnameprefix, mpi_size, _fid, comm,
++			      mpi_rank, _filterarray, _nentitiesfiltered, info) < 0 ) {
+ 	MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldnameprefix);
+ 	ISCRUTE(mpi_rank);
+ 	goto ERROR;
+--- a/tests/parallel/generateDatas.c
++++ b/tests/parallel/generateDatas.c
+@@ -21,6 +21,13 @@
+ #define MESGERR 1
+ #include "med_utils.h"
+ 
++static inline med_int _identity  (int i)  { return i; }
++
++static const med_int * profilearray_global;
++static inline med_int _withprofilearray(int i) {
++	return (profilearray_global[i]-1);
++}
++
+ /*Les données générées, le sont uniquement aux endroits utilisés */
+ void generateFullIDatas(const int myrank, const int lastrank, const int sizeoftype,
+ 			const med_storage_mode profilemode, const med_size profilesize, const med_int * const profilearray,
+@@ -30,10 +37,12 @@ void generateFullIDatas(const int myrank
+ 
+   med_size _start=start-1,_blockstart = 0,_blocksize=blocksize,_allblocksize=0,_index=0;
+   med_int  (*_profilearrayfunc)(int)=0;
+-  inline med_int _identity  (int i)  { return i; }
+-  inline med_int _withprofilearray(int i) { return (profilearray[i]-1); }
+   int _blocknum=0,_i=0,_j=0,_k=0;
+ 
++  /* inline med_int _identity  (int i)  { return i; } */
++  /* inline med_int _withprofilearray(int i) { return (profilearray[i]-1); } */
++  profilearray_global = profilearray;
++
+   if (profilesize) {
+     if ( profilearray == NULL ) {MESSAGE("Error, profilesize > 0 && profilearray == 0"); }
+     MESSAGE("Using a profile...");
+@@ -102,8 +111,9 @@ void generateNoIDatas(const int myrank,
+ 
+   med_size _start=start-1,_blockstart = 0,_blocksize=blocksize,_allblocksize=0,_index=0,_dim=0;
+   med_int  (*_profilearrayfunc)(int)=0;
+-  inline med_int _identity  (int i)  { return i; }
+-  inline med_int _withprofilearray(int i) { return (profilearray[i]-1); }
++  // inline med_int _identity  (int i)  { return i; }
++  // inline med_int _withprofilearray(int i) { return (profilearray[i]-1); }
++  profilearray_global = profilearray;
+   int _blocknum=0,_i=0,_j=0,_k=0;
+ 
+   if (profilearraysize) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/med-fichier.git



More information about the debian-science-commits mailing list