summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_mmloc.f90
blob: 03273e1b22c415a61bb21c8ec71cf6fe3b9d8bf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
! Program to test the MINLOC and MAXLOC intrinsics
program testmmloc
   implicit none
   integer, dimension (3, 3) :: a
   integer, dimension (3) :: b
   logical, dimension (3, 3) :: m, tr
   integer i
   character(len=10) line

   a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/));
   tr = .true.

   b = minloc (a, 1)
   if (b(1) .ne. 1) call abort
   if (b(2) .ne. 2) call abort
   if (b(3) .ne. 3) call abort
   b = -1
   write (line, 9000) minloc(a,1)
   read (line, 9000) b
   if (b(1) .ne. 1) call abort
   if (b(2) .ne. 2) call abort
   if (b(3) .ne. 3) call abort

   m = .true.
   m(1, 1) = .false.
   m(1, 2) = .false.
   b = minloc (a, 1, m)
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 2) call abort
   if (b(3) .ne. 3) call abort
   b = minloc (a, 1, m .and. tr)
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 2) call abort
   if (b(3) .ne. 3) call abort
   b = -1
   write (line, 9000) minloc(a, 1, m)
   read (line, 9000) b
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 2) call abort
   if (b(3) .ne. 3) call abort

   b(1:2) = minloc(a)
   if (b(1) .ne. 1) call abort
   if (b(2) .ne. 1) call abort
   b = -1
   write (line, 9000) minloc(a)
   read (line, 9000) b
   if (b(1) .ne. 1) call abort
   if (b(2) .ne. 1) call abort
   if (b(3) .ne. 0) call abort

   b(1:2) = minloc(a, mask=m)
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 1) call abort
   b(1:2) = minloc(a, mask=m .and. tr)
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 1) call abort
   b = -1
   write (line, 9000) minloc(a, mask=m)
   read (line, 9000) b
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 1) call abort
   if (b(3) .ne. 0) call abort

   b = maxloc (a, 1)
   if (b(1) .ne. 3) call abort
   if (b(2) .ne. 3) call abort
   if (b(3) .ne. 1) call abort
   b = -1
   write (line, 9000) maxloc(a, 1)
   read (line, 9000) b
   if (b(1) .ne. 3) call abort
   if (b(2) .ne. 3) call abort
   if (b(3) .ne. 1) call abort

   m = .true.
   m(1, 2) = .false.
   m(1, 3) = .false.
   b = maxloc (a, 1, m)
   if (b(1) .ne. 3) call abort
   if (b(2) .ne. 3) call abort
   if (b(3) .ne. 2) call abort
   b = maxloc (a, 1, m .and. tr)
   if (b(1) .ne. 3) call abort
   if (b(2) .ne. 3) call abort
   if (b(3) .ne. 2) call abort
   b = -1
   write (line, 9000) maxloc(a, 1, m)
   read (line, 9000) b
   if (b(1) .ne. 3) call abort
   if (b(2) .ne. 3) call abort
   if (b(3) .ne. 2) call abort

   b(1:2) = maxloc(a)
   if (b(1) .ne. 1) call abort
   if (b(2) .ne. 3) call abort
   b = -1
   write (line, 9000) maxloc(a)
   read (line, 9000) b
   if (b(1) .ne. 1) call abort
   if (b(2) .ne. 3) call abort

   b(1:2) = maxloc(a, mask=m)
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 3) call abort
   b(1:2) = maxloc(a, mask=m .and. tr)
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 3) call abort
   b = -1
   write (line, 9000) maxloc(a, mask=m)
   read (line, 9000) b
   if (b(1) .ne. 2) call abort
   if (b(2) .ne. 3) call abort
   if (b(3) .ne. 0) call abort

9000 format (3I3)
end program