med_err _MEDselectAllEntitiesNoI(const med_idt fid, const med_int nentity, const med_int nvaluesperentity, const med_int nconstituentpervalue, const med_int constituentselect, med_filter* const filter) { med_idt _memspace[1]={0},_diskspace[1]={0}; med_size _memspacesize[1],_diskspacesize[1]; med_size _start_mem[1]={0}; med_err _ret=-1; med_size _onedimallvaluesdiskoffset[1]={0}; med_size _profilearraysize[1]={0}; /*TODO : propager cette modif aux autres filtres*/ if ( ! nentity) { _memspace[0] = H5Screate(H5S_NULL); _diskspace[0] = H5Screate(H5S_NULL); goto _CREATE_FILTER; } _onedimallvaluesdiskoffset[0] = nentity*nvaluesperentity; _memspacesize[0] = _onedimallvaluesdiskoffset[0]*nconstituentpervalue; _diskspacesize[0] = _memspacesize[0]; if ( (_memspace[0] = H5Screate_simple (1, _memspacesize, NULL)) <0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MEMSPACE,MED_ERR_SIZE_MSG); ISCRUTE_size(*_memspacesize); ISCRUTE_int(_memspace[0]); goto ERROR; } if ( constituentselect != MED_ALL_CONSTITUENT) { _start_mem[0] = (constituentselect-1)*_onedimallvaluesdiskoffset[0]; _profilearraysize[0]=_onedimallvaluesdiskoffset[0]; } else { _start_mem[0] = 0; _profilearraysize[0]=_memspacesize[0]; }; if ( H5Sselect_hyperslab (_memspace[0], H5S_SELECT_SET, _start_mem, NULL, _profilearraysize, NULL) <0 ) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_MEMSPACE,MED_ERR_ID_MSG); ISCRUTE_id(_memspace[0]); goto ERROR; } /* ISCRUTE_int(_memspace[0]); */ if ( (_diskspace[0] = H5Scopy(_memspace[0])) < 0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DISKSPACE,MED_ERR_SIZE_MSG); ISCRUTE_size(*_memspacesize); ISCRUTE_id(_memspace[0]); ISCRUTE_id(_diskspace[0]); goto ERROR; } _CREATE_FILTER: if ( _MEDsetFilter(1,_memspace, _diskspace, nentity, nvaluesperentity, nconstituentpervalue, constituentselect, MED_NO_INTERLACE, MED_NO_FILTER_SIZE, MED_NO_PROFILE_SIZE, MED_UNDEF_STMODE, MED_NO_PROFILE, filter ) <0) { MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,""); goto ERROR; } _ret = 0; ERROR: return _ret; }
med_err _MEDfilterBlockOfEntityNoICompactCr(const med_idt fid, const med_int nentity, const med_int nvaluesperentity, const med_int nconstituentpervalue, const med_int constituentselect, const med_storage_mode storagemode, const char * const profilename, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, med_filter* const filter) { med_size _start=start-1,_count=count; med_size _1[1]={1}; med_idt _memspace [MED_MAX_FILTER_SPACES]= MED_MAX_FILTER_SPACES_INIT; med_idt _filespace[MED_MAX_FILTER_SPACES]= MED_MAX_FILTER_SPACES_INIT; med_size _memspacesize[1]={0},_filespacesize[1]={0}; med_size _startmem[1]={0},_startfile[1]={0},_filelastblocksize[1]={0}; med_size _stridemem[1]={0},_countmem[1]={0},_countfilelastblock[1]={0}; med_size _startfile_lastblock[1]={0},_stridefile[1]={0},_blocksize[1]={0},_memblocksize[1]={0}; med_size _onedimallvaluesfileoffset=0,_onedimallvaluesmemoffset=0; med_err _ret=-1; int _dim=0, _firstdim=0, _dimutil=0, _lastdim=0,_index=0 ; int _anyprofil=0,_anylastblock=0; med_int _profilearraysize=0,profilearraysize=0; if ( constituentselect != MED_ALL_CONSTITUENT) { _firstdim = constituentselect-1; _lastdim = constituentselect; _dimutil = 1; } else { _firstdim = 0; _lastdim = nconstituentpervalue; _dimutil = nconstituentpervalue; } if ( (count < 1 ) || ( blocksize < 1 ) ) { _index=0; for (_dim=_firstdim; _dim < _lastdim; _dim++) { if ( (_memspace[_index]=H5Screate(H5S_NULL)) < 0 ) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_MEMSPACE,MED_ERR_ID_MSG); ISCRUTE_id(_memspace[_index]); goto ERROR; } if ( (_filespace[_index]=H5Screate(H5S_NULL)) < 0 ) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILESPACE,MED_ERR_ID_MSG); ISCRUTE_int(_filespace[_index]); goto ERROR; } ++_index; } goto SAVEFILTER; } if ( (count > 1) && (lastblocksize != blocksize) && lastblocksize ) /*Tester ou non si lastblocksize est bien > blocksize */ {--_count;_anylastblock=1;_countfilelastblock[0]=1;_filelastblocksize[0]=1;} /* ISCRUTE(_start); */ /* ISCRUTE(_count); */ /* ISCRUTE(_countfilelastblock[0]); */ /* Conditionne les traitements à l'existence d'un profil */ if ( _anyprofil=(strlen(profilename)) ) { profilearraysize = MEDprofileSizeByName(fid,profilename); _profilearraysize=profilearraysize; } else { _profilearraysize = nentity; } _blocksize [0] = blocksize*nvaluesperentity; /*!*nconstituentpervalue car on sélectionne par constituent*/ _onedimallvaluesmemoffset = _blocksize[0]*_count+ _anylastblock*lastblocksize*nvaluesperentity; _memspacesize [0] = _onedimallvaluesmemoffset*nconstituentpervalue; _stridemem [0] = 1; _countmem [0] = 1; _memblocksize [0] = _onedimallvaluesmemoffset; _onedimallvaluesfileoffset = _profilearraysize*nvaluesperentity; _filespacesize [0] = _onedimallvaluesfileoffset*nconstituentpervalue; _stridefile [0] = stride*nvaluesperentity; _filelastblocksize [0] *= lastblocksize*nvaluesperentity; /* ISCRUTE(_blocksize [0] ); */ /* ISCRUTE(_onedimallvaluesmemoffset ); */ /* ISCRUTE_id(_memspacesize [0] ); */ /* ISCRUTE(_stridemem [0] ); */ /* ISCRUTE(_countmem [0] ); */ /* ISCRUTE(_memblocksize [0] ); */ /* ISCRUTE(_onedimallvaluesfileoffset ); */ /* ISCRUTE_int(_filespacesize [0] ); */ /* ISCRUTE(_stridefile [0] ); */ /* ISCRUTE(_filelastblocksize [0] ); */ if ( _memspacesize[0] > _filespacesize[0] ) { MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_MEMSPACE,MED_ERR_SIZE_MSG); ISCRUTE_size(_memspacesize[0]); ISCRUTE_size(_filespacesize[0]); goto ERROR; } _index=0; for (_dim=_firstdim; _dim < _lastdim; _dim++) { if ( (_memspace[_index] = H5Screate_simple (1, _memspacesize, NULL)) <0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MEMSPACE,MED_ERR_ID_MSG); ISCRUTE_id(_memspace[_index]); MESSAGE(MED_ERR_SIZE_MSG); ISCRUTE_size(_memspacesize[0]); goto ERROR; } _startmem [0] = _dim*_onedimallvaluesmemoffset; if ( H5Sselect_hyperslab (_memspace[_index], H5S_SELECT_SET, _startmem, _stridemem, _countmem, _memblocksize) <0 ) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_MEMSPACE,MED_ERR_ID_MSG); ISCRUTE_id(_memspace[_index]); goto ERROR; } /* ISCRUTE_id(_memspace[_index]); */ if ( (_filespace[_index] = H5Screate_simple(1,_filespacesize,NULL)) < 0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILESPACE,MED_ERR_ID_MSG); ISCRUTE_id(_filespace[_index]); MESSAGE(MED_ERR_SIZE_MSG); ISCRUTE_size(_filespacesize[0]); goto ERROR; } _startfile[0] = _dim*_onedimallvaluesfileoffset+_start*nvaluesperentity; if ( H5Sselect_hyperslab (_filespace[_index], H5S_SELECT_SET, _startfile, _stridefile, &_count, _blocksize ) <0) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILESPACE,MED_ERR_ID_MSG); ISCRUTE_int(_filespace[_index]); goto ERROR; } /*File: Conditionally (_count) add a specific lastblock selection */ _startfile_lastblock[0] = _startfile[0]+_stridefile[0]*_count; /* ISCRUTE(_startfile_lastblock[0]); */ if ( H5Sselect_hyperslab (_filespace[_index], H5S_SELECT_OR, _startfile_lastblock,_1 , _countfilelastblock, _filelastblocksize ) <0) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_FILESPACE,MED_ERR_ID_MSG); ISCRUTE_int(_filespace[_index]); goto ERROR; } /* ISCRUTE_int(_filespace[_index]); */ if (_index > MED_MAX_FILTER_SPACES) { MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_PARAMETER,""); ISCRUTE_int(_index); ISCRUTE(nconstituentpervalue); ISCRUTE_int(MED_MAX_FILTER_SPACES); goto ERROR; } else ++_index; } SAVEFILTER: if ( _MEDsetFilter(_dimutil,_memspace, _filespace, nentity, nvaluesperentity, nconstituentpervalue, constituentselect, MED_NO_INTERLACE, MED_NO_FILTER_SIZE,profilearraysize, storagemode, profilename, filter ) <0) { MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,""); goto ERROR; } _ret = 0; ERROR: return _ret; }
med_err _MEDfilterEntityFullIGlobalCr(const med_idt fid, const med_int nentity, const med_int nvaluesperentity, const med_int nconstituentpervalue, const med_int constituentselect, const med_storage_mode storagemode, const char * const profilename, const med_int filterarraysize, const med_int* const filterarray, med_filter* const filter) { med_idt _memspace[1]={0},_diskspace[1]={0}; med_size _memspacesize[1]={0},_diskspacesize[1]={0}; med_int profilearraysize=0; med_int _profilearraysize=0, *_profilearray=0, (*_profilearrayfunc)(const med_int * const,int)=0; med_int _filterarraysize=0,(*_filterarrayfunc)(const med_int * const,int)=0; med_size *_fltmem=NULL,*_pfldisk=NULL; med_size _fltmemsize[1],_pfldisksize[1]; med_size _onedimallvaluesdiskoffset=0; med_err _ret=-1; int _i=0,_j=0,_index=0; int _dim=0, _firstdim=0, _dimutil=0, _lastdim=0 ; if ( constituentselect != MED_ALL_CONSTITUENT) { _firstdim = constituentselect-1; _lastdim = constituentselect; _dimutil = 1; } else { _firstdim = 0; _lastdim = nconstituentpervalue; _dimutil = nconstituentpervalue; } /* Conditionne les traitements à l'existence d'un profil */ if ( strlen(profilename) ) { profilearraysize = MEDprofileSizeByName(fid,profilename); _profilearraysize = profilearraysize; _profilearray = (med_int *) malloc (sizeof(med_int)*_profilearraysize); if ( MEDprofileRd(fid,profilename, _profilearray) <0) { MED_ERR_(_ret,MED_ERR_READ,MED_ERR_PROFILE,profilename); goto ERROR; } _profilearrayfunc = _withprofilearray; } else { _profilearrayfunc = _identity; _profilearraysize = nentity; } /* Conditionne les traitements à l'existence d'un filtre */ if ( (filterarraysize <= 0) ) { _filterarrayfunc = _identity; _filterarraysize = _profilearraysize; } else { _filterarrayfunc = _withfilterarray; _filterarraysize = filterarraysize; } _fltmemsize[0] = _filterarraysize*nvaluesperentity*_dimutil; _fltmem = (med_size *) malloc (sizeof(med_size)*_fltmemsize[0]); _memspacesize[0] = nentity*nvaluesperentity*nconstituentpervalue; if ( (_memspace[0] = H5Screate_simple (1,_memspacesize, NULL)) <0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MEMSPACE,MED_ERR_SIZE_MSG); ISCRUTE_size(*_memspacesize); goto ERROR; } /*Dimensionement profil interne et diskspace */ _pfldisksize[0] = _fltmemsize[0]; _pfldisk = (med_size *) malloc (sizeof(med_size)*_pfldisksize[0]); _onedimallvaluesdiskoffset = _profilearraysize*nvaluesperentity; _diskspacesize[0] = _onedimallvaluesdiskoffset*nconstituentpervalue; if ( (_diskspace[0] = H5Screate_simple (1,_diskspacesize, NULL)) <0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DISKSPACE,MED_ERR_SIZE_MSG); ISCRUTE_size(*_diskspacesize); goto ERROR; } _index=0; for (_dim=_firstdim; _dim < _lastdim; ++_dim) { for (_i=0; _i < _filterarraysize; _i++) { for (_j=0; _j < nvaluesperentity; _j++) { /* ISCRUTE(_filterarrayfunc(_i));ISCRUTE(_profilearrayfunc(_filterarrayfunc(_i))); */ /* ISCRUTE(_profilearrayfunc(_filterarrayfunc(_i))*nvaluesperentity*nconstituentpervalue); */ _fltmem[_index] = _profilearrayfunc(_profilearray,_filterarrayfunc(filterarray,_i))*nvaluesperentity*nconstituentpervalue + _j*nconstituentpervalue+_dim; _pfldisk[_index] = _dim*_onedimallvaluesdiskoffset + _filterarrayfunc(filterarray,_i)*nvaluesperentity+_j; #ifdef _DEBUG_ printf("FullGlb :_fltmem[%d]=%llu -- _pfldisk[%d]=%llu \n",_index,_fltmem[_index],_index,_pfldisk[_index]); #endif ++_index; } } } if ( H5Sselect_elements(_memspace[0],H5S_SELECT_SET, _fltmemsize[0], HDF5_SELECT_BUG _fltmem ) <0) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_MEMSPACE,MED_ERR_ID_MSG); ISCRUTE_id(_memspace[0]); goto ERROR; } /*Ce type de sélection n'est pas utilisable en parallélisme*/ if ( H5Sselect_elements(_diskspace[0] ,H5S_SELECT_SET,_pfldisksize[0], HDF5_SELECT_BUG _pfldisk ) <0) { MED_ERR_(_ret,MED_ERR_SELECT,MED_ERR_DISKSPACE,MED_ERR_ID_MSG); ISCRUTE_id(_diskspace[0]); goto ERROR; } free(_fltmem); _fltmem=NULL; free(_pfldisk); _pfldisk=NULL; free(_profilearray); _profilearray=NULL; if ( _MEDsetFilter(1,_memspace, _diskspace, nentity, nvaluesperentity, nconstituentpervalue, constituentselect, MED_FULL_INTERLACE, filterarraysize,profilearraysize, storagemode, profilename, filter ) <0) { MED_ERR_(_ret,MED_ERR_INIT,MED_ERR_FILTER,""); goto ERROR; } _ret = 0; ERROR: if (_fltmem) free(_fltmem); if (_pfldisk) free(_pfldisk); if (_profilearray) free(_profilearray); return _ret; }