source: CIVL/examples/cast/pairConversion.cvl@ 2b25839

2.0 acw/focus-triggers main
Last change on this file since 2b25839 was 2b25839, checked in by Stephen Siegel <siegel@…>, 5 days ago

Implemented MPI operations MINLOC and MAXLOC and associated datatypes
for collective routines. Still need to do it for point-to-point, if
they are ever used in that way. Still need to think more deeply
about how to handle structs in general for MPI.
Found additional uses of deprecated $state and deleted them.
Added further complex and collective examples. Still need to make
them into JUnit tests.

  • Property mode set to 100644
File size: 560 bytes
Line 
1
2struct S1 {
3 double val;
4 int rank;
5};
6
7struct DoubleIntPair {
8 double x;
9 int y;
10};
11
12void convert(void * buf, int count) {
13 struct DoubleIntPair * p = (struct DoubleIntPair *)buf;
14 struct DoubleIntPair newbuf[count];
15 for (int i=0; i<count; i++) {
16 newbuf[i].x = p[i].x;
17 newbuf[i].y = p[i].y;
18 }
19 for (int i=0; i<count; i++) {
20 $assert(newbuf[i].x == 10.0*i);
21 $assert(newbuf[i].y == i);
22 }
23}
24
25int main(void) {
26 int n = 5;
27 struct S1 a[n];
28 for (int i=0; i<n; i++) {
29 a[i].val = 10.0*i;
30 a[i].rank = i;
31 }
32 convert(a, n);
33}
Note: See TracBrowser for help on using the repository browser.