\hypertarget{namespacemom__random}{}\section{mom\+\_\+random Module Reference}
\label{namespacemom__random}\index{mom\+\_\+random@{mom\+\_\+random}}


\subsection{Detailed Description}
Provides gridded random number capability. 

Provides M\+O\+M6 wrappers to the F\+MS implementation of the Mersenne twister.

Example usage\+: 
\begin{DoxyCode}
\textcolor{keywordtype}{type}(prng) :: rng
\textcolor{keywordtype}{real} :: rn
\textcolor{keyword}{call }random\_0d\_constructor(rng, time, seed) \textcolor{comment}{! Call this each time-step}
rn = random\_01(rng)
rn = random\_norm(rng)

\textcolor{keywordtype}{type}(prng) :: rng
\textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)} :: rn2d
\textcolor{keyword}{call }random\_2d\_constructor(rng, hi, time, seed) \textcolor{comment}{! Call this each time-step}
\textcolor{keyword}{call }random\_2d\_01(rng, hi, rn2d)
\textcolor{keyword}{call }random\_2d\_norm(rng, hi, rn2d)

note: reproducibility across restarts is implemented by using time-derived
seeds to pass to the mersenne twister. it is therefore important that any
prng \textcolor{keyword}{type} be re-initialized each time-step.
\end{DoxyCode}
 \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__random_1_1prng}{prng}
\begin{DoxyCompactList}\small\item\em Container for pseudo-\/random number generators. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
real function, public \hyperlink{namespacemom__random_a4a2b88d7b2768f18897efac819791bc7}{random\+\_\+01} (CS)
\begin{DoxyCompactList}\small\item\em Returns a random number between 0 and 1. \end{DoxyCompactList}\item 
real function, public \hyperlink{namespacemom__random_a9eac722032e06d49179558722d133cc6}{random\+\_\+norm} (CS)
\begin{DoxyCompactList}\small\item\em Returns an approximately normally distributed random number with mean 0 and variance 1. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__random_ad3a0c1bdadf5248234717987e6733bd0}{random\+\_\+2d\+\_\+01} (CS, HI, rand)
\begin{DoxyCompactList}\small\item\em Generates random numbers between 0 and 1 for each cell of the model grid. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__random_a3a029841b8ea26fc4cbd182a83700c39}{random\+\_\+2d\+\_\+norm} (CS, HI, rand)
\begin{DoxyCompactList}\small\item\em Returns an approximately normally distributed random number with mean 0 and variance 1 for each cell of the model grid. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__random_ad6fd0718a45b6896bbb40a58b7ca3499}{random\+\_\+0d\+\_\+constructor} (CS, Time, seed)
\begin{DoxyCompactList}\small\item\em Constructor for scalar P\+R\+NG. Can be used to reset the sequence. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__random_ae69c41901903bc31dccf0d4fa122ae9c}{random\+\_\+2d\+\_\+constructor} (CS, HI, Time, seed)
\begin{DoxyCompactList}\small\item\em Constructor for gridded P\+R\+NG. Can be used to reset the sequence. \end{DoxyCompactList}\item 
integer function \hyperlink{namespacemom__random_a48fc0d0eab640dedd565d14603e5b85c}{seed\+\_\+from\+\_\+time} (Time)
\begin{DoxyCompactList}\small\item\em Return a seed derived as hash of values in Time. \end{DoxyCompactList}\item 
integer function \hyperlink{namespacemom__random_a8605064631f07f3a7e9704422732c81c}{seed\+\_\+from\+\_\+index} (HI, i, j)
\begin{DoxyCompactList}\small\item\em Create seed from position index. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__random_abf96abc7e4ff0bd1a5a9016127669197}{random\+\_\+destruct} (CS)
\begin{DoxyCompactList}\small\item\em Destructor for P\+R\+NG. \end{DoxyCompactList}\item 
logical function, public \hyperlink{namespacemom__random_a9c1ce606b5ca91a6a550302aa5a552ae}{random\+\_\+unit\+\_\+tests} (verbose)
\begin{DoxyCompactList}\small\item\em Runs some statistical tests on the P\+R\+NG. \end{DoxyCompactList}\item 
logical function \hyperlink{namespacemom__random_a32dd7680a649486b9b96efc7c21ee7a1}{test\+\_\+fn} (verbose, good, label, rvalue, ivalue)
\begin{DoxyCompactList}\small\item\em Convenience function for reporting result of test. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__random_a4a2b88d7b2768f18897efac819791bc7}\label{namespacemom__random_a4a2b88d7b2768f18897efac819791bc7}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+01@{random\+\_\+01}}
\index{random\+\_\+01@{random\+\_\+01}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+01()}{random\_01()}}
{\footnotesize\ttfamily real function, public mom\+\_\+random\+::random\+\_\+01 (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), intent(inout)}]{CS }\end{DoxyParamCaption})}



Returns a random number between 0 and 1. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Container for pseudo-\/random number generators \\
\hline
\end{DoxyParams}


Definition at line 43 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
43   \textcolor{keywordtype}{type}(prng), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< Container for pseudo-random number generators}
44 
45   random\_01 = getrandomreal(cs%stream0d)
46 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_ad6fd0718a45b6896bbb40a58b7ca3499}\label{namespacemom__random_ad6fd0718a45b6896bbb40a58b7ca3499}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+0d\+\_\+constructor@{random\+\_\+0d\+\_\+constructor}}
\index{random\+\_\+0d\+\_\+constructor@{random\+\_\+0d\+\_\+constructor}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+0d\+\_\+constructor()}{random\_0d\_constructor()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+random\+::random\+\_\+0d\+\_\+constructor (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), intent(inout)}]{CS,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{integer, intent(in)}]{seed }\end{DoxyParamCaption})}



Constructor for scalar P\+R\+NG. Can be used to reset the sequence. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Container for pseudo-\/random number generators\\
\hline
\mbox{\tt in}  & {\em time} & Current model time\\
\hline
\mbox{\tt in}  & {\em seed} & Seed for P\+R\+NG \\
\hline
\end{DoxyParams}


Definition at line 102 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
102   \textcolor{keywordtype}{type}(prng),      \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{   !< Container for pseudo-random number generators}
103   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< Current model time}
104   \textcolor{keywordtype}{integer},         \textcolor{keywordtype}{intent(in)}    :: seed\textcolor{comment}{ !< Seed for PRNG}
105   \textcolor{comment}{! Local variables}
106   \textcolor{keywordtype}{integer} :: tseed
107 
108   tseed = seed\_from\_time(time)
109   tseed = ieor(tseed, seed)
110   cs%stream0d = new\_randomnumbersequence(tseed)
111 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_ad3a0c1bdadf5248234717987e6733bd0}\label{namespacemom__random_ad3a0c1bdadf5248234717987e6733bd0}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+2d\+\_\+01@{random\+\_\+2d\+\_\+01}}
\index{random\+\_\+2d\+\_\+01@{random\+\_\+2d\+\_\+01}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+2d\+\_\+01()}{random\_2d\_01()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+random\+::random\+\_\+2d\+\_\+01 (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), intent(inout)}]{CS,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{real, dimension( hi \%isd\+: hi \%ied, hi \%jsd\+: hi \%jed), intent(out)}]{rand }\end{DoxyParamCaption})}



Generates random numbers between 0 and 1 for each cell of the model grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Container for pseudo-\/random number generators\\
\hline
\mbox{\tt in}  & {\em hi} & Horizontal index structure\\
\hline
\mbox{\tt out}  & {\em rand} & Random numbers between 0 and 1 \\
\hline
\end{DoxyParams}


Definition at line 64 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
64   \textcolor{keywordtype}{type}(prng),           \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< Container for pseudo-random number generators}
65   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}    :: hi\textcolor{comment}{ !< Horizontal index structure}
66   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(HI),SZJ\_(HI))}, \textcolor{keywordtype}{intent(out)} :: rand\textcolor{comment}{ !< Random numbers between 0 and 1}
67   \textcolor{comment}{! Local variables}
68   \textcolor{keywordtype}{integer} :: i,j
69 
70   \textcolor{keywordflow}{do} j = hi%jsd,hi%jed
71     \textcolor{keywordflow}{do} i = hi%isd,hi%ied
72       rand(i,j) = getrandomreal( cs%stream2d(i,j) )
73 \textcolor{keywordflow}{    enddo}
74 \textcolor{keywordflow}{  enddo}
75 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_ae69c41901903bc31dccf0d4fa122ae9c}\label{namespacemom__random_ae69c41901903bc31dccf0d4fa122ae9c}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+2d\+\_\+constructor@{random\+\_\+2d\+\_\+constructor}}
\index{random\+\_\+2d\+\_\+constructor@{random\+\_\+2d\+\_\+constructor}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+2d\+\_\+constructor()}{random\_2d\_constructor()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+random\+::random\+\_\+2d\+\_\+constructor (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), intent(inout)}]{CS,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{integer, intent(in)}]{seed }\end{DoxyParamCaption})}



Constructor for gridded P\+R\+NG. Can be used to reset the sequence. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Container for pseudo-\/random number generators\\
\hline
\mbox{\tt in}  & {\em hi} & Horizontal index structure\\
\hline
\mbox{\tt in}  & {\em time} & Current model time\\
\hline
\mbox{\tt in}  & {\em seed} & Seed for P\+R\+NG \\
\hline
\end{DoxyParams}


Definition at line 116 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
116   \textcolor{keywordtype}{type}(prng),           \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{   !< Container for pseudo-random number generators}
117   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}    :: hi\textcolor{comment}{   !< Horizontal index structure}
118   \textcolor{keywordtype}{type}(time\_type),      \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< Current model time}
119   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)}    :: seed\textcolor{comment}{ !< Seed for PRNG}
120   \textcolor{comment}{! Local variables}
121   \textcolor{keywordtype}{integer} :: i,j,sseed,tseed
122 
123   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{allocated}(cs%stream2d)) \textcolor{keyword}{allocate}( cs%stream2d(hi%isd:hi%ied,hi%jsd:hi%jed) )
124 
125   tseed = seed\_from\_time(time)
126   tseed = ieor(tseed*9007, seed)
127   \textcolor{keywordflow}{do} j = hi%jsd,hi%jed
128     \textcolor{keywordflow}{do} i = hi%isd,hi%ied
129       sseed = seed\_from\_index(hi, i, j)
130       sseed = ieor(tseed, sseed*7993)
131       cs%stream2d(i,j) = new\_randomnumbersequence(sseed)
132 \textcolor{keywordflow}{    enddo}
133 \textcolor{keywordflow}{  enddo}
134 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_a3a029841b8ea26fc4cbd182a83700c39}\label{namespacemom__random_a3a029841b8ea26fc4cbd182a83700c39}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+2d\+\_\+norm@{random\+\_\+2d\+\_\+norm}}
\index{random\+\_\+2d\+\_\+norm@{random\+\_\+2d\+\_\+norm}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+2d\+\_\+norm()}{random\_2d\_norm()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+random\+::random\+\_\+2d\+\_\+norm (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), intent(inout)}]{CS,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{real, dimension( hi \%isd\+: hi \%ied, hi \%jsd\+: hi \%jed), intent(out)}]{rand }\end{DoxyParamCaption})}



Returns an approximately normally distributed random number with mean 0 and variance 1 for each cell of the model grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Container for pseudo-\/random number generators\\
\hline
\mbox{\tt in}  & {\em hi} & Horizontal index structure\\
\hline
\mbox{\tt out}  & {\em rand} & Random numbers between 0 and 1 \\
\hline
\end{DoxyParams}


Definition at line 81 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
81   \textcolor{keywordtype}{type}(prng),           \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< Container for pseudo-random number generators}
82   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}    :: hi\textcolor{comment}{ !< Horizontal index structure}
83   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(HI),SZJ\_(HI))}, \textcolor{keywordtype}{intent(out)} :: rand\textcolor{comment}{ !< Random numbers between 0 and 1}
84   \textcolor{comment}{! Local variables}
85   \textcolor{keywordtype}{integer} :: i,j,n
86 
87   \textcolor{keywordflow}{do} j = hi%jsd,hi%jed
88     \textcolor{keywordflow}{do} i = hi%isd,hi%ied
89       rand(i,j) = getrandomreal( cs%stream2d(i,j) ) - 0.5
90 \textcolor{keywordflow}{    enddo}
91     \textcolor{keywordflow}{do} n = 1,11
92       \textcolor{keywordflow}{do} i = hi%isd,hi%ied
93         rand(i,j) = rand(i,j) + ( getrandomreal( cs%stream2d(i,j) ) - 0.5 )
94 \textcolor{keywordflow}{      enddo}
95 \textcolor{keywordflow}{    enddo}
96 \textcolor{keywordflow}{  enddo}
97 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_abf96abc7e4ff0bd1a5a9016127669197}\label{namespacemom__random_abf96abc7e4ff0bd1a5a9016127669197}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+destruct@{random\+\_\+destruct}}
\index{random\+\_\+destruct@{random\+\_\+destruct}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+destruct()}{random\_destruct()}}
{\footnotesize\ttfamily subroutine mom\+\_\+random\+::random\+\_\+destruct (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Destructor for P\+R\+NG. 


\begin{DoxyParams}{Parameters}
{\em cs} & Container for pseudo-\/random number generators \\
\hline
\end{DoxyParams}


Definition at line 176 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
176   \textcolor{keywordtype}{type}(prng), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< Container for pseudo-random number generators}
177 
178   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%stream2d)) \textcolor{keyword}{deallocate}(cs%stream2d)
179   \textcolor{comment}{!deallocate(CS)}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_a9eac722032e06d49179558722d133cc6}\label{namespacemom__random_a9eac722032e06d49179558722d133cc6}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+norm@{random\+\_\+norm}}
\index{random\+\_\+norm@{random\+\_\+norm}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+norm()}{random\_norm()}}
{\footnotesize\ttfamily real function, public mom\+\_\+random\+::random\+\_\+norm (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__random_1_1prng}{prng}), intent(inout)}]{CS }\end{DoxyParamCaption})}



Returns an approximately normally distributed random number with mean 0 and variance 1. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Container for pseudo-\/random number generators \\
\hline
\end{DoxyParams}


Definition at line 51 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
51   \textcolor{keywordtype}{type}(prng), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{ !< Container for pseudo-random number generators}
52   \textcolor{comment}{! Local variables}
53   \textcolor{keywordtype}{integer} :: i
54 
55   random\_norm = getrandomreal(cs%stream0d) - 0.5
56   \textcolor{keywordflow}{do} i = 1,11
57     random\_norm = random\_norm + ( getrandomreal(cs%stream0d) - 0.5 )
58 \textcolor{keywordflow}{  enddo}
59 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_a9c1ce606b5ca91a6a550302aa5a552ae}\label{namespacemom__random_a9c1ce606b5ca91a6a550302aa5a552ae}} 
\index{mom\+\_\+random@{mom\+\_\+random}!random\+\_\+unit\+\_\+tests@{random\+\_\+unit\+\_\+tests}}
\index{random\+\_\+unit\+\_\+tests@{random\+\_\+unit\+\_\+tests}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{random\+\_\+unit\+\_\+tests()}{random\_unit\_tests()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+random\+::random\+\_\+unit\+\_\+tests (\begin{DoxyParamCaption}\item[{logical}]{verbose }\end{DoxyParamCaption})}



Runs some statistical tests on the P\+R\+NG. 


\begin{DoxyParams}{Parameters}
{\em verbose} & True if results should be written to stdout \\
\hline
\end{DoxyParams}


Definition at line 184 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
184   \textcolor{keywordtype}{logical} :: verbose\textcolor{comment}{ !< True if results should be written to stdout}
185   \textcolor{comment}{! Local variables}
186   \textcolor{keywordtype}{type}(prng) :: test\_rng \textcolor{comment}{! Generator}
187   \textcolor{keywordtype}{type}(time\_type) :: time \textcolor{comment}{! Model time}
188   \textcolor{keywordtype}{real} :: r1, r2, r3 \textcolor{comment}{! Some random numbers and re-used work variables}
189   \textcolor{keywordtype}{real} :: mean, var, ar1, std \textcolor{comment}{! Some statistics}
190   \textcolor{keywordtype}{integer} :: stdunit \textcolor{comment}{! For messages}
191   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: n\_samples = 800
192   \textcolor{keywordtype}{integer} :: i, j, ni, nj
193   \textcolor{comment}{! Fake being on a decomposed domain}
194   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: hi => null() \textcolor{comment}{!< Not the real HI}
195   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable} :: r2d \textcolor{comment}{! Random numbers}
196 
197   \textcolor{comment}{! Fake a decomposed domain}
198   ni = 6
199   nj = 9
200   \textcolor{keyword}{allocate}(hi)
201   hi%isd = 0
202   hi%ied = ni+1
203   hi%jsd = 0
204   hi%jed = nj+1
205   hi%niglobal = ni
206   hi%njglobal = nj
207   hi%idg\_offset = 0
208   hi%jdg\_offset = 0
209 
210   random\_unit\_tests = .false.
211   stdunit = stdout
212   \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,a)'}) \textcolor{stringliteral}{'==== MOM\_random: random\_unit\_tests ======================='}
213 
214   \textcolor{keywordflow}{if} (verbose) \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'-- Time-based seeds ---------------------'}
215   \textcolor{comment}{! Check time-based seed generation}
216   time = set\_date(1903, 11, 21, 13, 47, 29)
217   i = seed\_from\_time(time)
218   random\_unit\_tests = random\_unit\_tests .or. &
219       test\_fn(verbose, i==212584341, \textcolor{stringliteral}{'time seed 1903/11/21 13:47:29'}, ivalue=i)
220   time = set\_date(1903, 11, 22, 13, 47, 29)
221   i = seed\_from\_time(time)
222   random\_unit\_tests = random\_unit\_tests .or.&
223        test\_fn(verbose, i==212584342, \textcolor{stringliteral}{'time seed 1903/11/22 13:47:29'}, ivalue=i)
224   time = set\_date(1903, 11, 21, 13, 47, 30)
225   i = seed\_from\_time(time)
226   random\_unit\_tests = random\_unit\_tests .or.&
227        test\_fn(verbose, i==212596634, \textcolor{stringliteral}{'time seed 1903/11/21 13:47:30'}, ivalue=i)
228 
229   \textcolor{keywordflow}{if} (verbose) \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'-- PRNG tests ---------------------------'}
230   \textcolor{comment}{! Generate a random number, r1}
231   \textcolor{keyword}{call }random\_0d\_constructor(test\_rng, time, 1)
232   r1 = random\_01(test\_rng)
233   random\_unit\_tests = random\_unit\_tests .or. &
234        test\_fn(verbose, abs(r1-4.75310122e-2)<1.e-9, \textcolor{stringliteral}{'first call'}, r1)
235 
236   \textcolor{comment}{! Check that we get a different number, r2, on a second call}
237   r2 = random\_01(test\_rng)
238   random\_unit\_tests = random\_unit\_tests .or. &
239        test\_fn(verbose, abs(r2-2.71289742e-1)<1.e-9, \textcolor{stringliteral}{'consecutive test'}, r2)
240 
241   \textcolor{comment}{! Check that we can reproduce r1 by resetting the seed}
242   \textcolor{keyword}{call }random\_0d\_constructor(test\_rng, time, 1)
243   r2 = random\_01(test\_rng)
244   random\_unit\_tests = random\_unit\_tests .or. &
245        test\_fn(verbose, abs(r2-r1)==0., \textcolor{stringliteral}{'reproduce test'}, r2)
246 
247   \textcolor{comment}{! Check that we get a different number, r2, with a different seed but same date}
248   \textcolor{keyword}{call }random\_0d\_constructor(test\_rng, time, 2)
249   r2 = random\_01(test\_rng)
250   random\_unit\_tests = random\_unit\_tests .or. &
251        test\_fn(verbose, abs(r2-7.15508473e-1)<1.e-9, \textcolor{stringliteral}{'different seed test'}, r2)
252 
253   \textcolor{comment}{! Check that we get a different number, r2, for a different date but same seed}
254   time = set\_date(1903, 11, 21, 13, 0, 29)
255   \textcolor{keyword}{call }random\_0d\_constructor(test\_rng, time, 1)
256   r2 = random\_01(test\_rng)
257   random\_unit\_tests = random\_unit\_tests .or. &
258        test\_fn(verbose, abs(r2-9.56667163e-1)<1.e-9, \textcolor{stringliteral}{'different date test'}, r2)
259 
260   \textcolor{keywordflow}{if} (verbose) \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'-- index-based seeds --------------------'}
261   \textcolor{comment}{! Check index-based seed}
262   i = seed\_from\_index(hi,1,1)
263   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, i==1, \textcolor{stringliteral}{'seed from index (1,1)'}, ivalue=i)
264   j = seed\_from\_index(hi,ni+1,1)
265   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, j==i, \textcolor{stringliteral}{'seed from index (n+1,1)'}, ivalue=j)
266   i = seed\_from\_index(hi,ni,1)
267   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, i==6, \textcolor{stringliteral}{'seed from index (n,1)'}, ivalue=i)
268   j = seed\_from\_index(hi,0,1)
269   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, j==i, \textcolor{stringliteral}{'seed from index (0,1)'}, ivalue=j)
270   i = seed\_from\_index(hi,1,nj)
271   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, i==49, \textcolor{stringliteral}{'seed from index (1,n)'}, ivalue=i)
272   j = seed\_from\_index(hi,ni,nj+1)
273   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, j==i, \textcolor{stringliteral}{'seed from index (n,n+1)'}, ivalue=j)
274   i = seed\_from\_index(hi,ni,nj)
275   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, i==54, \textcolor{stringliteral}{'seed from index (n,n)'}, ivalue=i)
276   j = seed\_from\_index(hi,1,nj+1)
277   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, j==i, \textcolor{stringliteral}{'seed from index (1,n+1)'}, ivalue=j)
278 
279   \textcolor{keywordflow}{if} (.not.random\_unit\_tests) \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,a)'}) \textcolor{stringliteral}{'Passed unit tests'}
280   \textcolor{comment}{! The rest of these are not unit tests but statistical tests and as such}
281   \textcolor{comment}{! could fail for different sample sizes but happen to pass here.}
282 
283   \textcolor{comment}{! Check statistics of large samples for uniform generator}
284   mean = 0. ; var = 0. ; ar1 = 0. ; r2 = 0.
285   \textcolor{keywordflow}{do} i = 1, n\_samples
286     r1 = random\_01(test\_rng) - 0.5
287     mean = mean + r1
288     var = var + r1**2
289     ar1 = ar1 + r1*r2
290     r2 = r1 \textcolor{comment}{! Keep copy of last value}
291 \textcolor{keywordflow}{  enddo}
292   mean = mean / \textcolor{keywordtype}{real(n\_samples)} \textcolor{comment}{! Expected mean is 0}
293   var = var / \textcolor{keywordtype}{real(n\_samples)} \textcolor{comment}{! Expected variance is 1/12}
294   ar1 = ar1 / \textcolor{keywordtype}{real(n\_samples-1)} \textcolor{comment}{! Autocovariance}
295   std = sqrt(var) \textcolor{comment}{! Expected std is sqrt(1/12)}
296   r2 = mean*sqrt(\textcolor{keywordtype}{real}(12*n\_samples)) \textcolor{comment}{! Normalized error in mean}
297   r3 = std*sqrt(12.) \textcolor{comment}{! Normalized standard deviation}
298   r1 = ( ar1 * sqrt(\textcolor{keywordtype}{real}(n\_samples-1)) ) / var
299   \textcolor{keywordflow}{if} (verbose) \textcolor{keywordflow}{then}
300     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'-- Uniform -0.5 .. 0.5 generator --------'}
301     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'mean ='},mean,\textcolor{stringliteral}{'std ='},std,\textcolor{stringliteral}{'AR1 ='},ar1
302     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'norm. mean ='},r2, &
303                                              \textcolor{stringliteral}{'norm. std ='},r3,\textcolor{stringliteral}{'norm. AR1 ='},r1
304 \textcolor{keywordflow}{  endif}
305   random\_unit\_tests = random\_unit\_tests .or. &
306                       test\_fn(verbose, abs(r2)<2., &
307                               \textcolor{stringliteral}{'n>>1, mean within 2 sigma [uniform]'}, r2)
308   random\_unit\_tests = random\_unit\_tests .or. &
309                       test\_fn(verbose, abs(r3-1.)<1./sqrt(\textcolor{keywordtype}{real}(n\_samples)), &
310                               \textcolor{stringliteral}{'n>>1, std ~ 1/sqrt(12) [uniform]'}, r3-1.)
311   random\_unit\_tests = random\_unit\_tests .or. &
312                       test\_fn(verbose, abs(r1)<2., &
313                               \textcolor{stringliteral}{'n>>1, AR1 < std/sqrt(n) [uniform]'}, r1)
314 
315   \textcolor{comment}{! Check statistics of large samples for normal generator}
316   mean = 0. ; var = 0. ; ar1 = 0. ; r2 = 0.
317   \textcolor{keywordflow}{do} i = 1, n\_samples
318     r1 = random\_norm(test\_rng)
319     mean = mean + r1
320     var = var + r1**2
321     ar1 = ar1 + r1*r2
322     r2 = r1 \textcolor{comment}{! Keep copy of last value for AR calculation}
323 \textcolor{keywordflow}{  enddo}
324   mean = mean / \textcolor{keywordtype}{real}(n\_samples)
325   var = var / \textcolor{keywordtype}{real}(n\_samples)
326   ar1 = ar1 / \textcolor{keywordtype}{real}(n\_samples)
327   std = sqrt(var)
328   r3 = 1./sqrt(\textcolor{keywordtype}{real}(n\_samples)) \textcolor{comment}{! Standard error of mean}
329   r2 = mean*sqrt(\textcolor{keywordtype}{real}(n\_samples)) \textcolor{comment}{! Normalized error in mean}
330   r3 = std \textcolor{comment}{! Normalized standard deviation}
331   r1 = ( ar1 * sqrt(\textcolor{keywordtype}{real}(n\_samples-1)) ) / var
332   \textcolor{keywordflow}{if} (verbose) \textcolor{keywordflow}{then}
333     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'-- Normal distribution generator --------'}
334     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'mean ='},mean,\textcolor{stringliteral}{'std ='},std,\textcolor{stringliteral}{'AR1 ='},ar1
335     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'norm. error in mean ='},r2, &
336                                              \textcolor{stringliteral}{'norm. standard deviation ='},r3,\textcolor{stringliteral}{'norm. AR1 ='},r1
337 \textcolor{keywordflow}{  endif}
338   random\_unit\_tests = random\_unit\_tests .or. &
339                       test\_fn(verbose, abs(r2)<2., &
340                               \textcolor{stringliteral}{'n>>1, mean within 2 sigma [norm]'}, r2)
341   random\_unit\_tests = random\_unit\_tests .or. &
342                       test\_fn(verbose, abs(r3-1.)<1./sqrt(\textcolor{keywordtype}{real}(n\_samples)), &
343                               \textcolor{stringliteral}{'n>>1, std ~ 1 [norm]'}, r3-1.)
344   random\_unit\_tests = random\_unit\_tests .or. &
345                       test\_fn(verbose, abs(r1)<2., &
346                               \textcolor{stringliteral}{'n>>1, AR1 < std/sqrt(n) [norm]'}, r1)
347 
348   \textcolor{keywordflow}{if} (verbose) \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'-- 2d PRNG ------------------------------'}
349   \textcolor{comment}{! Check 2d random number generator 0..1}
350   \textcolor{keyword}{allocate}( r2d(hi%isd:hi%ied,hi%jsd:hi%jed) )
351   \textcolor{keyword}{call }random\_2d\_constructor(test\_rng, hi, time, 123)
352   r2d(:,:) = -999. \textcolor{comment}{! Use -9. to detect unset values}
353   \textcolor{keyword}{call }random\_2d\_01(test\_rng, hi, r2d)
354   \textcolor{keywordflow}{if} (any(abs(r2d(:,:)+999.)<=0.)) random\_unit\_tests=.true.
355   r1 = minval(r2d)
356   r2 = maxval(r2d)
357   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, r1>=0., \textcolor{stringliteral}{'2d all set'}, r1)
358   random\_unit\_tests = random\_unit\_tests .or. test\_fn(verbose, r2<=1., \textcolor{stringliteral}{'2d all valid'}, r2)
359   mean = sum( r2d(1:ni,1:nj) - 0.5 )/\textcolor{keywordtype}{real}(ni*nj)
360   var = sum( (r2d(1:ni,1:nj) - 0.5 - mean)**2 )/\textcolor{keywordtype}{real}(ni*nj)
361   std = sqrt(var)
362   r3 = 1./sqrt(\textcolor{keywordtype}{real}(12*ni*nj)) \textcolor{comment}{! Standard error of mean}
363   r2 = mean*sqrt(\textcolor{keywordtype}{real}(12*ni*nj)) \textcolor{comment}{! Normalized error in mean}
364   r3 = std*sqrt(12.) \textcolor{comment}{! Normalized standard deviation}
365   \textcolor{keywordflow}{if} (verbose) \textcolor{keywordflow}{then}
366     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'2D uniform 0..1 generator'}
367     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'mean ='},mean,\textcolor{stringliteral}{'std ='},std
368     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'norm. error in mean ='},r2
369     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'norm. standard deviation ='},r3
370 \textcolor{keywordflow}{  endif}
371   random\_unit\_tests = random\_unit\_tests .or. &
372                       test\_fn(verbose, abs(r2)<2., &
373                               \textcolor{stringliteral}{'2d, mean within 2 sigma [uniform]'}, r2)
374   random\_unit\_tests = random\_unit\_tests .or. &
375                       test\_fn(verbose, abs(r3-1.)<1./sqrt(\textcolor{keywordtype}{real}(ni*nj)), &
376                               \textcolor{stringliteral}{'2d, std ~ 1/sqrt(12) [uniform]'}, r3-1.)
377   \textcolor{keywordflow}{if} (verbose) \textcolor{keywordflow}{then}
378     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random:")'})
379     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random:",8f8.5)'}) r2d
380     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random:")'})
381 \textcolor{keywordflow}{  endif}
382 
383   \textcolor{comment}{! Check 2d normal random number generator}
384   \textcolor{keyword}{call }random\_2d\_norm(test\_rng, hi, r2d)
385   mean = sum( r2d(1:ni,1:nj) )/\textcolor{keywordtype}{real}(ni*nj)
386   var = sum( r2d(1:ni,1:nj)**2 )/\textcolor{keywordtype}{real}(ni*nj)
387   std = sqrt(var)
388   r3 = 1./sqrt(\textcolor{keywordtype}{real}(ni*nj)) \textcolor{comment}{! Standard error of mean}
389   r2 = mean*sqrt(\textcolor{keywordtype}{real}(ni*nj)) \textcolor{comment}{! Normalized error in mean}
390   r3 = std \textcolor{comment}{! Normalized standard deviation}
391   \textcolor{keywordflow}{if} (verbose) \textcolor{keywordflow}{then}
392     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a)'}) \textcolor{stringliteral}{'2D normal generator'}
393     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'mean ='},mean,\textcolor{stringliteral}{'std ='},std
394     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'norm. error in mean ='},r2
395     \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,"random: ",a,f12.9)'}) \textcolor{stringliteral}{'norm. standard deviation ='},r3
396 \textcolor{keywordflow}{  endif}
397   random\_unit\_tests = random\_unit\_tests .or. &
398                       test\_fn(verbose, abs(r2)<2., &
399                               \textcolor{stringliteral}{'2d, mean within 2 sigma [norm]'}, r2)
400   random\_unit\_tests = random\_unit\_tests .or. &
401                       test\_fn(verbose, abs(r3-1.)<1./sqrt(\textcolor{keywordtype}{real}(ni*nj)), &
402                               \textcolor{stringliteral}{'2d, std ~ 1/sqrt(12) [norm]'}, r3-1.)
403 
404   \textcolor{comment}{! Clean up}
405   \textcolor{keyword}{deallocate}(r2d)
406   \textcolor{keyword}{deallocate}(hi)
407 
408   \textcolor{keywordflow}{if} (.not.random\_unit\_tests) \textcolor{keyword}{write}(stdunit,\textcolor{stringliteral}{'(1x,a)'}) \textcolor{stringliteral}{'Passed statistical tests'}
409 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_a8605064631f07f3a7e9704422732c81c}\label{namespacemom__random_a8605064631f07f3a7e9704422732c81c}} 
\index{mom\+\_\+random@{mom\+\_\+random}!seed\+\_\+from\+\_\+index@{seed\+\_\+from\+\_\+index}}
\index{seed\+\_\+from\+\_\+index@{seed\+\_\+from\+\_\+index}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{seed\+\_\+from\+\_\+index()}{seed\_from\_index()}}
{\footnotesize\ttfamily integer function mom\+\_\+random\+::seed\+\_\+from\+\_\+index (\begin{DoxyParamCaption}\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{integer, intent(in)}]{i,  }\item[{integer, intent(in)}]{j }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Create seed from position index. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & Horizontal index structure\\
\hline
\mbox{\tt in}  & {\em i} & i-\/index (of h-\/cell)\\
\hline
\mbox{\tt in}  & {\em j} & j-\/index (of h-\/cell) \\
\hline
\end{DoxyParams}


Definition at line 155 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
155   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} :: hi\textcolor{comment}{ !< Horizontal index structure}
156   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)} :: i\textcolor{comment}{ !< i-index (of h-cell)}
157   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)} :: j\textcolor{comment}{ !< j-index (of h-cell)}
158   \textcolor{comment}{! Local variables}
159   \textcolor{keywordtype}{integer} :: ig, jg, ni, nj, ij
160 
161   ni = hi%niglobal
162   nj = hi%njglobal
163   \textcolor{comment}{! Periodicity is assumed here but does not break non-periodic models}
164   ig = mod(hi%idg\_offset + i - 1 + ni, ni)+1
165   jg = max(hi%jdg\_offset + j, 0)
166   \textcolor{keywordflow}{if} (jg>nj) \textcolor{keywordflow}{then} \textcolor{comment}{! Tri-polar hard-coded until we put needed info in HI **TODO**}
167     jg = 2*nj+1-jg
168     ig = ni+1-ig
169 \textcolor{keywordflow}{  endif}
170   seed\_from\_index = ig + ni*(jg-1)
171 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_a48fc0d0eab640dedd565d14603e5b85c}\label{namespacemom__random_a48fc0d0eab640dedd565d14603e5b85c}} 
\index{mom\+\_\+random@{mom\+\_\+random}!seed\+\_\+from\+\_\+time@{seed\+\_\+from\+\_\+time}}
\index{seed\+\_\+from\+\_\+time@{seed\+\_\+from\+\_\+time}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{seed\+\_\+from\+\_\+time()}{seed\_from\_time()}}
{\footnotesize\ttfamily integer function mom\+\_\+random\+::seed\+\_\+from\+\_\+time (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Return a seed derived as hash of values in Time. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & Current model time \\
\hline
\end{DoxyParams}


Definition at line 139 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
139   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< Current model time}
140   \textcolor{comment}{! Local variables}
141   \textcolor{keywordtype}{integer} :: yr,mo,dy,hr,mn,sc,s1,s2
142 
143   \textcolor{keyword}{call }get\_date(time,yr,mo,dy,hr,mn,sc)
144   s1 = sc + 61*(mn + 61*hr) + 379 \textcolor{comment}{! Range 379 .. 89620}
145   \textcolor{comment}{! Fun fact: 2147483647 is the eighth Mersenne prime.}
146   \textcolor{comment}{! This is not the reason for using 2147483647 here. It is the}
147   \textcolor{comment}{! largest integer of kind=4.}
148   s2 = modulo(dy + 32*(mo + 13*yr), 2147483647\_4) \textcolor{comment}{! Range 0 .. 2147483646}
149   seed\_from\_time = ieor(s1*4111, s2)
150 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__random_a32dd7680a649486b9b96efc7c21ee7a1}\label{namespacemom__random_a32dd7680a649486b9b96efc7c21ee7a1}} 
\index{mom\+\_\+random@{mom\+\_\+random}!test\+\_\+fn@{test\+\_\+fn}}
\index{test\+\_\+fn@{test\+\_\+fn}!mom\+\_\+random@{mom\+\_\+random}}
\subsubsection{\texorpdfstring{test\+\_\+fn()}{test\_fn()}}
{\footnotesize\ttfamily logical function mom\+\_\+random\+::test\+\_\+fn (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose,  }\item[{logical, intent(in)}]{good,  }\item[{character(len=$\ast$), intent(in)}]{label,  }\item[{real, intent(in), optional}]{rvalue,  }\item[{integer, intent(in), optional}]{ivalue }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Convenience function for reporting result of test. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em verbose} & Verbosity\\
\hline
\mbox{\tt in}  & {\em good} & True if pass, false otherwise\\
\hline
\mbox{\tt in}  & {\em label} & Label for messages\\
\hline
\mbox{\tt in}  & {\em rvalue} & Result of calculation\\
\hline
\mbox{\tt in}  & {\em ivalue} & Result of calculation \\
\hline
\end{DoxyParams}


Definition at line 414 of file M\+O\+M\+\_\+random.\+F90.


\begin{DoxyCode}
414   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< Verbosity}
415   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)} :: good\textcolor{comment}{ !< True if pass, false otherwise}
416   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: label\textcolor{comment}{ !< Label for messages}
417   \textcolor{keywordtype}{real},             \textcolor{keywordtype}{intent(in)} :: rvalue\textcolor{comment}{ !< Result of calculation}
418   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: ivalue\textcolor{comment}{ !< Result of calculation}
419   \textcolor{keywordtype}{optional} :: rvalue, ivalue
420 
421   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ivalue)) \textcolor{keywordflow}{then}
422     \textcolor{keywordflow}{if} (.not. good) \textcolor{keywordflow}{then}
423       \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(1x,a,i10,1x,a,a)'}) \textcolor{stringliteral}{'random: result ='},ivalue,label,\textcolor{stringliteral}{' <------- FAIL!'}
424       \textcolor{keyword}{write}(stderr,\textcolor{stringliteral}{'(1x,a,i10,1x,a,a)'}) \textcolor{stringliteral}{'random: result ='},ivalue,label,\textcolor{stringliteral}{' <------- FAIL!'}
425     \textcolor{keywordflow}{elseif} (verbose) \textcolor{keywordflow}{then}
426       \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(1x,a,i10,1x,a)'}) \textcolor{stringliteral}{'random: result ='},ivalue,label
427 \textcolor{keywordflow}{    endif}
428   \textcolor{keywordflow}{else}
429     \textcolor{keywordflow}{if} (.not. good) \textcolor{keywordflow}{then}
430       \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(1x,a,1pe15.8,1x,a,a)'}) \textcolor{stringliteral}{'random: result ='},rvalue,label,\textcolor{stringliteral}{' <------- FAIL!'}
431       \textcolor{keyword}{write}(stderr,\textcolor{stringliteral}{'(1x,a,1pe15.8,1x,a,a)'}) \textcolor{stringliteral}{'random: result ='},rvalue,label,\textcolor{stringliteral}{' <------- FAIL!'}
432     \textcolor{keywordflow}{elseif} (verbose) \textcolor{keywordflow}{then}
433       \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(1x,a,1pe15.8,1x,a)'}) \textcolor{stringliteral}{'random: result ='},rvalue,label
434 \textcolor{keywordflow}{    endif}
435 \textcolor{keywordflow}{  endif}
436   test\_fn = .not. good
437 
\end{DoxyCode}
