1 /*  This file is part of MED.
2  *
3  *  COPYRIGHT (C) 1999 - 2019  EDF R&D, CEA/DEN
4  *  MED is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU Lesser General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  MED is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public License
15  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #define MAX(a,b) ((a) > (b) ? (a) : (b))
19 
20 #include <med.h>
21 #define MESGERR 1
22 #include "med_utils.h"
23 #include "med_config.h"
24 
25 #include <stdlib.h>
26 #include <string.h>
27 #include <assert.h>
28 
29 #if TIME_WITH_SYS_TIME
30 # include <sys/time.h>
31 # include <time.h>
32 #else
33 # if HAVE_SYS_TIME_H
34 #  include <sys/time.h>
35 # else
36 #  include <time.h>
37 # endif
38 #endif
39 
40 #ifndef HAVE_UNISTD_H
41 #error "unistd.h required."
42 #endif
43 
44 #include "getBlocksOfEntitiesPartition.h"
45 #include "generateDatas.h"
46 #include "generateFilterArray.h"
47 
48 
49 #ifdef DEF_LECT_ECR
50 #define MODE_ACCES MED_ACC_RDWR
51 #elif DEF_LECT_AJOUT
52 #define MODE_ACCES MED_ACC_RDEXT
53 #else
54 #define MODE_ACCES MED_ACC_CREAT
55 #endif
56 
57 /*Valeur de l'enum dans med.h.in*/
58 /* #define MED_NO_INTERLACE 2 */
59 /* #define MED_FULL_INTERLACE 1 */
60 
61 
62 /* #ifndef USER_INTERLACE */
63 /* #define USER_INTERLACE MED_FULL_INTERLACE */
64 /* #warning "Defining MED_FULL_INTERLACE mode..." */
65 /* #endif */
66 
67 /* #if USER_INTERLACE == MED_NO_INTERLACE */
68 /* #define generateDatas generateNoIDatas */
69 /* #warning "Using generateNoIDatas..." */
70 /* #elif USER_INTERLACE == MED_FULL_INTERLACE */
71 /* #define generateDatas generateFullIDatas */
72 /* #warning "Using generateFullIDatas..." */
73 /* #else */
74 /* #error "The USER_INTERLACE macro value match neither MED_NO_INTERLACE nor MED_FULL_INTERLACE" */
75 /* #endif */
76 
77 /* #define USER_MODE MED_COMPACT */
78 
79 typedef struct {
80   MPI_Info info;
81   MPI_Comm comm;
82   int      mpi_size;
83   int      mpi_rank;
84   med_int  nentitiesfiltered;
85   med_int *filterarray;
86 } COM_info;
87 
88 
89 
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,COM_info * const cominfo)90 med_err generateFieldFile( const med_size nentities, const med_size nvaluesperentity, const med_size nconstituentpervalue,
91 			   const med_switch_mode constituentmode,GetBlocksOfEntitiesType getBlockOfEntities, const med_int nbblocksperproc,
92 			   GenerateDataType generateDatas,
93 			   const med_storage_mode storagemode, const med_size profilearraysize,  const char * const fieldnameprefix,  COM_info * const cominfo ) {
94 
95 /*     static int   _fileno=0; */
96     med_err      _ret=-1;
97     char         _filename   [255]="";
98     char         _meshname[MED_NAME_SIZE+1]="Empty mesh";
99     med_int      _meshdim=3;
100     char         _meshcomponentname[3*MED_SNAME_SIZE+1] = "x               y               z               ";
101     char         _meshcomponentunit[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
102     char         _fieldname  [MED_NAME_SIZE+1]="";
103     char         *componentname,*componentunit;
104     char         _profilename[MED_NAME_SIZE+1]=MED_NO_PROFILE;
105     med_int       *_profilearray=0;
106     int          _i=0,_j=0,_k=0, _lastusedrank=0;
107     med_size     _blocksize=0,_lastblocksize=0,_count=0,_stride=0,_start=0,_index=0;
108     med_float    *_arrayvalues;
109     med_filter   filter = MED_FILTER_INIT;
110     med_size     _nusedentities        = nentities;
111     med_size     _io_count                = nbblocksperproc;
112     med_idt      _fidseq,_fid;
113 
114     MPI_Info info     = cominfo->info;
115     MPI_Comm comm     = cominfo->comm;
116     int      mpi_size = cominfo->mpi_size;
117     int      mpi_rank = cominfo->mpi_rank;
118 
119     char         *_MED_MODE_SWITCH_MSG[3]={"MED_FULL_INTERLACE", "MED_NO_INTERLACE","MED_UNDEF_INTERLACE",};
120     char         *_MED_STORAGE_MODE_MSG[3]={"MED_NO_STMODE","MED_GLOBAL_STMODE", "MED_COMPACT_STMODE"};
121 
122     med_geometry_type     _geotype       = MED_TRIA6;
123     med_int               _geodim        = _geotype/100;
124     med_int               _geonnodes     = _geotype%100;
125     char       _ipointname[MED_NAME_SIZE+1];
126     med_float* _ipointrefcoo = 0;
127     med_int    _ipoint       = nvaluesperentity;
128     med_float* _ipointcoo    = 0;
129     med_float* _ipointwg     = 0;
130 
131     sprintf(_filename,"%s_CPU-%03d_@_%s_%s.med",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
132 /*     SSCRUTE(_filename); */
133     /* Ouverture du fichier en mode parallel */
134     if ((_fid = MEDparFileOpen(_filename, MODE_ACCES ,comm, info)) < 0){
135       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
136       goto ERROR;
137     }
138 
139 /*     SSCRUTE(_meshname); */
140     if (MEDmeshCr( _fid,_meshname,_meshdim,_meshdim, MED_UNSTRUCTURED_MESH,
141 		   "Un maillage pour le test parallel","s", MED_SORT_DTIT,
142 		   MED_CARTESIAN, _meshcomponentname, _meshcomponentunit) < 0) {
143       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MESH,_meshname);
144       goto ERROR;
145     };
146 
147     componentname = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
148     componentunit = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
149     /*TODO : Compléter le nom */
150     strcpy(componentname,"");
151     strcpy(componentunit,"");
152     strcpy(_fieldname,fieldnameprefix);
153     if ( MEDfieldCr(_fid,_fieldname,MED_FLOAT64,nconstituentpervalue,componentname,componentunit,"s",_meshname ) < 0) {
154       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FIELD,_fieldname);
155       goto ERROR;
156     };
157     free(componentname);
158     free(componentunit);
159 
160 
161     if ( _ipoint > 1 ) {
162 
163       MESSAGE("Creating a localization of integration points...");
164       strcpy(_ipointname,_fieldname);
165       strcat(_ipointname,"_loc");
166 
167       /*Attention ancienne spec*/
168       _ipointrefcoo = (med_float *) calloc(_geodim*_geonnodes,sizeof(med_float));
169       _ipointcoo    = (med_float *) calloc(_ipoint*_geodim,sizeof(med_float));
170       _ipointwg     = (med_float *) calloc(_ipoint,sizeof(med_float));
171 
172       if (MEDlocalizationWr(_fid, _ipointname, _geotype, _geotype/100, _ipointrefcoo, constituentmode,
173 			    _ipoint, _ipointcoo, _ipointwg, MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT ) < 0) {
174 	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_LOCALIZATION,_ipointname);
175 	ISCRUTE_int(constituentmode);
176 	goto ERROR;
177       }
178       free(_ipointrefcoo );
179       free(_ipointcoo    );
180       free(_ipointwg     );
181 
182     } else {
183       strcpy(_ipointname,MED_NO_LOCALIZATION);
184     }
185 
186     if (profilearraysize) {
187       MESSAGE("Creating a profile...");
188 
189       strcpy(_profilename,_fieldname);strcat(_profilename,"_profile");
190 
191       _profilearray = (med_int*) calloc(profilearraysize,sizeof(med_int));
192 
193       for (_i=0; _i < profilearraysize; ++_i) _profilearray[_i]=_i;
194       if ( MEDprofileWr(_fid,_profilename,profilearraysize,_profilearray) < 0) {
195 	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_PROFILE,_profilename);
196 	goto ERROR;
197       };
198       _nusedentities = profilearraysize;
199     } else {
200       strcpy(_profilename,MED_NO_PROFILE);
201     }
202 
203 
204     MESSAGE("Generating partition...");
205     getBlockOfEntities ( mpi_rank , mpi_size, _nusedentities,
206 			 &_start, &_stride, &_io_count, &_blocksize,
207 			 &_lastusedrank, &_lastblocksize);
208 
209     _count=_io_count;
210     MESSAGE("Generating filter...");
211     if ( MEDfilterBlockOfEntityCr(_fid, nentities, nvaluesperentity, nconstituentpervalue,
212 				  MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
213 				  _start,_stride,_count,_blocksize,_lastblocksize,  &filter) < 0 ) {
214 	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
215 	goto ERROR;
216     }
217 
218     MESSAGE("Generating datas...");
219     generateDatas(mpi_rank, _lastusedrank, sizeof(med_float),
220 		  storagemode, profilearraysize, _profilearray,
221 		  _start, _stride, _count, _blocksize, _lastblocksize,
222 		  nentities, nvaluesperentity, nconstituentpervalue,
223 		  &_arrayvalues );
224 
225     MESSAGE("Writing field...");
226     if ( MEDfieldValueAdvancedWr(_fid,_fieldname,MED_NO_DT,MED_NO_IT,0.0, MED_CELL, _geotype,
227 				 _ipointname, &filter, (unsigned char*)_arrayvalues ) < 0) {
228       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldname);
229       ISCRUTE(mpi_rank);
230       goto ERROR;
231     }
232 
233     /* Test de lecture du même fichier avec filtre simple par un seul processeur */
234     /* TODO : Créer MEDflush */
235     H5Fflush(_fid, H5F_SCOPE_GLOBAL );
236 
237     /*Le flush suffit pas besoin de synchroniser les processus : MPI_Barrier(MPI_COMM_WORLD); */
238     if (mpi_rank == 0 ) {
239       MESSAGE("Reading field...");
240 
241 
242       med_int    _nentitiesarrayvalues=0;
243       med_float  *_filteredarrayvalues=NULL;
244       med_filter filter2=MED_FILTER_INIT;
245       int        _ind=0;
246       FILE *     _asciifile;
247       char       _asciifilename[255]="";
248 
249 
250       if ((_fidseq = MEDfileOpen(_filename, MED_ACC_RDONLY )) < 0){
251 	MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
252 	goto ERROR;
253       }
254 
255       sprintf(_asciifilename,"%s_CPU-%03d_@_%s_%s.ascii",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
256       _asciifile=fopen(_asciifilename, "w");
257 
258       /*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 */
259       /*TODO : Déplacer cette appel dans le main après avoir externaliser la génération du profile */
260       if (!(cominfo->filterarray))
261 	if ( generateFilterArray(  nentities,  nvaluesperentity, nconstituentpervalue,
262 				   profilearraysize, _profilearray,
263 				   &(cominfo->nentitiesfiltered), &(cominfo->filterarray) ) < 0 ) {
264 	  goto ERROR;
265 	}
266 
267       ISCRUTE(cominfo->nentitiesfiltered);
268       /*Stocke le filtre utilisé dans le fichier .ascii*/
269       for (_i=0; _i < cominfo->nentitiesfiltered; ++_i ) {
270 /* 	ISCRUTE(cominfo->filterarray[_i]); */
271 	fprintf(_asciifile,"%d ",cominfo->filterarray[_i]) ;
272       }
273       fprintf(_asciifile,"\n") ;
274 
275 
276       /*Pas de profile possible (profilearraysize == 0) en MED_GLOBAL_STMODE sur un fichier géré en parallel */
277       if ( profilearraysize ) {
278 	_nentitiesarrayvalues = profilearraysize;
279       } else {
280 	_nentitiesarrayvalues = nentities;
281       }
282 
283       /*Attention allocation mémoire potentiellement grosse car réalisée uniquement par le processus 0
284        qui rassemble les données.*/
285       /* C'est une taille maxi qui ne prend pas en compte le COMPACT+filter */
286       /* TODO : Ajuster la taille au storage_mode*/
287       _filteredarrayvalues = (med_float*) malloc(_nentitiesarrayvalues*
288 						 nvaluesperentity*
289 						 nconstituentpervalue*sizeof(med_float));
290 
291       /* Permet de vérifier une erreur d'indiçage après la lecture */
292       for (_i=0;_i<_nentitiesarrayvalues*nvaluesperentity*nconstituentpervalue; ++_i)
293 	_filteredarrayvalues[_i]=-_i;
294 
295 
296       /*Création d'un filtre de sélection simple, pour une lecture séquentielle par le processys 0*/
297       if ( MEDfilterEntityCr(_fidseq, nentities, nvaluesperentity, nconstituentpervalue,
298 			     MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
299 			     cominfo->nentitiesfiltered,cominfo->filterarray, &filter2) < 0 ) {
300 	MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
301 	goto ERROR;
302       }
303 
304       if ( MEDfieldValueAdvancedRd(_fidseq,_fieldname,MED_NO_DT,MED_NO_IT, MED_CELL, _geotype,
305 				   &filter2, (unsigned char*)_filteredarrayvalues ) < 0) {
306 	MED_ERR_(_ret,MED_ERR_READ,MED_ERR_FIELD,_fieldname);
307 	ISCRUTE(mpi_rank);
308 	goto ERROR;
309       }
310 
311       /*AFFICHAGE TOUJOURS EN FULL INTERLACE QUELQUES SOIENT LES COMBINAISONS*/
312       /*TODO : Externaliser l'affichage*/
313       if ( storagemode == MED_GLOBAL_STMODE ) {
314 	switch (constituentmode) {
315 	case MED_FULL_INTERLACE:
316 	  for (_i=0; _i < cominfo->nentitiesfiltered; ++_i)
317 	    for (_j=0; _j < nvaluesperentity; ++_j)
318 	      for (_k=0; _k < nconstituentpervalue; ++_k) {
319 		_ind = (cominfo->filterarray[_i]-1)*nvaluesperentity*nconstituentpervalue+ _j*nconstituentpervalue+_k;
320 /* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLGLB[",_ind,"]",_filteredarrayvalues[_ind]) ; */
321 		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
322 	      }
323 	  break;
324 	case MED_NO_INTERLACE:
325 	  for (_j=0; _j < cominfo->nentitiesfiltered; ++_j)
326 	    for (_k=0; _k < nvaluesperentity; ++_k)
327 	      for (_i=0; _i < nconstituentpervalue; ++_i) {
328 		_ind =_i*nentities*nvaluesperentity+ (cominfo->filterarray[_j]-1)*nvaluesperentity +_k;
329 /* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOGLB[",_ind,"]",_filteredarrayvalues[_ind]); */
330 		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
331 	      }
332 	  break;
333 	}
334       }  else
335 	switch (constituentmode) {
336 	case MED_FULL_INTERLACE:
337 	  for (_i=0; _i < cominfo->nentitiesfiltered; ++_i )
338 	    for (_j=0; _j < nvaluesperentity; ++_j)
339 	      for (_k=0; _k < nconstituentpervalue; ++_k) {
340 		_ind = _i*nvaluesperentity*nconstituentpervalue+_j*nconstituentpervalue+_k;
341 /* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLCP[",_ind,"]",_filteredarrayvalues[_ind]) ; */
342 		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
343 	  }
344 	  break;
345 	case MED_NO_INTERLACE:
346 	  for (_j=0; _j < cominfo->nentitiesfiltered; ++_j)
347 	    for (_k=0; _k < nvaluesperentity; ++_k)
348 	      for (_i=0; _i < nconstituentpervalue; ++_i) {
349 		_ind =_i*cominfo->nentitiesfiltered*nvaluesperentity+ _j*nvaluesperentity +_k;
350 		/* _ind =_i*_nentitiesarrayvalues*nvaluesperentity+ (_filterarray[_j]-1)*nvaluesperentity +_k; */
351 /* 		fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOCP[",_ind,"]",_filteredarrayvalues[_ind]); */
352 		fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
353 	      }
354 	  break;
355 	}
356 
357 
358       free(_filteredarrayvalues);
359 
360       fclose(_asciifile);
361 
362       if ( MEDfilterClose(&filter2) < 0 ) {
363 	MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
364 	goto ERROR;
365       }
366 
367     } /*fin if (mpi_rank == 0) */
368 
369   if ( MEDfilterClose(&filter) < 0 ) {
370     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
371     goto ERROR;
372   }
373 
374 
375     _ret=0;
376   ERROR:
377     if (_arrayvalues)     free(_arrayvalues);
378     if (profilearraysize) free(_profilearray);
379 
380     if (  MEDfileClose(_fid) < 0) {
381       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
382     }
383 
384     if (mpi_rank == 0 ) {
385       if (  MEDfileClose(_fidseq) < 0) {
386 	MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
387       }
388     }
389 
390     return _ret;
391 }
392 
393 
394 
main(int argc,char ** argv)395 int main (int argc, char **argv)
396 
397 
398 {
399   med_err _ret=0;
400   COM_info _cominfo;
401   _cominfo.comm = MPI_COMM_WORLD;
402   _cominfo.info = MPI_INFO_NULL;
403   _cominfo.nentitiesfiltered=0;
404   _cominfo.filterarray      =NULL;
405 
406 
407 
408   MPI_Init(&argc, &argv);
409   MPI_Comm_size(MPI_COMM_WORLD, &(_cominfo.mpi_size));
410   MPI_Comm_rank(MPI_COMM_WORLD, &(_cominfo.mpi_rank));
411 
412   med_size      _nbblocksperproc       = 0;
413   int           _nentities             = 0;
414   int           _nvaluesperentity      = 0;
415   int           _nconstituentpervalue  = 0;
416 
417   if (_cominfo.mpi_rank == 0 ) {
418 
419     struct tm *_tm ;
420     time_t _tt=time(0);
421     _tm = localtime(&_tt);
422 
423     srandom((*_tm).tm_sec * (*_tm).tm_min );
424     _nbblocksperproc      = 1 + (int) (_cominfo.mpi_size * (random() / (RAND_MAX + 1.0)));
425     _nentities            = 1 + (int) (1000.0 * (random() / (RAND_MAX + 1.0)));
426     _nvaluesperentity     = 1 + (int) (11.0 * (random() / (RAND_MAX + 1.0)));
427     _nconstituentpervalue = 1 + (int) (7.0 * (random() / (RAND_MAX + 1.0)));
428 /*     _nbblocksperproc         = 1 + (int) (mpi_size * (random() / (RAND_MAX + 1.0))); */
429 /*     _nentities            = 1 + (int) (5.0 * (random() / (RAND_MAX + 1.0))); */
430 /*     _nvaluesperentity     = 1 + (int) (3.0 * (random() / (RAND_MAX + 1.0))); */
431 /*     _nconstituentpervalue = 1 + (int) (3.0 * (random() / (RAND_MAX + 1.0))); */
432 /*     _nbblocksperproc         = 2; */
433 /*     _nentities            = 4; */
434 /*     _nvaluesperentity     = 1; */
435 /*     _nconstituentpervalue = 1; */
436 
437   }
438 
439   if ( (sizeof(med_size)%(sizeof(MPI_LONG)))==0 ) {
440 
441     MPI_Bcast(&_nbblocksperproc      , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
442     MPI_Bcast(&_nentities            , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
443     MPI_Bcast(&_nvaluesperentity     , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
444     MPI_Bcast(&_nconstituentpervalue , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
445   } else {
446     assert(sizeof(med_size) == (sizeof(MPI_LONG)));
447   }
448 
449   char                _fieldnameprefix[256] = "";
450 
451   sprintf(_fieldnameprefix,"NENT-%03d_NVAL-%03d_NCST-%03d_NBL-%03llu",_nentities,_nvaluesperentity,
452 	  _nconstituentpervalue,_nbblocksperproc);
453 
454   GenerateDataType generateDatas = 0;
455   med_switch_mode  _switchmode  = MED_UNDEF_INTERLACE;
456   med_storage_mode _storagemode = MED_UNDEF_STMODE;
457   /*Pour que les 4 fichiers générés soient identiques, on désactive l'utilisation des profils
458     qui n'est pas utilisable en mode GLOBAL+// */
459   med_int          _profilearraysize=0;
460   /* med_int       _profilearraysize=_nentities/2; */
461 
462   for (_switchmode = MED_FULL_INTERLACE ; _switchmode <= MED_NO_INTERLACE; ++_switchmode) {
463 
464     if ( _switchmode == MED_FULL_INTERLACE ) generateDatas = generateFullIDatas;
465     else generateDatas = generateNoIDatas;
466 
467     for (_storagemode = MED_GLOBAL_STMODE ; _storagemode <= MED_COMPACT_STMODE; ++_storagemode) {
468 
469       if ( (_storagemode == MED_GLOBAL_STMODE ) && (_profilearraysize) ) _profilearraysize=0;
470 
471       if ( generateFieldFile( _nentities,  _nvaluesperentity, _nconstituentpervalue,
472 			      _switchmode, getCyclicBlocksOfEntities, _nbblocksperproc, generateDatas,
473 			      _storagemode, _profilearraysize,  _fieldnameprefix, & _cominfo) < 0 ) {
474 	MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldnameprefix);
475 	ISCRUTE(_cominfo.mpi_rank);
476 	goto ERROR;
477       }
478 
479     }
480   }
481 
482 
483   _ret = 0;
484  ERROR:
485 
486   if ( _cominfo.filterarray = NULL ) free( _cominfo.filterarray );
487 
488   /*pour arch. BLueGene : Sync entre GPFS et LSF : sleep(360) */
489 
490   /* MPI_Finalize must be called AFTER MEDclose which may use MPI calls */
491   MPI_Finalize();
492 
493   /* Catcher l'erreur en retour mpirun  et .sh*/
494   return _ret;
495 }
496 
497 
498 
499 
500