Send different amounts of data from all tasks to a single task. By default, the zeroth task in the parallel application receives the data. Xout is overwritten on the receiving task.
Xin and xout can be any intrinsic Fortran data type: integer, real, double precision, complex, logical or, character. Both must be arrays.
|
[ccm_host:~/ccm/source]% ccm_gatherv_x1
i= 0 xout= 1 2 2 3 3 3
[ccm_host:~/ccm/source] %
The call to ccm_init initializes the communication package. Task 0 allocates and fills the to_get array. The number of values to be sent from each task is equal to the id. The tasks are given this information by the call to ccm_scatter. The values to be gathered are also set to the id. Space is allocated for the output. The values are gathered with ccm_gatherv and task 0 prints what it has received. The call to ccm_close closes the communication package. |
|
[ccm_host:~/ccm/source]% ccm_gatherv_x2
send array is: abcdefghijklmnop
i= 0 xout= mnop
i= 1 xout= ijkl
i= 2 xout= efgh
i= 3 xout= abcd
i= 0 xin is now = ABCDEFGHIJKLMNOP
[ccm_host:~/ccm/source] %
This example is based on the second ccm_scatterv example. The call to ccm_init initializes the communication package. The count and offset arrays are allocated. Each task will receive 4 values. Task 0 fills an array with 16 characters. The program scatters values in reverse order by filling the offset array as shown. Task 3 gets characters from the beginning of the array and task 0 from the end. The program sends the values by using ccm_scatterv. They are printed with task 3 writing the beginning of the alphabet. Each task converts is characters to upper case. The values are gathered back to task zero. This is done by using the same inputs as the scatterv but flipping the xout/xin arrays Task 0 prints the upper case string. The call to ccm_close closes the communication package. |