111
|
1 `/* Implementation of the MINLOC intrinsic
|
|
2 Copyright (C) 2002-2017 Free Software Foundation, Inc.
|
|
3 Contributed by Paul Brook <paul@nowt.org>
|
|
4
|
|
5 This file is part of the GNU Fortran runtime library (libgfortran).
|
|
6
|
|
7 Libgfortran is free software; you can redistribute it and/or
|
|
8 modify it under the terms of the GNU General Public
|
|
9 License as published by the Free Software Foundation; either
|
|
10 version 3 of the License, or (at your option) any later version.
|
|
11
|
|
12 Libgfortran is distributed in the hope that it will be useful,
|
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 GNU General Public License for more details.
|
|
16
|
|
17 Under Section 7 of GPL version 3, you are granted additional
|
|
18 permissions described in the GCC Runtime Library Exception, version
|
|
19 3.1, as published by the Free Software Foundation.
|
|
20
|
|
21 You should have received a copy of the GNU General Public License and
|
|
22 a copy of the GCC Runtime Library Exception along with this program;
|
|
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
24 <http://www.gnu.org/licenses/>. */
|
|
25
|
|
26 #include "libgfortran.h"'
|
|
27
|
|
28 include(iparm.m4)dnl
|
|
29 include(ifunction.m4)dnl
|
|
30
|
|
31 `#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`)'
|
|
32
|
|
33 ARRAY_FUNCTION(0,
|
|
34 ` atype_name minval;
|
|
35 #if defined ('atype_inf`)
|
|
36 minval = atype_inf;
|
|
37 #else
|
|
38 minval = atype_max;
|
|
39 #endif
|
|
40 result = 1;',
|
|
41 `#if defined ('atype_nan`)
|
|
42 if (*src <= minval)
|
|
43 {
|
|
44 minval = *src;
|
|
45 result = (rtype_name)n + 1;
|
|
46 break;
|
|
47 }
|
|
48 }
|
|
49 for (; n < len; n++, src += delta)
|
|
50 {
|
|
51 #endif
|
|
52 if (*src < minval)
|
|
53 {
|
|
54 minval = *src;
|
|
55 result = (rtype_name)n + 1;
|
|
56 }')
|
|
57
|
|
58 MASKED_ARRAY_FUNCTION(0,
|
|
59 ` atype_name minval;
|
|
60 #if defined ('atype_inf`)
|
|
61 minval = atype_inf;
|
|
62 #else
|
|
63 minval = atype_max;
|
|
64 #endif
|
|
65 #if defined ('atype_nan`)
|
|
66 rtype_name result2 = 0;
|
|
67 #endif
|
|
68 result = 0;',
|
|
69 ` if (*msrc)
|
|
70 {
|
|
71 #if defined ('atype_nan`)
|
|
72 if (!result2)
|
|
73 result2 = (rtype_name)n + 1;
|
|
74 if (*src <= minval)
|
|
75 #endif
|
|
76 {
|
|
77 minval = *src;
|
|
78 result = (rtype_name)n + 1;
|
|
79 break;
|
|
80 }
|
|
81 }
|
|
82 }
|
|
83 #if defined ('atype_nan`)
|
|
84 if (unlikely (n >= len))
|
|
85 result = result2;
|
|
86 else
|
|
87 #endif
|
|
88 for (; n < len; n++, src += delta, msrc += mdelta)
|
|
89 {
|
|
90 if (*msrc && *src < minval)
|
|
91 {
|
|
92 minval = *src;
|
|
93 result = (rtype_name)n + 1;
|
|
94 }', `')
|
|
95
|
|
96 SCALAR_ARRAY_FUNCTION(0)
|
|
97
|
|
98 #endif
|