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
|
\hypertarget{interfacem__cli2_1_1locate}{}\doxysection{m\+\_\+cli2\+::locate Interface Reference}
\label{interfacem__cli2_1_1locate}\index{m\_cli2::locate@{m\_cli2::locate}}
\doxysubsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item
subroutine \mbox{\hyperlink{interfacem__cli2_1_1locate_a59a1546b8eab776a0ba5594b6b90ae72}{locate\+\_\+c}} (list, value, place, ier, errmsg)
\end{DoxyCompactItemize}
\doxysubsection{Member Function/\+Subroutine Documentation}
\mbox{\Hypertarget{interfacem__cli2_1_1locate_a59a1546b8eab776a0ba5594b6b90ae72}\label{interfacem__cli2_1_1locate_a59a1546b8eab776a0ba5594b6b90ae72}}
\index{m\_cli2::locate@{m\_cli2::locate}!locate\_c@{locate\_c}}
\index{locate\_c@{locate\_c}!m\_cli2::locate@{m\_cli2::locate}}
\doxysubsubsection{\texorpdfstring{locate\_c()}{locate\_c()}}
{\footnotesize\ttfamily subroutine m\+\_\+cli2\+::locate\+::locate\+\_\+c (\begin{DoxyParamCaption}\item[{character(len=\+:), dimension(\+:), allocatable}]{list, }\item[{character(len=$\ast$), intent(in)}]{value, }\item[{integer, intent(out)}]{place, }\item[{integer, intent(out), optional}]{ier, }\item[{character(len=$\ast$), intent(out), optional}]{errmsg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}
\hypertarget{namespacem__cli2_autotoc_md202}{}\doxysubsubsection{N\+A\+ME}\label{namespacem__cli2_autotoc_md202}
locate(3f) -\/ \mbox{[}M\+\_\+\+C\+L\+I2\mbox{]} finds the index where a string is found or should be in a sorted array (L\+I\+C\+E\+N\+SE\+:PD)\hypertarget{namespacem__cli2_autotoc_md203}{}\doxysubsubsection{S\+Y\+N\+O\+P\+S\+IS}\label{namespacem__cli2_autotoc_md203}
subroutine locate(list,value,place,ier,errmsg)
character(len=\+:)$\vert$doubleprecision$\vert$real$\vert$integer,allocatable \+:: list(\+:) character(len=$\ast$)$\vert$doubleprecision$\vert$real$\vert$integer,intent(in) \+:: value integer, intent(out) \+:: P\+L\+A\+CE
integer, intent(out),optional \+:: I\+ER character(len=$\ast$),intent(out),optional \+:: E\+R\+R\+M\+SG\hypertarget{namespacem__cli2_autotoc_md204}{}\doxysubsubsection{D\+E\+S\+C\+R\+I\+P\+T\+I\+ON}\label{namespacem__cli2_autotoc_md204}
\begin{DoxyVerb}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)
\end{DoxyVerb}
\hypertarget{namespacem__cli2_autotoc_md205}{}\doxysubsubsection{O\+P\+T\+I\+O\+NS}\label{namespacem__cli2_autotoc_md205}
\begin{DoxyVerb}VALUE the value to locate in the list.
LIST is the list array.
\end{DoxyVerb}
\hypertarget{namespacem__cli2_autotoc_md206}{}\doxysubsubsection{R\+E\+T\+U\+R\+NS}\label{namespacem__cli2_autotoc_md206}
P\+L\+A\+CE is the subscript that the entry was found at if it is greater than zero(0).
If P\+L\+A\+CE is negative, the absolute value of P\+L\+A\+CE indicates the subscript value where the new entry should be placed in order to keep the list alphabetized.
I\+ER is zero(0) if no error occurs. If an error occurs and I\+ER is not present, the program is stopped.
E\+R\+R\+M\+SG description of any error\hypertarget{namespacem__cli2_autotoc_md207}{}\doxysubsubsection{E\+X\+A\+M\+P\+L\+ES}\label{namespacem__cli2_autotoc_md207}
Find if a string is in a sorted array, and insert the string into the list if it is not present ... \begin{DoxyVerb}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
\end{DoxyVerb}
Results\+:
for \char`\"{}b\char`\"{} index is 2 5 for \char`\"{}\mbox{[}\char`\"{} index is -\/4 5 S\+I\+ZE=5 xxx,b,aaa,\mbox{[},Z\+ZZ, for \char`\"{}c\char`\"{} index is -\/2 6 S\+I\+ZE=6 xxx,c,b,aaa,\mbox{[},Z\+ZZ, for \char`\"{}\+Z\+Z\char`\"{} index is -\/7 7 S\+I\+ZE=7 xxx,c,b,aaa,\mbox{[},Z\+ZZ,, for \char`\"{}\+Z\+Z\+Z\+Z\char`\"{} index is -\/6 8 S\+I\+ZE=8 xxx,c,b,aaa,\mbox{[},Z\+Z\+ZZ,Z\+ZZ,, for \char`\"{}z\char`\"{} index is -\/1 9 S\+I\+ZE=9 z,xxx,c,b,aaa,\mbox{[},Z\+Z\+ZZ,Z\+ZZ,,\hypertarget{namespacem__cli2_autotoc_md208}{}\doxysubsubsection{A\+U\+T\+H\+OR}\label{namespacem__cli2_autotoc_md208}
1989,2017 John S. Urban \hypertarget{namespacem__cli2_autotoc_md209}{}\doxysubsubsection{L\+I\+C\+E\+N\+SE}\label{namespacem__cli2_autotoc_md209}
Public Domain
The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item
/home/urbanjs/venus/\+V600/github/\+A\+R\+G\+S/\+M\+\_\+\+C\+L\+I2/src/\mbox{\hyperlink{M__CLI2_8f90}{M\+\_\+\+C\+L\+I2.\+f90}}\end{DoxyCompactItemize}
|