\hypertarget{namespacemom__write__cputime}{}\doxysection{mom\+\_\+write\+\_\+cputime Module Reference}
\label{namespacemom__write__cputime}\index{mom\_write\_cputime@{mom\_write\_cputime}}


\doxysubsection{Detailed Description}
A module to monitor the overall C\+PU time used by M\+O\+M6 and project when to stop the model. 

By Robert Hallberg, May 2006.

This file contains the subroutine (write\+\_\+cputime) that writes the summed C\+PU time across all processors to an output file. In addition, write\+\_\+cputime estimates how many more time steps can be taken before 95\% of the available C\+PU time is used, so that the model can be checkpointed at that time. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__write__cputime_1_1write__cputime__cs}{write\+\_\+cputime\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em A control structure that regulates the writing of C\+PU time. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__write__cputime_aa95b991e5550816440480e52a61a50ee}{write\+\_\+cputime\+\_\+start\+\_\+clock}} (CS)
\begin{DoxyCompactList}\small\item\em Evaluate the C\+PU time returned by S\+Y\+S\+T\+E\+M\+\_\+\+C\+L\+O\+CK at the start of a run. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__write__cputime_a0228cbfaec6f37997e2fd42124d87fda}{mom\+\_\+write\+\_\+cputime\+\_\+init}} (param\+\_\+file, directory, Input\+\_\+start\+\_\+time, CS)
\begin{DoxyCompactList}\small\item\em Initialize the M\+O\+M\+\_\+write\+\_\+cputime module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__write__cputime_a9e65987c6c974dd7c1c5021239f7df90}{mom\+\_\+write\+\_\+cputime\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Close the M\+O\+M\+\_\+write\+\_\+cputime module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__write__cputime_a4a996420163b5e4985b83ba03652b69d}{write\+\_\+cputime}} (day, n, CS, nmax, call\+\_\+end)
\begin{DoxyCompactList}\small\item\em This subroutine assesses how much C\+PU time the model has taken and determines how long the model should be run before it saves a restart file and stops itself. Optionally this may also be used to trigger this module\textquotesingle{}s end routine. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__write__cputime_a37ecb378297ff61d70e35b0b295a214e}\label{namespacemom__write__cputime_a37ecb378297ff61d70e35b0b295a214e}} 
integer \mbox{\hyperlink{namespacemom__write__cputime_a37ecb378297ff61d70e35b0b295a214e}{clocks\+\_\+per\+\_\+sec}} = 1000
\begin{DoxyCompactList}\small\item\em The number of clock cycles per second, used by the system clock. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__write__cputime_a6ac4322a83898c01ec5e8e2ffc22f7cd}\label{namespacemom__write__cputime_a6ac4322a83898c01ec5e8e2ffc22f7cd}} 
integer \mbox{\hyperlink{namespacemom__write__cputime_a6ac4322a83898c01ec5e8e2ffc22f7cd}{max\+\_\+ticks}} = 1000
\begin{DoxyCompactList}\small\item\em The number of ticks per second, used by the system clock. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__write__cputime_a9e65987c6c974dd7c1c5021239f7df90}\label{namespacemom__write__cputime_a9e65987c6c974dd7c1c5021239f7df90}} 
\index{mom\_write\_cputime@{mom\_write\_cputime}!mom\_write\_cputime\_end@{mom\_write\_cputime\_end}}
\index{mom\_write\_cputime\_end@{mom\_write\_cputime\_end}!mom\_write\_cputime@{mom\_write\_cputime}}
\doxysubsubsection{\texorpdfstring{mom\_write\_cputime\_end()}{mom\_write\_cputime\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+write\+\_\+cputime\+::mom\+\_\+write\+\_\+cputime\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__write__cputime_1_1write__cputime__cs}{write\+\_\+cputime\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Close the M\+O\+M\+\_\+write\+\_\+cputime module. 


\begin{DoxyParams}{Parameters}
{\em cs} & The control structure set up by a previous call to M\+O\+M\+\_\+write\+\_\+cputime\+\_\+init. \\
\hline
\end{DoxyParams}


Definition at line 105 of file M\+O\+M\+\_\+write\+\_\+cputime.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{106   \textcolor{keywordtype}{type}(write\_cputime\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{    !< The control structure set up by a previous}}
\DoxyCodeLine{107 \textcolor{comment}{                                              !! call to MOM\_write\_cputime\_init.}}
\DoxyCodeLine{108 }
\DoxyCodeLine{109   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{110 }
\DoxyCodeLine{111   \textcolor{comment}{! Flush and close the output files.}}
\DoxyCodeLine{112   \textcolor{keywordflow}{if} (is\_root\_pe() .and. cs\%fileCPU\_ascii > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{113     \textcolor{keyword}{call }flush(cs\%fileCPU\_ascii)}
\DoxyCodeLine{114     \textcolor{keyword}{call }close\_file(cs\%fileCPU\_ascii)}
\DoxyCodeLine{115 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{116 }
\DoxyCodeLine{117   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{118 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__write__cputime_a0228cbfaec6f37997e2fd42124d87fda}\label{namespacemom__write__cputime_a0228cbfaec6f37997e2fd42124d87fda}} 
\index{mom\_write\_cputime@{mom\_write\_cputime}!mom\_write\_cputime\_init@{mom\_write\_cputime\_init}}
\index{mom\_write\_cputime\_init@{mom\_write\_cputime\_init}!mom\_write\_cputime@{mom\_write\_cputime}}
\doxysubsubsection{\texorpdfstring{mom\_write\_cputime\_init()}{mom\_write\_cputime\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+write\+\_\+cputime\+::mom\+\_\+write\+\_\+cputime\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{character(len=$\ast$), intent(in)}]{directory,  }\item[{type(time\+\_\+type), intent(in)}]{Input\+\_\+start\+\_\+time,  }\item[{type(\mbox{\hyperlink{structmom__write__cputime_1_1write__cputime__cs}{write\+\_\+cputime\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initialize the M\+O\+M\+\_\+write\+\_\+cputime module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in}}  & {\em directory} & The directory where the C\+PU time file goes. \\
\hline
\mbox{\texttt{ in}}  & {\em input\+\_\+start\+\_\+time} & The start model time of the simulation. \\
\hline
 & {\em cs} & A pointer that may be set to point to the control structure for this module. \\
\hline
\end{DoxyParams}


Definition at line 54 of file M\+O\+M\+\_\+write\+\_\+cputime.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{55   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{56   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)} :: directory\textcolor{comment}{  !< The directory where the CPU time file goes.}}
\DoxyCodeLine{57   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(in)} :: Input\_start\_time\textcolor{comment}{ !< The start model time of the simulation.}}
\DoxyCodeLine{58   \textcolor{keywordtype}{type}(write\_cputime\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< A pointer that may be set to point to the}}
\DoxyCodeLine{59 \textcolor{comment}{                                                   !! control structure for this module.}}
\DoxyCodeLine{60 }
\DoxyCodeLine{61   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{62   \textcolor{keywordtype}{integer} :: new\_cputime   \textcolor{comment}{! The CPU time returned by SYSTEM\_CLOCK}}
\DoxyCodeLine{63   \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{64 \textcolor{preprocessor}{\# include "{}version\_variable.h"{}}}
\DoxyCodeLine{65 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{'MOM\_write\_cputime'}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{66   \textcolor{keywordtype}{logical} :: all\_default   \textcolor{comment}{! If true, all parameters are using their default values.}}
\DoxyCodeLine{67 }
\DoxyCodeLine{68   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{69     \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{70     \textcolor{keyword}{call }system\_clock(new\_cputime, clocks\_per\_sec, max\_ticks)}
\DoxyCodeLine{71     cs\%prev\_cputime = new\_cputime}
\DoxyCodeLine{72 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{73 }
\DoxyCodeLine{74   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{75 }
\DoxyCodeLine{76   \textcolor{comment}{! Determine whether all paramters are set to their default values.}}
\DoxyCodeLine{77   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}MAXCPU"{}}, cs\%maxcpu, default=-\/1.0, do\_not\_log=.true.)}
\DoxyCodeLine{78   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}CPU\_TIME\_FILE"{}}, cs\%CPUfile, default=\textcolor{stringliteral}{"{}CPU\_stats"{}}, do\_not\_log=.true.)}
\DoxyCodeLine{79   all\_default = (cs\%maxcpu == -\/1.0) .and. (trim(cs\%CPUfile) == trim(\textcolor{stringliteral}{"{}CPU\_stats"{}}))}
\DoxyCodeLine{80 }
\DoxyCodeLine{81   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{"{}"{}}, all\_default=all\_default)}
\DoxyCodeLine{82   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}MAXCPU"{}}, cs\%maxcpu, \&}
\DoxyCodeLine{83                  \textcolor{stringliteral}{"{}The maximum amount of cpu time per processor for which "{}}//\&}
\DoxyCodeLine{84                  \textcolor{stringliteral}{"{}MOM should run before saving a restart file and "{}}//\&}
\DoxyCodeLine{85                  \textcolor{stringliteral}{"{}quitting with a return value that indicates that a "{}}//\&}
\DoxyCodeLine{86                  \textcolor{stringliteral}{"{}further run is required to complete the simulation. "{}}//\&}
\DoxyCodeLine{87                  \textcolor{stringliteral}{"{}If automatic restarts are not desired, use a negative "{}}//\&}
\DoxyCodeLine{88                  \textcolor{stringliteral}{"{}value for MAXCPU.  MAXCPU has units of wall-\/clock "{}}//\&}
\DoxyCodeLine{89                  \textcolor{stringliteral}{"{}seconds, so the actual CPU time used is larger by a "{}}//\&}
\DoxyCodeLine{90                  \textcolor{stringliteral}{"{}factor of the number of processors used."{}}, \&}
\DoxyCodeLine{91                  units=\textcolor{stringliteral}{"{}wall-\/clock seconds"{}}, default=-\/1.0)}
\DoxyCodeLine{92   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}CPU\_TIME\_FILE"{}}, cs\%CPUfile, \&}
\DoxyCodeLine{93                  \textcolor{stringliteral}{"{}The file into which CPU time is written."{}},default=\textcolor{stringliteral}{"{}CPU\_stats"{}})}
\DoxyCodeLine{94   cs\%CPUfile = trim(directory)//trim(cs\%CPUfile)}
\DoxyCodeLine{95   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"{}directory/CPU\_TIME\_FILE"{}}, cs\%CPUfile)}
\DoxyCodeLine{96 \textcolor{preprocessor}{\#ifdef STATSLABEL}}
\DoxyCodeLine{97 \textcolor{preprocessor}{}  cs\%CPUfile = trim(cs\%CPUfile)//\textcolor{stringliteral}{"{}."{}}//trim(adjustl(statslabel))}
\DoxyCodeLine{98 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{99 \textcolor{preprocessor}{}}
\DoxyCodeLine{100   cs\%Start\_time = input\_start\_time}
\DoxyCodeLine{101 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__write__cputime_a4a996420163b5e4985b83ba03652b69d}\label{namespacemom__write__cputime_a4a996420163b5e4985b83ba03652b69d}} 
\index{mom\_write\_cputime@{mom\_write\_cputime}!write\_cputime@{write\_cputime}}
\index{write\_cputime@{write\_cputime}!mom\_write\_cputime@{mom\_write\_cputime}}
\doxysubsubsection{\texorpdfstring{write\_cputime()}{write\_cputime()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+write\+\_\+cputime\+::write\+\_\+cputime (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(inout)}]{day,  }\item[{integer, intent(in)}]{n,  }\item[{type(\mbox{\hyperlink{structmom__write__cputime_1_1write__cputime__cs}{write\+\_\+cputime\+\_\+cs}}), pointer}]{CS,  }\item[{integer, intent(inout), optional}]{nmax,  }\item[{logical, intent(in), optional}]{call\+\_\+end }\end{DoxyParamCaption})}



This subroutine assesses how much C\+PU time the model has taken and determines how long the model should be run before it saves a restart file and stops itself. Optionally this may also be used to trigger this module\textquotesingle{}s end routine. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em day} & The current model time. \\
\hline
\mbox{\texttt{ in}}  & {\em n} & The time step number of the current execution. \\
\hline
 & {\em cs} & The control structure set up by a previous call to M\+O\+M\+\_\+write\+\_\+cputime\+\_\+init. \\
\hline
\mbox{\texttt{ in,out}}  & {\em nmax} & The number of iterations after which to stop so that the simulation will not run out of C\+PU time. \\
\hline
\mbox{\texttt{ in}}  & {\em call\+\_\+end} & If true, also call M\+O\+M\+\_\+write\+\_\+cputime\+\_\+end. \\
\hline
\end{DoxyParams}


Definition at line 124 of file M\+O\+M\+\_\+write\+\_\+cputime.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{125   \textcolor{keywordtype}{type}(time\_type),        \textcolor{keywordtype}{intent(inout)} :: day\textcolor{comment}{  !< The current model time.}}
\DoxyCodeLine{126   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}    :: n\textcolor{comment}{    !< The time step number of the current execution.}}
\DoxyCodeLine{127   \textcolor{keywordtype}{type}(write\_cputime\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< The control structure set up by a previous}}
\DoxyCodeLine{128 \textcolor{comment}{                                                !! call to MOM\_write\_cputime\_init.}}
\DoxyCodeLine{129   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: nmax\textcolor{comment}{ !< The number of iterations after which to stop so}}
\DoxyCodeLine{130 \textcolor{comment}{                                                !! that the simulation will not run out of CPU time.}}
\DoxyCodeLine{131   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: call\_end\textcolor{comment}{ !< If true, also call MOM\_write\_cputime\_end.}}
\DoxyCodeLine{132 }
\DoxyCodeLine{133   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{134 \textcolor{keywordtype}{  real}    :: d\_cputime     \textcolor{comment}{! The change in CPU time since the last call}}
\DoxyCodeLine{135                            \textcolor{comment}{! this subroutine.}}
\DoxyCodeLine{136   \textcolor{keywordtype}{integer} :: new\_cputime   \textcolor{comment}{! The CPU time returned by SYSTEM\_CLOCK}}
\DoxyCodeLine{137 \textcolor{keywordtype}{  real}    :: reday         \textcolor{comment}{! A real version of day.}}
\DoxyCodeLine{138   \textcolor{keywordtype}{character(len=256)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{139   \textcolor{keywordtype}{integer} :: start\_of\_day, num\_days}
\DoxyCodeLine{140 }
\DoxyCodeLine{141   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{142          \textcolor{stringliteral}{"{}write\_energy: Module must be initialized before it is used."{}})}
\DoxyCodeLine{143 }
\DoxyCodeLine{144   \textcolor{keyword}{call }system\_clock(new\_cputime, clocks\_per\_sec, max\_ticks)}
\DoxyCodeLine{145 \textcolor{comment}{!   The following lines extract useful information even if the clock has rolled}}
\DoxyCodeLine{146 \textcolor{comment}{! over, assuming a 32-\/bit SYSTEM\_CLOCK.  With more bits, rollover is essentially}}
\DoxyCodeLine{147 \textcolor{comment}{! impossible. Negative fluctuations of less than 10 seconds are not interpreted}}
\DoxyCodeLine{148 \textcolor{comment}{! as the clock rolling over.  This should be unnecessary but is sometimes needed}}
\DoxyCodeLine{149 \textcolor{comment}{! on the GFDL SGI/O3k.}}
\DoxyCodeLine{150   \textcolor{keywordflow}{if} (new\_cputime < cs\%prev\_cputime-\/(10.0*clocks\_per\_sec)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{151     d\_cputime = new\_cputime -\/ cs\%prev\_cputime + max\_ticks}
\DoxyCodeLine{152   \textcolor{keywordflow}{else}}
\DoxyCodeLine{153     d\_cputime = new\_cputime -\/ cs\%prev\_cputime}
\DoxyCodeLine{154 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{155 }
\DoxyCodeLine{156   \textcolor{keyword}{call }sum\_across\_pes(d\_cputime)}
\DoxyCodeLine{157   \textcolor{keywordflow}{if} (cs\%previous\_calls == 0) cs\%startup\_cputime = d\_cputime}
\DoxyCodeLine{158 }
\DoxyCodeLine{159   cs\%cputime2 = cs\%cputime2 + d\_cputime}
\DoxyCodeLine{160 }
\DoxyCodeLine{161   \textcolor{keywordflow}{if} ((cs\%previous\_calls >= 1) .and. (cs\%maxcpu > 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{162     \textcolor{comment}{! Determine the slowest rate at which time steps are executed.}}
\DoxyCodeLine{163     \textcolor{keywordflow}{if} ((n > cs\%prev\_n) .and. (d\_cputime > 0.0) .and. \&}
\DoxyCodeLine{164         ((cs\%dn\_dcpu\_min*d\_cputime < (n -\/ cs\%prev\_n)) .or. \&}
\DoxyCodeLine{165          (cs\%dn\_dcpu\_min < 0.0))) \&}
\DoxyCodeLine{166       cs\%dn\_dcpu\_min = (n -\/ cs\%prev\_n) / d\_cputime}
\DoxyCodeLine{167     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(nmax) .and. (cs\%dn\_dcpu\_min >= 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{168       \textcolor{comment}{! Have the model stop itself after 95\% of the CPU time has been used.}}
\DoxyCodeLine{169       nmax = n + int( cs\%dn\_dcpu\_min * \&}
\DoxyCodeLine{170           (0.95*cs\%maxcpu * real(num\_pes())*clocks\_per\_sec -\/ \&}
\DoxyCodeLine{171            (cs\%startup\_cputime + cs\%cputime2)) )}
\DoxyCodeLine{172 \textcolor{comment}{!     write(mesg,*) "{}Resetting nmax to "{},nmax,"{} at day"{},reday}}
\DoxyCodeLine{173 \textcolor{comment}{!     call MOM\_mesg(mesg)}}
\DoxyCodeLine{174 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{175 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{176   cs\%prev\_cputime = new\_cputime ; cs\%prev\_n = n}
\DoxyCodeLine{177 }
\DoxyCodeLine{178   \textcolor{keyword}{call }get\_time(day, start\_of\_day, num\_days)}
\DoxyCodeLine{179   reday = real(num\_days)+ (real(start\_of\_day)/86400.0)}
\DoxyCodeLine{180 }
\DoxyCodeLine{181   \textcolor{comment}{!  Reopen or create a text output file.}}
\DoxyCodeLine{182   \textcolor{keywordflow}{if} ((cs\%previous\_calls == 0) .and. (is\_root\_pe())) \textcolor{keywordflow}{then}}
\DoxyCodeLine{183     \textcolor{keywordflow}{if} (day > cs\%Start\_time) \textcolor{keywordflow}{then}}
\DoxyCodeLine{184       \textcolor{keyword}{call }open\_file(cs\%fileCPU\_ascii, trim(cs\%CPUfile), \&}
\DoxyCodeLine{185                      action=append\_file, form=ascii\_file, nohdrs=.true.)}
\DoxyCodeLine{186     \textcolor{keywordflow}{else}}
\DoxyCodeLine{187       \textcolor{keyword}{call }open\_file(cs\%fileCPU\_ascii, trim(cs\%CPUfile), \&}
\DoxyCodeLine{188                      action=writeonly\_file, form=ascii\_file, nohdrs=.true.)}
\DoxyCodeLine{189 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{190 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{191 }
\DoxyCodeLine{192   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}}
\DoxyCodeLine{193     \textcolor{keywordflow}{if} (cs\%previous\_calls == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{194       \textcolor{keyword}{write}(cs\%fileCPU\_ascii, \&}
\DoxyCodeLine{195         \textcolor{stringliteral}{'("{}Startup CPU time: "{}, F12.3, "{} sec summed across"{}, I5, "{} PEs."{})'}) \&}
\DoxyCodeLine{196                             (cs\%startup\_cputime / clocks\_per\_sec), num\_pes()}
\DoxyCodeLine{197       \textcolor{keyword}{write}(cs\%fileCPU\_ascii,*)\textcolor{stringliteral}{"{}        Day, Step number,     CPU time, CPU time change"{}}}
\DoxyCodeLine{198 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{199     \textcolor{keyword}{write}(cs\%fileCPU\_ascii,\textcolor{stringliteral}{'(F12.3,"{}, "{}I11,"{}, "{}, F12.3,"{}, "{}, F12.3)'}) \&}
\DoxyCodeLine{200            reday, n, (cs\%cputime2 / real(clocks\_per\_sec)), \&}
\DoxyCodeLine{201            d\_cputime / real(clocks\_per\_sec)}
\DoxyCodeLine{202 }
\DoxyCodeLine{203     \textcolor{keyword}{call }flush(cs\%fileCPU\_ascii)}
\DoxyCodeLine{204 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{205   cs\%previous\_calls = cs\%previous\_calls + 1}
\DoxyCodeLine{206 }
\DoxyCodeLine{207   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(call\_end)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{208     \textcolor{keywordflow}{if} (call\_end) \textcolor{keyword}{call }mom\_write\_cputime\_end(cs)}
\DoxyCodeLine{209 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{210 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__write__cputime_aa95b991e5550816440480e52a61a50ee}\label{namespacemom__write__cputime_aa95b991e5550816440480e52a61a50ee}} 
\index{mom\_write\_cputime@{mom\_write\_cputime}!write\_cputime\_start\_clock@{write\_cputime\_start\_clock}}
\index{write\_cputime\_start\_clock@{write\_cputime\_start\_clock}!mom\_write\_cputime@{mom\_write\_cputime}}
\doxysubsubsection{\texorpdfstring{write\_cputime\_start\_clock()}{write\_cputime\_start\_clock()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+write\+\_\+cputime\+::write\+\_\+cputime\+\_\+start\+\_\+clock (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__write__cputime_1_1write__cputime__cs}{write\+\_\+cputime\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Evaluate the C\+PU time returned by S\+Y\+S\+T\+E\+M\+\_\+\+C\+L\+O\+CK at the start of a run. 


\begin{DoxyParams}{Parameters}
{\em cs} & The control structure set up by a previous call to M\+O\+M\+\_\+write\+\_\+cputime\+\_\+init. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}{0}
\DoxyCodeLine{44   \textcolor{keywordtype}{type}(write\_cputime\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< The control structure set up by a previous}}
\DoxyCodeLine{45 \textcolor{comment}{                                        !! call to MOM\_write\_cputime\_init.}}
\DoxyCodeLine{46   \textcolor{keywordtype}{integer} :: new\_cputime   \textcolor{comment}{! The CPU time returned by SYSTEM\_CLOCK}}
\DoxyCodeLine{47   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{48 }
\DoxyCodeLine{49   \textcolor{keyword}{call }system\_clock(new\_cputime, clocks\_per\_sec, max\_ticks)}
\DoxyCodeLine{50   cs\%prev\_cputime = new\_cputime}

\end{DoxyCode}
