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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
<!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::replace 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&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&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_1replace.html">replace</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pri-methods">Private Member Functions</a> |
<a href="interfacem__cli2_1_1replace-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">m_cli2::replace 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:ab4d59b6a69d2768bf724f53604b3d0a9"><td class="memItemLeft" align="right" valign="top">subroutine </td><td class="memItemRight" valign="bottom"><a class="el" href="interfacem__cli2_1_1replace.html#ab4d59b6a69d2768bf724f53604b3d0a9">replace_c</a> (list, value, place)</td></tr>
<tr class="separator:ab4d59b6a69d2768bf724f53604b3d0a9"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a73a0dab38328c3db8a7eef48e27390bd"><td class="memItemLeft" align="right" valign="top">subroutine </td><td class="memItemRight" valign="bottom"><a class="el" href="interfacem__cli2_1_1replace.html#a73a0dab38328c3db8a7eef48e27390bd">replace_i</a> (list, value, place)</td></tr>
<tr class="separator:a73a0dab38328c3db8a7eef48e27390bd"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a9c995edced1d2665777e794a3aa5b2a0"><td class="memItemLeft" align="right" valign="top">subroutine </td><td class="memItemRight" valign="bottom"><a class="el" href="interfacem__cli2_1_1replace.html#a9c995edced1d2665777e794a3aa5b2a0">replace_l</a> (list, value, place)</td></tr>
<tr class="separator:a9c995edced1d2665777e794a3aa5b2a0"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Member Function/Subroutine Documentation</h2>
<a id="ab4d59b6a69d2768bf724f53604b3d0a9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab4d59b6a69d2768bf724f53604b3d0a9">◆ </a></span>replace_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::replace::replace_c </td>
<td>(</td>
<td class="paramtype">character(len=:), dimension(:), allocatable </td>
<td class="paramname"><em>list</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">character(len=*), intent(in) </td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer, intent(in) </td>
<td class="paramname"><em>place</em> </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_md217"></a>
NAME</h2>
<p>replace(3f) - [M_CLI2] replace entry in a string array at specified position (LICENSE:PD)</p>
<h2><a class="anchor" id="autotoc_md218"></a>
SYNOPSIS</h2>
<p>subroutine replace(list,value,place)</p>
<p>character(len=*)|doubleprecision|real|integer,intent(in) :: value character(len=:)|doubleprecision|real|integer,intent(in) :: list(:) integer, intent(out) :: PLACE</p>
<h2><a class="anchor" id="autotoc_md219"></a>
DESCRIPTION</h2>
<pre class="fragment">replace a value in an allocatable array at the specified index. Unless the
array needs the string length to increase this is merely an assign of a value
to an array element.
The array may be of type CHARACTER, DOUBLEPRECISION, REAL, or INTEGER>
It is assumed to be sorted in descending order without duplicate values.
The value and list must be of the same type.
</pre><h2><a class="anchor" id="autotoc_md220"></a>
OPTIONS</h2>
<pre class="fragment">VALUE the value to place in the array
LIST is the array.
PLACE is the subscript that the entry should be placed at
</pre><h2><a class="anchor" id="autotoc_md221"></a>
EXAMPLES</h2>
<p>Replace key-value pairs in a dictionary </p><pre class="fragment">program demo_replace
use M_CLI2, only : insert, locate, replace
! Find if a key is in a list and insert it
! into the key list and value list if it is not present
! or replace the associated value if the key existed
implicit none
character(len=20) :: key
character(len=100) :: val
character(len=:),allocatable :: keywords(:)
character(len=:),allocatable :: values(:)
integer :: i
integer :: place
call update('b','value of b')
call update('a','value of a')
call update('c','value of c')
call update('c','value of c again')
call update('d','value of d')
call update('a','value of a again')
! show array
write(*,'(*(a,"==>",a,/))')(trim(keywords(i)),trim(values(i)),i=1,size(keywords))
call locate_key('a',place)
if(place.gt.0)then
write(*,*)'The value of "a" is',trim(values(place))
else
write(*,*)'"a" not found'
endif
contains
subroutine update(key,val)
character(len=*),intent(in) :: key
character(len=*),intent(in) :: val
integer :: place
! find where string is or should be
call locate_key(key,place)
! if string was not found insert it
if(place.lt.1)then
call insert(keywords,key,abs(place))
call insert(values,val,abs(place))
else ! replace
call replace(values,val,place)
endif
end subroutine update
</pre><p> end program demo_replace</p>
<p>Expected output</p>
<p>d==>value of d c==>value of c again b==>value of b a==>value of a again</p>
<h2><a class="anchor" id="autotoc_md222"></a>
AUTHOR</h2>
<p>1989,2017 John S. Urban </p>
<h2><a class="anchor" id="autotoc_md223"></a>
LICENSE</h2>
<p>Public Domain </p>
</div>
</div>
<a id="a73a0dab38328c3db8a7eef48e27390bd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a73a0dab38328c3db8a7eef48e27390bd">◆ </a></span>replace_i()</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::replace::replace_i </td>
<td>(</td>
<td class="paramtype">integer, dimension(:), allocatable </td>
<td class="paramname"><em>list</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer, intent(in) </td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer, intent(in) </td>
<td class="paramname"><em>place</em> </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">
</div>
</div>
<a id="a9c995edced1d2665777e794a3aa5b2a0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9c995edced1d2665777e794a3aa5b2a0">◆ </a></span>replace_l()</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::replace::replace_l </td>
<td>(</td>
<td class="paramtype">logical, dimension(:), allocatable </td>
<td class="paramname"><em>list</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">logical, intent(in) </td>
<td class="paramname"><em>value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">integer, intent(in) </td>
<td class="paramname"><em>place</em> </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">
</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  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
|