File: interfacem__cli2_1_1locate.html

package info (click to toggle)
fortran-cli2 3.2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,856 kB
  • sloc: f90: 6,172; javascript: 3,423; makefile: 186; sh: 25
file content (234 lines) | stat: -rwxr-xr-x 9,472 bytes parent folder | download
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>M_CLI2: m_cli2::locate Interface Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">M_CLI2
   </div>
   <div id="projectbrief">M_CLI2 module (Fortran)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacem__cli2.html">m_cli2</a></li><li class="navelem"><a class="el" href="interfacem__cli2_1_1locate.html">locate</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pri-methods">Private Member Functions</a> &#124;
<a href="interfacem__cli2_1_1locate-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">m_cli2::locate Interface Reference</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr class="memitem:a59a1546b8eab776a0ba5594b6b90ae72"><td class="memItemLeft" align="right" valign="top">subroutine&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacem__cli2_1_1locate.html#a59a1546b8eab776a0ba5594b6b90ae72">locate_c</a> (list, value, place, ier, errmsg)</td></tr>
<tr class="separator:a59a1546b8eab776a0ba5594b6b90ae72"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Member Function/Subroutine Documentation</h2>
<a id="a59a1546b8eab776a0ba5594b6b90ae72"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a59a1546b8eab776a0ba5594b6b90ae72">&#9670;&nbsp;</a></span>locate_c()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">subroutine m_cli2::locate::locate_c </td>
          <td>(</td>
          <td class="paramtype">character(len=:), dimension(:), allocatable&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">character(len=*), intent(in)&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(out)&#160;</td>
          <td class="paramname"><em>place</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">integer, intent(out), optional&#160;</td>
          <td class="paramname"><em>ier</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">character(len=*), intent(out), optional&#160;</td>
          <td class="paramname"><em>errmsg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<h2><a class="anchor" id="autotoc_md202"></a>
NAME</h2>
<p>locate(3f) - [M_CLI2] finds the index where a string is found or should be in a sorted array (LICENSE:PD)</p>
<h2><a class="anchor" id="autotoc_md203"></a>
SYNOPSIS</h2>
<p>subroutine locate(list,value,place,ier,errmsg)</p>
<p>character(len=:)|doubleprecision|real|integer,allocatable :: list(:) character(len=*)|doubleprecision|real|integer,intent(in) :: value integer, intent(out) :: PLACE</p>
<p>integer, intent(out),optional :: IER character(len=*),intent(out),optional :: ERRMSG</p>
<h2><a class="anchor" id="autotoc_md204"></a>
DESCRIPTION</h2>
<pre class="fragment">LOCATE(3f) finds the index where the VALUE is found or should
be found in an array. The array must be sorted in descending
order (highest at top). If VALUE is not found it returns the index
where the name should be placed at with a negative sign.

The array and list must be of the same type (CHARACTER, DOUBLEPRECISION,
REAL,INTEGER)
</pre><h2><a class="anchor" id="autotoc_md205"></a>
OPTIONS</h2>
<pre class="fragment">VALUE         the value to locate in the list.
LIST          is the list array.
</pre><h2><a class="anchor" id="autotoc_md206"></a>
RETURNS</h2>
<p>PLACE is the subscript that the entry was found at if it is greater than zero(0).</p>
<p>If PLACE is negative, the absolute value of PLACE indicates the subscript value where the new entry should be placed in order to keep the list alphabetized.</p>
<p>IER is zero(0) if no error occurs. If an error occurs and IER is not present, the program is stopped.</p>
<p>ERRMSG description of any error</p>
<h2><a class="anchor" id="autotoc_md207"></a>
EXAMPLES</h2>
<p>Find if a string is in a sorted array, and insert the string into the list if it is not present ... </p><pre class="fragment">program demo_locate
use M_sort, only : sort_shell
use M_CLI2, only : locate
implicit none
character(len=:),allocatable  :: arr(:)
integer                       :: i

arr=[character(len=20) :: '', 'ZZZ', 'aaa', 'b', 'xxx' ]
! make sure sorted in descending order
call sort_shell(arr,order='d')

call update(arr,'b')
call update(arr,'[')
call update(arr,'c')
call update(arr,'ZZ')
call update(arr,'ZZZZ')
call update(arr,'z')

contains
subroutine update(arr,string)
character(len=:),allocatable :: arr(:)
character(len=*)             :: string
integer                      :: place, plus, ii, end
! find where string is or should be
call locate(arr,string,place)
write(*,*)'for "'//string//'" index is ',place, size(arr)
! if string was not found insert it
if(place.lt.1)then
   plus=abs(place)
   ii=len(arr)
   end=size(arr)
   ! empty array
   if(end.eq.0)then
      arr=[character(len=ii) :: string ]
   ! put in front of array
   elseif(plus.eq.1)then
      arr=[character(len=ii) :: string, arr]
   ! put at end of array
   elseif(plus.eq.end)then
      arr=[character(len=ii) :: arr, string ]
   ! put in middle of array
   else
      arr=[character(len=ii) :: arr(:plus-1), string,arr(plus:) ]
   endif
   ! show array
   write(*,'("SIZE=",i0,1x,*(a,","))')end,(trim(arr(i)),i=1,end)
endif
end subroutine update
end program demo_locate
</pre><p>Results:</p>
<p>for "b" index is 2 5 for "[" index is -4 5 SIZE=5 xxx,b,aaa,[,ZZZ, for "c" index is -2 6 SIZE=6 xxx,c,b,aaa,[,ZZZ, for "ZZ" index is -7 7 SIZE=7 xxx,c,b,aaa,[,ZZZ,, for "ZZZZ" index is -6 8 SIZE=8 xxx,c,b,aaa,[,ZZZZ,ZZZ,, for "z" index is -1 9 SIZE=9 z,xxx,c,b,aaa,[,ZZZZ,ZZZ,,</p>
<h2><a class="anchor" id="autotoc_md208"></a>
AUTHOR</h2>
<p>1989,2017 John S. Urban </p>
<h2><a class="anchor" id="autotoc_md209"></a>
LICENSE</h2>
<p>Public Domain </p>

</div>
</div>
<hr/>The documentation for this interface was generated from the following file:<ul>
<li>/home/urbanjs/venus/V600/github/ARGS/M_CLI2/src/<a class="el" href="M__CLI2_8f90.html">M_CLI2.f90</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>