00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <med.h>
00021 #define MESGERR 1
00022 #include "med_utils.h"
00023
00024
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
00050
00051
00052
00053 *valuesarray = (med_float *) calloc(nentities*nvaluesperentity*nconstituentpervalue,sizeoftype);
00054 for (_blocknum=0; _blocknum< count; ++_blocknum) {
00055 _blockstart=_blocknum*stride;
00056
00057 if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
00058
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
00066
00067
00068 }
00069 }
00070 break;
00071
00072 case MED_COMPACT_PFLMODE :
00073
00074
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
00086
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
00122
00123
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
00138
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
00157
00158 _index++;
00159 }
00160 }
00161 }
00162
00163 break;
00164 default:
00165 break;
00166 }
00167 }