MED fichier
generateDatas.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2021 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 
19 
20 #include <med.h>
21 #define MESGERR 1
22 #include "med_utils.h"
23 
24 static inline med_int _identity (int i) { return i; }
26 static inline med_int _withprofilearray(int i) {
27  return (profilearray_global[i]-1);
28 }
29 
30 /*Les données générées, le sont uniquement aux endroits utilisés */
31 void generateFullIDatas(const int myrank, const int lastrank, const int sizeoftype,
32  const med_storage_mode profilemode, const med_size profilesize, const med_int * const profilearray,
33  const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize,
34  const int nentities, const int nvaluesperentity, const int nconstituentpervalue,
35  med_float ** valuesarray ) {
36 
37  med_size _start=start-1,_blockstart = 0,_blocksize=blocksize,_allblocksize=0,_index=0;
38  med_int (*_profilearrayfunc)(int)=0;
39  int _blocknum=0,_i=0,_j=0,_k=0;
40 
41  profilearray_global = profilearray;
42 
43  if (profilesize) {
44  if ( profilearray == NULL ) { MESSAGE("Error, profilesize > 0 && profilearray == 0"); }
45  MESSAGE("Using a profile...");
46  _profilearrayfunc = _withprofilearray;
47  } else {
48  _profilearrayfunc = _identity;
49  }
50 
51  switch(profilemode) {
52 
53  case MED_GLOBAL_STMODE :
54 
55  /* ISCRUTE(lastblocksize); */
56  /*En mode global on n'a normalement pas besoin de prendre en compte les profils. Il ne peut pas y en avoir.
57  Celà n'a pas de sens sauf si la sélection demandée est un seul block !
58  Tous les processus possèdent le tableau global. */
59  *valuesarray = (med_float *) calloc(nentities*nvaluesperentity*nconstituentpervalue,sizeoftype);
60  for (_blocknum=0; _blocknum< count; ++_blocknum) {
61  _blockstart=_blocknum*stride;
62  /* ISCRUTE(_blockstart); */
63  if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
64  /* ISCRUTE(_blocksize); */
65  for (_i=0; _i<_blocksize; ++_i)
66  for (_j=0; _j < nvaluesperentity; ++_j)
67  for (_k=0; _k < nconstituentpervalue; ++_k) {
68  _index = _profilearrayfunc(_start+_blockstart+_i)*nvaluesperentity*nconstituentpervalue
69  +_j*nconstituentpervalue+_k;
70  (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_k;
71  /* ISCRUTE(_index); */
72  /* RSCRUTE((*valuesarray)[_index]); */
73 
74  }
75  }
76  break;
77 
78  case MED_COMPACT_STMODE :
79 
80  /*Idem avec ou sans profil*/
81  if ( (myrank == lastrank) ) _allblocksize=blocksize*count+lastblocksize; else _allblocksize = blocksize*count;
82  *valuesarray = (med_float *) calloc(_allblocksize*nvaluesperentity*nconstituentpervalue,sizeoftype);
83 
84  _index = 0;
85  for (_blocknum=0; _blocknum< count; ++_blocknum) {
86  if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
87  for (_i=0; _i<_blocksize; ++_i)
88  for (_j=0; _j < nvaluesperentity; ++_j)
89  for (_k=0; _k < nconstituentpervalue; ++_k) {
90  (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_k;
91  /* ISCRUTE(_index); */
92  /* RSCRUTE((*valuesarray)[_index]); */
93  _index++;
94  }
95  }
96 
97  break;
98  default:
99  break;
100  }
101 }
102 
103 void generateNoIDatas(const int myrank, const int lastrank, const int sizeoftype,
104  const med_storage_mode storagemode, const med_size profilearraysize, const med_int * const profilearray,
105  const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize,
106  const int nentities, const int nvaluesperentity, const int nconstituentpervalue,
107  med_float ** valuesarray ) {
108 
109  med_size _start=start-1,_blockstart = 0,_blocksize=blocksize,_allblocksize=0,_index=0,_dim=0;
110  med_int (*_profilearrayfunc)(int)=0;
111  int _blocknum=0,_i=0,_j=0,_k=0;
112  profilearray_global = profilearray;
113 
114  if (profilearraysize) {
115  MESSAGE("Using a profile...");
116  if ( profilearray == NULL ) {MESSAGE("Error, profilearraysize > 0 && profilearray == 0"); }
117  _profilearrayfunc = _withprofilearray;
118  } else {
119  _profilearrayfunc = _identity;
120  }
121 
122  switch(storagemode) {
123 
124  case MED_GLOBAL_STMODE :
125 
126  /*En mode global on n'a normalement pas besoin de prendre en compte les profils. Il ne peut pas y en avoir.
127  Celà n'a pas de sens sauf si la sélection demandée est un seul block !
128  Tous les processus possèdent le tableau global. */
129  *valuesarray = (med_float *) calloc(nentities*nvaluesperentity*nconstituentpervalue,sizeoftype);
130 
131  for (_dim=0; _dim< nconstituentpervalue; ++_dim) {
132  _blocksize = blocksize;
133  for (_blocknum=0; _blocknum< count; ++_blocknum) {
134  _blockstart=_blocknum*stride;
135  if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
136  for (_i=0; _i<_blocksize; ++_i)
137  for (_j=0; _j < nvaluesperentity; ++_j) {
138  _index = ( _dim*nentities
139  +_profilearrayfunc(_start+_blockstart+_i) )
140  *nvaluesperentity + _j;
141  (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_dim;
142  /* ISCRUTE(_index); */
143  /* RSCRUTE((*valuesarray)[_index]); */
144  }
145  }
146  }
147  break;
148 
149  case MED_COMPACT_STMODE :
150  if ( (myrank == lastrank) ) _allblocksize=blocksize*count+lastblocksize; else _allblocksize = blocksize*count;
151  *valuesarray = (med_float *) calloc(_allblocksize*nvaluesperentity*nconstituentpervalue,sizeoftype);
152 
153  _index = 0;
154  for (_dim=0; _dim< nconstituentpervalue; ++_dim) {
155  _blocksize = blocksize;
156  for (_blocknum=0; _blocknum< count; ++_blocknum) {
157  if ( (count > 1) && (_blocknum == (count-1) ) && (myrank == lastrank) ) _blocksize=lastblocksize;
158  for (_i=0; _i<_blocksize; ++_i)
159  for (_j=0; _j < nvaluesperentity; ++_j) {
160  (*valuesarray)[_index]= (myrank+1)*1000+_blocknum*100+_i+0.1*_j+0.01*_dim;
161  /* ISCRUTE(_index); */
162  /* RSCRUTE((*valuesarray)[_index]); */
163  _index++;
164  }
165  }
166  }
167 
168  break;
169  default:
170  break;
171  }
172 }
generateFullIDatas
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, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, const int nentities, const int nvaluesperentity, const int nconstituentpervalue, med_float **valuesarray)
Definition: generateDatas.c:31
_identity
static med_int _identity(int i)
Definition: generateDatas.c:24
_withprofilearray
static med_int _withprofilearray(int i)
Definition: generateDatas.c:26
med_size
hsize_t med_size
Definition: med.h:329
generateNoIDatas
void generateNoIDatas(const int myrank, const int lastrank, const int sizeoftype, const med_storage_mode storagemode, const med_size profilearraysize, const med_int *const profilearray, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, const int nentities, const int nvaluesperentity, const int nconstituentpervalue, med_float **valuesarray)
Definition: generateDatas.c:103
profilearray_global
static const med_int * profilearray_global
Definition: generateDatas.c:25
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:342
med.h
med_float
double med_float
Definition: med.h:336
MED_GLOBAL_STMODE
Definition: med.h:109
MED_COMPACT_STMODE
Definition: med.h:110
med_storage_mode
med_storage_mode
Definition: med.h:108
med_utils.h