I need to Scatter my string array. The problem is, I'm not sure, how to do it correctly, I'm used to it only in C.
My program has the array scatterArr
which contains several strings (one for every process, so this number is changing). String length is changing too - my program loads text from a file, so, it depends on the word count.
Example of scatterArr
(just for this example I assigned strings manually):
int world_size = 4; // number of processes
string * scatterArr = new string[world_size];
scatterArr[0] = "Hello;How;";
scatterArr[1] = "I;are;";
scatterArr[2] = "am;you;";
scatterArr[3] = "John;"; // only one word loaded
And now Scatter()
:
int arrCharCount = 21;
char * recvArr = new char[ ??? ]; // I'm not sure what size to expect
COMM_WORLD.Scatter( scatterArr, arrCharCount, CHAR, recvArr, ???, CHAR, 0 );
Here I'm not sure about using char *
as a recvArr
type (maybe string
would be better?) and about the size I should allocate for my recvArr
array.
So, could you please help me with this and explain it, if possible, more thoroughly? I've found this question, but I've not understood, how can I determine the size of recvArr
when I don't know the exact number of CHARS which will come.