generateDatas.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 
00020 #include <med.h>
00021 #define MESGERR 1
00022 #include "med_utils.h"
00023 
00024 /*Les données générées, le sont uniquement aux endroits utilisés */
00025 void generateFullIDatas(const int myrank, const int lastrank, const int sizeoftype,
00026                         const med_storage_mode profilemode, const med_size profilesize, const med_int * const profilearray,
00027                         const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize,
00028                         const int nentities, const int nvaluesperentity, const int nconstituentpervalue,
00029                         med_float ** valuesarray ) {
00030 
00031   med_size _start=start-1,_blockstart = 0,_blocksize=blocksize,_allblocksize=0,_index=0;
00032   med_int  (*_profilearrayfunc)(int)=0;
00033   inline med_int _identity  (int i)  { return i; }
00034   inline med_int _withprofilearray(int i) { return (profilearray[i]-1); }
00035   int _blocknum=0,_i=0,_j=0,_k=0;
00036 
00037   if (profilesize) {
00038     if ( profilearray == NULL ) {MESSAGE("Error, profilesize > 0 && profilearray == 0"); }
00039     MESSAGE("Using a profile...");
00040     _profilearrayfunc = _withprofilearray;
00041   } else {
00042     _profilearrayfunc = _identity;
00043   }
00044 
00045   switch(profilemode) {
00046 
00047   case MED_GLOBAL_PFLMODE :
00048 
00049     /*       ISCRUTE(lastblocksize); */
00050     /*En mode global on n'a normalement pas besoin de prendre en compte les profils. Il ne peut pas y en avoir.
00051       Celà n'a pas de sens sauf si la sélection demandée est un seul block !
00052       Tous les processus possèdent le tableau global. */
00053     *valuesarray = (med_float *) calloc(nentities*nvaluesperentity*nconstituentpervalue,sizeoftype);
00054     for (_blocknum=0; _blocknum< count; ++_blocknum) {
00055       _blockstart=_blocknum*stride;
00056       /*        ISCRUTE(_blockstart); */
00057       if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
00058       /*        ISCRUTE(_blocksize); */
00059       for (_i=0; _i<_blocksize; ++_i)
00060         for (_j=0; _j < nvaluesperentity; ++_j)
00061           for (_k=0; _k < nconstituentpervalue; ++_k) {
00062             _index = _profilearrayfunc(_start+_blockstart+_i)*nvaluesperentity*nconstituentpervalue
00063               +_j*nconstituentpervalue+_k;
00064             (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_k;
00065             /*      ISCRUTE(_index); */
00066             /*      RSCRUTE((*valuesarray)[_index]); */
00067 
00068           }
00069     }
00070     break;
00071 
00072   case MED_COMPACT_PFLMODE :
00073 
00074     /*Idem avec ou sans profil*/
00075     if ( (myrank == lastrank) ) _allblocksize=blocksize*count+lastblocksize; else _allblocksize = blocksize*count;
00076     *valuesarray = (med_float *) calloc(_allblocksize*nvaluesperentity*nconstituentpervalue,sizeoftype);
00077 
00078     _index = 0;
00079     for (_blocknum=0; _blocknum< count; ++_blocknum) {
00080       if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
00081       for (_i=0; _i<_blocksize; ++_i)
00082         for (_j=0; _j < nvaluesperentity; ++_j)
00083           for (_k=0; _k < nconstituentpervalue; ++_k) {
00084             (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_k;
00085             /*      ISCRUTE(_index); */
00086             /*      RSCRUTE((*valuesarray)[_index]); */
00087             _index++;
00088           }
00089     }
00090 
00091     break;
00092   default:
00093     break;
00094   }
00095 }
00096 
00097 void generateNoIDatas(const int myrank, const int lastrank, const int sizeoftype,
00098                       const med_storage_mode storagemode, const med_size profilearraysize, const med_int * const profilearray,
00099                       const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize,
00100                       const int nentities, const int nvaluesperentity, const int nconstituentpervalue,
00101                       med_float ** valuesarray ) {
00102 
00103   med_size _start=start-1,_blockstart = 0,_blocksize=blocksize,_allblocksize=0,_index=0,_dim=0;
00104   med_int  (*_profilearrayfunc)(int)=0;
00105   inline med_int _identity  (int i)  { return i; }
00106   inline med_int _withprofilearray(int i) { return (profilearray[i]-1); }
00107   int _blocknum=0,_i=0,_j=0,_k=0;
00108 
00109   if (profilearraysize) {
00110     MESSAGE("Using a profile...");
00111     if ( profilearray == NULL ) {MESSAGE("Error, profilearraysize > 0 && profilearray == 0"); }
00112     _profilearrayfunc = _withprofilearray;
00113   } else {
00114     _profilearrayfunc = _identity;
00115   }
00116 
00117   switch(storagemode) {
00118 
00119   case MED_GLOBAL_PFLMODE :
00120 
00121     /*En mode global on n'a normalement pas besoin de prendre en compte les profils. Il ne peut pas y en avoir.
00122       Celà n'a pas de sens sauf si la sélection demandée est un seul block !
00123       Tous les processus possèdent le tableau global. */
00124     *valuesarray = (med_float *) calloc(nentities*nvaluesperentity*nconstituentpervalue,sizeoftype);
00125 
00126     for (_dim=0; _dim< nconstituentpervalue; ++_dim) {
00127       _blocksize = blocksize;
00128       for (_blocknum=0; _blocknum< count; ++_blocknum) {
00129         _blockstart=_blocknum*stride;
00130         if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
00131         for (_i=0; _i<_blocksize; ++_i)
00132           for (_j=0; _j < nvaluesperentity; ++_j) {
00133             _index = ( _dim*nentities
00134                        +_profilearrayfunc(_start+_blockstart+_i) )
00135               *nvaluesperentity + _j;
00136             (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_dim;
00137             /*      ISCRUTE(_index); */
00138             /*      RSCRUTE((*valuesarray)[_index]); */
00139           }
00140       }
00141     }
00142     break;
00143 
00144   case MED_COMPACT_PFLMODE :
00145     if ( (myrank == lastrank) ) _allblocksize=blocksize*count+lastblocksize; else _allblocksize = blocksize*count;
00146     *valuesarray = (med_float *) calloc(_allblocksize*nvaluesperentity*nconstituentpervalue,sizeoftype);
00147 
00148     _index = 0;
00149     for (_dim=0; _dim< nconstituentpervalue; ++_dim) {
00150       _blocksize = blocksize;
00151       for (_blocknum=0; _blocknum< count; ++_blocknum) {
00152         if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
00153         for (_i=0; _i<_blocksize; ++_i)
00154           for (_j=0; _j < nvaluesperentity; ++_j) {
00155             (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_dim;
00156             /*      ISCRUTE(_index); */
00157             /*      RSCRUTE((*valuesarray)[_index]); */
00158             _index++;
00159           }
00160       }
00161     }
00162 
00163     break;
00164   default:
00165     break;
00166   }
00167 }

Généré le Thu Oct 8 14:26:16 2015 pour MED fichier par  doxygen 1.6.1