1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #include <ISO_Fortran_binding.h>
5 #include "dump-descriptors.h"
6
7 extern void ctest (int imax, int jmax, CFI_cdesc_t *a);
8
9 struct m {
10 int i;
11 int j;
12 };
13
14 void
15 ctest (int imax, int jmax, CFI_cdesc_t *a)
16 {
17
18 int i, j;
19 CFI_index_t subscripts[2];
20 struct m* mp;
21
22 /* Dump the descriptor contents to test that we can access the fields
23 correctly, etc. */
24 dump_CFI_cdesc_t (a);
25
26 if (a->rank != 2)
27 abort ();
28 if (a->attribute != CFI_attribute_other)
29 abort ();
30 if (a->dim[0].lower_bound != 0)
31 abort ();
32 if (a->dim[0].extent != imax)
33 abort ();
34 if (a->dim[1].lower_bound != 0)
35 abort ();
36 if (a->dim[1].extent != jmax)
37 abort ();
38
39 /* Fill in the contents of a. a is zero-based but we want the ->i and ->j
40 members of each element to be numbered starting from 1. */
41 for (j = 0; j < jmax; j++)
42 {
43 subscripts[1] = j;
44 for (i = 0; i < imax; i++)
45 {
46 subscripts[0] = i;
47 mp = (struct m *) CFI_address (a, subscripts);
48 mp->i = i + 1;
49 mp->j = j + 1;
50 }
51 }
52 }