1
1
module caf_co_min_test
2
- use prif, only : prif_co_min, prif_this_image_no_coarray, prif_num_images
2
+ use iso_c_binding, only: c_int32_t, c_int64_t, c_float, c_double
3
+ use prif, only : prif_co_min, prif_co_min_character, prif_this_image_no_coarray, prif_num_images
3
4
use veggies, only: result_t, test_item_t, assert_equals, describe, it, succeed
4
5
5
6
implicit none
@@ -22,27 +23,91 @@ function test_prif_co_min() result(tests)
22
23
23
24
function check_32_bit_integer () result(result_)
24
25
type (result_t) :: result_
25
- result_ = succeed(" temporarily" )
26
+
27
+ integer (c_int32_t), parameter :: values(* ) = [1 , 19 , 5 , 13 , 11 , 7 , 17 , 3 ]
28
+ integer :: me, ni, i
29
+ integer (c_int32_t) :: my_val, expected
30
+
31
+ call prif_this_image_no_coarray(this_image= me)
32
+ call prif_num_images(ni)
33
+
34
+ my_val = values(mod (me-1 , size (values))+ 1 )
35
+ call prif_co_min(my_val)
36
+
37
+ expected = minval ([(values(mod (i-1 ,size (values))+ 1 ), i = 1 , ni)])
38
+ result_ = assert_equals(expected, my_val)
26
39
end function
27
40
28
41
function check_64_bit_integer () result(result_)
29
42
type (result_t) :: result_
30
- result_ = succeed(" temporarily" )
43
+
44
+ integer (c_int64_t), parameter :: values(* ,* ) = reshape ([1 , 19 , 5 , 13 , 11 , 7 , 17 , 3 ], [2 , 4 ])
45
+ integer :: me, ni, i
46
+ integer (c_int64_t), dimension (size (values,1 )) :: my_val, expected
47
+
48
+ call prif_this_image_no_coarray(this_image= me)
49
+ call prif_num_images(ni)
50
+
51
+ my_val = values(:, mod (me-1 , size (values,2 ))+ 1 )
52
+ call prif_co_min(my_val)
53
+
54
+ expected = minval (reshape ([(values(:, mod (i-1 ,size (values,2 ))+ 1 ), i = 1 , ni)], [size (values,1 ),ni]), dim= 2 )
55
+ result_ = assert_equals(int (expected), int (my_val))
31
56
end function
32
57
33
58
function check_32_bit_real () result(result_)
34
59
type (result_t) :: result_
35
- result_ = succeed(" temporarily" )
60
+
61
+ real (c_float), parameter :: values(* ,* ,* ) = reshape ([1 , 19 , 5 , 13 , 11 , 7 , 17 , 3 ], [2 ,2 ,2 ])
62
+ integer :: me, ni, i
63
+ real (c_float), dimension (size (values,1 ), size (values,2 )) :: my_val, expected
64
+
65
+ call prif_this_image_no_coarray(this_image= me)
66
+ call prif_num_images(ni)
67
+
68
+ my_val = values(:, :, mod (me-1 , size (values,3 ))+ 1 )
69
+ call prif_co_min(my_val)
70
+
71
+ expected = minval (reshape ([(values(:,:,mod (i-1 ,size (values,3 ))+ 1 ), i = 1 , ni)], [size (values,1 ), size (values,2 ), ni]), dim= 3 )
72
+ result_ = assert_equals(real (expected,kind= c_double), real (my_val,kind= c_double))
36
73
end function
37
74
38
75
function check_64_bit_real () result(result_)
39
76
type (result_t) :: result_
40
- result_ = succeed(" temporarily" )
77
+
78
+ real (c_double), parameter :: values(* ,* ) = reshape ([1 , 19 , 5 , 13 , 11 , 7 , 17 , 3 ], [2 , 4 ])
79
+ integer :: me, ni, i
80
+ real (c_double), dimension (size (values,1 )) :: my_val, expected
81
+
82
+ call prif_this_image_no_coarray(this_image= me)
83
+ call prif_num_images(ni)
84
+
85
+ my_val = values(:, mod (me-1 , size (values,2 ))+ 1 )
86
+ call prif_co_min(my_val)
87
+
88
+ expected = minval (reshape ([(values(:, mod (i-1 ,size (values,2 ))+ 1 ), i = 1 , ni)], [size (values,1 ),ni]), dim= 2 )
89
+ result_ = assert_equals(expected, my_val)
41
90
end function
42
91
43
92
function check_character () result(result_)
44
- type (result_t) :: result_
45
- result_ = succeed(" temporarily" )
93
+ type (result_t) result_
94
+ result_ = succeed(" skip for now" )
95
+ ! character(len=*), parameter :: values(*) = &
96
+ ! [ "To be ","or not " &
97
+ ! , "to ","be. " &
98
+ ! , "that ","is " &
99
+ ! , "the ","question"]
100
+ ! integer :: me, ni, i
101
+ ! character(len=len(values)) :: my_val, expected
102
+
103
+ ! call prif_this_image_no_coarray(this_image=me)
104
+ ! call prif_num_images(ni)
105
+
106
+ ! my_val = values(mod(me-1, size(values))+1)
107
+ ! call prif_co_min_character(my_val)
108
+
109
+ ! expected = minval([(values(mod(i-1,size(values))+1), i = 1, ni)])
110
+ ! result_ = assert_equals(expected, my_val)
46
111
end function
47
112
48
113
end module caf_co_min_test
0 commit comments