\hypertarget{namespacemom__string__functions}{}\section{mom\+\_\+string\+\_\+functions Module Reference}
\label{namespacemom__string__functions}\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}


\subsection{Detailed Description}
Handy functions for manipulating strings. 

By Alistair Adcroft and Robert Hallberg, last updated Sept. 2013.

The functions here perform a set of useful manipulations of character strings. Although they are a part of M\+O\+M6, the do not require any other M\+OM software to be useful. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
character(len=len(input\+\_\+string)) function, public \hyperlink{namespacemom__string__functions_a4d76e9e8c2cd53f210b02006924a9212}{lowercase} (input\+\_\+string)
\begin{DoxyCompactList}\small\item\em Return a string in which all uppercase letters have been replaced by their lowercase counterparts. \end{DoxyCompactList}\item 
character(len=len(input\+\_\+string)) function, public \hyperlink{namespacemom__string__functions_aca148baf726de2f028b7e7baad3c85d4}{uppercase} (input\+\_\+string)
\begin{DoxyCompactList}\small\item\em Return a string in which all uppercase letters have been replaced by their lowercase counterparts. \end{DoxyCompactList}\item 
character(len=19) function, public \hyperlink{namespacemom__string__functions_ae6b4260129cce257d834cc9b32e847f3}{left\+\_\+int} (i)
\begin{DoxyCompactList}\small\item\em Returns a character string of a left-\/formatted integer e.\+g. \char`\"{}123       \char`\"{} (assumes 19 digit maximum) \end{DoxyCompactList}\item 
character(len=1320) function, public \hyperlink{namespacemom__string__functions_a0db6538cb622d0f20a577b07cb545f2e}{left\+\_\+ints} (i)
\begin{DoxyCompactList}\small\item\em Returns a character string of a comma-\/separated, compact formatted, integers e.\+g. \char`\"{}1, 2, 3, 4\char`\"{}. \end{DoxyCompactList}\item 
character(len=32) function, public \hyperlink{namespacemom__string__functions_ab56b89fb51a387279afc68c85d30dca2}{left\+\_\+real} (val)
\begin{DoxyCompactList}\small\item\em Returns a left-\/justified string with a real formatted like \textquotesingle{}(G)\textquotesingle{}. \end{DoxyCompactList}\item 
character(len=1320) function, public \hyperlink{namespacemom__string__functions_a07fa1b92ce5c4c4336bb45c5a89fa548}{left\+\_\+reals} (r, sep)
\begin{DoxyCompactList}\small\item\em Returns a character string of a comma-\/separated, compact formatted, reals e.\+g. \char`\"{}1., 2., 5$\ast$3., 5.\+E2\char`\"{}. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__string__functions_aec369a6ac0badc1dbd782a1668d2c7c3}{isformattedfloatequalto} (str, val)
\begin{DoxyCompactList}\small\item\em Returns True if the string can be read/parsed to give the exact value of \char`\"{}val\char`\"{}. \end{DoxyCompactList}\item 
character(len=120) function, public \hyperlink{namespacemom__string__functions_a7bfdab6bba33230cc94ed625e95022c9}{extractword} (string, n)
\begin{DoxyCompactList}\small\item\em Returns the string corresponding to the nth word in the argument or \char`\"{}\char`\"{} if the string is not long enough. Both spaces and commas are interpreted as separators. \end{DoxyCompactList}\item 
character(len=120) function, public \hyperlink{namespacemom__string__functions_aad76dee92b69dab4488da049fe11cdb8}{extract\+\_\+word} (string, separators, n)
\begin{DoxyCompactList}\small\item\em Returns the string corresponding to the nth word in the argument or \char`\"{}\char`\"{} if the string is not long enough. Words are delineated by the mandatory separators argument. \end{DoxyCompactList}\item 
integer function, public \hyperlink{namespacemom__string__functions_aae12046c1401f23bd7e038655e30654e}{extract\+\_\+integer} (string, separators, n, missing\+\_\+value)
\begin{DoxyCompactList}\small\item\em Returns the integer corresponding to the nth word in the argument. \end{DoxyCompactList}\item 
real function, public \hyperlink{namespacemom__string__functions_a2f700337c5cf4e70a48bd0663570484e}{extract\+\_\+real} (string, separators, n, missing\+\_\+value)
\begin{DoxyCompactList}\small\item\em Returns the real corresponding to the nth word in the argument. \end{DoxyCompactList}\item 
character(len=120) function, public \hyperlink{namespacemom__string__functions_a60262e56f544e4613754df43bf50652e}{remove\+\_\+spaces} (string)
\begin{DoxyCompactList}\small\item\em Returns string with all spaces removed. \end{DoxyCompactList}\item 
logical function, public \hyperlink{namespacemom__string__functions_a7b7aa802a4da2021801267f6c6f890bf}{string\+\_\+functions\+\_\+unit\+\_\+tests} (verbose)
\begin{DoxyCompactList}\small\item\em Returns true if a unit test of string\+\_\+functions fails. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__string__functions_a3f4583fac417ae45e370035ce0eecb04}{localtests} (verbose, str1, str2)
\begin{DoxyCompactList}\small\item\em True if str1 does not match str2. False otherwise. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__string__functions_a1ca01e01cf691da9ea4dd5c20ad81770}{localtesti} (verbose, i1, i2)
\begin{DoxyCompactList}\small\item\em True if i1 is not equal to i2. False otherwise. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__string__functions_a7ed3314f4fae014b9c35c321320063b2}{localtestr} (verbose, r1, r2)
\begin{DoxyCompactList}\small\item\em True if r1 is not equal to r2. False otherwise. \end{DoxyCompactList}\item 
character(len=len(dir)+2) function, public \hyperlink{namespacemom__string__functions_af18b819f6c6a917c57b9690d0580f642}{slasher} (dir)
\begin{DoxyCompactList}\small\item\em Returns a directory name that is terminated with a \char`\"{}/\char`\"{} or \char`\"{}./\char`\"{} if the argument is an empty string. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__string__functions_aae12046c1401f23bd7e038655e30654e}\label{namespacemom__string__functions_aae12046c1401f23bd7e038655e30654e}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!extract\+\_\+integer@{extract\+\_\+integer}}
\index{extract\+\_\+integer@{extract\+\_\+integer}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{extract\+\_\+integer()}{extract\_integer()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+string\+\_\+functions\+::extract\+\_\+integer (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{string,  }\item[{character(len=$\ast$), intent(in)}]{separators,  }\item[{integer, intent(in)}]{n,  }\item[{integer, intent(in), optional}]{missing\+\_\+value }\end{DoxyParamCaption})}



Returns the integer corresponding to the nth word in the argument. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em string} & String to scan\\
\hline
\mbox{\tt in}  & {\em separators} & Characters to use for delineation\\
\hline
\mbox{\tt in}  & {\em n} & Number of word to extract\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & Value to assign if word is missing \\
\hline
\end{DoxyParams}


Definition at line 246 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
246   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: string\textcolor{comment}{     !< String to scan}
247   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: separators\textcolor{comment}{ !< Characters to use for delineation}
248   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: n\textcolor{comment}{          !< Number of word to extract}
249   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< Value to assign if word is missing}
250   \textcolor{comment}{! Local variables}
251   \textcolor{keywordtype}{integer} :: ns, i, b, e, nw
252   \textcolor{keywordtype}{character(len=20)} :: word
253 
254   word = extract\_word(string, separators, n)
255 
256   \textcolor{keywordflow}{if} (len\_trim(word)>0) \textcolor{keywordflow}{then}
257     \textcolor{keyword}{read}(word(1:len\_trim(word)),*) extract\_integer
258   \textcolor{keywordflow}{else}
259     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(missing\_value)) \textcolor{keywordflow}{then}
260       extract\_integer = missing\_value
261     \textcolor{keywordflow}{else}
262       extract\_integer = 0
263 \textcolor{keywordflow}{    endif}
264 \textcolor{keywordflow}{  endif}
265 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a2f700337c5cf4e70a48bd0663570484e}\label{namespacemom__string__functions_a2f700337c5cf4e70a48bd0663570484e}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!extract\+\_\+real@{extract\+\_\+real}}
\index{extract\+\_\+real@{extract\+\_\+real}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{extract\+\_\+real()}{extract\_real()}}
{\footnotesize\ttfamily real function, public mom\+\_\+string\+\_\+functions\+::extract\+\_\+real (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{string,  }\item[{character(len=$\ast$), intent(in)}]{separators,  }\item[{integer, intent(in)}]{n,  }\item[{real, intent(in), optional}]{missing\+\_\+value }\end{DoxyParamCaption})}



Returns the real corresponding to the nth word in the argument. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em string} & String to scan\\
\hline
\mbox{\tt in}  & {\em separators} & Characters to use for delineation\\
\hline
\mbox{\tt in}  & {\em n} & Number of word to extract\\
\hline
\mbox{\tt in}  & {\em missing\+\_\+value} & Value to assign if word is missing \\
\hline
\end{DoxyParams}


Definition at line 270 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
270   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: string\textcolor{comment}{     !< String to scan}
271   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: separators\textcolor{comment}{ !< Characters to use for delineation}
272   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: n\textcolor{comment}{          !< Number of word to extract}
273   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional},   \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< Value to assign if word is missing}
274   \textcolor{comment}{! Local variables}
275   \textcolor{keywordtype}{integer} :: ns, i, b, e, nw
276   \textcolor{keywordtype}{character(len=20)} :: word
277 
278   word = extract\_word(string, separators, n)
279 
280   \textcolor{keywordflow}{if} (len\_trim(word)>0) \textcolor{keywordflow}{then}
281     \textcolor{keyword}{read}(word(1:len\_trim(word)),*) extract\_real
282   \textcolor{keywordflow}{else}
283     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(missing\_value)) \textcolor{keywordflow}{then}
284       extract\_real = missing\_value
285     \textcolor{keywordflow}{else}
286       extract\_real = 0
287 \textcolor{keywordflow}{    endif}
288 \textcolor{keywordflow}{  endif}
289 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_aad76dee92b69dab4488da049fe11cdb8}\label{namespacemom__string__functions_aad76dee92b69dab4488da049fe11cdb8}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!extract\+\_\+word@{extract\+\_\+word}}
\index{extract\+\_\+word@{extract\+\_\+word}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{extract\+\_\+word()}{extract\_word()}}
{\footnotesize\ttfamily character(len=120) function, public mom\+\_\+string\+\_\+functions\+::extract\+\_\+word (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{string,  }\item[{character(len=$\ast$), intent(in)}]{separators,  }\item[{integer, intent(in)}]{n }\end{DoxyParamCaption})}



Returns the string corresponding to the nth word in the argument or \char`\"{}\char`\"{} if the string is not long enough. Words are delineated by the mandatory separators argument. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em string} & String to scan\\
\hline
\mbox{\tt in}  & {\em separators} & Characters to use for delineation\\
\hline
\mbox{\tt in}  & {\em n} & Number of word to extract \\
\hline
\end{DoxyParams}


Definition at line 209 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
209   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: string\textcolor{comment}{     !< String to scan}
210   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: separators\textcolor{comment}{ !< Characters to use for delineation}
211   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: n\textcolor{comment}{          !< Number of word to extract}
212   \textcolor{comment}{! Local variables}
213   \textcolor{keywordtype}{integer} :: ns, i, b, e, nw
214   \textcolor{keywordtype}{logical} :: lastcharisseperator
215   extract\_word = \textcolor{stringliteral}{''}
216   lastcharisseperator = .true.
217   ns = len\_trim(string)
218   i = 0; b=0; e=0; nw=0
219   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (i<ns)
220     i = i+1
221     \textcolor{keywordflow}{if} (lastcharisseperator) \textcolor{keywordflow}{then} \textcolor{comment}{! search for end of word}
222       \textcolor{keywordflow}{if} (verify(string(i:i),separators)==0) \textcolor{keywordflow}{then}
223         \textcolor{keywordflow}{continue} \textcolor{comment}{! Multiple separators}
224       \textcolor{keywordflow}{else}
225         lastcharisseperator = .false. \textcolor{comment}{! character is beginning of word}
226         b = i
227         \textcolor{keywordflow}{continue}
228 \textcolor{keywordflow}{      endif}
229     \textcolor{keywordflow}{else} \textcolor{comment}{! continue search for end of word}
230       \textcolor{keywordflow}{if} (verify(string(i:i),separators)==0) \textcolor{keywordflow}{then}
231         lastcharisseperator = .true.
232         e = i-1 \textcolor{comment}{! Previous character is end of word}
233         nw = nw+1
234         \textcolor{keywordflow}{if} (nw==n) \textcolor{keywordflow}{then}
235           extract\_word = trim(string(b:e))
236           \textcolor{keywordflow}{return}
237 \textcolor{keywordflow}{        endif}
238 \textcolor{keywordflow}{      endif}
239 \textcolor{keywordflow}{    endif}
240 \textcolor{keywordflow}{  enddo}
241   \textcolor{keywordflow}{if} (b<=ns .and. nw==n-1) extract\_word = trim(string(b:ns))
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a7bfdab6bba33230cc94ed625e95022c9}\label{namespacemom__string__functions_a7bfdab6bba33230cc94ed625e95022c9}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!extractword@{extractword}}
\index{extractword@{extractword}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{extractword()}{extractword()}}
{\footnotesize\ttfamily character(len=120) function, public mom\+\_\+string\+\_\+functions\+::extractword (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{string,  }\item[{integer, intent(in)}]{n }\end{DoxyParamCaption})}



Returns the string corresponding to the nth word in the argument or \char`\"{}\char`\"{} if the string is not long enough. Both spaces and commas are interpreted as separators. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em string} & The string to scan\\
\hline
\mbox{\tt in}  & {\em n} & Number of word to extract \\
\hline
\end{DoxyParams}


Definition at line 198 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
198   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: string\textcolor{comment}{ !< The string to scan}
199   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: n\textcolor{comment}{      !< Number of word to extract}
200 
201   extractword = extract\_word(string, \textcolor{stringliteral}{' ,'}, n)
202 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_aec369a6ac0badc1dbd782a1668d2c7c3}\label{namespacemom__string__functions_aec369a6ac0badc1dbd782a1668d2c7c3}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!isformattedfloatequalto@{isformattedfloatequalto}}
\index{isformattedfloatequalto@{isformattedfloatequalto}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{isformattedfloatequalto()}{isformattedfloatequalto()}}
{\footnotesize\ttfamily logical function mom\+\_\+string\+\_\+functions\+::isformattedfloatequalto (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{str,  }\item[{real, intent(in)}]{val }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns True if the string can be read/parsed to give the exact value of \char`\"{}val\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em str} & The string to parse\\
\hline
\mbox{\tt in}  & {\em val} & The real value to compare with \\
\hline
\end{DoxyParams}


Definition at line 182 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
182   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: str\textcolor{comment}{ !< The string to parse}
183   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{intent(in)} :: val\textcolor{comment}{ !< The real value to compare with}
184   \textcolor{keywordtype}{logical}                      :: isformattedfloatequalto
185   \textcolor{comment}{! Local variables}
186   \textcolor{keywordtype}{real} :: scannedval
187 
188   isformattedfloatequalto=.false.
189   \textcolor{keyword}{read}(str(1:),*,err=987) scannedval
190   \textcolor{keywordflow}{if} (scannedval == val) isformattedfloatequalto=.true.
191  987 \textcolor{keywordflow}{return}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_ae6b4260129cce257d834cc9b32e847f3}\label{namespacemom__string__functions_ae6b4260129cce257d834cc9b32e847f3}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!left\+\_\+int@{left\+\_\+int}}
\index{left\+\_\+int@{left\+\_\+int}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{left\+\_\+int()}{left\_int()}}
{\footnotesize\ttfamily character(len=19) function, public mom\+\_\+string\+\_\+functions\+::left\+\_\+int (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{i }\end{DoxyParamCaption})}



Returns a character string of a left-\/formatted integer e.\+g. \char`\"{}123       \char`\"{} (assumes 19 digit maximum) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em i} & The integer to convert to a string\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output string 
\end{DoxyReturn}


Definition at line 62 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
62   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: i\textcolor{comment}{ !< The integer to convert to a string}
63   \textcolor{keywordtype}{character(len=19)} :: left\_int\textcolor{comment}{ !< The output string}
64 
65   \textcolor{keywordtype}{character(len=19)} :: tmp
66   \textcolor{keyword}{write}(tmp(1:19),\textcolor{stringliteral}{'(I19)'}) i
67   \textcolor{keyword}{write}(left\_int(1:19),\textcolor{stringliteral}{'(A)'}) adjustl(tmp)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a0db6538cb622d0f20a577b07cb545f2e}\label{namespacemom__string__functions_a0db6538cb622d0f20a577b07cb545f2e}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!left\+\_\+ints@{left\+\_\+ints}}
\index{left\+\_\+ints@{left\+\_\+ints}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{left\+\_\+ints()}{left\_ints()}}
{\footnotesize\ttfamily character(len=1320) function, public mom\+\_\+string\+\_\+functions\+::left\+\_\+ints (\begin{DoxyParamCaption}\item[{integer, dimension(\+:), intent(in)}]{i }\end{DoxyParamCaption})}



Returns a character string of a comma-\/separated, compact formatted, integers e.\+g. \char`\"{}1, 2, 3, 4\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em i} & The array of integers to convert to a string\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output string 
\end{DoxyReturn}


Definition at line 73 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
73   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: i(:)\textcolor{comment}{ !< The array of integers to convert to a string}
74   \textcolor{keywordtype}{character(len=1320)} :: left\_ints\textcolor{comment}{ !< The output string}
75 
76   \textcolor{keywordtype}{character(len=1320)} :: tmp
77   \textcolor{keywordtype}{integer} :: j
78   \textcolor{keyword}{write}(left\_ints(1:1320),\textcolor{stringliteral}{'(A)'}) trim(left\_int(i(1)))
79   \textcolor{keywordflow}{if} (\textcolor{keyword}{size}(i)>1) \textcolor{keywordflow}{then}
80     \textcolor{keywordflow}{do} j=2,\textcolor{keyword}{size}(i)
81       tmp=left\_ints
82       \textcolor{keyword}{write}(left\_ints(1:1320),\textcolor{stringliteral}{'(A,", ",A)'}) trim(tmp),trim(left\_int(i(j)))
83 \textcolor{keywordflow}{    enddo}
84 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_ab56b89fb51a387279afc68c85d30dca2}\label{namespacemom__string__functions_ab56b89fb51a387279afc68c85d30dca2}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!left\+\_\+real@{left\+\_\+real}}
\index{left\+\_\+real@{left\+\_\+real}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{left\+\_\+real()}{left\_real()}}
{\footnotesize\ttfamily character(len=32) function, public mom\+\_\+string\+\_\+functions\+::left\+\_\+real (\begin{DoxyParamCaption}\item[{real, intent(in)}]{val }\end{DoxyParamCaption})}



Returns a left-\/justified string with a real formatted like \textquotesingle{}(G)\textquotesingle{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em val} & The real variable to convert to a string\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output string 
\end{DoxyReturn}


Definition at line 89 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
89   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: val\textcolor{comment}{ !< The real variable to convert to a string}
90   \textcolor{keywordtype}{character(len=32)} :: left\_real\textcolor{comment}{ !< The output string}
91 
92   \textcolor{keywordtype}{integer} :: l, ind
93 
94   \textcolor{keywordflow}{if} ((abs(val) < 1.0e4) .and. (abs(val) >= 1.0e-3)) \textcolor{keywordflow}{then}
95     \textcolor{keyword}{write}(left\_real, \textcolor{stringliteral}{'(F30.11)'}) val
96     \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) \textcolor{keywordflow}{then}
97       \textcolor{keyword}{write}(left\_real, \textcolor{stringliteral}{'(F30.12)'}) val
98       \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) \textcolor{keywordflow}{then}
99         \textcolor{keyword}{write}(left\_real, \textcolor{stringliteral}{'(F30.13)'}) val
100         \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) \textcolor{keywordflow}{then}
101           \textcolor{keyword}{write}(left\_real, \textcolor{stringliteral}{'(F30.14)'}) val
102           \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) \textcolor{keywordflow}{then}
103             \textcolor{keyword}{write}(left\_real, \textcolor{stringliteral}{'(F30.15)'}) val
104             \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) \textcolor{keywordflow}{then}
105               \textcolor{keyword}{write}(left\_real, \textcolor{stringliteral}{'(F30.16)'}) val
106 \textcolor{keywordflow}{            endif}
107 \textcolor{keywordflow}{          endif}
108 \textcolor{keywordflow}{        endif}
109 \textcolor{keywordflow}{      endif}
110 \textcolor{keywordflow}{    endif}
111     \textcolor{keywordflow}{do}
112       l = len\_trim(left\_real)
113       \textcolor{keywordflow}{if} ((l<2) .or. (left\_real(l-1:l) == \textcolor{stringliteral}{".0"}) .or. &
114           (left\_real(l:l) /= \textcolor{stringliteral}{"0"})) \textcolor{keywordflow}{exit}
115       left\_real(l:l) = \textcolor{stringliteral}{" "}
116 \textcolor{keywordflow}{    enddo}
117   \textcolor{keywordflow}{elseif} (val == 0.) \textcolor{keywordflow}{then}
118     left\_real = \textcolor{stringliteral}{"0.0"}
119   \textcolor{keywordflow}{else}
120     \textcolor{keywordflow}{if} ((abs(val) <= 1.0e-100) .or. (abs(val) >= 1.0e100)) \textcolor{keywordflow}{then}
121       \textcolor{keyword}{write}(left\_real(1:32), \textcolor{stringliteral}{'(ES24.14E3)'}) val
122       \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) &
123         \textcolor{keyword}{write}(left\_real(1:32), \textcolor{stringliteral}{'(ES24.15E3)'}) val
124     \textcolor{keywordflow}{else}
125       \textcolor{keyword}{write}(left\_real(1:32), \textcolor{stringliteral}{'(ES23.14)'}) val
126       \textcolor{keywordflow}{if} (.not.isformattedfloatequalto(left\_real,val)) &
127         \textcolor{keyword}{write}(left\_real(1:32), \textcolor{stringliteral}{'(ES23.15)'}) val
128 \textcolor{keywordflow}{    endif}
129     \textcolor{keywordflow}{do}
130       ind = index(left\_real,\textcolor{stringliteral}{"0E"})
131       \textcolor{keywordflow}{if} (ind == 0) \textcolor{keywordflow}{exit}
132       \textcolor{keywordflow}{if} (left\_real(ind-1:ind-1) == \textcolor{stringliteral}{"."}) \textcolor{keywordflow}{exit}
133       left\_real = left\_real(1:ind-1)//left\_real(ind+1:)
134 \textcolor{keywordflow}{    enddo}
135 \textcolor{keywordflow}{  endif}
136   left\_real = adjustl(left\_real)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a07fa1b92ce5c4c4336bb45c5a89fa548}\label{namespacemom__string__functions_a07fa1b92ce5c4c4336bb45c5a89fa548}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!left\+\_\+reals@{left\+\_\+reals}}
\index{left\+\_\+reals@{left\+\_\+reals}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{left\+\_\+reals()}{left\_reals()}}
{\footnotesize\ttfamily character(len=1320) function, public mom\+\_\+string\+\_\+functions\+::left\+\_\+reals (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{r,  }\item[{character(len=$\ast$), intent(in), optional}]{sep }\end{DoxyParamCaption})}



Returns a character string of a comma-\/separated, compact formatted, reals e.\+g. \char`\"{}1., 2., 5$\ast$3., 5.\+E2\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em r} & The array of real variables to convert to a string\\
\hline
\mbox{\tt in}  & {\em sep} & The separator between successive values, by default it is \textquotesingle{}, \textquotesingle{}.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The output string 
\end{DoxyReturn}


Definition at line 142 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
142   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: r(:)\textcolor{comment}{ !< The array of real variables to convert to a string}
143   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: sep\textcolor{comment}{ !< The separator between}
144 \textcolor{comment}{                                    !! successive values, by default it is ', '.}
145   \textcolor{keywordtype}{character(len=1320)} :: left\_reals\textcolor{comment}{ !< The output string}
146 
147   \textcolor{keywordtype}{integer} :: j, n, b, ns
148   \textcolor{keywordtype}{logical} :: dowrite
149   \textcolor{keywordtype}{character(len=10)} :: separator
150 
151   n=1 ; dowrite=.true. ; left\_reals=\textcolor{stringliteral}{''} ; b=1
152   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(sep)) \textcolor{keywordflow}{then}
153     separator=sep ; ns=len(sep)
154   \textcolor{keywordflow}{else}
155     separator=\textcolor{stringliteral}{', '} ; ns=2
156 \textcolor{keywordflow}{  endif}
157   \textcolor{keywordflow}{do} j=1,\textcolor{keyword}{size}(r)
158     dowrite=.true.
159     \textcolor{keywordflow}{if} (j<\textcolor{keyword}{size}(r)) \textcolor{keywordflow}{then}
160       \textcolor{keywordflow}{if} (r(j)==r(j+1)) \textcolor{keywordflow}{then}
161         n=n+1
162         dowrite=.false.
163 \textcolor{keywordflow}{      endif}
164 \textcolor{keywordflow}{    endif}
165     \textcolor{keywordflow}{if} (dowrite) \textcolor{keywordflow}{then}
166       \textcolor{keywordflow}{if} (b>1) \textcolor{keywordflow}{then} \textcolor{comment}{! Write separator if a number has already been written}
167         \textcolor{keyword}{write}(left\_reals(b:),\textcolor{stringliteral}{'(A)'}) separator
168         b=b+ns
169 \textcolor{keywordflow}{      endif}
170       \textcolor{keywordflow}{if} (n>1) \textcolor{keywordflow}{then}
171         \textcolor{keyword}{write}(left\_reals(b:),\textcolor{stringliteral}{'(A,"*",A)'}) trim(left\_int(n)),trim(left\_real(r(j)))
172       \textcolor{keywordflow}{else}
173         \textcolor{keyword}{write}(left\_reals(b:),\textcolor{stringliteral}{'(A)'}) trim(left\_real(r(j)))
174 \textcolor{keywordflow}{      endif}
175       n=1 ; b=len\_trim(left\_reals)+1
176 \textcolor{keywordflow}{    endif}
177 \textcolor{keywordflow}{  enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a1ca01e01cf691da9ea4dd5c20ad81770}\label{namespacemom__string__functions_a1ca01e01cf691da9ea4dd5c20ad81770}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!localtesti@{localtesti}}
\index{localtesti@{localtesti}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{localtesti()}{localtesti()}}
{\footnotesize\ttfamily logical function mom\+\_\+string\+\_\+functions\+::localtesti (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose,  }\item[{integer, intent(in)}]{i1,  }\item[{integer, intent(in)}]{i2 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



True if i1 is not equal to i2. False otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em verbose} & If true, write results to stdout\\
\hline
\mbox{\tt in}  & {\em i1} & Integer\\
\hline
\mbox{\tt in}  & {\em i2} & Integer \\
\hline
\end{DoxyParams}


Definition at line 376 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
376   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}
377   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: i1\textcolor{comment}{ !< Integer}
378   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: i2\textcolor{comment}{ !< Integer}
379   localtesti=.false.
380   \textcolor{keywordflow}{if} (i1/=i2) localtesti=.true.
381   \textcolor{keywordflow}{if} (localtesti .or. verbose) \textcolor{keywordflow}{then}
382     \textcolor{keyword}{write}(stdout,*) i1,i2
383     \textcolor{keywordflow}{if} (localtesti) \textcolor{keywordflow}{then}
384       \textcolor{keyword}{write}(stdout,*) i1,\textcolor{stringliteral}{'!='},i2, \textcolor{stringliteral}{'<-- FAIL'}
385       \textcolor{keyword}{write}(stderr,*) i1,\textcolor{stringliteral}{'!='},i2, \textcolor{stringliteral}{'<-- FAIL'}
386 \textcolor{keywordflow}{    endif}
387 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a7ed3314f4fae014b9c35c321320063b2}\label{namespacemom__string__functions_a7ed3314f4fae014b9c35c321320063b2}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!localtestr@{localtestr}}
\index{localtestr@{localtestr}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{localtestr()}{localtestr()}}
{\footnotesize\ttfamily logical function mom\+\_\+string\+\_\+functions\+::localtestr (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose,  }\item[{real, intent(in)}]{r1,  }\item[{real, intent(in)}]{r2 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



True if r1 is not equal to r2. False otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em verbose} & If true, write results to stdout\\
\hline
\mbox{\tt in}  & {\em r1} & Float\\
\hline
\mbox{\tt in}  & {\em r2} & Float \\
\hline
\end{DoxyParams}


Definition at line 392 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
392   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}
393   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: r1\textcolor{comment}{ !< Float}
394   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: r2\textcolor{comment}{ !< Float}
395   localtestr=.false.
396   \textcolor{keywordflow}{if} (r1/=r2) localtestr=.true.
397   \textcolor{keywordflow}{if} (localtestr .or. verbose) \textcolor{keywordflow}{then}
398     \textcolor{keyword}{write}(stdout,*) r1,r2
399     \textcolor{keywordflow}{if} (localtestr) \textcolor{keywordflow}{then}
400       \textcolor{keyword}{write}(stdout,*) r1,\textcolor{stringliteral}{'!='},r2, \textcolor{stringliteral}{'<-- FAIL'}
401       \textcolor{keyword}{write}(stderr,*) r1,\textcolor{stringliteral}{'!='},r2, \textcolor{stringliteral}{'<-- FAIL'}
402 \textcolor{keywordflow}{    endif}
403 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a3f4583fac417ae45e370035ce0eecb04}\label{namespacemom__string__functions_a3f4583fac417ae45e370035ce0eecb04}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!localtests@{localtests}}
\index{localtests@{localtests}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{localtests()}{localtests()}}
{\footnotesize\ttfamily logical function mom\+\_\+string\+\_\+functions\+::localtests (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose,  }\item[{character(len=$\ast$), intent(in)}]{str1,  }\item[{character(len=$\ast$), intent(in)}]{str2 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



True if str1 does not match str2. False otherwise. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em verbose} & If true, write results to stdout\\
\hline
\mbox{\tt in}  & {\em str1} & String\\
\hline
\mbox{\tt in}  & {\em str2} & String \\
\hline
\end{DoxyParams}


Definition at line 360 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
360   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}
361   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: str1\textcolor{comment}{ !< String}
362   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: str2\textcolor{comment}{ !< String}
363   localtests=.false.
364   \textcolor{keywordflow}{if} (trim(str1)/=trim(str2)) localtests=.true.
365   \textcolor{keywordflow}{if} (localtests .or. verbose) \textcolor{keywordflow}{then}
366     \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'>'}//trim(str1)//\textcolor{stringliteral}{'<'}
367     \textcolor{keywordflow}{if} (localtests) \textcolor{keywordflow}{then}
368       \textcolor{keyword}{write}(stdout,*) trim(str1),\textcolor{stringliteral}{':'},trim(str2), \textcolor{stringliteral}{'<-- FAIL'}
369       \textcolor{keyword}{write}(stderr,*) trim(str1),\textcolor{stringliteral}{':'},trim(str2), \textcolor{stringliteral}{'<-- FAIL'}
370 \textcolor{keywordflow}{    endif}
371 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a4d76e9e8c2cd53f210b02006924a9212}\label{namespacemom__string__functions_a4d76e9e8c2cd53f210b02006924a9212}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!lowercase@{lowercase}}
\index{lowercase@{lowercase}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{lowercase()}{lowercase()}}
{\footnotesize\ttfamily character(len=len(input\+\_\+string)) function, public mom\+\_\+string\+\_\+functions\+::lowercase (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{input\+\_\+string }\end{DoxyParamCaption})}



Return a string in which all uppercase letters have been replaced by their lowercase counterparts. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em input\+\_\+string} & The string to modify\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The modified output string 
\end{DoxyReturn}


Definition at line 26 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
26   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{intent(in)} :: input\_string\textcolor{comment}{ !< The string to modify}
27   \textcolor{keywordtype}{character(len=len(input\_string))} :: lowercase\textcolor{comment}{ !< The modified output string}
28 \textcolor{comment}{!   This function returns a string in which all uppercase letters have been}
29 \textcolor{comment}{! replaced by their lowercase counterparts.  It is loosely based on the}
30 \textcolor{comment}{! lowercase function in mpp\_util.F90.}
31   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: co=iachar(\textcolor{stringliteral}{'a'})-iachar(\textcolor{stringliteral}{'A'}) \textcolor{comment}{! case offset}
32   \textcolor{keywordtype}{integer} :: k
33 
34   lowercase = input\_string
35   \textcolor{keywordflow}{do} k=1, len\_trim(input\_string)
36     \textcolor{keywordflow}{if} (lowercase(k:k) >= \textcolor{stringliteral}{'A'} .and. lowercase(k:k) <= \textcolor{stringliteral}{'Z'}) &
37         lowercase(k:k) = achar(ichar(lowercase(k:k))+co)
38 \textcolor{keywordflow}{  enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a60262e56f544e4613754df43bf50652e}\label{namespacemom__string__functions_a60262e56f544e4613754df43bf50652e}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!remove\+\_\+spaces@{remove\+\_\+spaces}}
\index{remove\+\_\+spaces@{remove\+\_\+spaces}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{remove\+\_\+spaces()}{remove\_spaces()}}
{\footnotesize\ttfamily character(len=120) function, public mom\+\_\+string\+\_\+functions\+::remove\+\_\+spaces (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{string }\end{DoxyParamCaption})}



Returns string with all spaces removed. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em string} & String to scan \\
\hline
\end{DoxyParams}


Definition at line 294 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
294   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)} :: string\textcolor{comment}{     !< String to scan}
295   \textcolor{comment}{! Local variables}
296   \textcolor{keywordtype}{integer} :: ns, i, o
297   \textcolor{keywordtype}{logical} :: lastcharisseperator
298   lastcharisseperator = .true.
299   ns = len\_trim(string)
300   i = 0; o = 0
301   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (i<ns)
302     i = i+1
303     \textcolor{keywordflow}{if} (string(i:i) /= \textcolor{stringliteral}{' '}) \textcolor{keywordflow}{then} \textcolor{comment}{! Copy character to output string}
304       o = o + 1
305       remove\_spaces(o:o) = string(i:i)
306 \textcolor{keywordflow}{    endif}
307 \textcolor{keywordflow}{  enddo}
308   \textcolor{keywordflow}{do} i = o+1, 120
309     remove\_spaces(i:i) = \textcolor{stringliteral}{' '} \textcolor{comment}{! Wipe any non-empty characters}
310 \textcolor{keywordflow}{  enddo}
311   remove\_spaces = trim(remove\_spaces)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_af18b819f6c6a917c57b9690d0580f642}\label{namespacemom__string__functions_af18b819f6c6a917c57b9690d0580f642}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!slasher@{slasher}}
\index{slasher@{slasher}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{slasher()}{slasher()}}
{\footnotesize\ttfamily character(len=len(dir)+2) function, public mom\+\_\+string\+\_\+functions\+::slasher (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{dir }\end{DoxyParamCaption})}



Returns a directory name that is terminated with a \char`\"{}/\char`\"{} or \char`\"{}./\char`\"{} if the argument is an empty string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em dir} & A directory to be terminated with a \char`\"{}/\char`\"{} or changed to \char`\"{}./\char`\"{} if it is blank. \\
\hline
\end{DoxyParams}


Definition at line 409 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
409   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: dir\textcolor{comment}{ !< A directory to be terminated with a "/"}
410 \textcolor{comment}{                                      !! or changed to "./" if it is blank.}
411   \textcolor{keywordtype}{character(len=len(dir)+2)} :: slasher
412 
413   \textcolor{keywordflow}{if} (len\_trim(dir) == 0) \textcolor{keywordflow}{then}
414     slasher = \textcolor{stringliteral}{"./"}
415   \textcolor{keywordflow}{elseif} (dir(len\_trim(dir):len\_trim(dir)) == \textcolor{stringliteral}{'/'}) \textcolor{keywordflow}{then}
416     slasher = trim(dir)
417   \textcolor{keywordflow}{else}
418     slasher = trim(dir)//\textcolor{stringliteral}{"/"}
419 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_a7b7aa802a4da2021801267f6c6f890bf}\label{namespacemom__string__functions_a7b7aa802a4da2021801267f6c6f890bf}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!string\+\_\+functions\+\_\+unit\+\_\+tests@{string\+\_\+functions\+\_\+unit\+\_\+tests}}
\index{string\+\_\+functions\+\_\+unit\+\_\+tests@{string\+\_\+functions\+\_\+unit\+\_\+tests}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{string\+\_\+functions\+\_\+unit\+\_\+tests()}{string\_functions\_unit\_tests()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+string\+\_\+functions\+::string\+\_\+functions\+\_\+unit\+\_\+tests (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose }\end{DoxyParamCaption})}



Returns true if a unit test of string\+\_\+functions fails. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em verbose} & If true, write results to stdout \\
\hline
\end{DoxyParams}


Definition at line 316 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
316   \textcolor{comment}{! Arguments}
317   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}
318   \textcolor{comment}{! Local variables}
319   \textcolor{keywordtype}{integer} :: i(5) = (/ -1, 1, 3, 3, 0 /)
320   \textcolor{keywordtype}{real} :: r(8) = (/ 0., 1., -2., 1.3, 3.e-11, 3.e-11, 3.e-11, -5.1e12 /)
321   \textcolor{keywordtype}{logical} :: fail, v
322   fail = .false.
323   v = verbose
324   \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'==== MOM\_string\_functions: string\_functions\_unit\_tests ==='}
325   fail = fail .or. localtests(v,left\_int(-1),\textcolor{stringliteral}{'-1'})
326   fail = fail .or. localtests(v,left\_ints(i(:)),\textcolor{stringliteral}{'-1, 1, 3, 3, 0'})
327   fail = fail .or. localtests(v,left\_real(0.),\textcolor{stringliteral}{'0.0'})
328   fail = fail .or. localtests(v,left\_reals(r(:)),\textcolor{stringliteral}{'0.0, 1.0, -2.0, 1.3, 3*3.0E-11, -5.1E+12'})
329   fail = fail .or. localtests(v,left\_reals(r(:),sep=\textcolor{stringliteral}{' '}),\textcolor{stringliteral}{'0.0 1.0 -2.0 1.3 3*3.0E-11 -5.1E+12'})
330   fail = fail .or. localtests(v,left\_reals(r(:),sep=\textcolor{stringliteral}{','}),\textcolor{stringliteral}{'0.0,1.0,-2.0,1.3,3*3.0E-11,-5.1E+12'})
331   fail = fail .or. localtests(v,extractword(\textcolor{stringliteral}{"One Two,Three"},1),\textcolor{stringliteral}{"One"})
332   fail = fail .or. localtests(v,extractword(\textcolor{stringliteral}{"One Two,Three"},2),\textcolor{stringliteral}{"Two"})
333   fail = fail .or. localtests(v,extractword(\textcolor{stringliteral}{"One Two,Three"},3),\textcolor{stringliteral}{"Three"})
334   fail = fail .or. localtests(v,extractword(\textcolor{stringliteral}{"One Two,  Three"},3),\textcolor{stringliteral}{"Three"})
335   fail = fail .or. localtests(v,extractword(\textcolor{stringliteral}{" One Two,Three"},1),\textcolor{stringliteral}{"One"})
336   fail = fail .or. localtests(v,extract\_word(\textcolor{stringliteral}{"One,Two,Three"},\textcolor{stringliteral}{","},3),\textcolor{stringliteral}{"Three"})
337   fail = fail .or. localtests(v,extract\_word(\textcolor{stringliteral}{"One,Two,Three"},\textcolor{stringliteral}{","},4),\textcolor{stringliteral}{""})
338   fail = fail .or. localtests(v,remove\_spaces(\textcolor{stringliteral}{"1 2 3"}),\textcolor{stringliteral}{"123"})
339   fail = fail .or. localtests(v,remove\_spaces(\textcolor{stringliteral}{" 1 2 3"}),\textcolor{stringliteral}{"123"})
340   fail = fail .or. localtests(v,remove\_spaces(\textcolor{stringliteral}{"1 2 3 "}),\textcolor{stringliteral}{"123"})
341   fail = fail .or. localtests(v,remove\_spaces(\textcolor{stringliteral}{"123"}),\textcolor{stringliteral}{"123"})
342   fail = fail .or. localtests(v,remove\_spaces(\textcolor{stringliteral}{" "}),\textcolor{stringliteral}{""})
343   fail = fail .or. localtests(v,remove\_spaces(\textcolor{stringliteral}{""}),\textcolor{stringliteral}{""})
344   fail = fail .or. localtesti(v,extract\_integer(\textcolor{stringliteral}{"1"},\textcolor{stringliteral}{""},1),1)
345   fail = fail .or. localtesti(v,extract\_integer(\textcolor{stringliteral}{"1,2,3"},\textcolor{stringliteral}{","},1),1)
346   fail = fail .or. localtesti(v,extract\_integer(\textcolor{stringliteral}{"1,2"},\textcolor{stringliteral}{","},2),2)
347   fail = fail .or. localtesti(v,extract\_integer(\textcolor{stringliteral}{"1,2"},\textcolor{stringliteral}{","},3),0)
348   fail = fail .or. localtesti(v,extract\_integer(\textcolor{stringliteral}{"1,2"},\textcolor{stringliteral}{","},4,4),4)
349   fail = fail .or. localtestr(v,extract\_real(\textcolor{stringliteral}{"1."},\textcolor{stringliteral}{""},1),1.)
350   fail = fail .or. localtestr(v,extract\_real(\textcolor{stringliteral}{"1.,2.,3."},\textcolor{stringliteral}{","},1),1.)
351   fail = fail .or. localtestr(v,extract\_real(\textcolor{stringliteral}{"1.,2."},\textcolor{stringliteral}{","},2),2.)
352   fail = fail .or. localtestr(v,extract\_real(\textcolor{stringliteral}{"1.,2."},\textcolor{stringliteral}{","},3),0.)
353   fail = fail .or. localtestr(v,extract\_real(\textcolor{stringliteral}{"1.,2."},\textcolor{stringliteral}{","},4,4.),4.)
354   \textcolor{keywordflow}{if} (.not. fail) \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'Pass'}
355   string\_functions\_unit\_tests = fail
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__string__functions_aca148baf726de2f028b7e7baad3c85d4}\label{namespacemom__string__functions_aca148baf726de2f028b7e7baad3c85d4}} 
\index{mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}!uppercase@{uppercase}}
\index{uppercase@{uppercase}!mom\+\_\+string\+\_\+functions@{mom\+\_\+string\+\_\+functions}}
\subsubsection{\texorpdfstring{uppercase()}{uppercase()}}
{\footnotesize\ttfamily character(len=len(input\+\_\+string)) function, public mom\+\_\+string\+\_\+functions\+::uppercase (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{input\+\_\+string }\end{DoxyParamCaption})}



Return a string in which all uppercase letters have been replaced by their lowercase counterparts. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em input\+\_\+string} & The string to modify\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The modified output string 
\end{DoxyReturn}


Definition at line 44 of file M\+O\+M\+\_\+string\+\_\+functions.\+F90.


\begin{DoxyCode}
44   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{intent(in)} :: input\_string\textcolor{comment}{ !< The string to modify}
45   \textcolor{keywordtype}{character(len=len(input\_string))} :: uppercase\textcolor{comment}{ !< The modified output string}
46 \textcolor{comment}{!   This function returns a string in which all lowercase letters have been}
47 \textcolor{comment}{! replaced by their uppercase counterparts.  It is loosely based on the}
48 \textcolor{comment}{! uppercase function in mpp\_util.F90.}
49   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: co=iachar(\textcolor{stringliteral}{'A'})-iachar(\textcolor{stringliteral}{'a'}) \textcolor{comment}{! case offset}
50   \textcolor{keywordtype}{integer} :: k
51 
52   uppercase = input\_string
53   \textcolor{keywordflow}{do} k=1, len\_trim(input\_string)
54     \textcolor{keywordflow}{if} (uppercase(k:k) >= \textcolor{stringliteral}{'a'} .and. uppercase(k:k) <= \textcolor{stringliteral}{'z'}) &
55         uppercase(k:k) = achar(ichar(uppercase(k:k))+co)
56 \textcolor{keywordflow}{  enddo}
\end{DoxyCode}
