1#define NUM_ELEMS 10 2#define NUM_ROWS 2 3#define NUM_COLS 3 4 5void test_long_long_1d(int *array, int num_elems); 6void test_long_long_2d(int *array, int num_rows, int num_cols); 7void test_long_1d(int *array, int num_elems); 8void test_int_1d(int *array, int num_elems); 9void test_short_1d(int *array, int num_elems); 10void test_mixed(int *array, int num_elems); 11 12int main(int argc, char **argv) 13{ 14 int my_array[NUM_ELEMS]; 15 int my_2d_array[NUM_ROWS][NUM_COLS]; 16 int i, j; 17 18 for(i = 0; i < NUM_ELEMS; i++) 19 my_array[i] = i; 20 21 for(i = 0; i < NUM_ROWS; i++) 22 for(j = 0; j < NUM_COLS; j++) 23 my_2d_array[i][j] = (i*NUM_COLS) + j; 24 25 /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long. */ 26 test_long_long_1d(my_array, NUM_ELEMS); 27 28 /* Test c_f_pointer where SHAPE is of type integer, kind=c_long_long. 29 The indices are transposed for Fortran. */ 30 test_long_long_2d(my_2d_array[0], NUM_COLS, NUM_ROWS); 31 32 /* Test c_f_pointer where SHAPE is of type integer, kind=c_long. */ 33 test_long_1d(my_array, NUM_ELEMS); 34 35 /* Test c_f_pointer where SHAPE is of type integer, kind=c_int. */ 36 test_int_1d(my_array, NUM_ELEMS); 37 38 /* Test c_f_pointer where SHAPE is of type integer, kind=c_short. */ 39 test_short_1d(my_array, NUM_ELEMS); 40 41 /* Test c_f_pointer where SHAPE is of type integer, kind=c_int and 42 kind=c_long_long. */ 43 test_mixed(my_array, NUM_ELEMS); 44 45 return 0; 46} 47