\hypertarget{namespacemom}{}\section{mom Module Reference}
\label{namespacemom}\index{mom@{mom}}


The central module of the M\+O\+M6 ocean model.  


\subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}
\begin{DoxyCompactList}\small\item\em Control structure for the M\+OM module, including the variables that describe the state of the ocean. \end{DoxyCompactList}\item 
type \hyperlink{structmom_1_1mom__diag__ids}{mom\+\_\+diag\+\_\+ids}
\begin{DoxyCompactList}\small\item\em A structure with diagnostic I\+Ds of the state variables. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom} (forces\+\_\+in, fluxes\+\_\+in, sfc\+\_\+state, Time\+\_\+start, time\+\_\+int\+\_\+in, CS, Waves, do\+\_\+dynamics, do\+\_\+thermodynamics, start\+\_\+cycle, end\+\_\+cycle, cycle\+\_\+length, reset\+\_\+therm)
\begin{DoxyCompactList}\small\item\em This subroutine orchestrates the time stepping of M\+OM. The adiabatic dynamics are stepped by calls to one of the step\+\_\+\+M\+O\+M\+\_\+dyn\+\_\+...routines. The action of lateral processes on tracers occur in calls to advect\+\_\+tracer and tracer\+\_\+hordiff. Vertical mixing and possibly remapping occur inside of diabatic. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics} (forces, p\+\_\+surf\+\_\+begin, p\+\_\+surf\+\_\+end, dt, dt\+\_\+thermo, bbl\+\_\+time\+\_\+int, CS, Time\+\_\+local, Waves)
\begin{DoxyCompactList}\small\item\em Time step the ocean dynamics, including the momentum and continuity equations. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn} (CS, G, GV, US, h, Time\+\_\+local)
\begin{DoxyCompactList}\small\item\em step\+\_\+\+M\+O\+M\+\_\+tracer\+\_\+dyn does tracer advection and lateral diffusion, bringing the tracers up to date with the changes in state due to the dynamics. Surface sources and sinks and remapping are handled via step\+\_\+\+M\+O\+M\+\_\+thermo. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo} (CS, G, GV, US, u, v, h, tv, fluxes, dtdia, Time\+\_\+end\+\_\+thermo, update\+\_\+\+B\+BL, Waves)
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+step\+\_\+thermo orchestrates the thermodynamic time stepping and vertical remapping, via calls to diabatic (or adiabatic) and A\+L\+E\+\_\+main. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}{step\+\_\+offline} (forces, fluxes, sfc\+\_\+state, Time\+\_\+start, time\+\_\+interval, CS)
\begin{DoxyCompactList}\small\item\em step\+\_\+offline is the main driver for running tracers offline in M\+O\+M6. This has been primarily developed with A\+LE configurations in mind. Some work has been done in isopycnal configuration, but the work is very preliminary. Some more detail about this capability along with some of the subroutines called here can be found in tracers/\+M\+O\+M\+\_\+offline\+\_\+control.\+F90 \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom} (Time, Time\+\_\+init, param\+\_\+file, dirs, CS, restart\+\_\+\+C\+Sp, Time\+\_\+in, offline\+\_\+tracer\+\_\+mode, input\+\_\+restart\+\_\+file, diag\+\_\+ptr, count\+\_\+calls, tracer\+\_\+flow\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize M\+OM, including memory allocation, setting up parameters and diagnostics, initializing the ocean state variables, and initializing subsidiary modules. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_a2269d5cd79625cbf16cb916346379207}{finish\+\_\+mom\+\_\+initialization} (Time, dirs, CS, restart\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Finishes initializing M\+OM and writes out the initial conditions. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_af0f791729b0ccb6cb8ae2f4d28edee21}{register\+\_\+diags} (Time, G, GV, US, I\+Ds, diag)
\begin{DoxyCompactList}\small\item\em Register certain diagnostics. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init} (CS)
\begin{DoxyCompactList}\small\item\em Set up C\+PU clock I\+Ds for timing various subroutines. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_a76cb0af280a5c9e877dc206a6849b46b}{set\+\_\+restart\+\_\+fields} (GV, US, param\+\_\+file, CS, restart\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Set the fields that are needed for bitwise identical restarting the time stepping scheme. In addition to those specified here directly, there may be fields related to the forcing or to the barotropic solver that are needed; these are specified in sub-\/ routines that are called from this one. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_a16f7cc52cef3eb7a99687bf3d0694285}{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm} (tv, G, GV, US, ssh, p\+\_\+atm, use\+\_\+\+E\+OS)
\begin{DoxyCompactList}\small\item\em Apply a correction to the sea surface height to compensate for the atmospheric pressure (the inverse barometer). \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_a699d6c5bfb5b9dcdaa03c18806fa824e}{extract\+\_\+surface\+\_\+state} (CS, sfc\+\_\+state\+\_\+in)
\begin{DoxyCompactList}\small\item\em Set the surface (return) properties of the ocean model by setting the appropriate fields in sfc\+\_\+state. Unused fields are set to N\+U\+LL or are unallocated. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom_a8f5160e583b599050515b8fe5575aa15}{rotate\+\_\+initial\+\_\+state} (u\+\_\+in, v\+\_\+in, h\+\_\+in, T\+\_\+in, S\+\_\+in, use\+\_\+temperature, turns, u, v, h, T, S)
\begin{DoxyCompactList}\small\item\em Rotate initialization fields from input to rotated arrays. \end{DoxyCompactList}\item 
logical function, public \hyperlink{namespacemom_ada38a8329b76f9fa1685a230869a7647}{mom\+\_\+state\+\_\+is\+\_\+synchronized} (CS, adv\+\_\+dyn)
\begin{DoxyCompactList}\small\item\em Return true if all phases of step\+\_\+\+M\+OM are at the same point in time. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_aece0dd1e2c9498844befd8ba71986b96}{get\+\_\+mom\+\_\+state\+\_\+elements} (CS, G, GV, US, C\+\_\+p, C\+\_\+p\+\_\+scaled, use\+\_\+temp)
\begin{DoxyCompactList}\small\item\em This subroutine offers access to values or pointers to other types from within the M\+O\+M\+\_\+control\+\_\+struct, allowing the M\+O\+M\+\_\+control\+\_\+struct to be opaque. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_a462293ed92e99927ef9939747d633080}{get\+\_\+ocean\+\_\+stocks} (CS, mass, heat, salt, on\+\_\+\+P\+E\+\_\+only)
\begin{DoxyCompactList}\small\item\em Find the global integrals of various quantities. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom_ae6dad976fb4be1c7ba7fc1aff809616b}{mom\+\_\+end} (CS)
\begin{DoxyCompactList}\small\item\em End of ocean model, including memory deallocation. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
integer \hyperlink{namespacemom_a2e9f4b71ee77ba5bcb3f03a863948db3}{id\+\_\+clock\+\_\+ocean}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_ae1cf2d523679b925a5e5baa9d974968c}{id\+\_\+clock\+\_\+dynamics}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a052256dfa3e56390f62ef3a826d62617}{id\+\_\+clock\+\_\+thermo}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a0fa4debacd02de6fcd066066c232adf3}{id\+\_\+clock\+\_\+tracer}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a50edf00aa5998073d2db0360949253ba}{id\+\_\+clock\+\_\+diabatic}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_af865d838388a05163e8de8d266316d5f}{id\+\_\+clock\+\_\+adiabatic}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_aa512b2d8dd73b02634e772701be07a87}{id\+\_\+clock\+\_\+continuity}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a8f5feb87a0cb40d9fcee00456e982b8a}{id\+\_\+clock\+\_\+thick\+\_\+diff}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_aa69e79e4c51e1c24c474b84311322251}{id\+\_\+clock\+\_\+bbl\+\_\+visc}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a41b67fabfc13e52cf3a5d1c337c780eb}{id\+\_\+clock\+\_\+ml\+\_\+restrat}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_aa773fddb51f99098d75304eb271270d4}{id\+\_\+clock\+\_\+diagnostics}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a09f2ac3470372b9ee233f4cc5a7a0da1}{id\+\_\+clock\+\_\+z\+\_\+diag}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a7cf03c18244d0630616e925bab1841a2}{id\+\_\+clock\+\_\+init}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a4180eb85bab39df7cbb72bb8e5b19fd4}{id\+\_\+clock\+\_\+mom\+\_\+init}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}{id\+\_\+clock\+\_\+pass}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_ac4d20612cad32d412dae492fedc2e971}{id\+\_\+clock\+\_\+pass\+\_\+init}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a722ed13d0e6d76852e680054a0e3c964}{id\+\_\+clock\+\_\+ale}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}{id\+\_\+clock\+\_\+other}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a2ab767469f0d918b9e479d8e0fde44b0}{id\+\_\+clock\+\_\+offline\+\_\+tracer}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\item 
integer \hyperlink{namespacemom_a785851181d2a3db5a938322d2ff9498a}{id\+\_\+clock\+\_\+unit\+\_\+tests}
\begin{DoxyCompactList}\small\item\em C\+PU time clock I\+Ds. \end{DoxyCompactList}\end{DoxyCompactItemize}



\subsection{Detailed Description}
The central module of the M\+O\+M6 ocean model. 

Modular Ocean Model (M\+OM) Version 6.\+0 (M\+O\+M6)

\begin{DoxyAuthor}{Authors}
Alistair Adcroft, Robert Hallberg, and Stephen Griffies
\end{DoxyAuthor}
Additional contributions from\+:
\begin{DoxyItemize}
\item Whit Anderson
\item Brian Arbic
\item Will Cooke
\item Anand Gnanadesikan
\item Matthew Harrison
\item Mehmet Ilicak
\item Laura Jackson
\item Jasmine John
\item John Krasting
\item Zhi Liang
\item Bonnie Samuels
\item Harper Simmons
\item Laurent White
\item Niki Zadeh
\end{DoxyItemize}

M\+OM ice-\/shelf code was developed by
\begin{DoxyItemize}
\item Daniel Goldberg
\item Robert Hallberg
\item Chris Little
\item Olga Sergienko
\end{DoxyItemize}\hypertarget{namespacemom_section_overview}{}\subsection{Overview of M\+OM}\label{namespacemom_section_overview}
This program (M\+OM) simulates the ocean by numerically solving the hydrostatic primitive equations in generalized Lagrangian vertical coordinates, typically tracking stretched pressure (p$\ast$) surfaces or following isopycnals in the ocean\textquotesingle{}s interior, and general orthogonal horizontal coordinates. Unlike earlier versions of M\+OM, in M\+O\+M6 these equations are horizontally discretized on an Arakawa C-\/grid. (It remains to be seen whether a B-\/grid dynamic core will be revived in M\+O\+M6 at a later date; for now applications requiring a B-\/grid discretization should use M\+O\+M5.\+1.) M\+O\+M6 offers a range of options for the physical parameterizations, from those most appropriate to highly idealized models for geophysical fluid dynamics studies to a rich suite of processes appropriate for realistic ocean simulations. The thermodynamic options typically use conservative temperature and preformed salinity as conservative state variables and a full nonlinear equation of state, but there are also idealized adiabatic configurations of the model that use fixed density layers. Version 6.\+0 of M\+OM continues in the long tradition of a commitment to climate-\/quality ocean simulations embodied in previous versions of M\+OM, even as it draws extensively on the lessons learned in the development of the Generalized Ocean Layered Dynamics (G\+O\+LD) ocean model, which was also primarily developed at N\+O\+A\+A/\+G\+F\+DL. M\+OM has also benefited tremendously from the F\+MS infrastructure, which it utilizes and shares with other component models developed at N\+O\+A\+A/\+G\+F\+DL.

When run is isopycnal-\/coordinate mode, the uppermost few layers are often used to describe a bulk mixed layer, including the effects of penetrating shortwave radiation. Either a split-\/ explicit time stepping scheme or a non-\/split scheme may be used for the dynamics, while the time stepping may be split (and use different numbers of steps to cover the same interval) for the forcing, the thermodynamics, and for the dynamics. Most of the numerics are second order accurate in space. M\+OM can run with an absurdly thin minimum layer thickness. A variety of non-\/isopycnal vertical coordinate options are under development, but all exploit the advantages of a Lagrangian vertical coordinate, as discussed in detail by Adcroft and Hallberg (Ocean Modelling, 2006).

Details of the numerics and physical parameterizations are provided in the appropriate source files. All of the available options are selected at run-\/time by parsing the input files, usually M\+O\+M\+\_\+input and M\+O\+M\+\_\+override, and the options choices are then documented for each run in M\+O\+M\+\_\+param\+\_\+docs.

M\+O\+M6 integrates the equations forward in time in three distinct phases. In one phase, the dynamic equations for the velocities and layer thicknesses are advanced, capturing the propagation of external and internal inertia-\/gravity waves, Rossby waves, and other strictly adiabatic processes, including lateral stresses, vertical viscosity and momentum forcing, and interface height diffusion (commonly called Gent-\/\+Mc\+Williams diffusion in depth-\/ coordinate models). In the second phase, all tracers are advected and diffused along the layers. The third phase applies diabatic processes, vertical mixing of water properties, and perhaps vertical remapping to cause the layers to track the desired vertical coordinate.

The present file (\hyperlink{MOM_8F90}{M\+O\+M.\+F90}) orchestrates the main time stepping loops. One time integration option for the dynamics uses a split explicit time stepping scheme to rapidly step the barotropic pressure and velocity fields. The barotropic velocities are averaged over the baroclinic time step before they are used to advect thickness and determine the baroclinic accelerations. As described in Hallberg and Adcroft (2009), a barotropic correction is applied to the time-\/mean layer velocities to ensure that the sum of the layer transports agrees with the time-\/mean barotropic transport, thereby ensuring that the estimates of the free surface from the sum of the layer thicknesses agrees with the final free surface height as calculated by the barotropic solver. The barotropic and baroclinic velocities are kept consistent by recalculating the barotropic velocities from the baroclinic transports each time step. This scheme is described in Hallberg, 1997, J. Comp. Phys. 135, 54-\/65 and in Hallberg and Adcroft, 2009, Ocean Modelling, 29, 15-\/26.

The other time integration options use non-\/split time stepping schemes based on the 3-\/step third order Runge-\/\+Kutta scheme described in Matsuno, 1966, J. Met. Soc. Japan, 44, 85-\/88, or on a two-\/step quasi-\/2nd order Runge-\/\+Kutta scheme. These are much slower than the split time-\/stepping scheme, but they are useful for providing a more robust solution for debugging cases where the more complicated split time-\/stepping scheme may be giving suspect solutions.

There are a range of closure options available. Horizontal velocities are subject to a combination of horizontal biharmonic and Laplacian friction (based on a stress tensor formalism) and a vertical Fickian viscosity (perhaps using the kinematic viscosity of water). The horizontal viscosities may be constant, spatially varying or may be dynamically calculated using Smagorinsky\textquotesingle{}s approach. A diapycnal diffusion of density and thermodynamic quantities is also allowed, but not required, as is horizontal diffusion of interface heights (akin to the Gent-\/\+Mc\+Williams closure of geopotential coordinate models). The diapycnal mixing may use a fixed diffusivity or it may use the shear Richardson number dependent closure, like that described in Jackson et al. (J\+PO, 2008). When there is diapycnal diffusion, it applies to momentum as well. As this is in addition to the vertical viscosity, the vertical Prandtl always exceeds 1. A refined bulk-\/mixed layer is often used to describe the planetary boundary layer in realistic ocean simulations.

M\+OM has a number of noteworthy debugging capabilities. Excessively large velocities are truncated and M\+OM will stop itself after a number of such instances to keep the model from crashing altogether. This is useful in diagnosing failures, or (by accepting some truncations) it may be useful for getting the model past the adjustment from an ill-\/balanced initial condition. In addition, all of the accelerations in the columns with excessively large velocities may be directed to a text file. Parallelization errors may be diagnosed using the D\+E\+B\+UG option, which causes extensive checksums to be written out along with comments indicating where in the algorithm the sums originate and what variable is being summed. The point where these checksums differ between runs is usually a good indication of where in the code the problem lies. All of the test cases provided with M\+OM are routinely tested to ensure that they give bitwise identical results regardless of the domain decomposition, or whether they use static or dynamic memory allocation.\hypertarget{namespacemom_section_structure}{}\subsection{Structure of M\+OM}\label{namespacemom_section_structure}
About 115 other files of source code and 4 header files comprise the M\+OM code, although there are several hundred more files that make up the F\+MS infrastructure upon which M\+OM is built. Each of the M\+OM files contains comments documenting what it does, and most of the file names are fairly self-\/evident. In addition, all subroutines and data types are referenced via a module use, only statement, and the module names are consistent with the file names, so it is not too hard to find the source file for a subroutine.

The typical M\+OM directory tree is as follows\+:

\begin{DoxyVerb}        ../MOM
        |-- config_src
        |   |-- coupled_driver
        |   |-- dynamic
        |   `-- solo_driver
        |-- examples
        |   |-- CM2G
        |   |-- ...
        |   `-- torus_advection_test
        `-- src
            |-- core
            |-- diagnostics
            |-- equation_of_state
            |-- framework
            |-- ice_shelf
            |-- initialization
            |-- parameterizations
            |   |-- lateral
            |   `-- vertical
            |-- tracer
            `-- user\end{DoxyVerb}


Rather than describing each file here, each directory contents will be described to give a broad overview of the M\+OM code structure.

The directories under config\+\_\+src contain files that are used for configuring the code, for instance for coupled or ocean-\/only runs. Only one or two of these directories are used in compiling any, particular run.


\begin{DoxyItemize}
\item config\+\_\+src/coupled\+\_\+driver\+: The files here are used to couple M\+OM as a component in a larger run driven by the F\+MS coupler. This includes code that converts various forcing fields into the code structures and flux and unit conventions used by M\+OM, and converts the M\+OM surface fields back to the forms used by other F\+MS components.
\item config\+\_\+src/dynamic\+: The only file here is the version of M\+O\+M\+\_\+memory.\+h that is used for dynamic memory configurations of M\+OM.
\item config\+\_\+src/solo\+\_\+driver\+: The files here are include the \+\_\+main driver that is used when M\+OM is configured as an ocean-\/only model, as well as the files that specify the surface forcing in this configuration.

The directories under examples provide a large number of working configurations of M\+OM, along with reference solutions for several different compilers on G\+F\+DL\textquotesingle{}s latest large computer. The versions of M\+O\+M\+\_\+memory.\+h in these directories need not be used if dynamic memory allocation is desired, and the answers should be unchanged.

The directories under src contain most of the M\+OM files. These files are used in every configuration using M\+OM.
\item src/core\+: The files here constitute the M\+OM dynamic core. This directory also includes files with the types that describe the model\textquotesingle{}s lateral grid and have defined types that are shared across various M\+OM modules to allow for more succinct and flexible subroutine argument lists.
\item src/diagnostics\+: The files here calculate various diagnostics that are anciliary to the model itself. While most of these diagnostics do not directly affect the model\textquotesingle{}s solution, there are some, like the calculation of the deformation radius, that are used in some of the process parameterizations.
\item src/equation\+\_\+of\+\_\+state\+: These files describe the physical properties of sea-\/water, including both the equation of state and when it freezes.
\item src/framework\+: These files provide infrastructure utilities for M\+OM. Many are simply wrappers for capabilities provided by F\+MS, although others provide capabilities (like the file\+\_\+parser) that are unique to M\+OM. When M\+OM is adapted to use a modeling infrastructure distinct from F\+MS, most of the required changes are in this directory.
\item src/initialization\+: These are the files that are used to initialize the M\+OM grid or provide the initial physical state for M\+OM. These files are not intended to be modified, but provide a means for calling user-\/specific initialization code like the examples in src/user.
\item src/parameterizations/lateral\+: These files implement a number of quasi-\/lateral (along-\/layer) process parameterizations, including lateral viscosities, parameterizations of eddy effects, and the calculation of tidal forcing.
\item src/parameterizations/vertical\+: These files implement a number of vertical mixing or diabatic processes, including the effects of vertical viscosity and code to parameterize the planetary boundary layer. There is a separate driver that orchestrates this portion of the algorithm, and there is a diversity of parameterizations to be found here.
\item src/tracer\+: These files handle the lateral transport and diffusion of tracers, or are the code to implement various passive tracer packages. Additional tracer packages are readily accommodated.
\item src/user\+: These are either stub routines that a user could use to change the model\textquotesingle{}s initial conditions or forcing, or are examples that implement specific test cases. These files can easily be hand edited to create new analytically specified configurations.
\end{DoxyItemize}

Most simulations can be set up by modifying only the files M\+O\+M\+\_\+input, and possibly one or two of the files in src/user. In addition, the diag\+\_\+table (M\+O\+M\+\_\+diag\+\_\+table) will commonly be modified to tailor the output to the needs of the question at hand. The F\+MS utility mkmf works with a file called path\+\_\+names to build an appropriate makefile, and path\+\_\+names should be edited to reflect the actual location of the desired source code.

There are 3 publicly visible subroutines in this file (\hyperlink{MOM_8F90}{M\+O\+M.\+F90}).
\begin{DoxyItemize}
\item step\+\_\+\+M\+OM steps M\+OM over a specified interval of time.
\item M\+O\+M\+\_\+initialize calls initialize and does other initialization that does not warrant user modification.
\item extract\+\_\+surface\+\_\+state determines the surface (bulk mixed layer if traditional isoycnal vertical coordinate) properties of the current model state and packages pointers to these fields into an exported structure.

The remaining subroutines in this file (\hyperlink{MOM_8F90}{src/core/\+M\+O\+M.\+F90}) are\+:
\item find\+\_\+total\+\_\+transport determines the barotropic mass transport.
\item register\+\_\+diags registers many diagnostic fields for the dynamic solver, or of the main model variables.
\item M\+O\+M\+\_\+timing\+\_\+init initializes various C\+PU time clocks.
\item write\+\_\+static\+\_\+fields writes out various time-\/invariant fields.
\item set\+\_\+restart\+\_\+fields is used to specify those fields that are written to and read from the restart file.
\end{DoxyItemize}\hypertarget{namespacemom_section_heat_budget}{}\subsection{Diagnosing M\+O\+M heat budget}\label{namespacemom_section_heat_budget}
Here are some example heat budgets for the A\+LE version of M\+O\+M6.\hypertarget{namespacemom_subsection_2d_heat_budget}{}\subsubsection{Depth integrated heat budget}\label{namespacemom_subsection_2d_heat_budget}
Depth integrated heat budget diagnostic for M\+OM.


\begin{DoxyItemize}
\item O\+P\+O\+T\+T\+E\+M\+P\+T\+E\+N\+D\+\_\+2d = T\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+X\+Y\+\_\+2d + O\+P\+O\+T\+T\+E\+M\+P\+P\+M\+D\+I\+F\+F\+\_\+2d + H\+F\+DS + H\+F\+G\+E\+OU
\item T\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+X\+Y\+\_\+2d = horizontal advection
\item O\+P\+O\+T\+T\+E\+M\+P\+P\+M\+D\+I\+F\+F\+\_\+2d = neutral diffusion
\item H\+F\+DS = net surface boundary heat flux
\item H\+F\+G\+E\+OU = geothermal heat flux
\item H\+F\+DS = net surface boundary heat flux entering the ocean = rsntds + rlntds + hfls + hfss + heat\+\_\+pme + hfsifrazil
\item More heat flux cross-\/checks
\begin{DoxyItemize}
\item hfds = net\+\_\+heat\+\_\+coupler + hfsifrazil + heat\+\_\+pme
\item heat\+\_\+pme = heat\+\_\+content\+\_\+surfwater = heat\+\_\+content\+\_\+massin + heat\+\_\+content\+\_\+massout = heat\+\_\+content\+\_\+fprec + heat\+\_\+content\+\_\+cond + heat\+\_\+content\+\_\+vprec
\begin{DoxyItemize}
\item hfrunoffds + hfevapds + hfrainds
\end{DoxyItemize}
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{namespacemom_subsection_3d_heat_budget}{}\subsubsection{Depth integrated heat budget}\label{namespacemom_subsection_3d_heat_budget}
Here is an example 3d heat budget diagnostic for M\+OM.


\begin{DoxyItemize}
\item O\+P\+O\+T\+T\+E\+M\+P\+T\+E\+ND = T\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+XY + T\+H\+\_\+\+T\+E\+N\+D\+E\+N\+C\+Y\+\_\+\+V\+E\+R\+T\+\_\+\+R\+E\+M\+AP + O\+P\+O\+T\+T\+E\+M\+P\+D\+I\+FF + O\+P\+O\+T\+T\+E\+M\+P\+P\+M\+D\+I\+FF
\begin{DoxyItemize}
\item B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY + F\+R\+A\+Z\+I\+L\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY
\end{DoxyItemize}
\item O\+P\+O\+T\+T\+E\+M\+P\+T\+E\+ND = net tendency of heat as diagnosed in \hyperlink{MOM_8F90}{M\+O\+M.\+F90}
\item T\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+XY = heating of a cell from lateral advection
\item T\+H\+\_\+\+T\+E\+N\+D\+E\+N\+C\+Y\+\_\+\+V\+E\+R\+T\+\_\+\+R\+E\+M\+AP = heating of a cell from vertical remapping
\item O\+P\+O\+T\+T\+E\+M\+P\+D\+I\+FF = heating of a cell from diabatic diffusion
\item O\+P\+O\+T\+T\+E\+M\+P\+P\+M\+D\+I\+FF = heating of a cell from neutral diffusion
\item B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY = heating of cell from boundary fluxes
\item F\+R\+A\+Z\+I\+L\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY = heating of cell from frazil
\item T\+H\+\_\+\+T\+E\+N\+D\+E\+N\+C\+Y\+\_\+\+V\+E\+R\+T\+\_\+\+R\+E\+M\+AP has zero vertical sum, as it redistributes heat in vertical.
\item O\+P\+O\+T\+T\+E\+M\+P\+D\+I\+FF has zero vertical sum, as it redistributes heat in the vertical.
\item B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY generally has 3d structure, with k $>$ 1 contributions from penetrative shortwave, and from other fluxes for the case when layers are tiny, in which case M\+O\+M6 partitions tendencies into k $>$ 1 layers.
\item F\+R\+A\+Z\+I\+L\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY generally has 3d structure, since M\+O\+M6 frazil calculation checks the full ocean column.
\item F\+R\+A\+Z\+I\+L\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY\mbox{[}k=@sum\mbox{]} = H\+F\+S\+I\+F\+R\+A\+Z\+IL = column integrated frazil heating.
\item H\+F\+DS = F\+R\+A\+Z\+I\+L\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY\mbox{[}k=@sum\mbox{]} + B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+H\+E\+A\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY\mbox{[}k=@sum\mbox{]}

Here is an example 2d heat budget (depth summed) diagnostic for M\+OM.
\item O\+P\+O\+T\+T\+E\+M\+P\+T\+E\+N\+D\+\_\+2d = T\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+X\+Y\+\_\+2d + O\+P\+O\+T\+T\+E\+M\+P\+P\+M\+D\+I\+F\+F\+\_\+2d + H\+F\+DS

Here is an example 3d salt budget diagnostic for M\+OM.
\item O\+S\+A\+L\+T\+T\+E\+ND = S\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+XY + S\+H\+\_\+\+T\+E\+N\+D\+E\+N\+C\+Y\+\_\+\+V\+E\+R\+T\+\_\+\+R\+E\+M\+AP + O\+S\+A\+L\+T\+D\+I\+FF + O\+S\+A\+L\+T\+P\+M\+D\+I\+FF
\begin{DoxyItemize}
\item B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+S\+A\+L\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY
\end{DoxyItemize}
\item O\+S\+A\+L\+T\+T\+E\+ND = net tendency of salt as diagnosed in \hyperlink{MOM_8F90}{M\+O\+M.\+F90}
\item S\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+XY = salt convergence to cell from lateral advection
\item S\+H\+\_\+\+T\+E\+N\+D\+E\+N\+C\+Y\+\_\+\+V\+E\+R\+T\+\_\+\+R\+E\+M\+AP = salt convergence to cell from vertical remapping
\item O\+S\+A\+L\+T\+D\+I\+FF = salt convergence to cell from diabatic diffusion
\item O\+S\+A\+L\+T\+P\+M\+D\+I\+FF = salt convergence to cell from neutral diffusion
\item B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+S\+A\+L\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY = salt convergence to cell from boundary fluxes
\item S\+H\+\_\+\+T\+E\+N\+D\+E\+N\+C\+Y\+\_\+\+V\+E\+R\+T\+\_\+\+R\+E\+M\+AP has zero vertical sum, as it redistributes salt in vertical.
\item O\+S\+A\+L\+T\+D\+I\+FF has zero vertical sum, as it redistributes salt in the vertical.
\item B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+S\+A\+L\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY generally has 3d structure, with k $>$ 1 contributions from the case when layers are tiny, in which case M\+O\+M6 partitions tendencies into k $>$ 1 layers.
\item S\+F\+D\+SI = B\+O\+U\+N\+D\+A\+R\+Y\+\_\+\+F\+O\+R\+C\+I\+N\+G\+\_\+\+S\+A\+L\+T\+\_\+\+T\+E\+N\+D\+E\+N\+CY\mbox{[}k=@sum\mbox{]}

Here is an example 2d salt budget (depth summed) diagnostic for M\+OM.
\item O\+S\+A\+L\+T\+T\+E\+N\+D\+\_\+2d = S\+\_\+\+A\+D\+V\+E\+C\+T\+I\+O\+N\+\_\+\+X\+Y\+\_\+2d + O\+S\+A\+L\+T\+P\+M\+D\+I\+F\+F\+\_\+2d + S\+F\+D\+SI (+ S\+A\+L\+T\+\_\+\+F\+L\+U\+X\+\_\+\+R\+E\+S\+T\+O\+RE) 
\end{DoxyItemize}

\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom_a16f7cc52cef3eb7a99687bf3d0694285}\label{namespacemom_a16f7cc52cef3eb7a99687bf3d0694285}} 
\index{mom@{mom}!adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm@{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm}}
\index{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm@{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm}!mom@{mom}}
\subsubsection{\texorpdfstring{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm()}{adjust\_ssh\_for\_p\_atm()}}
{\footnotesize\ttfamily subroutine mom\+::adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm (\begin{DoxyParamCaption}\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(inout)}]{ssh,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{p\+\_\+atm,  }\item[{logical, intent(in), optional}]{use\+\_\+\+E\+OS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Apply a correction to the sea surface height to compensate for the atmospheric pressure (the inverse barometer). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em tv} & A structure pointing to various thermodynamic variables\\
\hline
\mbox{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em ssh} & time mean surface height \mbox{[}m\mbox{]}\\
\hline
 & {\em p\+\_\+atm} & Ocean surface pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em use\+\_\+eos} & If true, calculate the density for the S\+SH correction using the equation of state. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l02964}{2964} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}, and \hyperlink{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}{step\+\_\+offline()}.


\begin{DoxyCode}
02964   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),             \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{  !< A structure pointing to various thermodynamic
       variables}
02965   \textcolor{keywordtype}{type}(ocean\_grid\_type),             \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< ocean grid structure}
02966   \textcolor{keywordtype}{type}(verticalgrid\_type),           \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< ocean vertical grid structure}
02967   \textcolor{keywordtype}{type}(unit\_scale\_type),             \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{  !< A dimensional unit scaling type}
02968   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))},  \textcolor{keywordtype}{intent(inout)} :: ssh\textcolor{comment}{ !< time mean surface height [m]}
02969   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: p\_atm\textcolor{comment}{ !< Ocean surface pressure [R L2 T-2 ~> Pa]}
02970   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: use\_eos\textcolor{comment}{ !< If true, calculate the density for}
02971 \textcolor{comment}{                                                       !! the SSH correction using the equation of state.}
02972 
02973   \textcolor{keywordtype}{real} :: rho\_conv(szi\_(g))  \textcolor{comment}{! The density used to convert surface pressure to}
02974                       \textcolor{comment}{! a corrected effective SSH [R ~> kg m-3].}
02975   \textcolor{keywordtype}{real} :: igr0        \textcolor{comment}{! The SSH conversion factor from R L2 T-2 to m [m T2 R-1 L-2 ~> m Pa-1].}
02976   \textcolor{keywordtype}{logical} :: calc\_rho
02977   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: eosdom \textcolor{comment}{! The i-computational domain for the equation of state}
02978   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
02979 
02980   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
02981   eosdom(:) = eos\_domain(g%HI)
02982   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(p\_atm)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(p\_atm)) \textcolor{keywordflow}{then}
02983     calc\_rho = \textcolor{keyword}{associated}(tv%eqn\_of\_state)
02984     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(use\_eos) .and. calc\_rho) calc\_rho = use\_eos
02985     \textcolor{comment}{! Correct the output sea surface height for the contribution from the ice pressure.}
02986     \textcolor{keywordflow}{do} j=js,je
02987       \textcolor{keywordflow}{if} (calc\_rho) \textcolor{keywordflow}{then}
02988         \textcolor{keyword}{call }calculate\_density(tv%T(:,j,1), tv%S(:,j,1), 0.5*p\_atm(:,j), rho\_conv, &
02989                                tv%eqn\_of\_state, eosdom)
02990         \textcolor{keywordflow}{do} i=is,ie
02991           igr0 = us%Z\_to\_m / (rho\_conv(i) * gv%g\_Earth)
02992           ssh(i,j) = ssh(i,j) + p\_atm(i,j) * igr0
02993 \textcolor{keywordflow}{        enddo}
02994       \textcolor{keywordflow}{else}
02995         \textcolor{keywordflow}{do} i=is,ie
02996           ssh(i,j) = ssh(i,j) + p\_atm(i,j) * (us%Z\_to\_m / (gv%Rho0 * gv%g\_Earth))
02997 \textcolor{keywordflow}{        enddo}
02998 \textcolor{keywordflow}{      endif}
02999 \textcolor{keywordflow}{    enddo}
03000 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
03001 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a699d6c5bfb5b9dcdaa03c18806fa824e}\label{namespacemom_a699d6c5bfb5b9dcdaa03c18806fa824e}} 
\index{mom@{mom}!extract\+\_\+surface\+\_\+state@{extract\+\_\+surface\+\_\+state}}
\index{extract\+\_\+surface\+\_\+state@{extract\+\_\+surface\+\_\+state}!mom@{mom}}
\subsubsection{\texorpdfstring{extract\+\_\+surface\+\_\+state()}{extract\_surface\_state()}}
{\footnotesize\ttfamily subroutine, public mom\+::extract\+\_\+surface\+\_\+state (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{type(surface), intent(inout), target}]{sfc\+\_\+state\+\_\+in }\end{DoxyParamCaption})}



Set the surface (return) properties of the ocean model by setting the appropriate fields in sfc\+\_\+state. Unused fields are set to N\+U\+LL or are unallocated. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Master M\+OM control structure\\
\hline
\mbox{\tt in,out}  & {\em sfc\+\_\+state\+\_\+in} & transparent ocean surface state structure shared with the calling routine data in this structure is intent out. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l03008}{3008} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}, and \hyperlink{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}{step\+\_\+offline()}.


\begin{DoxyCode}
03008   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{ !< Master MOM control structure}
03009   \textcolor{keywordtype}{type}(surface), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: sfc\_state\_in\textcolor{comment}{ !< transparent ocean surface state}
03010 \textcolor{comment}{                                             !! structure shared with the calling routine}
03011 \textcolor{comment}{                                             !! data in this structure is intent out.}
03012 
03013   \textcolor{comment}{! Local variables}
03014   \textcolor{keywordtype}{real} :: hu, hv  \textcolor{comment}{! Thicknesses interpolated to velocity points [H ~> m or kg m-2]}
03015   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer} :: g => null() \textcolor{comment}{!< pointer to a structure containing}
03016 \textcolor{comment}{                                                  !! metrics and related information}
03017   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer} :: g\_in => null() \textcolor{comment}{!< Input grid metric}
03018   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv => null() \textcolor{comment}{!< structure containing vertical grid info}
03019   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{!< structure containing various unit conversion factors}
03020   \textcolor{keywordtype}{type}(surface),           \textcolor{keywordtype}{pointer} :: sfc\_state => null()  \textcolor{comment}{! surface state on the model grid}
03021   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{pointer} :: &
03022     h => null()    \textcolor{comment}{!< h : layer thickness [H ~> m or kg m-2]}
03023   \textcolor{keywordtype}{real} :: depth(szi\_(cs%g))\textcolor{comment}{  !< Distance from the surface in depth units [Z ~> m] or [H ~> m or kg m-2]}
03024   \textcolor{keywordtype}{real} :: depth\_ml\textcolor{comment}{           !< Depth over which to average to determine mixed}
03025 \textcolor{comment}{                             !! layer properties [Z ~> m] or [H ~> m or kg m-2]}
03026   \textcolor{keywordtype}{real} :: dh\textcolor{comment}{                 !< Thickness of a layer within the mixed layer [Z ~> m] or [H ~> m or kg m-2]}
03027   \textcolor{keywordtype}{real} :: mass\textcolor{comment}{               !< Mass per unit area of a layer [R Z ~> kg m-2]}
03028   \textcolor{keywordtype}{real} :: t\_freeze\textcolor{comment}{           !< freezing temperature [degC]}
03029   \textcolor{keywordtype}{real} :: i\_depth\textcolor{comment}{            !< The inverse of depth [Z-1 ~> m-1] or [H-1 ~> m-1 or m2 kg-1]}
03030   \textcolor{keywordtype}{real} :: missing\_depth\textcolor{comment}{      !< The portion of depth\_ml that can not be found in a column [H ~> m or kg
       m-2]}
03031   \textcolor{keywordtype}{real} :: h\_rescale\textcolor{comment}{          !< A conversion factor from thickness units to the units used in the}
03032 \textcolor{comment}{                             !! calculation of properties of the uppermost ocean [nondim] or [Z H-1 ~> 1 or
       m3 kg-1]}
03033                              \textcolor{comment}{!  After the ANSWERS\_2018 flag has been obsoleted, H\_rescale will be 1.}
03034   \textcolor{keywordtype}{real} :: delt(szi\_(cs%g))\textcolor{comment}{   !< Depth integral of T-T\_freeze [Z degC ~> m degC]}
03035   \textcolor{keywordtype}{logical} :: use\_temperature\textcolor{comment}{ !< If true, temp and saln used as state variables.}
03036   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, numberoferrors, ig, jg
03037   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed
03038   \textcolor{keywordtype}{integer} :: iscb, iecb, jscb, jecb, isdb, iedb, jsdb, jedb
03039   \textcolor{keywordtype}{logical} :: localerror
03040   \textcolor{keywordtype}{character(240)} :: msg
03041   \textcolor{keywordtype}{integer} :: turns    \textcolor{comment}{! Number of quarter turns}
03042 
03043   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"extract\_surface\_state(), MOM.F90"})
03044   g => cs%G ; g\_in => cs%G\_in ; gv => cs%GV ; us => cs%US
03045   is  = g%isc ; ie  = g%iec ; js  = g%jsc ; je  = g%jec ; nz = gv%ke
03046   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
03047   iscb = g%iscB ; iecb = g%iecB; jscb = g%jscB ; jecb = g%jecB
03048   isdb = g%isdB ; iedb = g%iedB; jsdb = g%jsdB ; jedb = g%jedB
03049   h => cs%h
03050 
03051   use\_temperature = \textcolor{keyword}{associated}(cs%tv%T)
03052 
03053   turns = 0
03054   \textcolor{keywordflow}{if} (cs%rotate\_index) &
03055     turns = g%HI%turns
03056 
03057   \textcolor{keywordflow}{if} (.not.sfc\_state\_in%arrays\_allocated) &
03058     \textcolor{comment}{!  Consider using a run-time flag to determine whether to do the vertical}
03059     \textcolor{comment}{! integrals, since the 3-d sums are not negligible in cost.}
03060     \textcolor{keyword}{call }allocate\_surface\_state(sfc\_state\_in, g\_in, use\_temperature, &
03061         do\_integrals=.true., omit\_frazil=.not.\textcolor{keyword}{associated}(cs%tv%frazil))
03062 
03063   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
03064     \textcolor{keyword}{allocate}(sfc\_state)
03065     \textcolor{keyword}{call }allocate\_surface\_state(sfc\_state, g, use\_temperature, &
03066         do\_integrals=.true., omit\_frazil=.not.\textcolor{keyword}{associated}(cs%tv%frazil))
03067   \textcolor{keywordflow}{else}
03068     sfc\_state => sfc\_state\_in
03069 \textcolor{keywordflow}{  endif}
03070 
03071   sfc\_state%T\_is\_conT = cs%tv%T\_is\_conT
03072   sfc\_state%S\_is\_absS = cs%tv%S\_is\_absS
03073 
03074   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03075     sfc\_state%sea\_lev(i,j) = us%m\_to\_Z*cs%ave\_ssh\_ibc(i,j)
03076 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
03077 
03078   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%frazil) .and. \textcolor{keyword}{associated}(cs%tv%frazil)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03079     sfc\_state%frazil(i,j) = cs%tv%frazil(i,j)
03080 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
03081 
03082   \textcolor{comment}{! copy Hml into sfc\_state, so that caps can access it}
03083   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%Hml)) \textcolor{keywordflow}{then}
03084     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03085       sfc\_state%Hml(i,j) = cs%Hml(i,j)
03086 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03087 \textcolor{keywordflow}{  endif}
03088 
03089   \textcolor{keywordflow}{if} (cs%Hmix < 0.0) \textcolor{keywordflow}{then}  \textcolor{comment}{! A bulk mixed layer is in use, so layer 1 has the properties}
03090     \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03091       sfc\_state%SST(i,j) = cs%tv%T(i,j,1)
03092       sfc\_state%SSS(i,j) = cs%tv%S(i,j,1)
03093 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
03094     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ie
03095       sfc\_state%u(i,j) = cs%u(i,j,1)
03096 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03097     \textcolor{keywordflow}{do} j=js-1,je ; \textcolor{keywordflow}{do} i=is,ie
03098       sfc\_state%v(i,j) = cs%v(i,j,1)
03099 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03100 
03101   \textcolor{keywordflow}{else}  \textcolor{comment}{! (CS%Hmix >= 0.0)}
03102     h\_rescale = 1.0 ; \textcolor{keywordflow}{if} (cs%answers\_2018) h\_rescale = gv%H\_to\_Z
03103     depth\_ml = cs%Hmix
03104     \textcolor{keywordflow}{if} (.not.cs%answers\_2018) depth\_ml = cs%Hmix*gv%Z\_to\_H
03105     \textcolor{comment}{! Determine the mean tracer properties of the uppermost depth\_ml fluid.}
03106 
03107     \textcolor{comment}{!$OMP parallel do default(shared) private(depth,dh)}
03108     \textcolor{keywordflow}{do} j=js,je
03109       \textcolor{keywordflow}{do} i=is,ie
03110         depth(i) = 0.0
03111         \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03112           sfc\_state%SST(i,j) = 0.0 ; sfc\_state%SSS(i,j) = 0.0
03113         \textcolor{keywordflow}{else}
03114           sfc\_state%sfc\_density(i,j) = 0.0
03115 \textcolor{keywordflow}{        endif}
03116 \textcolor{keywordflow}{      enddo}
03117 
03118       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
03119         \textcolor{keywordflow}{if} (depth(i) + h(i,j,k)*h\_rescale < depth\_ml) \textcolor{keywordflow}{then}
03120           dh = h(i,j,k)*h\_rescale
03121         \textcolor{keywordflow}{elseif} (depth(i) < depth\_ml) \textcolor{keywordflow}{then}
03122           dh = depth\_ml - depth(i)
03123         \textcolor{keywordflow}{else}
03124           dh = 0.0
03125 \textcolor{keywordflow}{        endif}
03126         \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03127           sfc\_state%SST(i,j) = sfc\_state%SST(i,j) + dh * cs%tv%T(i,j,k)
03128           sfc\_state%SSS(i,j) = sfc\_state%SSS(i,j) + dh * cs%tv%S(i,j,k)
03129         \textcolor{keywordflow}{else}
03130           sfc\_state%sfc\_density(i,j) = sfc\_state%sfc\_density(i,j) + dh * gv%Rlay(k)
03131 \textcolor{keywordflow}{        endif}
03132         depth(i) = depth(i) + dh
03133 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
03134   \textcolor{comment}{! Calculate the average properties of the mixed layer depth.}
03135       \textcolor{keywordflow}{do} i=is,ie
03136         \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
03137           \textcolor{keywordflow}{if} (depth(i) < gv%H\_subroundoff*h\_rescale) &
03138               depth(i) = gv%H\_subroundoff*h\_rescale
03139           \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03140             sfc\_state%SST(i,j) = sfc\_state%SST(i,j) / depth(i)
03141             sfc\_state%SSS(i,j) = sfc\_state%SSS(i,j) / depth(i)
03142           \textcolor{keywordflow}{else}
03143             sfc\_state%sfc\_density(i,j) = sfc\_state%sfc\_density(i,j) / depth(i)
03144 \textcolor{keywordflow}{          endif}
03145         \textcolor{keywordflow}{else}
03146           \textcolor{keywordflow}{if} (depth(i) < gv%H\_subroundoff*h\_rescale) \textcolor{keywordflow}{then}
03147             i\_depth = 1.0 / (gv%H\_subroundoff*h\_rescale)
03148             missing\_depth = gv%H\_subroundoff*h\_rescale - depth(i)
03149             \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03150               sfc\_state%SST(i,j) = (sfc\_state%SST(i,j) + missing\_depth*cs%tv%T(i,j,1)) * i\_depth
03151               sfc\_state%SSS(i,j) = (sfc\_state%SSS(i,j) + missing\_depth*cs%tv%S(i,j,1)) * i\_depth
03152             \textcolor{keywordflow}{else}
03153               sfc\_state%sfc\_density(i,j) = (sfc\_state%sfc\_density(i,j) + &
03154                                             missing\_depth*gv%Rlay(1)) * i\_depth
03155 \textcolor{keywordflow}{            endif}
03156           \textcolor{keywordflow}{else}
03157             i\_depth = 1.0 / depth(i)
03158             \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03159               sfc\_state%SST(i,j) = sfc\_state%SST(i,j) * i\_depth
03160               sfc\_state%SSS(i,j) = sfc\_state%SSS(i,j) * i\_depth
03161             \textcolor{keywordflow}{else}
03162               sfc\_state%sfc\_density(i,j) = sfc\_state%sfc\_density(i,j) * i\_depth
03163 \textcolor{keywordflow}{            endif}
03164 \textcolor{keywordflow}{          endif}
03165 \textcolor{keywordflow}{        endif}
03166 \textcolor{keywordflow}{      enddo}
03167 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! end of j loop}
03168 
03169 \textcolor{comment}{!   Determine the mean velocities in the uppermost depth\_ml fluid.}
03170     \textcolor{comment}{! NOTE: Velocity loops start on `[ij]s-1` in order to update halo values}
03171     \textcolor{comment}{!       required by the speed diagnostic on the non-symmetric grid.}
03172     \textcolor{comment}{!       This assumes that u and v halos have already been updated.}
03173     \textcolor{keywordflow}{if} (cs%Hmix\_UV>0.) \textcolor{keywordflow}{then}
03174       depth\_ml = cs%Hmix\_UV
03175       \textcolor{keywordflow}{if} (.not.cs%answers\_2018) depth\_ml = cs%Hmix\_UV*gv%Z\_to\_H
03176       \textcolor{comment}{!$OMP parallel do default(shared) private(depth,dh,hv)}
03177       \textcolor{keywordflow}{do} j=js-1,ie
03178         \textcolor{keywordflow}{do} i=is,ie
03179           depth(i) = 0.0
03180           sfc\_state%v(i,j) = 0.0
03181 \textcolor{keywordflow}{        enddo}
03182         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
03183           hv = 0.5 * (h(i,j,k) + h(i,j+1,k)) * h\_rescale
03184           \textcolor{keywordflow}{if} (depth(i) + hv < depth\_ml) \textcolor{keywordflow}{then}
03185             dh = hv
03186           \textcolor{keywordflow}{elseif} (depth(i) < depth\_ml) \textcolor{keywordflow}{then}
03187             dh = depth\_ml - depth(i)
03188           \textcolor{keywordflow}{else}
03189             dh = 0.0
03190 \textcolor{keywordflow}{          endif}
03191           sfc\_state%v(i,j) = sfc\_state%v(i,j) + dh * cs%v(i,j,k)
03192           depth(i) = depth(i) + dh
03193 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
03194         \textcolor{comment}{! Calculate the average properties of the mixed layer depth.}
03195         \textcolor{keywordflow}{do} i=is,ie
03196           sfc\_state%v(i,j) = sfc\_state%v(i,j) / max(depth(i), gv%H\_subroundoff*h\_rescale)
03197 \textcolor{keywordflow}{        enddo}
03198 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! end of j loop}
03199 
03200       \textcolor{comment}{!$OMP parallel do default(shared) private(depth,dh,hu)}
03201       \textcolor{keywordflow}{do} j=js,je
03202         \textcolor{keywordflow}{do} i=is-1,ie
03203           depth(i) = 0.0
03204           sfc\_state%u(i,j) = 0.0
03205 \textcolor{keywordflow}{        enddo}
03206         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is-1,ie
03207           hu = 0.5 * (h(i,j,k) + h(i+1,j,k)) * h\_rescale
03208           \textcolor{keywordflow}{if} (depth(i) + hu < depth\_ml) \textcolor{keywordflow}{then}
03209             dh = hu
03210           \textcolor{keywordflow}{elseif} (depth(i) < depth\_ml) \textcolor{keywordflow}{then}
03211             dh = depth\_ml - depth(i)
03212           \textcolor{keywordflow}{else}
03213             dh = 0.0
03214 \textcolor{keywordflow}{          endif}
03215           sfc\_state%u(i,j) = sfc\_state%u(i,j) + dh * cs%u(i,j,k)
03216           depth(i) = depth(i) + dh
03217 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
03218         \textcolor{comment}{! Calculate the average properties of the mixed layer depth.}
03219         \textcolor{keywordflow}{do} i=is-1,ie
03220           sfc\_state%u(i,j) = sfc\_state%u(i,j) / max(depth(i), gv%H\_subroundoff*h\_rescale)
03221 \textcolor{keywordflow}{        enddo}
03222 \textcolor{keywordflow}{      enddo} \textcolor{comment}{! end of j loop}
03223     \textcolor{keywordflow}{else} \textcolor{comment}{! Hmix\_UV<=0.}
03224       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ie
03225         sfc\_state%u(i,j) = cs%u(i,j,1)
03226 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
03227       \textcolor{keywordflow}{do} j=js-1,je ; \textcolor{keywordflow}{do} i=is,ie
03228         sfc\_state%v(i,j) = cs%v(i,j,1)
03229 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
03230 \textcolor{keywordflow}{    endif}
03231 \textcolor{keywordflow}{  endif}  \textcolor{comment}{! (CS%Hmix >= 0.0)}
03232 
03233 
03234   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%melt\_potential)) \textcolor{keywordflow}{then}
03235     \textcolor{comment}{!$OMP parallel do default(shared) private(depth\_ml, dh, T\_freeze, depth, delT)}
03236     \textcolor{keywordflow}{do} j=js,je
03237       \textcolor{keywordflow}{do} i=is,ie
03238         depth(i) = 0.0
03239         delt(i) = 0.0
03240 \textcolor{keywordflow}{      enddo}
03241 
03242       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
03243         depth\_ml = min(cs%HFrz, cs%visc%MLD(i,j))
03244         \textcolor{keywordflow}{if} (depth(i) + h(i,j,k)*gv%H\_to\_Z < depth\_ml) \textcolor{keywordflow}{then}
03245           dh = h(i,j,k)*gv%H\_to\_Z
03246         \textcolor{keywordflow}{elseif} (depth(i) < depth\_ml) \textcolor{keywordflow}{then}
03247           dh = depth\_ml - depth(i)
03248         \textcolor{keywordflow}{else}
03249           dh = 0.0
03250 \textcolor{keywordflow}{        endif}
03251 
03252         \textcolor{comment}{! p=0 OK, HFrz ~ 10 to 20m}
03253         \textcolor{keyword}{call }calculate\_tfreeze(cs%tv%S(i,j,k), 0.0, t\_freeze, cs%tv%eqn\_of\_state)
03254         depth(i) = depth(i) + dh
03255         delt(i) =  delt(i) + dh * (cs%tv%T(i,j,k) - t\_freeze)
03256 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
03257 
03258       \textcolor{keywordflow}{do} i=is,ie
03259        \textcolor{comment}{! set melt\_potential to zero to avoid passing previous values}
03260        sfc\_state%melt\_potential(i,j) = 0.0
03261 
03262        \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
03263          \textcolor{comment}{! instantaneous melt\_potential [Q R Z ~> J m-2]}
03264          sfc\_state%melt\_potential(i,j) = cs%tv%C\_p * gv%Rho0 * delt(i)
03265 \textcolor{keywordflow}{       endif}
03266 \textcolor{keywordflow}{      enddo}
03267 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! end of j loop}
03268 \textcolor{keywordflow}{  endif}   \textcolor{comment}{! melt\_potential}
03269 
03270   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%salt\_deficit) .and. \textcolor{keyword}{associated}(cs%tv%salt\_deficit)) \textcolor{keywordflow}{then}
03271     \textcolor{comment}{!$OMP parallel do default(shared)}
03272     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03273       \textcolor{comment}{! Convert from gSalt to kgSalt}
03274       sfc\_state%salt\_deficit(i,j) = 0.001 * cs%tv%salt\_deficit(i,j)
03275 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03276 \textcolor{keywordflow}{  endif}
03277   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%TempxPmE) .and. \textcolor{keyword}{associated}(cs%tv%TempxPmE)) \textcolor{keywordflow}{then}
03278     \textcolor{comment}{!$OMP parallel do default(shared)}
03279     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03280       sfc\_state%TempxPmE(i,j) = cs%tv%TempxPmE(i,j)
03281 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03282 \textcolor{keywordflow}{  endif}
03283   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%internal\_heat) .and. \textcolor{keyword}{associated}(cs%tv%internal\_heat)) \textcolor{keywordflow}{then}
03284     \textcolor{comment}{!$OMP parallel do default(shared)}
03285     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03286       sfc\_state%internal\_heat(i,j) = cs%tv%internal\_heat(i,j)
03287 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03288 \textcolor{keywordflow}{  endif}
03289   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%taux\_shelf) .and. \textcolor{keyword}{associated}(cs%visc%taux\_shelf)) \textcolor{keywordflow}{then}
03290     \textcolor{comment}{!$OMP parallel do default(shared)}
03291     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ie
03292       sfc\_state%taux\_shelf(i,j) = cs%visc%taux\_shelf(i,j)
03293 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03294 \textcolor{keywordflow}{  endif}
03295   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%tauy\_shelf) .and. \textcolor{keyword}{associated}(cs%visc%tauy\_shelf)) \textcolor{keywordflow}{then}
03296     \textcolor{comment}{!$OMP parallel do default(shared)}
03297     \textcolor{keywordflow}{do} j=js-1,je ; \textcolor{keywordflow}{do} i=is,ie
03298       sfc\_state%tauy\_shelf(i,j) = cs%visc%tauy\_shelf(i,j)
03299 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03300 \textcolor{keywordflow}{  endif}
03301 
03302   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%ocean\_mass) .and. \textcolor{keyword}{allocated}(sfc\_state%ocean\_heat) .and. &
03303       \textcolor{keyword}{allocated}(sfc\_state%ocean\_salt)) \textcolor{keywordflow}{then}
03304     \textcolor{comment}{!$OMP parallel do default(shared)}
03305     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
03306       sfc\_state%ocean\_mass(i,j) = 0.0
03307       sfc\_state%ocean\_heat(i,j) = 0.0 ; sfc\_state%ocean\_salt(i,j) = 0.0
03308 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03309     \textcolor{comment}{!$OMP parallel do default(shared) private(mass)}
03310     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} i=is,ie
03311       mass = gv%H\_to\_RZ*h(i,j,k)
03312       sfc\_state%ocean\_mass(i,j) = sfc\_state%ocean\_mass(i,j) + mass
03313       sfc\_state%ocean\_heat(i,j) = sfc\_state%ocean\_heat(i,j) + mass * cs%tv%T(i,j,k)
03314       sfc\_state%ocean\_salt(i,j) = sfc\_state%ocean\_salt(i,j) + mass * (1.0e-3*cs%tv%S(i,j,k))
03315 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03316   \textcolor{keywordflow}{else}
03317     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%ocean\_mass)) \textcolor{keywordflow}{then}
03318       \textcolor{comment}{!$OMP parallel do default(shared)}
03319       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; sfc\_state%ocean\_mass(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03320       \textcolor{comment}{!$OMP parallel do default(shared)}
03321       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
03322         sfc\_state%ocean\_mass(i,j) = sfc\_state%ocean\_mass(i,j) + gv%H\_to\_RZ*h(i,j,k)
03323 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03324 \textcolor{keywordflow}{    endif}
03325     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%ocean\_heat)) \textcolor{keywordflow}{then}
03326       \textcolor{comment}{!$OMP parallel do default(shared)}
03327       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; sfc\_state%ocean\_heat(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03328       \textcolor{comment}{!$OMP parallel do default(shared) private(mass)}
03329       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
03330         mass = gv%H\_to\_RZ*h(i,j,k)
03331         sfc\_state%ocean\_heat(i,j) = sfc\_state%ocean\_heat(i,j) + mass*cs%tv%T(i,j,k)
03332 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03333 \textcolor{keywordflow}{    endif}
03334     \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%ocean\_salt)) \textcolor{keywordflow}{then}
03335       \textcolor{comment}{!$OMP parallel do default(shared)}
03336       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; sfc\_state%ocean\_salt(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03337       \textcolor{comment}{!$OMP parallel do default(shared) private(mass)}
03338       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
03339         mass = gv%H\_to\_RZ*h(i,j,k)
03340         sfc\_state%ocean\_salt(i,j) = sfc\_state%ocean\_salt(i,j) + mass * (1.0e-3*cs%tv%S(i,j,k))
03341 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
03342 \textcolor{keywordflow}{    endif}
03343 \textcolor{keywordflow}{  endif}
03344 
03345   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tracer\_flow\_CSp)) \textcolor{keywordflow}{then}
03346     \textcolor{keyword}{call }call\_tracer\_surface\_state(sfc\_state, h, g, cs%tracer\_flow\_CSp)
03347 \textcolor{keywordflow}{  endif}
03348 
03349   \textcolor{keywordflow}{if} (cs%check\_bad\_sfc\_vals) \textcolor{keywordflow}{then}
03350     numberoferrors=0 \textcolor{comment}{! count number of errors}
03351     \textcolor{keywordflow}{do} j=js,je; \textcolor{keywordflow}{do} i=is,ie
03352       \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
03353         localerror = sfc\_state%sea\_lev(i,j) <= -g%bathyT(i,j) &
03354                 .or. sfc\_state%sea\_lev(i,j) >=  cs%bad\_val\_ssh\_max  &
03355                 .or. sfc\_state%sea\_lev(i,j) <= -cs%bad\_val\_ssh\_max  &
03356                 .or. sfc\_state%sea\_lev(i,j) + g%bathyT(i,j) < cs%bad\_val\_col\_thick
03357         \textcolor{keywordflow}{if} (use\_temperature) localerror = localerror &
03358                 .or. sfc\_state%SSS(i,j)<0.                        &
03359                 .or. sfc\_state%SSS(i,j)>=cs%bad\_val\_sss\_max       &
03360                 .or. sfc\_state%SST(i,j)< cs%bad\_val\_sst\_min       &
03361                 .or. sfc\_state%SST(i,j)>=cs%bad\_val\_sst\_max
03362         \textcolor{keywordflow}{if} (localerror) \textcolor{keywordflow}{then}
03363           numberoferrors=numberoferrors+1
03364           \textcolor{keywordflow}{if} (numberoferrors<9) \textcolor{keywordflow}{then} \textcolor{comment}{! Only report details for the first few errors}
03365             ig = i + g%HI%idg\_offset \textcolor{comment}{! Global i-index}
03366             jg = j + g%HI%jdg\_offset \textcolor{comment}{! Global j-index}
03367             \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03368               \textcolor{keyword}{write}(msg(1:240),\textcolor{stringliteral}{'(2(a,i4,x),4(a,f8.3,x),8(a,es11.4,x))'}) &
03369                 \textcolor{stringliteral}{'Extreme surface sfc\_state detected: i='},ig,\textcolor{stringliteral}{'j='},jg, &
03370                 \textcolor{stringliteral}{'lon='},g%geoLonT(i,j), \textcolor{stringliteral}{'lat='},g%geoLatT(i,j), &
03371                 \textcolor{stringliteral}{'x='},g%gridLonT(ig), \textcolor{stringliteral}{'y='},g%gridLatT(jg), &
03372                 \textcolor{stringliteral}{'D='},cs%US%Z\_to\_m*g%bathyT(i,j),  \textcolor{stringliteral}{'SSH='},cs%US%Z\_to\_m*sfc\_state%sea\_lev(i,j), &
03373                 \textcolor{stringliteral}{'SST='},sfc\_state%SST(i,j), \textcolor{stringliteral}{'SSS='},sfc\_state%SSS(i,j), &
03374                 \textcolor{stringliteral}{'U-='},us%L\_T\_to\_m\_s*sfc\_state%u(i-1,j), \textcolor{stringliteral}{'U+='},us%L\_T\_to\_m\_s*sfc\_state%u(i,j), &
03375                 \textcolor{stringliteral}{'V-='},us%L\_T\_to\_m\_s*sfc\_state%v(i,j-1), \textcolor{stringliteral}{'V+='},us%L\_T\_to\_m\_s*sfc\_state%v(i,j)
03376             \textcolor{keywordflow}{else}
03377               \textcolor{keyword}{write}(msg(1:240),\textcolor{stringliteral}{'(2(a,i4,x),4(a,f8.3,x),6(a,es11.4))'}) &
03378                 \textcolor{stringliteral}{'Extreme surface sfc\_state detected: i='},ig,\textcolor{stringliteral}{'j='},jg, &
03379                 \textcolor{stringliteral}{'lon='},g%geoLonT(i,j), \textcolor{stringliteral}{'lat='},g%geoLatT(i,j), &
03380                 \textcolor{stringliteral}{'x='},g%gridLonT(i), \textcolor{stringliteral}{'y='},g%gridLatT(j), &
03381                 \textcolor{stringliteral}{'D='},cs%US%Z\_to\_m*g%bathyT(i,j),  \textcolor{stringliteral}{'SSH='},cs%US%Z\_to\_m*sfc\_state%sea\_lev(i,j), &
03382                 \textcolor{stringliteral}{'U-='},us%L\_T\_to\_m\_s*sfc\_state%u(i-1,j), \textcolor{stringliteral}{'U+='},us%L\_T\_to\_m\_s*sfc\_state%u(i,j), &
03383                 \textcolor{stringliteral}{'V-='},us%L\_T\_to\_m\_s*sfc\_state%v(i,j-1), \textcolor{stringliteral}{'V+='},us%L\_T\_to\_m\_s*sfc\_state%v(i,j)
03384 \textcolor{keywordflow}{            endif}
03385             \textcolor{keyword}{call }mom\_error(warning, trim(msg), all\_print=.true.)
03386           \textcolor{keywordflow}{elseif} (numberoferrors==9) \textcolor{keywordflow}{then} \textcolor{comment}{! Indicate once that there are more errors}
03387             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{'There were more unreported extreme events!'}, all\_print=.true.)
03388 \textcolor{keywordflow}{          endif} \textcolor{comment}{! numberOfErrors}
03389 \textcolor{keywordflow}{        endif} \textcolor{comment}{! localError}
03390 \textcolor{keywordflow}{      endif} \textcolor{comment}{! mask2dT}
03391 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
03392     \textcolor{keyword}{call }sum\_across\_pes(numberoferrors)
03393     \textcolor{keywordflow}{if} (numberoferrors>0) \textcolor{keywordflow}{then}
03394       \textcolor{keyword}{write}(msg(1:240),\textcolor{stringliteral}{'(3(a,i9,x))'}) \textcolor{stringliteral}{'There were a total of '},numberoferrors, &
03395           \textcolor{stringliteral}{'locations detected with extreme surface values!'}
03396       \textcolor{keyword}{call }mom\_error(fatal, trim(msg))
03397 \textcolor{keywordflow}{    endif}
03398 \textcolor{keywordflow}{  endif}
03399 
03400   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keyword}{call }mom\_surface\_chksum(\textcolor{stringliteral}{"Post extract\_sfc"}, sfc\_state, g, us, haloshift=0)
03401 
03402   \textcolor{comment}{! Rotate sfc\_state back onto the input grid, sfc\_state\_in}
03403   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
03404     \textcolor{keyword}{call }rotate\_surface\_state(sfc\_state, g, sfc\_state\_in, g\_in, -turns)
03405     \textcolor{keyword}{call }deallocate\_surface\_state(sfc\_state)
03406 \textcolor{keywordflow}{  endif}
03407 
03408   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"extract\_surface\_sfc\_state()"})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a2269d5cd79625cbf16cb916346379207}\label{namespacemom_a2269d5cd79625cbf16cb916346379207}} 
\index{mom@{mom}!finish\+\_\+mom\+\_\+initialization@{finish\+\_\+mom\+\_\+initialization}}
\index{finish\+\_\+mom\+\_\+initialization@{finish\+\_\+mom\+\_\+initialization}!mom@{mom}}
\subsubsection{\texorpdfstring{finish\+\_\+mom\+\_\+initialization()}{finish\_mom\_initialization()}}
{\footnotesize\ttfamily subroutine, public mom\+::finish\+\_\+mom\+\_\+initialization (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(directories), intent(in)}]{dirs,  }\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Finishes initializing M\+OM and writes out the initial conditions. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & model time, used in this routine\\
\hline
\mbox{\tt in}  & {\em dirs} & structure with directory paths\\
\hline
 & {\em cs} & pointer to M\+OM control structure\\
\hline
 & {\em restart\+\_\+csp} & pointer to the restart control structure that will be used for M\+OM. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l02774}{2774} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_a7cf03c18244d0630616e925bab1841a2}{id\+\_\+clock\+\_\+init}.


\begin{DoxyCode}
02774   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{        !< model time, used in this routine}
02775   \textcolor{keywordtype}{type}(directories),        \textcolor{keywordtype}{intent(in)}    :: dirs\textcolor{comment}{        !< structure with directory paths}
02776   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{          !< pointer to MOM control structure}
02777   \textcolor{keywordtype}{type}(mom\_restart\_cs),     \textcolor{keywordtype}{pointer}       :: restart\_csp\textcolor{comment}{ !< pointer to the restart control}
02778 \textcolor{comment}{                                                         !! structure that will be used for MOM.}
02779   \textcolor{comment}{! Local variables}
02780   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer} :: g => null()  \textcolor{comment}{! pointer to a structure containing}
02781                                                    \textcolor{comment}{! metrics and related information}
02782   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv => null() \textcolor{comment}{! Pointer to the vertical grid structure}
02783   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{! Pointer to a structure containing}
02784                                                    \textcolor{comment}{! various unit conversion factors}
02785   \textcolor{keywordtype}{type}(mom\_restart\_cs),    \textcolor{keywordtype}{pointer} :: restart\_csp\_tmp => null()
02786   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable} :: z\_interface(:,:,:) \textcolor{comment}{! Interface heights [m]}
02787   \textcolor{keywordtype}{type}(vardesc) :: vd
02788 
02789   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_init)
02790   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"finish\_MOM\_initialization()"})
02791 
02792   \textcolor{comment}{! Pointers for convenience}
02793   g => cs%G ; gv => cs%GV ; us => cs%US
02794 
02795   \textcolor{comment}{!### Move to initialize\_MOM?}
02796   \textcolor{keyword}{call }fix\_restart\_scaling(gv)
02797   \textcolor{keyword}{call }fix\_restart\_unit\_scaling(us)
02798 
02799   \textcolor{comment}{! Write initial conditions}
02800   \textcolor{keywordflow}{if} (cs%write\_IC) \textcolor{keywordflow}{then}
02801     \textcolor{keyword}{allocate}(restart\_csp\_tmp)
02802     restart\_csp\_tmp = restart\_csp
02803     \textcolor{keyword}{allocate}(z\_interface(szi\_(g),szj\_(g),szk\_(g)+1))
02804     \textcolor{keyword}{call }find\_eta(cs%h, cs%tv, g, gv, us, z\_interface, eta\_to\_m=1.0)
02805     \textcolor{keyword}{call }register\_restart\_field(z\_interface, \textcolor{stringliteral}{"eta"}, .true., restart\_csp\_tmp, &
02806                                 \textcolor{stringliteral}{"Interface heights"}, \textcolor{stringliteral}{"meter"}, z\_grid=\textcolor{stringliteral}{'i'})
02807 
02808     \textcolor{keyword}{call }save\_restart(dirs%output\_directory, time, cs%G\_in, &
02809                       restart\_csp\_tmp, filename=cs%IC\_file, gv=gv)
02810     \textcolor{keyword}{deallocate}(z\_interface)
02811     \textcolor{keyword}{deallocate}(restart\_csp\_tmp)
02812 \textcolor{keywordflow}{  endif}
02813 
02814   \textcolor{keyword}{call }write\_energy(cs%u, cs%v, cs%h, cs%tv, time, 0, g, gv, us, &
02815                     cs%sum\_output\_CSp, cs%tracer\_flow\_CSp)
02816 
02817   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"finish\_MOM\_initialization()"})
02818   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_init)
02819 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_aece0dd1e2c9498844befd8ba71986b96}\label{namespacemom_aece0dd1e2c9498844befd8ba71986b96}} 
\index{mom@{mom}!get\+\_\+mom\+\_\+state\+\_\+elements@{get\+\_\+mom\+\_\+state\+\_\+elements}}
\index{get\+\_\+mom\+\_\+state\+\_\+elements@{get\+\_\+mom\+\_\+state\+\_\+elements}!mom@{mom}}
\subsubsection{\texorpdfstring{get\+\_\+mom\+\_\+state\+\_\+elements()}{get\_mom\_state\_elements()}}
{\footnotesize\ttfamily subroutine, public mom\+::get\+\_\+mom\+\_\+state\+\_\+elements (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), optional, pointer}]{G,  }\item[{type(verticalgrid\+\_\+type), optional, pointer}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), optional, pointer}]{US,  }\item[{real, intent(out), optional}]{C\+\_\+p,  }\item[{real, intent(out), optional}]{C\+\_\+p\+\_\+scaled,  }\item[{logical, intent(out), optional}]{use\+\_\+temp }\end{DoxyParamCaption})}



This subroutine offers access to values or pointers to other types from within the M\+O\+M\+\_\+control\+\_\+struct, allowing the M\+O\+M\+\_\+control\+\_\+struct to be opaque. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & M\+OM control structure\\
\hline
 & {\em g} & structure containing metrics and grid info\\
\hline
 & {\em gv} & structure containing vertical grid info\\
\hline
 & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt out}  & {\em c\+\_\+p} & The heat capacity \mbox{[}J kg deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em c\+\_\+p\+\_\+scaled} & The heat capacity in scaled units \mbox{[}Q deg\+C-\/1 $\sim$$>$ J kg deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em use\+\_\+temp} & True if temperature is a state variable \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l03450}{3450} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.


\begin{DoxyCode}
03450   \textcolor{keywordtype}{type}(mom\_control\_struct),          \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{ !< MOM control structure}
03451   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: g\textcolor{comment}{    !< structure containing metrics and grid info}
03452   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: gv\textcolor{comment}{   !< structure containing vertical grid info}
03453   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}     :: us\textcolor{comment}{   !< A dimensional unit scaling type}
03454   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: c\_p\textcolor{comment}{  !< The heat capacity [J kg degC-1]}
03455   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: c\_p\_scaled\textcolor{comment}{ !< The heat capacity in scaled}
03456 \textcolor{comment}{                                                         !! units [Q degC-1 ~> J kg degC-1]}
03457   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: use\_temp\textcolor{comment}{ !< True if temperature is a state variable}
03458 
03459   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(g)) g => cs%G\_in
03460   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(gv)) gv => cs%GV
03461   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) us => cs%US
03462   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(c\_p)) c\_p = cs%US%Q\_to\_J\_kg * cs%tv%C\_p
03463   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(c\_p\_scaled)) c\_p\_scaled = cs%tv%C\_p
03464   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(use\_temp)) use\_temp = \textcolor{keyword}{associated}(cs%tv%T)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a462293ed92e99927ef9939747d633080}\label{namespacemom_a462293ed92e99927ef9939747d633080}} 
\index{mom@{mom}!get\+\_\+ocean\+\_\+stocks@{get\+\_\+ocean\+\_\+stocks}}
\index{get\+\_\+ocean\+\_\+stocks@{get\+\_\+ocean\+\_\+stocks}!mom@{mom}}
\subsubsection{\texorpdfstring{get\+\_\+ocean\+\_\+stocks()}{get\_ocean\_stocks()}}
{\footnotesize\ttfamily subroutine, public mom\+::get\+\_\+ocean\+\_\+stocks (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{real, intent(out), optional}]{mass,  }\item[{real, intent(out), optional}]{heat,  }\item[{real, intent(out), optional}]{salt,  }\item[{logical, intent(in), optional}]{on\+\_\+\+P\+E\+\_\+only }\end{DoxyParamCaption})}



Find the global integrals of various quantities. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & M\+OM control structure\\
\hline
\mbox{\tt out}  & {\em heat} & The globally integrated integrated ocean heat \mbox{[}J\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em salt} & The globally integrated integrated ocean salt \mbox{[}kg\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em mass} & The globally integrated integrated ocean mass \mbox{[}kg\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em on\+\_\+pe\+\_\+only} & If present and true, only sum on the local PE. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l03469}{3469} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.


\begin{DoxyCode}
03469   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< MOM control structure}
03470   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: heat\textcolor{comment}{  !< The globally integrated integrated ocean heat [J].}
03471   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: salt\textcolor{comment}{  !< The globally integrated integrated ocean salt [kg].}
03472   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: mass\textcolor{comment}{  !< The globally integrated integrated ocean mass [kg].}
03473   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: on\_pe\_only\textcolor{comment}{ !< If present and true, only sum on the local PE.}
03474 
03475   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(mass)) &
03476     mass = global\_mass\_integral(cs%h, cs%G, cs%GV, on\_pe\_only=on\_pe\_only)
03477   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(heat)) &
03478     heat = cs%US%Q\_to\_J\_kg*cs%tv%C\_p * global\_mass\_integral(cs%h, cs%G, cs%GV, cs%tv%T, on\_pe\_only=
      on\_pe\_only)
03479   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(salt)) &
03480     salt = 1.0e-3 * global\_mass\_integral(cs%h, cs%G, cs%GV, cs%tv%S, on\_pe\_only=on\_pe\_only)
03481 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a96708b16215666edbfa5b46228f3a200}\label{namespacemom_a96708b16215666edbfa5b46228f3a200}} 
\index{mom@{mom}!initialize\+\_\+mom@{initialize\+\_\+mom}}
\index{initialize\+\_\+mom@{initialize\+\_\+mom}!mom@{mom}}
\subsubsection{\texorpdfstring{initialize\+\_\+mom()}{initialize\_mom()}}
{\footnotesize\ttfamily subroutine, public mom\+::initialize\+\_\+mom (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(inout), target}]{Time,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+init,  }\item[{type(param\+\_\+file\+\_\+type), intent(out)}]{param\+\_\+file,  }\item[{type(directories), intent(out)}]{dirs,  }\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+C\+Sp,  }\item[{type(time\+\_\+type), intent(in), optional}]{Time\+\_\+in,  }\item[{logical, intent(out), optional}]{offline\+\_\+tracer\+\_\+mode,  }\item[{character(len=$\ast$), intent(in), optional}]{input\+\_\+restart\+\_\+file,  }\item[{type(diag\+\_\+ctrl), optional, pointer}]{diag\+\_\+ptr,  }\item[{logical, intent(in), optional}]{count\+\_\+calls,  }\item[{type(tracer\+\_\+flow\+\_\+control\+\_\+cs), optional, pointer}]{tracer\+\_\+flow\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initialize M\+OM, including memory allocation, setting up parameters and diagnostics, initializing the ocean state variables, and initializing subsidiary modules. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em time} & model time, set in this routine\\
\hline
\mbox{\tt in}  & {\em time\+\_\+init} & The start time for the coupled model\textquotesingle{}s calendar\\
\hline
\mbox{\tt out}  & {\em param\+\_\+file} & structure indicating parameter file to parse\\
\hline
\mbox{\tt out}  & {\em dirs} & structure with directory paths\\
\hline
 & {\em cs} & pointer set in this routine to M\+OM control structure\\
\hline
 & {\em restart\+\_\+csp} & pointer set in this routine to the restart control structure that will be used for M\+OM.\\
\hline
\mbox{\tt in}  & {\em time\+\_\+in} & time passed to M\+O\+M\+\_\+initialize\+\_\+state when model is not being started from a restart file\\
\hline
\mbox{\tt out}  & {\em offline\+\_\+tracer\+\_\+mode} & True is returned if tracers are being run offline\\
\hline
\mbox{\tt in}  & {\em input\+\_\+restart\+\_\+file} & If present, name of restart file to read\\
\hline
 & {\em diag\+\_\+ptr} & A pointer set in this routine to the diagnostic regulatory structure\\
\hline
 & {\em tracer\+\_\+flow\+\_\+csp} & A pointer set in this routine to\\
\hline
\mbox{\tt in}  & {\em count\+\_\+calls} & If true, nstep\+\_\+tot counts the number of calls to step\+\_\+\+M\+OM instead of the number of dynamics timesteps. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l01604}{1604} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_a7cf03c18244d0630616e925bab1841a2}{id\+\_\+clock\+\_\+init}, \hyperlink{namespacemom_a4180eb85bab39df7cbb72bb8e5b19fd4}{id\+\_\+clock\+\_\+mom\+\_\+init}, \hyperlink{namespacemom_ac4d20612cad32d412dae492fedc2e971}{id\+\_\+clock\+\_\+pass\+\_\+init}, \hyperlink{namespacemom_a785851181d2a3db5a938322d2ff9498a}{id\+\_\+clock\+\_\+unit\+\_\+tests}, \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_af0f791729b0ccb6cb8ae2f4d28edee21}{register\+\_\+diags()}, \hyperlink{namespacemom_a8f5160e583b599050515b8fe5575aa15}{rotate\+\_\+initial\+\_\+state()}, and \hyperlink{namespacemom_a76cb0af280a5c9e877dc206a6849b46b}{set\+\_\+restart\+\_\+fields()}.


\begin{DoxyCode}
01604   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target},   \textcolor{keywordtype}{intent(inout)} :: time\textcolor{comment}{        !< model time, set in this routine}
01605   \textcolor{keywordtype}{type}(time\_type),           \textcolor{keywordtype}{intent(in)}    :: time\_init\textcolor{comment}{   !< The start time for the coupled model's
       calendar}
01606   \textcolor{keywordtype}{type}(param\_file\_type),     \textcolor{keywordtype}{intent(out)}   :: param\_file\textcolor{comment}{  !< structure indicating parameter file to parse}
01607   \textcolor{keywordtype}{type}(directories),         \textcolor{keywordtype}{intent(out)}   :: dirs\textcolor{comment}{        !< structure with directory paths}
01608   \textcolor{keywordtype}{type}(mom\_control\_struct),  \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{          !< pointer set in this routine to MOM control
       structure}
01609   \textcolor{keywordtype}{type}(mom\_restart\_cs),      \textcolor{keywordtype}{pointer}       :: restart\_csp\textcolor{comment}{ !< pointer set in this routine to the}
01610 \textcolor{comment}{                                                          !! restart control structure that will}
01611 \textcolor{comment}{                                                          !! be used for MOM.}
01612   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: time\_in\textcolor{comment}{     !< time passed to MOM\_initialize\_state when}
01613 \textcolor{comment}{                                                          !! model is not being started from a restart file}
01614   \textcolor{keywordtype}{logical},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: offline\_tracer\_mode\textcolor{comment}{ !< True is returned if tracers are being
       run offline}
01615   \textcolor{keywordtype}{character(len=*)},\textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: input\_restart\_file\textcolor{comment}{ !< If present, name of restart file to
       read}
01616   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: diag\_ptr\textcolor{comment}{    !< A pointer set in this routine to the
       diagnostic}
01617 \textcolor{comment}{                                                          !! regulatory structure}
01618   \textcolor{keywordtype}{type}(tracer\_flow\_control\_cs), &
01619                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: tracer\_flow\_csp\textcolor{comment}{ !< A pointer set in this routine to}
01620 \textcolor{comment}{                                                          !! the tracer flow control structure.}
01621   \textcolor{keywordtype}{logical},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: count\_calls\textcolor{comment}{ !< If true, nstep\_tot counts the number of}
01622 \textcolor{comment}{                                                          !! calls to step\_MOM instead of the number of}
01623 \textcolor{comment}{                                                          !! dynamics timesteps.}
01624   \textcolor{comment}{! local variables}
01625   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{pointer} :: g => null()    \textcolor{comment}{! A pointer to the metric grid use for the run}
01626   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{pointer} :: g\_in => null() \textcolor{comment}{! Pointer to the input grid}
01627   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{pointer} :: hi => null()   \textcolor{comment}{! A hor\_index\_type for array extents}
01628   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{target}  :: hi\_in          \textcolor{comment}{! HI on the input grid}
01629   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv => null()
01630   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: dg => null()
01631   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: dg\_in => null()
01632   \textcolor{keywordtype}{type}(diag\_ctrl),        \textcolor{keywordtype}{pointer} :: diag => null()
01633   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{pointer} :: us => null()
01634   \textcolor{keywordtype}{character(len=4)}, \textcolor{keywordtype}{parameter} :: vers\_num = \textcolor{stringliteral}{'v2.0'}
01635   \textcolor{keywordtype}{integer} :: turns   \textcolor{comment}{! Number of grid quarter-turns}
01636 
01637   \textcolor{comment}{! Initial state on the input index map}
01638   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: u\_in, v\_in, h\_in
01639   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{target} :: t\_in, s\_in
01640   \textcolor{keywordtype}{type}(ocean\_obc\_type), \textcolor{keywordtype}{pointer} :: obc\_in => null()
01641   \textcolor{keywordtype}{type}(sponge\_cs), \textcolor{keywordtype}{pointer} :: sponge\_in\_csp => null()
01642   \textcolor{keywordtype}{type}(ale\_sponge\_cs), \textcolor{keywordtype}{pointer} :: ale\_sponge\_in\_csp => null()
01643 
01644   \textcolor{comment}{! This include declares and sets the variable "version".}
01645 \textcolor{preprocessor}{# include "version\_variable.h"}
01646 \textcolor{preprocessor}{}
01647   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz
01648   \textcolor{keywordtype}{integer} :: isdb, iedb, jsdb, jedb
01649   \textcolor{keywordtype}{real}    :: dtbt        \textcolor{comment}{! The barotropic timestep [s]}
01650 
01651   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)}   :: eta \textcolor{comment}{! free surface height or column mass [H ~> m or kg m-2]}
01652   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)}   :: area\_shelf\_h \textcolor{comment}{! area occupied by ice shelf [L2 ~> m2]}
01653   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target}  :: frac\_shelf\_h \textcolor{comment}{! fraction of total area occupied by ice shelf
       [nondim]}
01654   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: shelf\_area => null()
01655   \textcolor{keywordtype}{type}(mom\_restart\_cs),  \textcolor{keywordtype}{pointer}      :: restart\_csp\_tmp => null()
01656   \textcolor{keywordtype}{type}(group\_pass\_type) :: tmp\_pass\_uv\_t\_s\_h, pass\_uv\_t\_s\_h
01657 
01658   \textcolor{keywordtype}{real}    :: default\_val       \textcolor{comment}{! default value for a parameter}
01659   \textcolor{keywordtype}{logical} :: write\_geom\_files  \textcolor{comment}{! If true, write out the grid geometry files.}
01660   \textcolor{keywordtype}{logical} :: ensemble\_ocean    \textcolor{comment}{! If true, perform an ensemble gather at the end of step\_MOM}
01661   \textcolor{keywordtype}{logical} :: new\_sim
01662   \textcolor{keywordtype}{logical} :: use\_geothermal    \textcolor{comment}{! If true, apply geothermal heating.}
01663   \textcolor{keywordtype}{logical} :: use\_eos           \textcolor{comment}{! If true, density calculated from T & S using an equation of state.}
01664   \textcolor{keywordtype}{logical} :: symmetric         \textcolor{comment}{! If true, use symmetric memory allocation.}
01665   \textcolor{keywordtype}{logical} :: save\_ic           \textcolor{comment}{! If true, save the initial conditions.}
01666   \textcolor{keywordtype}{logical} :: do\_unit\_tests     \textcolor{comment}{! If true, call unit tests.}
01667   \textcolor{keywordtype}{logical} :: test\_grid\_copy = .false.
01668 
01669   \textcolor{keywordtype}{logical} :: bulkmixedlayer    \textcolor{comment}{! If true, a refined bulk mixed layer scheme is used}
01670                                \textcolor{comment}{! with nkml sublayers and nkbl buffer layer.}
01671   \textcolor{keywordtype}{logical} :: use\_temperature   \textcolor{comment}{! If true, temp and saln used as state variables.}
01672   \textcolor{keywordtype}{logical} :: use\_frazil        \textcolor{comment}{! If true, liquid seawater freezes if temp below freezing,}
01673                                \textcolor{comment}{! with accumulated heat deficit returned to surface ocean.}
01674   \textcolor{keywordtype}{logical} :: bound\_salinity    \textcolor{comment}{! If true, salt is added to keep salinity above}
01675                                \textcolor{comment}{! a minimum value, and the deficit is reported.}
01676   \textcolor{keywordtype}{logical} :: default\_2018\_answers \textcolor{comment}{! The default setting for the various 2018\_ANSWERS flags.}
01677   \textcolor{keywordtype}{logical} :: use\_cont\_abss     \textcolor{comment}{! If true, the prognostics T & S are conservative temperature}
01678                                \textcolor{comment}{! and absolute salinity. Care should be taken to convert them}
01679                                \textcolor{comment}{! to potential temperature and practical salinity before}
01680                                \textcolor{comment}{! exchanging them with the coupler and/or reporting T&S diagnostics.}
01681   \textcolor{keywordtype}{logical} :: advect\_ts         \textcolor{comment}{! If false, then no horizontal advection of temperature}
01682                                \textcolor{comment}{! and salnity is performed}
01683   \textcolor{keywordtype}{logical} :: use\_ice\_shelf     \textcolor{comment}{! Needed for ALE}
01684   \textcolor{keywordtype}{logical} :: global\_indexing   \textcolor{comment}{! If true use global horizontal index values instead}
01685                                \textcolor{comment}{! of having the data domain on each processor start at 1.}
01686   \textcolor{keywordtype}{logical} :: bathy\_at\_vel      \textcolor{comment}{! If true, also define bathymetric fields at the}
01687                                \textcolor{comment}{! the velocity points.}
01688   \textcolor{keywordtype}{logical} :: calc\_dtbt         \textcolor{comment}{! Indicates whether the dynamically adjusted barotropic}
01689                                \textcolor{comment}{! time step needs to be updated before it is used.}
01690   \textcolor{keywordtype}{logical} :: debug\_truncations \textcolor{comment}{! If true, turn on diagnostics useful for debugging truncations.}
01691   \textcolor{keywordtype}{integer} :: first\_direction   \textcolor{comment}{! An integer that indicates which direction is to be}
01692                                \textcolor{comment}{! updated first in directionally split parts of the}
01693                                \textcolor{comment}{! calculation.  This can be altered during the course}
01694                                \textcolor{comment}{! of the run via calls to set\_first\_direction.}
01695   \textcolor{keywordtype}{integer} :: nkml, nkbl, verbosity, write\_geom
01696   \textcolor{keywordtype}{integer} :: dynamics\_stencil  \textcolor{comment}{! The computational stencil for the calculations}
01697                                \textcolor{comment}{! in the dynamic core.}
01698   \textcolor{keywordtype}{real} :: conv2watt, conv2salt
01699   \textcolor{keywordtype}{real} :: rl2\_t2\_rescale, z\_rescale, qrz\_rescale \textcolor{comment}{! Unit conversion factors}
01700   \textcolor{keywordtype}{character(len=48)} :: flux\_units, s\_flux\_units
01701 
01702   \textcolor{keywordtype}{type}(vardesc) :: vd\_t, vd\_s  \textcolor{comment}{! Structures describing temperature and salinity variables.}
01703   \textcolor{keywordtype}{type}(time\_type)                 :: start\_time
01704   \textcolor{keywordtype}{type}(ocean\_internal\_state)      :: mom\_internal\_state
01705   \textcolor{keywordtype}{character(len=200)} :: area\_varname, ice\_shelf\_file, inputdir, filename
01706 
01707   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
01708     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"initialize\_MOM called with an associated "}// &
01709                             \textcolor{stringliteral}{"control structure."})
01710     \textcolor{keywordflow}{return}
01711 \textcolor{keywordflow}{  endif}
01712   \textcolor{keyword}{allocate}(cs)
01713 
01714   cs%Time => time
01715 
01716   id\_clock\_init = cpu\_clock\_id(\textcolor{stringliteral}{'Ocean Initialization'}, grain=clock\_subcomponent)
01717   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_init)
01718 
01719   start\_time = time ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(time\_in)) start\_time = time\_in
01720 
01721   \textcolor{comment}{! Read paths and filenames from namelist and store in "dirs".}
01722   \textcolor{comment}{! Also open the parsed input parameter file(s) and setup param\_file.}
01723   \textcolor{keyword}{call }get\_mom\_input(param\_file, dirs, default\_input\_filename=input\_restart\_file)
01724 
01725   verbosity = 2 ; \textcolor{keyword}{call }read\_param(param\_file, \textcolor{stringliteral}{"VERBOSITY"}, verbosity)
01726   \textcolor{keyword}{call }mom\_set\_verbosity(verbosity)
01727   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"initialize\_MOM(), MOM.F90"})
01728 
01729   \textcolor{keyword}{call }find\_obsolete\_params(param\_file)
01730 
01731   \textcolor{comment}{! Determining the internal unit scaling factors for this run.}
01732   \textcolor{keyword}{call }unit\_scaling\_init(param\_file, cs%US)
01733   us => cs%US
01734 
01735   \textcolor{comment}{! Read relevant parameters and write them to the model log.}
01736   \textcolor{keyword}{call }log\_version(param\_file, \textcolor{stringliteral}{"MOM"}, version, \textcolor{stringliteral}{""}, log\_to\_all=.true., layout=.true., debugging=.true.)
01737   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"VERBOSITY"}, verbosity,  &
01738                  \textcolor{stringliteral}{"Integer controlling level of messaging\(\backslash\)n"} // &
01739                  \textcolor{stringliteral}{"\(\backslash\)t0 = Only FATAL messages\(\backslash\)n"} // &
01740                  \textcolor{stringliteral}{"\(\backslash\)t2 = Only FATAL, WARNING, NOTE [default]\(\backslash\)n"} // &
01741                  \textcolor{stringliteral}{"\(\backslash\)t9 = All)"}, default=2, debuggingparam=.true.)
01742   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DO\_UNIT\_TESTS"}, do\_unit\_tests, &
01743                  \textcolor{stringliteral}{"If True, exercises unit tests at model start up."}, &
01744                  default=.false., debuggingparam=.true.)
01745   \textcolor{keywordflow}{if} (do\_unit\_tests) \textcolor{keywordflow}{then}
01746     id\_clock\_unit\_tests = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean unit tests)'}, grain=clock\_module)
01747     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_unit\_tests)
01748     \textcolor{keyword}{call }unit\_tests(verbosity)
01749     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_unit\_tests)
01750 \textcolor{keywordflow}{  endif}
01751 
01752   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"SPLIT"}, cs%split, &
01753                  \textcolor{stringliteral}{"Use the split time stepping if true."}, default=.true.)
01754   \textcolor{keywordflow}{if} (cs%split) \textcolor{keywordflow}{then}
01755     cs%use\_RK2 = .false.
01756   \textcolor{keywordflow}{else}
01757     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_RK2"}, cs%use\_RK2, &
01758                  \textcolor{stringliteral}{"If true, use RK2 instead of RK3 in the unsplit time stepping."}, &
01759                  default=.false.)
01760 \textcolor{keywordflow}{  endif}
01761 
01762   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"CALC\_RHO\_FOR\_SEA\_LEVEL"}, cs%calc\_rho\_for\_sea\_lev, &
01763                  \textcolor{stringliteral}{"If true, the in-situ density is used to calculate the "}//&
01764                  \textcolor{stringliteral}{"effective sea level that is returned to the coupler. If false, "}//&
01765                  \textcolor{stringliteral}{"the Boussinesq parameter RHO\_0 is used."}, default=.false.)
01766   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, use\_temperature, &
01767                  \textcolor{stringliteral}{"If true, Temperature and salinity are used as state "}//&
01768                  \textcolor{stringliteral}{"variables."}, default=.true.)
01769   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_EOS"}, use\_eos, &
01770                  \textcolor{stringliteral}{"If true,  density is calculated from temperature and "}//&
01771                  \textcolor{stringliteral}{"salinity with an equation of state.  If USE\_EOS is "}//&
01772                  \textcolor{stringliteral}{"true, ENABLE\_THERMODYNAMICS must be true as well."}, &
01773                  default=use\_temperature)
01774   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DIABATIC\_FIRST"}, cs%diabatic\_first, &
01775                  \textcolor{stringliteral}{"If true, apply diabatic and thermodynamic processes, "}//&
01776                  \textcolor{stringliteral}{"including buoyancy forcing and mass gain or loss, "}//&
01777                  \textcolor{stringliteral}{"before stepping the dynamics forward."}, default=.false.)
01778   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_CONTEMP\_ABSSAL"}, use\_cont\_abss, &
01779                  \textcolor{stringliteral}{"If true, the prognostics T&S are the conservative temperature "}//&
01780                  \textcolor{stringliteral}{"and absolute salinity. Care should be taken to convert them "}//&
01781                  \textcolor{stringliteral}{"to potential temperature and practical salinity before "}//&
01782                  \textcolor{stringliteral}{"exchanging them with the coupler and/or reporting T&S diagnostics."}, &
01783                  default=.false.)
01784   cs%tv%T\_is\_conT = use\_cont\_abss ; cs%tv%S\_is\_absS = use\_cont\_abss
01785   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ADIABATIC"}, cs%adiabatic, &
01786                  \textcolor{stringliteral}{"There are no diapycnal mass fluxes if ADIABATIC is "}//&
01787                  \textcolor{stringliteral}{"true. This assumes that KD = KDML = 0.0 and that "}//&
01788                  \textcolor{stringliteral}{"there is no buoyancy forcing, but makes the model "}//&
01789                  \textcolor{stringliteral}{"faster by eliminating subroutine calls."}, default=.false.)
01790   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DO\_DYNAMICS"}, cs%do\_dynamics, &
01791                  \textcolor{stringliteral}{"If False, skips the dynamics calls that update u & v, as well as "}//&
01792                  \textcolor{stringliteral}{"the gravity wave adjustment to h. This may be a fragile feature, "}//&
01793                  \textcolor{stringliteral}{"but can be useful during development"}, default=.true.)
01794   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ADVECT\_TS"}, advect\_ts, &
01795                  \textcolor{stringliteral}{"If True, advect temperature and salinity horizontally "}//&
01796                  \textcolor{stringliteral}{"If False, T/S are registered for advection. "}//&
01797                  \textcolor{stringliteral}{"This is intended only to be used in offline tracer mode "}//&
01798                  \textcolor{stringliteral}{"and is by default false in that case."}, &
01799                  do\_not\_log = .true., default=.true. )
01800   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(offline\_tracer\_mode)) \textcolor{keywordflow}{then} \textcolor{comment}{! Only read this parameter in enabled modes}
01801     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"OFFLINE\_TRACER\_MODE"}, cs%offline\_tracer\_mode, &
01802                  \textcolor{stringliteral}{"If true, barotropic and baroclinic dynamics, thermodynamics "}//&
01803                  \textcolor{stringliteral}{"are all bypassed with all the fields necessary to integrate "}//&
01804                  \textcolor{stringliteral}{"the tracer advection and diffusion equation are read in from "}//&
01805                  \textcolor{stringliteral}{"files stored from a previous integration of the prognostic model. "}//&
01806                  \textcolor{stringliteral}{"NOTE: This option only used in the ocean\_solo\_driver."}, default=.false.)
01807     \textcolor{keywordflow}{if} (cs%offline\_tracer\_mode) \textcolor{keywordflow}{then}
01808       \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ADVECT\_TS"}, advect\_ts, &
01809                    \textcolor{stringliteral}{"If True, advect temperature and salinity horizontally "}//&
01810                    \textcolor{stringliteral}{"If False, T/S are registered for advection. "}//&
01811                    \textcolor{stringliteral}{"This is intended only to be used in offline tracer mode."}//&
01812                    \textcolor{stringliteral}{"and is by default false in that case"}, &
01813                    default=.false. )
01814 \textcolor{keywordflow}{    endif}
01815 \textcolor{keywordflow}{  endif}
01816   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_REGRIDDING"}, cs%use\_ALE\_algorithm, &
01817                  \textcolor{stringliteral}{"If True, use the ALE algorithm (regridding/remapping). "}//&
01818                  \textcolor{stringliteral}{"If False, use the layered isopycnal algorithm."}, default=.false. )
01819   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BULKMIXEDLAYER"}, bulkmixedlayer, &
01820                  \textcolor{stringliteral}{"If true, use a Kraus-Turner-like bulk mixed layer "}//&
01821                  \textcolor{stringliteral}{"with transitional buffer layers.  Layers 1 through "}//&
01822                  \textcolor{stringliteral}{"NKML+NKBL have variable densities. There must be at "}//&
01823                  \textcolor{stringliteral}{"least NKML+NKBL+1 layers if BULKMIXEDLAYER is true. "}//&
01824                  \textcolor{stringliteral}{"BULKMIXEDLAYER can not be used with USE\_REGRIDDING. "}//&
01825                  \textcolor{stringliteral}{"The default is influenced by ENABLE\_THERMODYNAMICS."}, &
01826                  default=use\_temperature .and. .not.cs%use\_ALE\_algorithm)
01827   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"THICKNESSDIFFUSE"}, cs%thickness\_diffuse, &
01828                  \textcolor{stringliteral}{"If true, interface heights are diffused with a "}//&
01829                  \textcolor{stringliteral}{"coefficient of KHTH."}, default=.false.)
01830   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"},  \textcolor{stringliteral}{"THICKNESSDIFFUSE\_FIRST"}, &
01831                                       cs%thickness\_diffuse\_first, &
01832                  \textcolor{stringliteral}{"If true, do thickness diffusion before dynamics. "}//&
01833                  \textcolor{stringliteral}{"This is only used if THICKNESSDIFFUSE is true."}, &
01834                  default=.false.)
01835   \textcolor{keywordflow}{if} (.not.cs%thickness\_diffuse) cs%thickness\_diffuse\_first = .false.
01836   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BATHYMETRY\_AT\_VEL"}, bathy\_at\_vel, &
01837                  \textcolor{stringliteral}{"If true, there are separate values for the basin depths "}//&
01838                  \textcolor{stringliteral}{"at velocity points.  Otherwise the effects of topography "}//&
01839                  \textcolor{stringliteral}{"are entirely determined from thickness points."}, &
01840                  default=.false.)
01841   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_WAVES"}, cs%UseWaves, default=.false., &
01842                  do\_not\_log=.true.)
01843 
01844   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DEBUG"}, cs%debug, &
01845                  \textcolor{stringliteral}{"If true, write out verbose debugging data."}, &
01846                  default=.false., debuggingparam=.true.)
01847   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DEBUG\_TRUNCATIONS"}, debug\_truncations, &
01848                  \textcolor{stringliteral}{"If true, calculate all diagnostics that are useful for "}//&
01849                  \textcolor{stringliteral}{"debugging truncations."}, default=.false., debuggingparam=.true.)
01850 
01851   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DT"}, cs%dt, &
01852                  \textcolor{stringliteral}{"The (baroclinic) dynamics time step.  The time-step that "}//&
01853                  \textcolor{stringliteral}{"is actually used will be an integer fraction of the "}//&
01854                  \textcolor{stringliteral}{"forcing time-step (DT\_FORCING in ocean-only mode or the "}//&
01855                  \textcolor{stringliteral}{"coupling timestep in coupled mode.)"}, units=\textcolor{stringliteral}{"s"}, scale=us%s\_to\_T, &
01856                  fail\_if\_missing=.true.)
01857   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DT\_THERM"}, cs%dt\_therm, &
01858                  \textcolor{stringliteral}{"The thermodynamic and tracer advection time step. "}//&
01859                  \textcolor{stringliteral}{"Ideally DT\_THERM should be an integer multiple of DT "}//&
01860                  \textcolor{stringliteral}{"and less than the forcing or coupling time-step, unless "}//&
01861                  \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING is true, in which case DT\_THERM "}//&
01862                  \textcolor{stringliteral}{"can be an integer multiple of the coupling timestep.  By "}//&
01863                  \textcolor{stringliteral}{"default DT\_THERM is set to DT."}, &
01864                  units=\textcolor{stringliteral}{"s"}, scale=us%s\_to\_T, default=us%T\_to\_s*cs%dt)
01865   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING"}, cs%thermo\_spans\_coupling, &
01866                  \textcolor{stringliteral}{"If true, the MOM will take thermodynamic and tracer "}//&
01867                  \textcolor{stringliteral}{"timesteps that can be longer than the coupling timestep. "}//&
01868                  \textcolor{stringliteral}{"The actual thermodynamic timestep that is used in this "}//&
01869                  \textcolor{stringliteral}{"case is the largest integer multiple of the coupling "}//&
01870                  \textcolor{stringliteral}{"timestep that is less than or equal to DT\_THERM."}, default=.false.)
01871 
01872   \textcolor{keywordflow}{if} (bulkmixedlayer) \textcolor{keywordflow}{then}
01873     cs%Hmix = -1.0 ; cs%Hmix\_UV = -1.0
01874   \textcolor{keywordflow}{else}
01875     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"HMIX\_SFC\_PROP"}, cs%Hmix, &
01876                  \textcolor{stringliteral}{"If BULKMIXEDLAYER is false, HMIX\_SFC\_PROP is the depth "}//&
01877                  \textcolor{stringliteral}{"over which to average to find surface properties like "}//&
01878                  \textcolor{stringliteral}{"SST and SSS or density (but not surface velocities)."}, &
01879                  units=\textcolor{stringliteral}{"m"}, default=1.0, scale=us%m\_to\_Z)
01880     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"HMIX\_UV\_SFC\_PROP"}, cs%Hmix\_UV, &
01881                  \textcolor{stringliteral}{"If BULKMIXEDLAYER is false, HMIX\_UV\_SFC\_PROP is the depth "}//&
01882                  \textcolor{stringliteral}{"over which to average to find surface flow properties, "}//&
01883                  \textcolor{stringliteral}{"SSU, SSV. A non-positive value indicates no averaging."}, &
01884                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
01885 \textcolor{keywordflow}{  endif}
01886   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"HFREEZE"}, cs%HFrz, &
01887                  \textcolor{stringliteral}{"If HFREEZE > 0, melt potential will be computed. The actual depth "}//&
01888                  \textcolor{stringliteral}{"over which melt potential is computed will be min(HFREEZE, OBLD), "}//&
01889                  \textcolor{stringliteral}{"where OBLD is the boundary layer depth. If HFREEZE <= 0 (default), "}//&
01890                  \textcolor{stringliteral}{"melt potential will not be computed."}, units=\textcolor{stringliteral}{"m"}, default=-1.0, scale=us%m\_to\_Z)
01891   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"INTERPOLATE\_P\_SURF"}, cs%interp\_p\_surf, &
01892                  \textcolor{stringliteral}{"If true, linearly interpolate the surface pressure "}//&
01893                  \textcolor{stringliteral}{"over the coupling time step, using the specified value "}//&
01894                  \textcolor{stringliteral}{"at the end of the step."}, default=.false.)
01895 
01896   \textcolor{keywordflow}{if} (cs%split) \textcolor{keywordflow}{then}
01897     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DTBT"}, dtbt, default=-0.98)
01898     default\_val = us%T\_to\_s*cs%dt\_therm ; \textcolor{keywordflow}{if} (dtbt > 0.0) default\_val = -1.0
01899     cs%dtbt\_reset\_period = -1.0
01900     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DTBT\_RESET\_PERIOD"}, cs%dtbt\_reset\_period, &
01901                  \textcolor{stringliteral}{"The period between recalculations of DTBT (if DTBT <= 0). "}//&
01902                  \textcolor{stringliteral}{"If DTBT\_RESET\_PERIOD is negative, DTBT is set based "}//&
01903                  \textcolor{stringliteral}{"only on information available at initialization.  If 0, "}//&
01904                  \textcolor{stringliteral}{"DTBT will be set every dynamics time step. The default "}//&
01905                  \textcolor{stringliteral}{"is set by DT\_THERM.  This is only used if SPLIT is true."}, &
01906                  units=\textcolor{stringliteral}{"s"}, default=default\_val, do\_not\_read=(dtbt > 0.0))
01907 \textcolor{keywordflow}{  endif}
01908 
01909   \textcolor{comment}{! This is here in case these values are used inappropriately.}
01910   use\_frazil = .false. ; bound\_salinity = .false.
01911   cs%tv%P\_Ref = 2.0e7*us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2
01912   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
01913     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"FRAZIL"}, use\_frazil, &
01914                  \textcolor{stringliteral}{"If true, water freezes if it gets too cold, and the "}//&
01915                  \textcolor{stringliteral}{"accumulated heat deficit is returned in the "}//&
01916                  \textcolor{stringliteral}{"surface state.  FRAZIL is only used if "}//&
01917                  \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS is true."}, default=.false.)
01918     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DO\_GEOTHERMAL"}, use\_geothermal, &
01919                  \textcolor{stringliteral}{"If true, apply geothermal heating."}, default=.false.)
01920     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BOUND\_SALINITY"}, bound\_salinity, &
01921                  \textcolor{stringliteral}{"If true, limit salinity to being positive. (The sea-ice "}//&
01922                  \textcolor{stringliteral}{"model may ask for more salt than is available and "}//&
01923                  \textcolor{stringliteral}{"drive the salinity negative otherwise.)"}, default=.false.)
01924     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"MIN\_SALINITY"}, cs%tv%min\_salinity, &
01925                  \textcolor{stringliteral}{"The minimum value of salinity when BOUND\_SALINITY=True."}, &
01926                  units=\textcolor{stringliteral}{"PPT"}, default=0.0, do\_not\_log=.not.bound\_salinity)
01927     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"C\_P"}, cs%tv%C\_p, &
01928                  \textcolor{stringliteral}{"The heat capacity of sea water, approximated as a "}//&
01929                  \textcolor{stringliteral}{"constant. This is only used if ENABLE\_THERMODYNAMICS is "}//&
01930                  \textcolor{stringliteral}{"true. The default value is from the TEOS-10 definition "}//&
01931                  \textcolor{stringliteral}{"of conservative temperature."}, units=\textcolor{stringliteral}{"J kg-1 K-1"}, &
01932                  default=3991.86795711963, scale=us%J\_kg\_to\_Q)
01933     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_PSURF\_IN\_EOS"}, cs%use\_p\_surf\_in\_EOS, &
01934                  \textcolor{stringliteral}{"If true, always include the surface pressure contributions "}//&
01935                  \textcolor{stringliteral}{"in equation of state calculations."}, default=.true.)
01936 \textcolor{keywordflow}{  endif}
01937   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"P\_REF"}, cs%tv%P\_Ref, &
01938                  \textcolor{stringliteral}{"The pressure that is used for calculating the coordinate "}//&
01939                  \textcolor{stringliteral}{"density.  (1 Pa = 1e4 dbar, so 2e7 is commonly used.) "}//&
01940                  \textcolor{stringliteral}{"This is only used if USE\_EOS and ENABLE\_THERMODYNAMICS are true."}, &
01941                  units=\textcolor{stringliteral}{"Pa"}, default=2.0e7, scale=us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2)
01942 
01943   \textcolor{keywordflow}{if} (bulkmixedlayer) \textcolor{keywordflow}{then}
01944     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"NKML"}, nkml, &
01945                  \textcolor{stringliteral}{"The number of sublayers within the mixed layer if "}//&
01946                  \textcolor{stringliteral}{"BULKMIXEDLAYER is true."}, units=\textcolor{stringliteral}{"nondim"}, default=2)
01947     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"NKBL"}, nkbl, &
01948                  \textcolor{stringliteral}{"The number of layers that are used as variable density "}//&
01949                  \textcolor{stringliteral}{"buffer layers if BULKMIXEDLAYER is true."}, units=\textcolor{stringliteral}{"nondim"}, &
01950                  default=2)
01951 \textcolor{keywordflow}{  endif}
01952 
01953   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"GLOBAL\_INDEXING"}, global\_indexing, &
01954                  \textcolor{stringliteral}{"If true, use a global lateral indexing convention, so "}//&
01955                  \textcolor{stringliteral}{"that corresponding points on different processors have "}//&
01956                  \textcolor{stringliteral}{"the same index. This does not work with static memory."}, &
01957                  default=.false., layoutparam=.true.)
01958 \textcolor{preprocessor}{#ifdef STATIC\_MEMORY\_}
01959 \textcolor{preprocessor}{}  \textcolor{keywordflow}{if} (global\_indexing) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"initialize\_MOM: "}//&
01960        \textcolor{stringliteral}{"GLOBAL\_INDEXING can not be true with STATIC\_MEMORY."})
01961 \textcolor{preprocessor}{#endif}
01962 \textcolor{preprocessor}{}  \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"FIRST\_DIRECTION"}, first\_direction, &
01963                  \textcolor{stringliteral}{"An integer that indicates which direction goes first "}//&
01964                  \textcolor{stringliteral}{"in parts of the code that use directionally split "}//&
01965                  \textcolor{stringliteral}{"updates, with even numbers (or 0) used for x- first "}//&
01966                  \textcolor{stringliteral}{"and odd numbers used for y-first."}, default=0)
01967 
01968   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"CHECK\_BAD\_SURFACE\_VALS"}, cs%check\_bad\_sfc\_vals, &
01969                  \textcolor{stringliteral}{"If true, check the surface state for ridiculous values."}, &
01970                  default=.false.)
01971   \textcolor{keywordflow}{if} (cs%check\_bad\_sfc\_vals) \textcolor{keywordflow}{then}
01972     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BAD\_VAL\_SSH\_MAX"}, cs%bad\_val\_ssh\_max, &
01973                  \textcolor{stringliteral}{"The value of SSH above which a bad value message is "}//&
01974                  \textcolor{stringliteral}{"triggered, if CHECK\_BAD\_SURFACE\_VALS is true."}, &
01975                  units=\textcolor{stringliteral}{"m"}, default=20.0, scale=us%m\_to\_Z)
01976     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BAD\_VAL\_SSS\_MAX"}, cs%bad\_val\_sss\_max, &
01977                  \textcolor{stringliteral}{"The value of SSS above which a bad value message is "}//&
01978                  \textcolor{stringliteral}{"triggered, if CHECK\_BAD\_SURFACE\_VALS is true."}, units=\textcolor{stringliteral}{"PPT"}, &
01979                  default=45.0)
01980     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BAD\_VAL\_SST\_MAX"}, cs%bad\_val\_sst\_max, &
01981                  \textcolor{stringliteral}{"The value of SST above which a bad value message is "}//&
01982                  \textcolor{stringliteral}{"triggered, if CHECK\_BAD\_SURFACE\_VALS is true."}, &
01983                  units=\textcolor{stringliteral}{"deg C"}, default=45.0)
01984     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BAD\_VAL\_SST\_MIN"}, cs%bad\_val\_sst\_min, &
01985                  \textcolor{stringliteral}{"The value of SST below which a bad value message is "}//&
01986                  \textcolor{stringliteral}{"triggered, if CHECK\_BAD\_SURFACE\_VALS is true."}, &
01987                  units=\textcolor{stringliteral}{"deg C"}, default=-2.1)
01988     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"BAD\_VAL\_COLUMN\_THICKNESS"}, cs%bad\_val\_col\_thick, &
01989                  \textcolor{stringliteral}{"The value of column thickness below which a bad value message is "}//&
01990                  \textcolor{stringliteral}{"triggered, if CHECK\_BAD\_SURFACE\_VALS is true."}, &
01991                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=us%m\_to\_Z)
01992 \textcolor{keywordflow}{  endif}
01993   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
01994                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
01995                  default=.false.)
01996   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"SURFACE\_2018\_ANSWERS"}, cs%answers\_2018, &
01997                  \textcolor{stringliteral}{"If true, use expressions for the surface properties that recover the answers "}//&
01998                  \textcolor{stringliteral}{"from the end of 2018. Otherwise, use more appropriate expressions that differ "}//&
01999                  \textcolor{stringliteral}{"at roundoff for non-Boussinesq cases."}, default=default\_2018\_answers)
02000 
02001   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"SAVE\_INITIAL\_CONDS"}, save\_ic, &
02002                  \textcolor{stringliteral}{"If true, write the initial conditions to a file given "}//&
02003                  \textcolor{stringliteral}{"by IC\_OUTPUT\_FILE."}, default=.false.)
02004   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"IC\_OUTPUT\_FILE"}, cs%IC\_file, &
02005                  \textcolor{stringliteral}{"The file into which to write the initial conditions."}, &
02006                  default=\textcolor{stringliteral}{"MOM\_IC"})
02007   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"WRITE\_GEOM"}, write\_geom, &
02008                  \textcolor{stringliteral}{"If =0, never write the geometry and vertical grid files. "}//&
02009                  \textcolor{stringliteral}{"If =1, write the geometry and vertical grid files only for "}//&
02010                  \textcolor{stringliteral}{"a new simulation. If =2, always write the geometry and "}//&
02011                  \textcolor{stringliteral}{"vertical grid files. Other values are invalid."}, default=1)
02012   \textcolor{keywordflow}{if} (write\_geom<0 .or. write\_geom>2) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM: "}//&
02013          \textcolor{stringliteral}{"WRITE\_GEOM must be equal to 0, 1 or 2."})
02014   write\_geom\_files = ((write\_geom==2) .or. ((write\_geom==1) .and. &
02015      ((dirs%input\_filename(1:1)==\textcolor{stringliteral}{'n'}) .and. (len\_trim(dirs%input\_filename)==1))))
02016 \textcolor{comment}{! If the restart file type had been initialized, this could become:}
02017 \textcolor{comment}{!  write\_geom\_files = ((write\_geom==2) .or. &}
02018 \textcolor{comment}{!                      ((write\_geom==1) .and. is\_new\_run(restart\_CSp)))}
02019 
02020   \textcolor{comment}{! Check for inconsistent parameter settings.}
02021   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm .and. bulkmixedlayer) \textcolor{keyword}{call }mom\_error(fatal, &
02022     \textcolor{stringliteral}{"MOM: BULKMIXEDLAYER can not currently be used with the ALE algorithm."})
02023   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm .and. .not.use\_temperature) \textcolor{keyword}{call }mom\_error(fatal, &
02024      \textcolor{stringliteral}{"MOM: At this time, USE\_EOS should be True when using the ALE algorithm."})
02025   \textcolor{keywordflow}{if} (cs%adiabatic .and. use\_temperature) \textcolor{keyword}{call }mom\_error(warning, &
02026     \textcolor{stringliteral}{"MOM: ADIABATIC and ENABLE\_THERMODYNAMICS both defined is usually unwise."})
02027   \textcolor{keywordflow}{if} (use\_eos .and. .not.use\_temperature) \textcolor{keyword}{call }mom\_error(fatal, &
02028     \textcolor{stringliteral}{"MOM: ENABLE\_THERMODYNAMICS must be defined to use USE\_EOS."})
02029   \textcolor{keywordflow}{if} (cs%adiabatic .and. bulkmixedlayer) \textcolor{keyword}{call }mom\_error(fatal, &
02030     \textcolor{stringliteral}{"MOM: ADIABATIC and BULKMIXEDLAYER can not both be defined."})
02031   \textcolor{keywordflow}{if} (bulkmixedlayer .and. .not.use\_eos) \textcolor{keyword}{call }mom\_error(fatal, &
02032       \textcolor{stringliteral}{"initialize\_MOM: A bulk mixed layer can only be used with T & S as "}//&
02033       \textcolor{stringliteral}{"state variables. Add USE\_EOS = True to MOM\_input."})
02034 
02035   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{'MOM'}, \textcolor{stringliteral}{"ICE\_SHELF"}, use\_ice\_shelf, default=.false., do\_not\_log=.true.)
02036   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}
02037      inputdir = \textcolor{stringliteral}{"."} ;  \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{'MOM'}, \textcolor{stringliteral}{"INPUTDIR"}, inputdir)
02038      inputdir = slasher(inputdir)
02039      \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{'MOM'}, \textcolor{stringliteral}{"ICE\_THICKNESS\_FILE"}, ice\_shelf\_file, &
02040                     \textcolor{stringliteral}{"The file from which the ice bathymetry and area are read."}, &
02041                     fail\_if\_missing=.true.)
02042      \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{'MOM'}, \textcolor{stringliteral}{"ICE\_AREA\_VARNAME"}, area\_varname, &
02043                     \textcolor{stringliteral}{"The name of the area variable in ICE\_THICKNESS\_FILE."}, &
02044                     fail\_if\_missing=.true.)
02045 \textcolor{keywordflow}{  endif}
02046 
02047 
02048   cs%ensemble\_ocean=.false.
02049   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ENSEMBLE\_OCEAN"}, cs%ensemble\_ocean, &
02050                  \textcolor{stringliteral}{"If False, The model is being run in serial mode as a single realization. "}//&
02051                  \textcolor{stringliteral}{"If True, The current model realization is part of a larger ensemble "}//&
02052                  \textcolor{stringliteral}{"and at the end of step MOM, we will perform a gather of the ensemble "}//&
02053                  \textcolor{stringliteral}{"members for statistical evaluation and/or data assimilation."}, default=.false.)
02054 
02055   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"MOM parameters read (initialize\_MOM)"})
02056 
02057   \textcolor{comment}{! Grid rotation test}
02058   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ROTATE\_INDEX"}, cs%rotate\_index, &
02059       \textcolor{stringliteral}{"Enable rotation of the horizontal indices."}, default=.false., &
02060       debuggingparam=.true.)
02061   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
02062     \textcolor{comment}{! TODO: Index rotation currently only works when index rotation does not}
02063     \textcolor{comment}{!   change the MPI rank of each domain.  Resolving this will require a}
02064     \textcolor{comment}{!   modification to FMS PE assignment.}
02065     \textcolor{comment}{!   For now, we only permit single-core runs.}
02066 
02067     \textcolor{keywordflow}{if} (num\_pes() /= 1) &
02068       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Index rotation is only supported on one PE."})
02069 
02070     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"INDEX\_TURNS"}, turns, &
02071         \textcolor{stringliteral}{"Number of counterclockwise quarter-turn index rotations."}, &
02072         default=1, debuggingparam=.true.)
02073 \textcolor{keywordflow}{  endif}
02074 
02075   \textcolor{comment}{! Set up the model domain and grids.}
02076 \textcolor{preprocessor}{#ifdef SYMMETRIC\_MEMORY\_}
02077 \textcolor{preprocessor}{}  symmetric = .true.
02078 \textcolor{preprocessor}{#else}
02079 \textcolor{preprocessor}{}  symmetric = .false.
02080 \textcolor{preprocessor}{#endif}
02081 \textcolor{preprocessor}{}  g\_in => cs%G\_in
02082 \textcolor{preprocessor}{#ifdef STATIC\_MEMORY\_}
02083 \textcolor{preprocessor}{}  \textcolor{keyword}{call }mom\_domains\_init(g\_in%domain, param\_file, symmetric=symmetric, &
02084             static\_memory=.true., nihalo=nihalo\_, njhalo=njhalo\_, &
02085             niglobal=niglobal\_, njglobal=njglobal\_, niproc=niproc\_, &
02086             njproc=njproc\_)
02087 \textcolor{preprocessor}{#else}
02088 \textcolor{preprocessor}{}  \textcolor{keyword}{call }mom\_domains\_init(g\_in%domain, param\_file, symmetric=symmetric, &
02089                         domain\_name=\textcolor{stringliteral}{"MOM\_in"})
02090 \textcolor{preprocessor}{#endif}
02091 \textcolor{preprocessor}{}
02092   \textcolor{comment}{! Copy input grid (G\_in) domain to active grid G}
02093   \textcolor{comment}{! Swap axes for quarter and 3-quarter turns}
02094   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
02095     \textcolor{keyword}{allocate}(cs%G)
02096     \textcolor{keyword}{call }clone\_mom\_domain(g\_in%Domain, cs%G%Domain, turns=turns)
02097     first\_direction = modulo(first\_direction + turns, 2)
02098   \textcolor{keywordflow}{else}
02099     cs%G => g\_in
02100 \textcolor{keywordflow}{  endif}
02101 
02102   \textcolor{comment}{! TODO: It is unlikey that test\_grid\_copy and rotate\_index would work at the}
02103   \textcolor{comment}{!   same time.  It may be possible to enable both but for now we prevent it.}
02104   \textcolor{keywordflow}{if} (test\_grid\_copy .and. cs%rotate\_index) &
02105     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Grid cannot be copied during index rotation."})
02106 
02107   \textcolor{keywordflow}{if} (test\_grid\_copy) \textcolor{keywordflow}{then} ; \textcolor{keyword}{allocate}(g)
02108   \textcolor{keywordflow}{else} ; g => cs%G ;\textcolor{keywordflow}{ endif}
02109 
02110   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"domains initialized (initialize\_MOM)"})
02111 
02112   \textcolor{keyword}{call }mom\_debugging\_init(param\_file)
02113   \textcolor{keyword}{call }diag\_mediator\_infrastructure\_init()
02114   \textcolor{keyword}{call }mom\_io\_init(param\_file)
02115 
02116   \textcolor{comment}{! Create HI and dG on the input index map.}
02117   \textcolor{keyword}{call }hor\_index\_init(g\_in%Domain, hi\_in, param\_file, &
02118                       local\_indexing=.not.global\_indexing)
02119   \textcolor{keyword}{call }create\_dyn\_horgrid(dg\_in, hi\_in, bathymetry\_at\_vel=bathy\_at\_vel)
02120   \textcolor{keyword}{call }clone\_mom\_domain(g\_in%Domain, dg\_in%Domain)
02121 
02122   \textcolor{comment}{! Allocate initialize time-invariant MOM variables.}
02123   \textcolor{keyword}{call }mom\_initialize\_fixed(dg\_in, us, obc\_in, param\_file, write\_geom\_files, &
02124                             dirs%output\_directory)
02125 
02126   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"returned from MOM\_initialize\_fixed() (initialize\_MOM)"})
02127 
02128   \textcolor{comment}{! Determine HI and dG for the model index map.}
02129   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
02130     \textcolor{keyword}{allocate}(hi)
02131     \textcolor{keyword}{call }rotate\_hor\_index(hi\_in, turns, hi)
02132     \textcolor{keyword}{call }create\_dyn\_horgrid(dg, hi, bathymetry\_at\_vel=bathy\_at\_vel)
02133     \textcolor{keyword}{call }clone\_mom\_domain(g%Domain, dg%Domain)
02134     \textcolor{keyword}{call }rotate\_dyngrid(dg\_in, dg, us, turns)
02135     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\_in)) \textcolor{keywordflow}{then}
02136       \textcolor{comment}{! TODO: General OBC index rotations is not yet supported.}
02137       \textcolor{keywordflow}{if} (modulo(turns, 4) /= 1) &
02138         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"OBC index rotation of 180 and 270 degrees is "} &
02139           // \textcolor{stringliteral}{"not yet unsupported."})
02140       \textcolor{keyword}{allocate}(cs%OBC)
02141       \textcolor{keyword}{call }rotate\_obc\_config(obc\_in, dg\_in, cs%OBC, dg, turns)
02142 \textcolor{keywordflow}{    endif}
02143   \textcolor{keywordflow}{else}
02144     hi => hi\_in
02145     dg => dg\_in
02146     cs%OBC => obc\_in
02147 \textcolor{keywordflow}{  endif}
02148 
02149   \textcolor{keyword}{call }verticalgridinit( param\_file, cs%GV, us )
02150   gv => cs%GV
02151 
02152   \textcolor{comment}{! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.}
02153   \textcolor{keywordflow}{if} (cs%debug .or. dg%symmetric) &
02154     \textcolor{keyword}{call }clone\_mom\_domain(dg%Domain, dg%Domain\_aux, symmetric=.false.)
02155 
02156   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"grids initialized (initialize\_MOM)"})
02157 
02158   \textcolor{keyword}{call }mom\_timing\_init(cs)
02159 
02160   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) \textcolor{keyword}{call }call\_obc\_register(param\_file, cs%update\_OBC\_CSp, cs%OBC)
02161 
02162   \textcolor{keyword}{call }tracer\_registry\_init(param\_file, cs%tracer\_Reg)
02163 
02164   \textcolor{comment}{! Allocate and initialize space for the primary time-varying MOM variables.}
02165   is   = dg%isc   ; ie   = dg%iec  ; js   = dg%jsc  ; je   = dg%jec ; nz = gv%ke
02166   isd  = dg%isd   ; ied  = dg%ied  ; jsd  = dg%jsd  ; jed  = dg%jed
02167   isdb = dg%IsdB  ; iedb = dg%IedB ; jsdb = dg%JsdB ; jedb = dg%JedB
02168   alloc\_(cs%u(isdb:iedb,jsd:jed,nz))   ; cs%u(:,:,:) = 0.0
02169   alloc\_(cs%v(isd:ied,jsdb:jedb,nz))   ; cs%v(:,:,:) = 0.0
02170   alloc\_(cs%h(isd:ied,jsd:jed,nz))     ; cs%h(:,:,:) = gv%Angstrom\_H
02171   alloc\_(cs%uh(isdb:iedb,jsd:jed,nz))  ; cs%uh(:,:,:) = 0.0
02172   alloc\_(cs%vh(isd:ied,jsdb:jedb,nz))  ; cs%vh(:,:,:) = 0.0
02173   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02174     alloc\_(cs%T(isd:ied,jsd:jed,nz))   ; cs%T(:,:,:) = 0.0
02175     alloc\_(cs%S(isd:ied,jsd:jed,nz))   ; cs%S(:,:,:) = 0.0
02176     cs%tv%T => cs%T ; cs%tv%S => cs%S
02177     \textcolor{keywordflow}{if} (cs%tv%T\_is\_conT) \textcolor{keywordflow}{then}
02178       vd\_t = var\_desc(name=\textcolor{stringliteral}{"contemp"}, units=\textcolor{stringliteral}{"Celsius"}, longname=\textcolor{stringliteral}{"Conservative Temperature"}, &
02179                       cmor\_field\_name=\textcolor{stringliteral}{"thetao"}, cmor\_longname=\textcolor{stringliteral}{"Sea Water Potential Temperature"}, &
02180                       conversion=us%Q\_to\_J\_kg*cs%tv%C\_p)
02181     \textcolor{keywordflow}{else}
02182       vd\_t = var\_desc(name=\textcolor{stringliteral}{"temp"}, units=\textcolor{stringliteral}{"degC"}, longname=\textcolor{stringliteral}{"Potential Temperature"}, &
02183                       cmor\_field\_name=\textcolor{stringliteral}{"thetao"}, cmor\_longname=\textcolor{stringliteral}{"Sea Water Potential Temperature"}, &
02184                       conversion=us%Q\_to\_J\_kg*cs%tv%C\_p)
02185 \textcolor{keywordflow}{    endif}
02186     \textcolor{keywordflow}{if} (cs%tv%S\_is\_absS) \textcolor{keywordflow}{then}
02187       vd\_s = var\_desc(name=\textcolor{stringliteral}{"abssalt"},units=\textcolor{stringliteral}{"g kg-1"},longname=\textcolor{stringliteral}{"Absolute Salinity"}, &
02188                       cmor\_field\_name=\textcolor{stringliteral}{"so"}, cmor\_longname=\textcolor{stringliteral}{"Sea Water Salinity"}, &
02189                       conversion=0.001)
02190     \textcolor{keywordflow}{else}
02191       vd\_s = var\_desc(name=\textcolor{stringliteral}{"salt"},units=\textcolor{stringliteral}{"psu"},longname=\textcolor{stringliteral}{"Salinity"}, &
02192                       cmor\_field\_name=\textcolor{stringliteral}{"so"}, cmor\_longname=\textcolor{stringliteral}{"Sea Water Salinity"}, &
02193                       conversion=0.001)
02194 \textcolor{keywordflow}{    endif}
02195 
02196     \textcolor{keywordflow}{if} (advect\_ts) \textcolor{keywordflow}{then}
02197       s\_flux\_units = get\_tr\_flux\_units(gv, \textcolor{stringliteral}{"psu"}) \textcolor{comment}{! Could change to "kg m-2 s-1"?}
02198       conv2watt    = gv%H\_to\_kg\_m2 * us%Q\_to\_J\_kg*cs%tv%C\_p
02199       \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then}
02200         conv2salt = gv%H\_to\_m \textcolor{comment}{! Could change to GV%H\_to\_kg\_m2 * 0.001?}
02201       \textcolor{keywordflow}{else}
02202         conv2salt = gv%H\_to\_kg\_m2
02203 \textcolor{keywordflow}{      endif}
02204       \textcolor{keyword}{call }register\_tracer(cs%tv%T, cs%tracer\_Reg, param\_file, dg%HI, gv, &
02205                            tr\_desc=vd\_t, registry\_diags=.true., flux\_nameroot=\textcolor{stringliteral}{'T'}, &
02206                            flux\_units=\textcolor{stringliteral}{'W'}, flux\_longname=\textcolor{stringliteral}{'Heat'}, &
02207                            flux\_scale=conv2watt, convergence\_units=\textcolor{stringliteral}{'W m-2'}, &
02208                            convergence\_scale=conv2watt, cmor\_tendprefix=\textcolor{stringliteral}{"opottemp"}, diag\_form=2)
02209       \textcolor{keyword}{call }register\_tracer(cs%tv%S, cs%tracer\_Reg, param\_file, dg%HI, gv, &
02210                            tr\_desc=vd\_s, registry\_diags=.true., flux\_nameroot=\textcolor{stringliteral}{'S'}, &
02211                            flux\_units=s\_flux\_units, flux\_longname=\textcolor{stringliteral}{'Salt'}, &
02212                            flux\_scale=conv2salt, convergence\_units=\textcolor{stringliteral}{'kg m-2 s-1'}, &
02213                            convergence\_scale=0.001*gv%H\_to\_kg\_m2, cmor\_tendprefix=\textcolor{stringliteral}{"osalt"}, diag\_form=2)
02214 \textcolor{keywordflow}{    endif}
02215     \textcolor{comment}{! NOTE: register\_temp\_salt\_segments includes allocation of tracer fields}
02216     \textcolor{comment}{!   along segments.  Bit reproducibility requires that MOM\_initialize\_state}
02217     \textcolor{comment}{!   be called on the input index map, so we must setup both OBC and OBC\_in.}
02218     \textcolor{comment}{!}
02219     \textcolor{comment}{! XXX: This call on OBC\_in allocates the tracer fields on the unrotated}
02220     \textcolor{comment}{!   grid, but also incorrectly stores a pointer to a tracer\_type for the}
02221     \textcolor{comment}{!   rotated registry (e.g. segment%tr\_reg%Tr(n)%Tr) from CS%tracer\_reg.}
02222     \textcolor{comment}{!}
02223     \textcolor{comment}{!   While incorrect and potentially dangerous, it does not seem that this}
02224     \textcolor{comment}{!   pointer is used during initialization, so we leave it for now.}
02225     \textcolor{keywordflow}{if} (cs%rotate\_index .and. \textcolor{keyword}{associated}(obc\_in)) &
02226       \textcolor{keyword}{call }register\_temp\_salt\_segments(gv, obc\_in, cs%tracer\_Reg, param\_file)
02227     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) &
02228       \textcolor{keyword}{call }register\_temp\_salt\_segments(gv, cs%OBC, cs%tracer\_Reg, param\_file)
02229 \textcolor{keywordflow}{  endif}
02230   \textcolor{keywordflow}{if} (use\_frazil) \textcolor{keywordflow}{then}
02231     \textcolor{keyword}{allocate}(cs%tv%frazil(isd:ied,jsd:jed)) ; cs%tv%frazil(:,:) = 0.0
02232 \textcolor{keywordflow}{  endif}
02233   \textcolor{keywordflow}{if} (bound\_salinity) \textcolor{keywordflow}{then}
02234     \textcolor{keyword}{allocate}(cs%tv%salt\_deficit(isd:ied,jsd:jed)) ; cs%tv%salt\_deficit(:,:) = 0.0
02235 \textcolor{keywordflow}{  endif}
02236 
02237   \textcolor{keywordflow}{if} (bulkmixedlayer .or. use\_temperature) \textcolor{keywordflow}{then}
02238     \textcolor{keyword}{allocate}(cs%Hml(isd:ied,jsd:jed)) ; cs%Hml(:,:) = 0.0
02239 \textcolor{keywordflow}{  endif}
02240 
02241   \textcolor{keywordflow}{if} (bulkmixedlayer) \textcolor{keywordflow}{then}
02242     gv%nkml = nkml ; gv%nk\_rho\_varies = nkml + nkbl
02243   \textcolor{keywordflow}{else}
02244     gv%nkml = 0 ; gv%nk\_rho\_varies = 0
02245 \textcolor{keywordflow}{  endif}
02246   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm) \textcolor{keywordflow}{then}
02247     \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"NK\_RHO\_VARIES"}, gv%nk\_rho\_varies, default=0) \textcolor{comment}{! Will default to nz
       later... -AJA}
02248 \textcolor{keywordflow}{  endif}
02249 
02250   alloc\_(cs%uhtr(isdb:iedb,jsd:jed,nz)) ; cs%uhtr(:,:,:) = 0.0
02251   alloc\_(cs%vhtr(isd:ied,jsdb:jedb,nz)) ; cs%vhtr(:,:,:) = 0.0
02252   cs%t\_dyn\_rel\_adv = 0.0 ; cs%t\_dyn\_rel\_thermo = 0.0 ; cs%t\_dyn\_rel\_diag = 0.0
02253 
02254   \textcolor{keywordflow}{if} (debug\_truncations) \textcolor{keywordflow}{then}
02255     \textcolor{keyword}{allocate}(cs%u\_prev(isdb:iedb,jsd:jed,nz)) ; cs%u\_prev(:,:,:) = 0.0
02256     \textcolor{keyword}{allocate}(cs%v\_prev(isd:ied,jsdb:jedb,nz)) ; cs%v\_prev(:,:,:) = 0.0
02257     mom\_internal\_state%u\_prev => cs%u\_prev
02258     mom\_internal\_state%v\_prev => cs%v\_prev
02259     \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%du\_dt\_visc,isdb,iedb,jsd,jed,nz)
02260     \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%dv\_dt\_visc,isd,ied,jsdb,jedb,nz)
02261     \textcolor{keywordflow}{if} (.not.cs%adiabatic) \textcolor{keywordflow}{then}
02262       \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%du\_dt\_dia,isdb,iedb,jsd,jed,nz)
02263       \textcolor{keyword}{call }safe\_alloc\_ptr(cs%ADp%dv\_dt\_dia,isd,ied,jsdb,jedb,nz)
02264 \textcolor{keywordflow}{    endif}
02265 \textcolor{keywordflow}{  endif}
02266 
02267   mom\_internal\_state%u => cs%u ; mom\_internal\_state%v => cs%v
02268   mom\_internal\_state%h => cs%h
02269   mom\_internal\_state%uh => cs%uh ; mom\_internal\_state%vh => cs%vh
02270   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02271     mom\_internal\_state%T => cs%T ; mom\_internal\_state%S => cs%S
02272 \textcolor{keywordflow}{  endif}
02273 
02274   cs%CDp%uh => cs%uh ; cs%CDp%vh => cs%vh
02275 
02276   \textcolor{keywordflow}{if} (cs%interp\_p\_surf) \textcolor{keywordflow}{then}
02277     \textcolor{keyword}{allocate}(cs%p\_surf\_prev(isd:ied,jsd:jed)) ; cs%p\_surf\_prev(:,:) = 0.0
02278 \textcolor{keywordflow}{  endif}
02279 
02280   alloc\_(cs%ssh\_rint(isd:ied,jsd:jed)) ; cs%ssh\_rint(:,:) = 0.0
02281   alloc\_(cs%ave\_ssh\_ibc(isd:ied,jsd:jed)) ; cs%ave\_ssh\_ibc(:,:) = 0.0
02282   alloc\_(cs%eta\_av\_bc(isd:ied,jsd:jed)) ; cs%eta\_av\_bc(:,:) = 0.0
02283   cs%time\_in\_cycle = 0.0 ; cs%time\_in\_thermo\_cycle = 0.0
02284 
02285   \textcolor{comment}{! Use the Wright equation of state by default, unless otherwise specified}
02286   \textcolor{comment}{! Note: this line and the following block ought to be in a separate}
02287   \textcolor{comment}{! initialization routine for tv.}
02288   \textcolor{keywordflow}{if} (use\_eos) \textcolor{keyword}{call }eos\_init(param\_file, cs%tv%eqn\_of\_state, us)
02289   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02290     \textcolor{keyword}{allocate}(cs%tv%TempxPmE(isd:ied,jsd:jed)) ; cs%tv%TempxPmE(:,:) = 0.0
02291     \textcolor{keywordflow}{if} (use\_geothermal) \textcolor{keywordflow}{then}
02292       \textcolor{keyword}{allocate}(cs%tv%internal\_heat(isd:ied,jsd:jed)) ; cs%tv%internal\_heat(:,:) = 0.0
02293 \textcolor{keywordflow}{    endif}
02294 \textcolor{keywordflow}{  endif}
02295   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state variables allocated (initialize\_MOM)"})
02296 
02297   \textcolor{comment}{! Set the fields that are needed for bitwise identical restarting}
02298   \textcolor{comment}{! the time stepping scheme.}
02299   \textcolor{keyword}{call }restart\_init(param\_file, restart\_csp)
02300   \textcolor{keyword}{call }set\_restart\_fields(gv, us, param\_file, cs, restart\_csp)
02301   \textcolor{keywordflow}{if} (cs%split) \textcolor{keywordflow}{then}
02302     \textcolor{keyword}{call }register\_restarts\_dyn\_split\_rk2(dg%HI, gv, param\_file, &
02303              cs%dyn\_split\_RK2\_CSp, restart\_csp, cs%uh, cs%vh)
02304   \textcolor{keywordflow}{elseif} (cs%use\_RK2) \textcolor{keywordflow}{then}
02305     \textcolor{keyword}{call }register\_restarts\_dyn\_unsplit\_rk2(dg%HI, gv, param\_file, &
02306            cs%dyn\_unsplit\_RK2\_CSp, restart\_csp)
02307   \textcolor{keywordflow}{else}
02308     \textcolor{keyword}{call }register\_restarts\_dyn\_unsplit(dg%HI, gv, param\_file, &
02309            cs%dyn\_unsplit\_CSp, restart\_csp)
02310 \textcolor{keywordflow}{  endif}
02311 
02312   \textcolor{comment}{! This subroutine calls user-specified tracer registration routines.}
02313   \textcolor{comment}{! Additional calls can be added to MOM\_tracer\_flow\_control.F90.}
02314   \textcolor{keyword}{call }call\_tracer\_register(dg%HI, gv, us, param\_file, cs%tracer\_flow\_CSp, &
02315                             cs%tracer\_Reg, restart\_csp)
02316 
02317   \textcolor{keyword}{call }meke\_alloc\_register\_restart(dg%HI, param\_file, cs%MEKE, restart\_csp)
02318   \textcolor{keyword}{call }set\_visc\_register\_restarts(dg%HI, gv, param\_file, cs%visc, restart\_csp)
02319   \textcolor{keyword}{call }mixedlayer\_restrat\_register\_restarts(dg%HI, param\_file, &
02320            cs%mixedlayer\_restrat\_CSp, restart\_csp)
02321 
02322   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%OBC)) &
02323     \textcolor{keyword}{call }open\_boundary\_register\_restarts(dg%HI, gv, cs%OBC, cs%tracer\_Reg, &
02324                           param\_file, restart\_csp, use\_temperature)
02325 
02326   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"restart registration complete (initialize\_MOM)"})
02327 
02328   \textcolor{comment}{! Initialize dynamically evolving fields, perhaps from restart files.}
02329   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_init)
02330   \textcolor{keyword}{call }mom\_initialize\_coord(gv, us, param\_file, write\_geom\_files, &
02331                             dirs%output\_directory, cs%tv, dg%max\_depth)
02332   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"returned from MOM\_initialize\_coord() (initialize\_MOM)"})
02333 
02334   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm) \textcolor{keywordflow}{then}
02335     \textcolor{keyword}{call }ale\_init(param\_file, gv, us, dg%max\_depth, cs%ALE\_CSp)
02336     \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"returned from ALE\_init() (initialize\_MOM)"})
02337 \textcolor{keywordflow}{  endif}
02338 
02339   \textcolor{comment}{!   Shift from using the temporary dynamic grid type to using the final}
02340   \textcolor{comment}{! (potentially static) ocean-specific grid type.}
02341   \textcolor{comment}{!   The next line would be needed if G%Domain had not already been init'd above:}
02342   \textcolor{comment}{!     call clone\_MOM\_domain(dG%Domain, G%Domain)}
02343 
02344   \textcolor{comment}{! NOTE: If indices are rotated, then G and G\_in must both be initialized.}
02345   \textcolor{comment}{!   If not rotated, then G\_in and G are the same grid.}
02346   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
02347     \textcolor{keyword}{call }mom\_grid\_init(g, param\_file, us, hi, bathymetry\_at\_vel=bathy\_at\_vel)
02348     \textcolor{keyword}{call }copy\_dyngrid\_to\_mom\_grid(dg, g, us)
02349     \textcolor{keyword}{call }destroy\_dyn\_horgrid(dg)
02350 \textcolor{keywordflow}{  endif}
02351   \textcolor{keyword}{call }mom\_grid\_init(g\_in, param\_file, us, hi\_in, bathymetry\_at\_vel=bathy\_at\_vel)
02352   \textcolor{keyword}{call }copy\_dyngrid\_to\_mom\_grid(dg\_in, g\_in, us)
02353   \textcolor{keyword}{call }destroy\_dyn\_horgrid(dg\_in)
02354 
02355   \textcolor{comment}{! Set a few remaining fields that are specific to the ocean grid type.}
02356   \textcolor{keyword}{call }set\_first\_direction(g, first\_direction)
02357   \textcolor{comment}{! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.}
02358   \textcolor{keywordflow}{if} (cs%debug .or. g%symmetric) \textcolor{keywordflow}{then}
02359     \textcolor{keyword}{call }clone\_mom\_domain(g%Domain, g%Domain\_aux, symmetric=.false.)
02360   \textcolor{keywordflow}{else} ; g%Domain\_aux => g%Domain ;\textcolor{keywordflow}{ endif}
02361   \textcolor{comment}{! Copy common variables from the vertical grid to the horizontal grid.}
02362   \textcolor{comment}{! Consider removing this later?}
02363   g%ke = gv%ke
02364 
02365   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
02366     g\_in%ke = gv%ke
02367 
02368     \textcolor{keyword}{allocate}(u\_in(g\_in%IsdB:g\_in%IedB, g\_in%jsd:g\_in%jed, nz))
02369     \textcolor{keyword}{allocate}(v\_in(g\_in%isd:g\_in%ied, g\_in%JsdB:g\_in%JedB, nz))
02370     \textcolor{keyword}{allocate}(h\_in(g\_in%isd:g\_in%ied, g\_in%jsd:g\_in%jed, nz))
02371     u\_in(:,:,:) = 0.0
02372     v\_in(:,:,:) = 0.0
02373     h\_in(:,:,:) = gv%Angstrom\_H
02374 
02375     \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02376       \textcolor{keyword}{allocate}(t\_in(g\_in%isd:g\_in%ied, g\_in%jsd:g\_in%jed, nz))
02377       \textcolor{keyword}{allocate}(s\_in(g\_in%isd:g\_in%ied, g\_in%jsd:g\_in%jed, nz))
02378       t\_in(:,:,:) = 0.0
02379       s\_in(:,:,:) = 0.0
02380 
02381       cs%tv%T => t\_in
02382       cs%tv%S => s\_in
02383 \textcolor{keywordflow}{    endif}
02384 
02385     \textcolor{keyword}{call }mom\_initialize\_state(u\_in, v\_in, h\_in, cs%tv, time, g\_in, gv, us, &
02386         param\_file, dirs, restart\_csp, cs%ALE\_CSp, cs%tracer\_Reg, &
02387         sponge\_in\_csp, ale\_sponge\_in\_csp, obc\_in, time\_in)
02388 
02389     \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02390       cs%tv%T => cs%T
02391       cs%tv%S => cs%S
02392 \textcolor{keywordflow}{    endif}
02393 
02394     \textcolor{keyword}{call }rotate\_initial\_state(u\_in, v\_in, h\_in, t\_in, s\_in, use\_temperature, &
02395         turns, cs%u, cs%v, cs%h, cs%T, cs%S)
02396 
02397     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(sponge\_in\_csp)) \textcolor{keywordflow}{then}
02398       \textcolor{comment}{! TODO: Implementation and testing of non-ALE spong rotation}
02399       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"Index rotation of non-ALE sponge is not yet implemented."})
02400 \textcolor{keywordflow}{    endif}
02401 
02402     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(ale\_sponge\_in\_csp)) \textcolor{keywordflow}{then}
02403       \textcolor{keyword}{call }rotate\_ale\_sponge(ale\_sponge\_in\_csp, g\_in, cs%ALE\_sponge\_CSp, g, turns, param\_file)
02404       \textcolor{keyword}{call }update\_ale\_sponge\_field(cs%ALE\_sponge\_CSp, t\_in, g, gv, cs%T)
02405       \textcolor{keyword}{call }update\_ale\_sponge\_field(cs%ALE\_sponge\_CSp, s\_in, g, gv, cs%S)
02406 \textcolor{keywordflow}{    endif}
02407 
02408     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\_in)) &
02409       \textcolor{keyword}{call }rotate\_obc\_init(obc\_in, g, gv, us, param\_file, cs%tv, restart\_csp, cs%OBC)
02410 
02411     \textcolor{keyword}{deallocate}(u\_in)
02412     \textcolor{keyword}{deallocate}(v\_in)
02413     \textcolor{keyword}{deallocate}(h\_in)
02414     \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02415       \textcolor{keyword}{deallocate}(t\_in)
02416       \textcolor{keyword}{deallocate}(s\_in)
02417 \textcolor{keywordflow}{    endif}
02418   \textcolor{keywordflow}{else}
02419     \textcolor{keyword}{call }mom\_initialize\_state(cs%u, cs%v, cs%h, cs%tv, time, g, gv, us, &
02420         param\_file, dirs, restart\_csp, cs%ALE\_CSp, cs%tracer\_Reg, &
02421         cs%sponge\_CSp, cs%ALE\_sponge\_CSp, cs%OBC, time\_in)
02422 \textcolor{keywordflow}{  endif}
02423 
02424   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_init)
02425   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"returned from MOM\_initialize\_state() (initialize\_MOM)"})
02426 
02427 \textcolor{comment}{! ! Need this after MOM\_initialize\_state for DOME OBC stuff.}
02428 \textcolor{comment}{! if (associated(CS%OBC)) &}
02429 \textcolor{comment}{!   call open\_boundary\_register\_restarts(G%HI, GV, CS%OBC, CS%tracer\_Reg, &}
02430 \textcolor{comment}{!                         param\_file, restart\_CSp, use\_temperature)}
02431 
02432 \textcolor{comment}{! call callTree\_waypoint("restart registration complete (initialize\_MOM)")}
02433 
02434   \textcolor{comment}{! From this point, there may be pointers being set, so the final grid type}
02435   \textcolor{comment}{! that will persist throughout the run has to be used.}
02436 
02437   \textcolor{keywordflow}{if} (test\_grid\_copy) \textcolor{keywordflow}{then}
02438     \textcolor{comment}{!  Copy the data from the temporary grid to the dyn\_hor\_grid to CS%G.}
02439     \textcolor{keyword}{call }create\_dyn\_horgrid(dg, g%HI)
02440     \textcolor{keyword}{call }clone\_mom\_domain(g%Domain, dg%Domain)
02441 
02442     \textcolor{keyword}{call }clone\_mom\_domain(g%Domain, cs%G%Domain)
02443     \textcolor{keyword}{call }mom\_grid\_init(cs%G, param\_file, us)
02444 
02445     \textcolor{keyword}{call }copy\_mom\_grid\_to\_dyngrid(g, dg, us)
02446     \textcolor{keyword}{call }copy\_dyngrid\_to\_mom\_grid(dg, cs%G, us)
02447 
02448     \textcolor{keyword}{call }destroy\_dyn\_horgrid(dg)
02449     \textcolor{keyword}{call }mom\_grid\_end(g) ; \textcolor{keyword}{deallocate}(g)
02450 
02451     g => cs%G
02452     \textcolor{keywordflow}{if} (cs%debug .or. cs%G%symmetric) \textcolor{keywordflow}{then}
02453       \textcolor{keyword}{call }clone\_mom\_domain(cs%G%Domain, cs%G%Domain\_aux, symmetric=.false.)
02454     \textcolor{keywordflow}{else} ; cs%G%Domain\_aux => cs%G%Domain ;\textcolor{keywordflow}{ endif}
02455     g%ke = gv%ke
02456 \textcolor{keywordflow}{  endif}
02457 
02458   \textcolor{comment}{! At this point, all user-modified initialization code has been called.  The}
02459   \textcolor{comment}{! remainder of this subroutine is controlled by the parameters that have}
02460   \textcolor{comment}{! have already been set.}
02461 
02462   \textcolor{keywordflow}{if} (ale\_remap\_init\_conds(cs%ALE\_CSp) .and. .not. query\_initialized(cs%h,\textcolor{stringliteral}{"h"},restart\_csp)) \textcolor{keywordflow}{then}
02463     \textcolor{comment}{! This block is controlled by the ALE parameter REMAP\_AFTER\_INITIALIZATION.}
02464     \textcolor{comment}{! \(\backslash\)todo This block exists for legacy reasons and we should phase it out of}
02465     \textcolor{comment}{! all examples. !###}
02466     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
02467       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Pre ALE adjust init cond [uv]"}, &
02468                     cs%u, cs%v, g%HI, haloshift=1)
02469       \textcolor{keyword}{call }hchksum(cs%h,\textcolor{stringliteral}{"Pre ALE adjust init cond h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
02470 \textcolor{keywordflow}{    endif}
02471     \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"Calling adjustGridForIntegrity() to remap initial conditions (initialize\_MOM)"})
02472     \textcolor{keyword}{call }adjustgridforintegrity(cs%ALE\_CSp, g, gv, cs%h )
02473     \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"Calling ALE\_main() to remap initial conditions (initialize\_MOM)"})
02474     \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}
02475       filename = trim(inputdir)//trim(ice\_shelf\_file)
02476       \textcolor{keywordflow}{if} (.not.file\_exists(filename, g%Domain)) \textcolor{keyword}{call }mom\_error(fatal, &
02477         \textcolor{stringliteral}{"MOM: Unable to open "}//trim(filename))
02478 
02479       \textcolor{keyword}{allocate}(area\_shelf\_h(isd:ied,jsd:jed))
02480       \textcolor{keyword}{allocate}(frac\_shelf\_h(isd:ied,jsd:jed))
02481       \textcolor{keyword}{call }mom\_read\_data(filename, trim(area\_varname), area\_shelf\_h, g%Domain, scale=us%m\_to\_L**2)
02482       \textcolor{comment}{! initialize frac\_shelf\_h with zeros (open water everywhere)}
02483       frac\_shelf\_h(:,:) = 0.0
02484       \textcolor{comment}{! compute fractional ice shelf coverage of h}
02485       \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
02486         \textcolor{keywordflow}{if} (g%areaT(i,j) > 0.0) &
02487           frac\_shelf\_h(i,j) = area\_shelf\_h(i,j) / g%areaT(i,j)
02488 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
02489       \textcolor{comment}{! pass to the pointer}
02490       shelf\_area => frac\_shelf\_h
02491       \textcolor{keyword}{call }ale\_main(g, gv, us, cs%h, cs%u, cs%v, cs%tv, cs%tracer\_Reg, cs%ALE\_CSp, &
02492                     cs%OBC, frac\_shelf\_h=shelf\_area)
02493     \textcolor{keywordflow}{else}
02494       \textcolor{keyword}{call }ale\_main( g, gv, us, cs%h, cs%u, cs%v, cs%tv, cs%tracer\_Reg, cs%ALE\_CSp, cs%OBC)
02495 \textcolor{keywordflow}{    endif}
02496 
02497     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass\_init)
02498     \textcolor{keyword}{call }create\_group\_pass(tmp\_pass\_uv\_t\_s\_h, cs%u, cs%v, g%Domain)
02499     \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02500       \textcolor{keyword}{call }create\_group\_pass(tmp\_pass\_uv\_t\_s\_h, cs%tv%T, g%Domain, halo=1)
02501       \textcolor{keyword}{call }create\_group\_pass(tmp\_pass\_uv\_t\_s\_h, cs%tv%S, g%Domain, halo=1)
02502 \textcolor{keywordflow}{    endif}
02503     \textcolor{keyword}{call }create\_group\_pass(tmp\_pass\_uv\_t\_s\_h, cs%h, g%Domain, halo=1)
02504     \textcolor{keyword}{call }do\_group\_pass(tmp\_pass\_uv\_t\_s\_h, g%Domain)
02505     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass\_init)
02506 
02507     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
02508       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Post ALE adjust init cond [uv]"}, cs%u, cs%v, g%HI, haloshift=1)
02509       \textcolor{keyword}{call }hchksum(cs%h, \textcolor{stringliteral}{"Post ALE adjust init cond h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
02510 \textcolor{keywordflow}{    endif}
02511 \textcolor{keywordflow}{  endif}
02512   \textcolor{keywordflow}{if} ( cs%use\_ALE\_algorithm ) \textcolor{keyword}{call }ale\_updateverticalgridtype( cs%ALE\_CSp, gv )
02513 
02514   diag => cs%diag
02515   \textcolor{comment}{! Initialize the diag mediator.}
02516   \textcolor{keyword}{call }diag\_mediator\_init(g, gv, us, gv%ke, param\_file, diag, doc\_file\_dir=dirs%output\_directory)
02517   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(diag\_ptr)) diag\_ptr => cs%diag
02518 
02519   \textcolor{comment}{! Initialize the diagnostics masks for native arrays.}
02520   \textcolor{comment}{! This step has to be done after call to MOM\_initialize\_state}
02521   \textcolor{comment}{! and before MOM\_diagnostics\_init}
02522   \textcolor{keyword}{call }diag\_masks\_set(g, gv%ke, diag)
02523 
02524   \textcolor{comment}{! Set up pointers within diag mediator control structure,}
02525   \textcolor{comment}{! this needs to occur \_after\_ CS%h etc. have been allocated.}
02526   \textcolor{keyword}{call }diag\_set\_state\_ptrs(cs%h, cs%T, cs%S, cs%tv%eqn\_of\_state, diag)
02527 
02528   \textcolor{comment}{! This call sets up the diagnostic axes. These are needed,}
02529   \textcolor{comment}{! e.g. to generate the target grids below.}
02530   \textcolor{keyword}{call }set\_axes\_info(g, gv, us, param\_file, diag)
02531 
02532   \textcolor{comment}{! Whenever thickness/T/S changes let the diag manager know, target grids}
02533   \textcolor{comment}{! for vertical remapping may need to be regenerated.}
02534   \textcolor{comment}{! FIXME: are h, T, S updated at the same time? Review these for T, S updates.}
02535   \textcolor{keyword}{call }diag\_update\_remap\_grids(diag)
02536 
02537   \textcolor{comment}{! Setup the diagnostic grid storage types}
02538   \textcolor{keyword}{call }diag\_grid\_storage\_init(cs%diag\_pre\_sync, g, diag)
02539   \textcolor{keyword}{call }diag\_grid\_storage\_init(cs%diag\_pre\_dyn, g, diag)
02540 
02541   \textcolor{comment}{! Calculate masks for diagnostics arrays in non-native coordinates}
02542   \textcolor{comment}{! This step has to be done after set\_axes\_info() because the axes needed}
02543   \textcolor{comment}{! to be configured, and after diag\_update\_remap\_grids() because the grids}
02544   \textcolor{comment}{! must be defined.}
02545   \textcolor{keyword}{call }set\_masks\_for\_axes(g, diag)
02546 
02547   \textcolor{comment}{! Diagnose static fields AND associate areas/volumes with axes}
02548   \textcolor{keyword}{call }write\_static\_fields(g, gv, us, cs%tv, cs%diag)
02549   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"static fields written (initialize\_MOM)"})
02550 
02551   \textcolor{comment}{! Register the volume cell measure (must be one of first diagnostics)}
02552   \textcolor{keyword}{call }register\_cell\_measure(g, cs%diag, time)
02553 
02554   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_mom\_init)
02555   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm) \textcolor{keywordflow}{then}
02556     \textcolor{keyword}{call }ale\_writecoordinatefile( cs%ALE\_CSp, gv, dirs%output\_directory )
02557 \textcolor{keywordflow}{  endif}
02558   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_mom\_init)
02559   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"ALE initialized (initialize\_MOM)"})
02560 
02561   cs%useMEKE = meke\_init(time, g, us, param\_file, diag, cs%MEKE\_CSp, cs%MEKE, restart\_csp)
02562 
02563   \textcolor{keyword}{call }varmix\_init(time, g, gv, us, param\_file, diag, cs%VarMix)
02564   \textcolor{keyword}{call }set\_visc\_init(time, g, gv, us, param\_file, diag, cs%visc, cs%set\_visc\_CSp, restart\_csp, cs%OBC)
02565   \textcolor{keyword}{call }thickness\_diffuse\_init(time, g, gv, us, param\_file, diag, cs%CDp, cs%thickness\_diffuse\_CSp)
02566 
02567   \textcolor{keywordflow}{if} (cs%split) \textcolor{keywordflow}{then}
02568     \textcolor{keyword}{allocate}(eta(szi\_(g),szj\_(g))) ; eta(:,:) = 0.0
02569     \textcolor{keyword}{call }initialize\_dyn\_split\_rk2(cs%u, cs%v, cs%h, cs%uh, cs%vh, eta, time, &
02570               g, gv, us, param\_file, diag, cs%dyn\_split\_RK2\_CSp, restart\_csp, &
02571               cs%dt, cs%ADp, cs%CDp, mom\_internal\_state, cs%VarMix, cs%MEKE, &
02572               cs%thickness\_diffuse\_CSp,                                      &
02573               cs%OBC, cs%update\_OBC\_CSp, cs%ALE\_CSp, cs%set\_visc\_CSp,        &
02574               cs%visc, dirs, cs%ntrunc, calc\_dtbt=calc\_dtbt, cont\_stencil=cs%cont\_stencil)
02575     \textcolor{keywordflow}{if} (cs%dtbt\_reset\_period > 0.0) \textcolor{keywordflow}{then}
02576       cs%dtbt\_reset\_interval = real\_to\_time(cs%dtbt\_reset\_period)
02577       \textcolor{comment}{! Set dtbt\_reset\_time to be the next even multiple of dtbt\_reset\_interval.}
02578       cs%dtbt\_reset\_time = time\_init + cs%dtbt\_reset\_interval * &
02579                                  ((time - time\_init) / cs%dtbt\_reset\_interval)
02580       \textcolor{keywordflow}{if} ((cs%dtbt\_reset\_time > time) .and. calc\_dtbt) \textcolor{keywordflow}{then}
02581         \textcolor{comment}{! Back up dtbt\_reset\_time one interval to force dtbt to be calculated,}
02582         \textcolor{comment}{! because the restart was not aligned with the interval to recalculate}
02583         \textcolor{comment}{! dtbt, and dtbt was not read from a restart file.}
02584         cs%dtbt\_reset\_time = cs%dtbt\_reset\_time - cs%dtbt\_reset\_interval
02585 \textcolor{keywordflow}{      endif}
02586 \textcolor{keywordflow}{    endif}
02587   \textcolor{keywordflow}{elseif} (cs%use\_RK2) \textcolor{keywordflow}{then}
02588     \textcolor{keyword}{call }initialize\_dyn\_unsplit\_rk2(cs%u, cs%v, cs%h, time, g, gv, us,     &
02589             param\_file, diag, cs%dyn\_unsplit\_RK2\_CSp, restart\_csp,         &
02590             cs%ADp, cs%CDp, mom\_internal\_state, cs%MEKE, cs%OBC,           &
02591             cs%update\_OBC\_CSp, cs%ALE\_CSp, cs%set\_visc\_CSp, cs%visc, dirs, &
02592             cs%ntrunc, cont\_stencil=cs%cont\_stencil)
02593   \textcolor{keywordflow}{else}
02594     \textcolor{keyword}{call }initialize\_dyn\_unsplit(cs%u, cs%v, cs%h, time, g, gv, us,         &
02595             param\_file, diag, cs%dyn\_unsplit\_CSp, restart\_csp,             &
02596             cs%ADp, cs%CDp, mom\_internal\_state, cs%MEKE, cs%OBC,           &
02597             cs%update\_OBC\_CSp, cs%ALE\_CSp, cs%set\_visc\_CSp, cs%visc, dirs, &
02598             cs%ntrunc, cont\_stencil=cs%cont\_stencil)
02599 \textcolor{keywordflow}{  endif}
02600 
02601   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"dynamics initialized (initialize\_MOM)"})
02602 
02603   cs%mixedlayer\_restrat = mixedlayer\_restrat\_init(time, g, gv, us, param\_file, diag, &
02604                                                   cs%mixedlayer\_restrat\_CSp, restart\_csp)
02605   \textcolor{keywordflow}{if} (cs%mixedlayer\_restrat) \textcolor{keywordflow}{then}
02606     \textcolor{keywordflow}{if} (.not.(bulkmixedlayer .or. cs%use\_ALE\_algorithm)) &
02607       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM: MIXEDLAYER\_RESTRAT true requires a boundary layer scheme."})
02608     \textcolor{comment}{! When DIABATIC\_FIRST=False and using CS%visc%ML in mixedlayer\_restrat we need to update after a
       restart}
02609     \textcolor{keywordflow}{if} (.not. cs%diabatic\_first .and. \textcolor{keyword}{associated}(cs%visc%MLD)) &
02610       \textcolor{keyword}{call }pass\_var(cs%visc%MLD, g%domain, halo=1)
02611 \textcolor{keywordflow}{  endif}
02612 
02613   \textcolor{keyword}{call }mom\_diagnostics\_init(mom\_internal\_state, cs%ADp, cs%CDp, time, g, gv, us, &
02614                             param\_file, diag, cs%diagnostics\_CSp, cs%tv)
02615   \textcolor{keyword}{call }diag\_copy\_diag\_to\_storage(cs%diag\_pre\_sync, cs%h, cs%diag)
02616 
02617   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%sponge\_CSp)) &
02618     \textcolor{keyword}{call }init\_sponge\_diags(time, g, gv, us, diag, cs%sponge\_CSp)
02619 
02620   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%ALE\_sponge\_CSp)) &
02621     \textcolor{keyword}{call }init\_ale\_sponge\_diags(time, g, diag, cs%ALE\_sponge\_CSp)
02622 
02623   \textcolor{keywordflow}{if} (cs%adiabatic) \textcolor{keywordflow}{then}
02624     \textcolor{keyword}{call }adiabatic\_driver\_init(time, g, param\_file, diag, cs%diabatic\_CSp, &
02625                                cs%tracer\_flow\_CSp)
02626   \textcolor{keywordflow}{else}
02627     \textcolor{keyword}{call }diabatic\_driver\_init(time, g, gv, us, param\_file, cs%use\_ALE\_algorithm, diag, &
02628                               cs%ADp, cs%CDp, cs%diabatic\_CSp, cs%tracer\_flow\_CSp, &
02629                               cs%sponge\_CSp, cs%ALE\_sponge\_CSp)
02630 \textcolor{keywordflow}{  endif}
02631 
02632   \textcolor{keyword}{call }tracer\_advect\_init(time, g, us, param\_file, diag, cs%tracer\_adv\_CSp)
02633   \textcolor{keyword}{call }tracer\_hor\_diff\_init(time, g, us, param\_file, diag, cs%tv%eqn\_of\_state, cs%diabatic\_CSp, &
02634                             cs%tracer\_diff\_CSp)
02635 
02636   \textcolor{keyword}{call }lock\_tracer\_registry(cs%tracer\_Reg)
02637   \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"tracer registry now locked (initialize\_MOM)"})
02638 
02639   \textcolor{comment}{! now register some diagnostics since the tracer registry is now locked}
02640   \textcolor{keyword}{call }register\_surface\_diags(time, g, us, cs%sfc\_IDs, cs%diag, cs%tv)
02641   \textcolor{keyword}{call }register\_diags(time, g, gv, us, cs%IDs, cs%diag)
02642   \textcolor{keyword}{call }register\_transport\_diags(time, g, gv, us, cs%transport\_IDs, cs%diag)
02643   \textcolor{keyword}{call }register\_tracer\_diagnostics(cs%tracer\_Reg, cs%h, time, diag, g, gv, us, &
02644                                    cs%use\_ALE\_algorithm)
02645   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm) \textcolor{keywordflow}{then}
02646     \textcolor{keyword}{call }ale\_register\_diags(time, g, gv, us, diag, cs%ALE\_CSp)
02647 \textcolor{keywordflow}{  endif}
02648 
02649   \textcolor{comment}{! This subroutine initializes any tracer packages.}
02650   new\_sim = is\_new\_run(restart\_csp)
02651   \textcolor{keyword}{call }tracer\_flow\_control\_init(.not.new\_sim, time, g, gv, us, cs%h, param\_file, &
02652              cs%diag, cs%OBC, cs%tracer\_flow\_CSp, cs%sponge\_CSp, &
02653              cs%ALE\_sponge\_CSp, cs%tv)
02654   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tracer\_flow\_csp)) tracer\_flow\_csp => cs%tracer\_flow\_CSp
02655 
02656   \textcolor{comment}{! If running in offline tracer mode, initialize the necessary control structure and}
02657   \textcolor{comment}{! parameters}
02658   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(offline\_tracer\_mode)) offline\_tracer\_mode=cs%offline\_tracer\_mode
02659 
02660   \textcolor{keywordflow}{if} (cs%offline\_tracer\_mode) \textcolor{keywordflow}{then}
02661     \textcolor{comment}{! Setup some initial parameterizations and also assign some of the subtypes}
02662     \textcolor{keyword}{call }offline\_transport\_init(param\_file, cs%offline\_CSp, cs%diabatic\_CSp, g, gv, us)
02663     \textcolor{keyword}{call }insert\_offline\_main( cs=cs%offline\_CSp, ale\_csp=cs%ALE\_CSp, diabatic\_csp=cs%diabatic\_CSp, &
02664                               diag=cs%diag, obc=cs%OBC, tracer\_adv\_csp=cs%tracer\_adv\_CSp,              &
02665                               tracer\_flow\_csp=cs%tracer\_flow\_CSp, tracer\_reg=cs%tracer\_Reg,            &
02666                               tv=cs%tv, x\_before\_y = (mod(first\_direction,2)==0), debug=cs%debug )
02667     \textcolor{keyword}{call }register\_diags\_offline\_transport(time, cs%diag, cs%offline\_CSp)
02668 \textcolor{keywordflow}{  endif}
02669 
02670   \textcolor{comment}{!--- set up group pass for u,v,T,S and h. pass\_uv\_T\_S\_h also is used in step\_MOM}
02671   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass\_init)
02672   dynamics\_stencil = min(3, g%Domain%nihalo, g%Domain%njhalo)
02673   \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, cs%u, cs%v, g%Domain, halo=dynamics\_stencil)
02674   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
02675     \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, cs%tv%T, g%Domain, halo=dynamics\_stencil)
02676     \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, cs%tv%S, g%Domain, halo=dynamics\_stencil)
02677 \textcolor{keywordflow}{  endif}
02678   \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, cs%h, g%Domain, halo=dynamics\_stencil)
02679 
02680   \textcolor{keyword}{call }do\_group\_pass(pass\_uv\_t\_s\_h, g%Domain)
02681 
02682   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%visc%Kv\_shear)) &
02683     \textcolor{keyword}{call }pass\_var(cs%visc%Kv\_shear, g%Domain, to\_all+omit\_corners, halo=1)
02684 
02685   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%visc%Kv\_slow)) &
02686     \textcolor{keyword}{call }pass\_var(cs%visc%Kv\_slow, g%Domain, to\_all+omit\_corners, halo=1)
02687 
02688   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass\_init)
02689 
02690   \textcolor{keyword}{call }register\_obsolete\_diagnostics(param\_file, cs%diag)
02691 
02692   \textcolor{keywordflow}{if} (use\_frazil) \textcolor{keywordflow}{then}
02693     \textcolor{keywordflow}{if} (query\_initialized(cs%tv%frazil, \textcolor{stringliteral}{"frazil"}, restart\_csp)) \textcolor{keywordflow}{then}
02694       \textcolor{comment}{! Test whether the dimensional rescaling has changed for heat content.}
02695       \textcolor{keywordflow}{if} ((us%kg\_m3\_to\_R\_restart*us%m\_to\_Z\_restart*us%J\_kg\_to\_Q\_restart /= 0.0) .and. &
02696           ((us%J\_kg\_to\_Q*us%kg\_m3\_to\_R*us%m\_to\_Z) /= &
02697            (us%J\_kg\_to\_Q\_restart*us%kg\_m3\_to\_R\_restart*us%m\_to\_Z\_restart)) ) \textcolor{keywordflow}{then}
02698         qrz\_rescale = (us%J\_kg\_to\_Q*us%kg\_m3\_to\_R*us%m\_to\_Z) / &
02699                       (us%J\_kg\_to\_Q\_restart*us%kg\_m3\_to\_R\_restart*us%m\_to\_Z\_restart)
02700         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
02701           cs%tv%frazil(i,j) = qrz\_rescale * cs%tv%frazil(i,j)
02702 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
02703 \textcolor{keywordflow}{      endif}
02704     \textcolor{keywordflow}{else}
02705       cs%tv%frazil(:,:) = 0.0
02706 \textcolor{keywordflow}{    endif}
02707 \textcolor{keywordflow}{  endif}
02708 
02709   \textcolor{keywordflow}{if} (cs%interp\_p\_surf) \textcolor{keywordflow}{then}
02710     cs%p\_surf\_prev\_set = query\_initialized(cs%p\_surf\_prev,\textcolor{stringliteral}{"p\_surf\_prev"},restart\_csp)
02711 
02712     \textcolor{keywordflow}{if} (cs%p\_surf\_prev\_set) \textcolor{keywordflow}{then}
02713       \textcolor{comment}{! Test whether the dimensional rescaling has changed for pressure.}
02714       \textcolor{keywordflow}{if} ((us%kg\_m3\_to\_R\_restart*us%s\_to\_T\_restart*us%m\_to\_L\_restart /= 0.0) .and. &
02715           ((us%kg\_m3\_to\_R*(us%m\_to\_L*us%s\_to\_T\_restart)**2) /= &
02716            (us%kg\_m3\_to\_R\_restart*(us%m\_to\_L\_restart*us%s\_to\_T)**2)) ) \textcolor{keywordflow}{then}
02717         rl2\_t2\_rescale = (us%kg\_m3\_to\_R*(us%m\_to\_L*us%s\_to\_T\_restart)**2) / &
02718                          (us%kg\_m3\_to\_R\_restart*(us%m\_to\_L\_restart*us%s\_to\_T)**2)
02719         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
02720           cs%p\_surf\_prev(i,j) = rl2\_t2\_rescale * cs%p\_surf\_prev(i,j)
02721 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
02722 \textcolor{keywordflow}{      endif}
02723 
02724       \textcolor{keyword}{call }pass\_var(cs%p\_surf\_prev, g%domain)
02725 \textcolor{keywordflow}{    endif}
02726 \textcolor{keywordflow}{  endif}
02727 
02728   \textcolor{keywordflow}{if} (use\_ice\_shelf .and. \textcolor{keyword}{associated}(cs%Hml)) \textcolor{keywordflow}{then}
02729     \textcolor{keywordflow}{if} (query\_initialized(cs%Hml, \textcolor{stringliteral}{"hML"}, restart\_csp)) \textcolor{keywordflow}{then}
02730       \textcolor{comment}{! Test whether the dimensional rescaling has changed for depths.}
02731       \textcolor{keywordflow}{if} ((us%m\_to\_Z\_restart /= 0.0) .and. (us%m\_to\_Z /= us%m\_to\_Z\_restart) ) \textcolor{keywordflow}{then}
02732         z\_rescale = us%m\_to\_Z / us%m\_to\_Z\_restart
02733         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
02734           cs%Hml(i,j) = z\_rescale * cs%Hml(i,j)
02735 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
02736 \textcolor{keywordflow}{      endif}
02737 \textcolor{keywordflow}{    endif}
02738 \textcolor{keywordflow}{  endif}
02739 
02740   \textcolor{keywordflow}{if} (.not.query\_initialized(cs%ave\_ssh\_ibc,\textcolor{stringliteral}{"ave\_ssh"},restart\_csp)) \textcolor{keywordflow}{then}
02741     \textcolor{keywordflow}{if} (cs%split) \textcolor{keywordflow}{then}
02742       \textcolor{keyword}{call }find\_eta(cs%h, cs%tv, g, gv, us, cs%ave\_ssh\_ibc, eta, eta\_to\_m=1.0)
02743     \textcolor{keywordflow}{else}
02744       \textcolor{keyword}{call }find\_eta(cs%h, cs%tv, g, gv, us, cs%ave\_ssh\_ibc, eta\_to\_m=1.0)
02745 \textcolor{keywordflow}{    endif}
02746 \textcolor{keywordflow}{  endif}
02747   \textcolor{keywordflow}{if} (cs%split) \textcolor{keyword}{deallocate}(eta)
02748 
02749   cs%nstep\_tot = 0
02750   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(count\_calls)) cs%count\_calls = count\_calls
02751   \textcolor{keyword}{call }mom\_sum\_output\_init(g\_in, us, param\_file, dirs%output\_directory, &
02752                            cs%ntrunc, time\_init, cs%sum\_output\_CSp)
02753 
02754   \textcolor{comment}{! Flag whether to save initial conditions in finish\_MOM\_initialization() or not.}
02755   cs%write\_IC = save\_ic .and. &
02756                 .not.((dirs%input\_filename(1:1) == \textcolor{stringliteral}{'r'}) .and. &
02757                       (len\_trim(dirs%input\_filename) == 1))
02758 
02759   \textcolor{keywordflow}{if} (cs%ensemble\_ocean) \textcolor{keywordflow}{then}
02760     \textcolor{keyword}{call }init\_oda(time, g, gv, cs%odaCS)
02761 \textcolor{keywordflow}{  endif}
02762 
02763   \textcolor{comment}{!### This could perhaps go here instead of in finish\_MOM\_initialization?}
02764   \textcolor{comment}{! call fix\_restart\_scaling(GV)}
02765   \textcolor{comment}{! call fix\_restart\_unit\_scaling(US)}
02766 
02767   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"initialize\_MOM()"})
02768   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_init)
02769 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_ae6dad976fb4be1c7ba7fc1aff809616b}\label{namespacemom_ae6dad976fb4be1c7ba7fc1aff809616b}} 
\index{mom@{mom}!mom\+\_\+end@{mom\+\_\+end}}
\index{mom\+\_\+end@{mom\+\_\+end}!mom@{mom}}
\subsubsection{\texorpdfstring{mom\+\_\+end()}{mom\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+::mom\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS }\end{DoxyParamCaption})}



End of ocean model, including memory deallocation. 


\begin{DoxyParams}{Parameters}
{\em cs} & M\+OM control structure \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l03486}{3486} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.


\begin{DoxyCode}
03486   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< MOM control structure}
03487 
03488   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm) \textcolor{keyword}{call }ale\_end(cs%ALE\_CSp)
03489 
03490   dealloc\_(cs%u) ; dealloc\_(cs%v) ; dealloc\_(cs%h)
03491   dealloc\_(cs%uh) ; dealloc\_(cs%vh)
03492 
03493   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%T)) \textcolor{keywordflow}{then}
03494     dealloc\_(cs%T) ; cs%tv%T => null() ; dealloc\_(cs%S) ; cs%tv%S => null()
03495 \textcolor{keywordflow}{  endif}
03496   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%frazil)) \textcolor{keyword}{deallocate}(cs%tv%frazil)
03497   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%salt\_deficit)) \textcolor{keyword}{deallocate}(cs%tv%salt\_deficit)
03498   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%Hml)) \textcolor{keyword}{deallocate}(cs%Hml)
03499 
03500   \textcolor{keyword}{call }tracer\_advect\_end(cs%tracer\_adv\_CSp)
03501   \textcolor{keyword}{call }tracer\_hor\_diff\_end(cs%tracer\_diff\_CSp)
03502   \textcolor{keyword}{call }tracer\_registry\_end(cs%tracer\_Reg)
03503   \textcolor{keyword}{call }tracer\_flow\_control\_end(cs%tracer\_flow\_CSp)
03504 
03505   \textcolor{keyword}{call }diabatic\_driver\_end(cs%diabatic\_CSp)
03506 
03507   \textcolor{keywordflow}{if} (cs%offline\_tracer\_mode) \textcolor{keyword}{call }offline\_transport\_end(cs%offline\_CSp)
03508 
03509   dealloc\_(cs%uhtr) ; dealloc\_(cs%vhtr)
03510   \textcolor{keywordflow}{if} (cs%split) \textcolor{keywordflow}{then}
03511     \textcolor{keyword}{call }end\_dyn\_split\_rk2(cs%dyn\_split\_RK2\_CSp)
03512   \textcolor{keywordflow}{elseif} (cs%use\_RK2) \textcolor{keywordflow}{then}
03513     \textcolor{keyword}{call }end\_dyn\_unsplit\_rk2(cs%dyn\_unsplit\_RK2\_CSp)
03514   \textcolor{keywordflow}{else}
03515     \textcolor{keyword}{call }end\_dyn\_unsplit(cs%dyn\_unsplit\_CSp)
03516 \textcolor{keywordflow}{  endif}
03517   dealloc\_(cs%ave\_ssh\_ibc) ; dealloc\_(cs%ssh\_rint)
03518   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%update\_OBC\_CSp)) \textcolor{keyword}{call }obc\_register\_end(cs%update\_OBC\_CSp)
03519 
03520   \textcolor{keyword}{call }verticalgridend(cs%GV)
03521   \textcolor{keyword}{call }unit\_scaling\_end(cs%US)
03522   \textcolor{keyword}{call }mom\_grid\_end(cs%G)
03523 
03524   \textcolor{keyword}{deallocate}(cs)
03525 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_ada38a8329b76f9fa1685a230869a7647}\label{namespacemom_ada38a8329b76f9fa1685a230869a7647}} 
\index{mom@{mom}!mom\+\_\+state\+\_\+is\+\_\+synchronized@{mom\+\_\+state\+\_\+is\+\_\+synchronized}}
\index{mom\+\_\+state\+\_\+is\+\_\+synchronized@{mom\+\_\+state\+\_\+is\+\_\+synchronized}!mom@{mom}}
\subsubsection{\texorpdfstring{mom\+\_\+state\+\_\+is\+\_\+synchronized()}{mom\_state\_is\_synchronized()}}
{\footnotesize\ttfamily logical function, public mom\+::mom\+\_\+state\+\_\+is\+\_\+synchronized (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{logical, intent(in), optional}]{adv\+\_\+dyn }\end{DoxyParamCaption})}



Return true if all phases of step\+\_\+\+M\+OM are at the same point in time. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & M\+OM control structure\\
\hline
\mbox{\tt in}  & {\em adv\+\_\+dyn} & If present and true, only check whether the advection is up-\/to-\/date with the dynamics.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
True if all phases of the update are synchronized. 
\end{DoxyReturn}


Definition at line \hyperlink{MOM_8F90_source_l03429}{3429} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}.


\begin{DoxyCode}
03429   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< MOM control structure}
03430   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: adv\_dyn\textcolor{comment}{  !< If present and true, only check}
03431 \textcolor{comment}{                                          !! whether the advection is up-to-date with}
03432 \textcolor{comment}{                                          !! the dynamics.}
03433   \textcolor{keywordtype}{logical} :: in\_synch\textcolor{comment}{ !< True if all phases of the update are synchronized.}
03434 
03435   \textcolor{keywordtype}{logical} :: adv\_only
03436 
03437   adv\_only = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(adv\_dyn)) adv\_only = adv\_dyn
03438 
03439   \textcolor{keywordflow}{if} (adv\_only) \textcolor{keywordflow}{then}
03440     in\_synch = (cs%t\_dyn\_rel\_adv == 0.0)
03441   \textcolor{keywordflow}{else}
03442     in\_synch = ((cs%t\_dyn\_rel\_adv == 0.0) .and. (cs%t\_dyn\_rel\_thermo == 0.0))
03443 \textcolor{keywordflow}{  endif}
03444 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_ab57e47834591c651339770f7e51efe57}\label{namespacemom_ab57e47834591c651339770f7e51efe57}} 
\index{mom@{mom}!mom\+\_\+timing\+\_\+init@{mom\+\_\+timing\+\_\+init}}
\index{mom\+\_\+timing\+\_\+init@{mom\+\_\+timing\+\_\+init}!mom@{mom}}
\subsubsection{\texorpdfstring{mom\+\_\+timing\+\_\+init()}{mom\_timing\_init()}}
{\footnotesize\ttfamily subroutine mom\+::mom\+\_\+timing\+\_\+init (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), intent(in)}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Set up C\+PU clock I\+Ds for timing various subroutines. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em cs} & control structure set up by initialize\+\_\+\+M\+OM. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l02855}{2855} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_af865d838388a05163e8de8d266316d5f}{id\+\_\+clock\+\_\+adiabatic}, \hyperlink{namespacemom_a722ed13d0e6d76852e680054a0e3c964}{id\+\_\+clock\+\_\+ale}, \hyperlink{namespacemom_aa69e79e4c51e1c24c474b84311322251}{id\+\_\+clock\+\_\+bbl\+\_\+visc}, \hyperlink{namespacemom_aa512b2d8dd73b02634e772701be07a87}{id\+\_\+clock\+\_\+continuity}, \hyperlink{namespacemom_a50edf00aa5998073d2db0360949253ba}{id\+\_\+clock\+\_\+diabatic}, \hyperlink{namespacemom_aa773fddb51f99098d75304eb271270d4}{id\+\_\+clock\+\_\+diagnostics}, \hyperlink{namespacemom_ae1cf2d523679b925a5e5baa9d974968c}{id\+\_\+clock\+\_\+dynamics}, \hyperlink{namespacemom_a41b67fabfc13e52cf3a5d1c337c780eb}{id\+\_\+clock\+\_\+ml\+\_\+restrat}, \hyperlink{namespacemom_a4180eb85bab39df7cbb72bb8e5b19fd4}{id\+\_\+clock\+\_\+mom\+\_\+init}, \hyperlink{namespacemom_a2e9f4b71ee77ba5bcb3f03a863948db3}{id\+\_\+clock\+\_\+ocean}, \hyperlink{namespacemom_a2ab767469f0d918b9e479d8e0fde44b0}{id\+\_\+clock\+\_\+offline\+\_\+tracer}, \hyperlink{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}{id\+\_\+clock\+\_\+other}, \hyperlink{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}{id\+\_\+clock\+\_\+pass}, \hyperlink{namespacemom_ac4d20612cad32d412dae492fedc2e971}{id\+\_\+clock\+\_\+pass\+\_\+init}, \hyperlink{namespacemom_a052256dfa3e56390f62ef3a826d62617}{id\+\_\+clock\+\_\+thermo}, \hyperlink{namespacemom_a8f5feb87a0cb40d9fcee00456e982b8a}{id\+\_\+clock\+\_\+thick\+\_\+diff}, \hyperlink{namespacemom_a0fa4debacd02de6fcd066066c232adf3}{id\+\_\+clock\+\_\+tracer}, and \hyperlink{namespacemom_a09f2ac3470372b9ee233f4cc5a7a0da1}{id\+\_\+clock\+\_\+z\+\_\+diag}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}.


\begin{DoxyCode}
02855   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{intent(in)} :: cs\textcolor{comment}{  !< control structure set up by initialize\_MOM.}
02856 
02857  id\_clock\_ocean    = cpu\_clock\_id(\textcolor{stringliteral}{'Ocean'}, grain=clock\_component)
02858  id\_clock\_dynamics = cpu\_clock\_id(\textcolor{stringliteral}{'Ocean dynamics'}, grain=clock\_subcomponent)
02859  id\_clock\_thermo   = cpu\_clock\_id(\textcolor{stringliteral}{'Ocean thermodynamics and tracers'}, grain=clock\_subcomponent)
02860  id\_clock\_other    = cpu\_clock\_id(\textcolor{stringliteral}{'Ocean Other'}, grain=clock\_subcomponent)
02861  id\_clock\_tracer   = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean tracer advection)'}, grain=clock\_module\_driver)
02862  \textcolor{keywordflow}{if} (.not.cs%adiabatic) \textcolor{keywordflow}{then}
02863    id\_clock\_diabatic = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean diabatic driver)'}, grain=clock\_module\_driver)
02864  \textcolor{keywordflow}{else}
02865    id\_clock\_adiabatic = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean adiabatic driver)'}, grain=clock\_module\_driver)
02866 \textcolor{keywordflow}{ endif}
02867 
02868  id\_clock\_continuity = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean continuity equation *)'}, grain=clock\_module)
02869  id\_clock\_bbl\_visc   = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean set BBL viscosity)'}, grain=clock\_module)
02870  id\_clock\_pass       = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean message passing *)'}, grain=clock\_module)
02871  id\_clock\_mom\_init   = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean MOM\_initialize\_state)'}, grain=clock\_module)
02872  id\_clock\_pass\_init  = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean init message passing *)'}, grain=clock\_routine)
02873  \textcolor{keywordflow}{if} (cs%thickness\_diffuse) &
02874    id\_clock\_thick\_diff = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean thickness diffusion *)'}, grain=clock\_module)
02875 \textcolor{comment}{!if (CS%mixedlayer\_restrat) &}
02876    id\_clock\_ml\_restrat = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean mixed layer restrat)'}, grain=clock\_module)
02877  id\_clock\_diagnostics  = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean collective diagnostics)'}, grain=clock\_module)
02878  id\_clock\_z\_diag       = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean Z-space diagnostics)'}, grain=clock\_module)
02879  id\_clock\_ale          = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean ALE)'}, grain=clock\_module)
02880  \textcolor{keywordflow}{if} (cs%offline\_tracer\_mode) \textcolor{keywordflow}{then}
02881   id\_clock\_offline\_tracer = cpu\_clock\_id(\textcolor{stringliteral}{'Ocean offline tracers'}, grain=clock\_subcomponent)
02882 \textcolor{keywordflow}{ endif}
02883 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_af0f791729b0ccb6cb8ae2f4d28edee21}\label{namespacemom_af0f791729b0ccb6cb8ae2f4d28edee21}} 
\index{mom@{mom}!register\+\_\+diags@{register\+\_\+diags}}
\index{register\+\_\+diags@{register\+\_\+diags}!mom@{mom}}
\subsubsection{\texorpdfstring{register\+\_\+diags()}{register\_diags()}}
{\footnotesize\ttfamily subroutine mom\+::register\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(inout)}]{US,  }\item[{type(\hyperlink{structmom_1_1mom__diag__ids}{mom\+\_\+diag\+\_\+ids}), intent(inout)}]{I\+Ds,  }\item[{type(diag\+\_\+ctrl), intent(inout)}]{diag }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Register certain diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & current model time\\
\hline
\mbox{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em ids} & A structure with the diagnostic I\+Ds.\\
\hline
\mbox{\tt in,out}  & {\em diag} & regulates diagnostic output \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l02824}{2824} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}.


\begin{DoxyCode}
02824   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{  !< current model time}
02825   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{     !< ocean grid structure}
02826   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{    !< ocean vertical grid structure}
02827   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(inout)} :: us\textcolor{comment}{    !< A dimensional unit scaling type}
02828   \textcolor{keywordtype}{type}(mom\_diag\_ids),      \textcolor{keywordtype}{intent(inout)} :: ids\textcolor{comment}{   !< A structure with the diagnostic IDs.}
02829   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{  !< regulates diagnostic output}
02830 
02831   \textcolor{keywordtype}{real} :: h\_convert
02832   \textcolor{keywordtype}{character(len=48)} :: thickness\_units
02833 
02834   thickness\_units = get\_thickness\_units(gv)
02835   \textcolor{keywordflow}{if} (gv%Boussinesq) \textcolor{keywordflow}{then}
02836     h\_convert = gv%H\_to\_m
02837   \textcolor{keywordflow}{else}
02838     h\_convert = gv%H\_to\_kg\_m2
02839 \textcolor{keywordflow}{  endif}
02840 
02841   \textcolor{comment}{! Diagnostics of the rapidly varying dynamic state}
02842   ids%id\_u = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_dyn'}, diag%axesCuL, time, &
02843       \textcolor{stringliteral}{'Zonal velocity after the dynamics update'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
02844   ids%id\_v = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_dyn'}, diag%axesCvL, time, &
02845       \textcolor{stringliteral}{'Meridional velocity after the dynamics update'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
02846   ids%id\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_dyn'}, diag%axesTL, time, &
02847       \textcolor{stringliteral}{'Layer Thickness after the dynamics update'}, thickness\_units, &
02848       v\_extensive=.true., conversion=h\_convert)
02849   ids%id\_ssh\_inst = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'SSH\_inst'}, diag%axesT1, &
02850       time, \textcolor{stringliteral}{'Instantaneous Sea Surface Height'}, \textcolor{stringliteral}{'m'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a8f5160e583b599050515b8fe5575aa15}\label{namespacemom_a8f5160e583b599050515b8fe5575aa15}} 
\index{mom@{mom}!rotate\+\_\+initial\+\_\+state@{rotate\+\_\+initial\+\_\+state}}
\index{rotate\+\_\+initial\+\_\+state@{rotate\+\_\+initial\+\_\+state}!mom@{mom}}
\subsubsection{\texorpdfstring{rotate\+\_\+initial\+\_\+state()}{rotate\_initial\_state()}}
{\footnotesize\ttfamily subroutine mom\+::rotate\+\_\+initial\+\_\+state (\begin{DoxyParamCaption}\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{u\+\_\+in,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{v\+\_\+in,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h\+\_\+in,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{T\+\_\+in,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{S\+\_\+in,  }\item[{logical, intent(in)}]{use\+\_\+temperature,  }\item[{integer, intent(in)}]{turns,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{u,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{v,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{h,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{T,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{S }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Rotate initialization fields from input to rotated arrays. 



Definition at line \hyperlink{MOM_8F90_source_l03414}{3414} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}.


\begin{DoxyCode}
03414   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: u\_in, v\_in, h\_in, t\_in, s\_in
03415   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: use\_temperature
03416   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: turns
03417   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(out)} :: u, v, h, t, s
03418 
03419   \textcolor{keyword}{call }rotate\_vector(u\_in, v\_in, turns, u, v)
03420   \textcolor{keyword}{call }rotate\_array(h\_in, turns, h)
03421   \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}
03422     \textcolor{keyword}{call }rotate\_array(t\_in, turns, t)
03423     \textcolor{keyword}{call }rotate\_array(s\_in, turns, s)
03424 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a76cb0af280a5c9e877dc206a6849b46b}\label{namespacemom_a76cb0af280a5c9e877dc206a6849b46b}} 
\index{mom@{mom}!set\+\_\+restart\+\_\+fields@{set\+\_\+restart\+\_\+fields}}
\index{set\+\_\+restart\+\_\+fields@{set\+\_\+restart\+\_\+fields}!mom@{mom}}
\subsubsection{\texorpdfstring{set\+\_\+restart\+\_\+fields()}{set\_restart\_fields()}}
{\footnotesize\ttfamily subroutine mom\+::set\+\_\+restart\+\_\+fields (\begin{DoxyParamCaption}\item[{type(verticalgrid\+\_\+type), intent(inout)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(inout)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), intent(in)}]{CS,  }\item[{type(mom\+\_\+restart\+\_\+cs), pointer}]{restart\+\_\+\+C\+Sp }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Set the fields that are needed for bitwise identical restarting the time stepping scheme. In addition to those specified here directly, there may be fields related to the forcing or to the barotropic solver that are needed; these are specified in sub-\/ routines that are called from this one. 

This routine should be altered if there are any changes to the time stepping scheme. The C\+H\+E\+C\+K\+\_\+\+R\+E\+S\+T\+A\+RT facility may be used to confirm that all needed restart fields have been included.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & opened file for parsing to get parameters\\
\hline
\mbox{\tt in}  & {\em cs} & control structure set up by initialize\+\_\+\+M\+OM\\
\hline
 & {\em restart\+\_\+csp} & pointer to the restart control structure that will be used for M\+OM. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l02896}{2896} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}.


\begin{DoxyCode}
02896   \textcolor{keywordtype}{type}(verticalgrid\_type),  \textcolor{keywordtype}{intent(inout)} :: gv\textcolor{comment}{         !< ocean vertical grid structure}
02897   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(inout)} :: us\textcolor{comment}{         !< A dimensional unit scaling type}
02898   \textcolor{keywordtype}{type}(param\_file\_type),    \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{    !< opened file for parsing to get parameters}
02899   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{intent(in)} :: cs\textcolor{comment}{            !< control structure set up by initialize\_MOM}
02900   \textcolor{keywordtype}{type}(mom\_restart\_cs),     \textcolor{keywordtype}{pointer}    :: restart\_csp\textcolor{comment}{   !< pointer to the restart control}
02901 \textcolor{comment}{                                                        !! structure that will be used for MOM.}
02902   \textcolor{comment}{! Local variables}
02903   \textcolor{keywordtype}{logical} :: use\_ice\_shelf \textcolor{comment}{! Needed to determine whether to add CS%Hml to restarts}
02904   \textcolor{keywordtype}{character(len=48)} :: thickness\_units, flux\_units
02905   \textcolor{keywordtype}{type}(vardesc) :: u\_desc, v\_desc
02906 
02907   thickness\_units = get\_thickness\_units(gv)
02908   flux\_units = get\_flux\_units(gv)
02909 
02910   u\_desc = var\_desc(\textcolor{stringliteral}{"u"}, \textcolor{stringliteral}{"m s-1"}, \textcolor{stringliteral}{"Zonal velocity"}, hor\_grid=\textcolor{stringliteral}{'Cu'})
02911   v\_desc = var\_desc(\textcolor{stringliteral}{"v"}, \textcolor{stringliteral}{"m s-1"}, \textcolor{stringliteral}{"Meridional velocity"}, hor\_grid=\textcolor{stringliteral}{'Cv'})
02912 
02913   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%T)) &
02914     \textcolor{keyword}{call }register\_restart\_field(cs%tv%T, \textcolor{stringliteral}{"Temp"}, .true., restart\_csp, &
02915                                 \textcolor{stringliteral}{"Potential Temperature"}, \textcolor{stringliteral}{"degC"})
02916   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%S)) &
02917     \textcolor{keyword}{call }register\_restart\_field(cs%tv%S, \textcolor{stringliteral}{"Salt"}, .true., restart\_csp, &
02918                                 \textcolor{stringliteral}{"Salinity"}, \textcolor{stringliteral}{"PPT"})
02919 
02920   \textcolor{keyword}{call }register\_restart\_field(cs%h, \textcolor{stringliteral}{"h"}, .true., restart\_csp, &
02921                               \textcolor{stringliteral}{"Layer Thickness"}, thickness\_units)
02922 
02923   \textcolor{keyword}{call }register\_restart\_pair(cs%u, cs%v, u\_desc, v\_desc, .true., restart\_csp)
02924 
02925   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%frazil)) &
02926     \textcolor{keyword}{call }register\_restart\_field(cs%tv%frazil, \textcolor{stringliteral}{"frazil"}, .false., restart\_csp, &
02927                                 \textcolor{stringliteral}{"Frazil heat flux into ocean"}, \textcolor{stringliteral}{"J m-2"})
02928 
02929   \textcolor{keywordflow}{if} (cs%interp\_p\_surf) \textcolor{keywordflow}{then}
02930     \textcolor{keyword}{call }register\_restart\_field(cs%p\_surf\_prev, \textcolor{stringliteral}{"p\_surf\_prev"}, .false., restart\_csp, &
02931                                 \textcolor{stringliteral}{"Previous ocean surface pressure"}, \textcolor{stringliteral}{"Pa"})
02932 \textcolor{keywordflow}{  endif}
02933 
02934   \textcolor{keyword}{call }register\_restart\_field(cs%ave\_ssh\_ibc, \textcolor{stringliteral}{"ave\_ssh"}, .false., restart\_csp, &
02935                               \textcolor{stringliteral}{"Time average sea surface height"}, \textcolor{stringliteral}{"meter"})
02936 
02937   \textcolor{comment}{! hML is needed when using the ice shelf module}
02938   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{"ICE\_SHELF"}, use\_ice\_shelf, default=.false., &
02939                  do\_not\_log=.true.)
02940   \textcolor{keywordflow}{if} (use\_ice\_shelf .and. \textcolor{keyword}{associated}(cs%Hml)) \textcolor{keywordflow}{then}
02941     \textcolor{keyword}{call }register\_restart\_field(cs%Hml, \textcolor{stringliteral}{"hML"}, .false., restart\_csp, &
02942                                 \textcolor{stringliteral}{"Mixed layer thickness"}, \textcolor{stringliteral}{"meter"})
02943 \textcolor{keywordflow}{  endif}
02944 
02945   \textcolor{comment}{! Register scalar unit conversion factors.}
02946   \textcolor{keyword}{call }register\_restart\_field(us%m\_to\_Z\_restart, \textcolor{stringliteral}{"m\_to\_Z"}, .false., restart\_csp, &
02947                               \textcolor{stringliteral}{"Height unit conversion factor"}, \textcolor{stringliteral}{"Z meter-1"})
02948   \textcolor{keyword}{call }register\_restart\_field(gv%m\_to\_H\_restart, \textcolor{stringliteral}{"m\_to\_H"}, .false., restart\_csp, &
02949                               \textcolor{stringliteral}{"Thickness unit conversion factor"}, \textcolor{stringliteral}{"H meter-1"})
02950   \textcolor{keyword}{call }register\_restart\_field(us%m\_to\_L\_restart, \textcolor{stringliteral}{"m\_to\_L"}, .false., restart\_csp, &
02951                               \textcolor{stringliteral}{"Length unit conversion factor"}, \textcolor{stringliteral}{"L meter-1"})
02952   \textcolor{keyword}{call }register\_restart\_field(us%s\_to\_T\_restart, \textcolor{stringliteral}{"s\_to\_T"}, .false., restart\_csp, &
02953                               \textcolor{stringliteral}{"Time unit conversion factor"}, \textcolor{stringliteral}{"T second-1"})
02954   \textcolor{keyword}{call }register\_restart\_field(us%kg\_m3\_to\_R\_restart, \textcolor{stringliteral}{"kg\_m3\_to\_R"}, .false., restart\_csp, &
02955                               \textcolor{stringliteral}{"Density unit conversion factor"}, \textcolor{stringliteral}{"R m3 kg-1"})
02956   \textcolor{keyword}{call }register\_restart\_field(us%J\_kg\_to\_Q\_restart, \textcolor{stringliteral}{"J\_kg\_to\_Q"}, .false., restart\_csp, &
02957                               \textcolor{stringliteral}{"Heat content unit conversion factor."}, units=\textcolor{stringliteral}{"Q kg J-1"})
02958 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_adf54a4e3a72611aa2088f46076e56e53}\label{namespacemom_adf54a4e3a72611aa2088f46076e56e53}} 
\index{mom@{mom}!step\+\_\+mom@{step\+\_\+mom}}
\index{step\+\_\+mom@{step\+\_\+mom}!mom@{mom}}
\subsubsection{\texorpdfstring{step\+\_\+mom()}{step\_mom()}}
{\footnotesize\ttfamily subroutine, public mom\+::step\+\_\+mom (\begin{DoxyParamCaption}\item[{type(mech\+\_\+forcing), intent(inout), target}]{forces\+\_\+in,  }\item[{type(forcing), intent(inout), target}]{fluxes\+\_\+in,  }\item[{type(surface), intent(inout), target}]{sfc\+\_\+state,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+start,  }\item[{real, intent(in)}]{time\+\_\+int\+\_\+in,  }\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves,  }\item[{logical, intent(in), optional}]{do\+\_\+dynamics,  }\item[{logical, intent(in), optional}]{do\+\_\+thermodynamics,  }\item[{logical, intent(in), optional}]{start\+\_\+cycle,  }\item[{logical, intent(in), optional}]{end\+\_\+cycle,  }\item[{real, intent(in), optional}]{cycle\+\_\+length,  }\item[{logical, intent(in), optional}]{reset\+\_\+therm }\end{DoxyParamCaption})}



This subroutine orchestrates the time stepping of M\+OM. The adiabatic dynamics are stepped by calls to one of the step\+\_\+\+M\+O\+M\+\_\+dyn\+\_\+...routines. The action of lateral processes on tracers occur in calls to advect\+\_\+tracer and tracer\+\_\+hordiff. Vertical mixing and possibly remapping occur inside of diabatic. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em forces\+\_\+in} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in,out}  & {\em fluxes\+\_\+in} & A structure with pointers to themodynamic, tracer and mass exchange forcing fields\\
\hline
\mbox{\tt in,out}  & {\em sfc\+\_\+state} & surface ocean state\\
\hline
\mbox{\tt in}  & {\em time\+\_\+start} & starting time of a segment, as a time type\\
\hline
\mbox{\tt in}  & {\em time\+\_\+int\+\_\+in} & time interval covered by this run segment \mbox{[}s\mbox{]}.\\
\hline
 & {\em cs} & control structure from initialize\+\_\+\+M\+OM\\
\hline
 & {\em waves} & An optional pointer to a wave property CS\\
\hline
\mbox{\tt in}  & {\em do\+\_\+dynamics} & Present and false, do not do updates due to the dynamics.\\
\hline
\mbox{\tt in}  & {\em do\+\_\+thermodynamics} & Present and false, do not do updates due to the thermodynamics or remapping.\\
\hline
\mbox{\tt in}  & {\em start\+\_\+cycle} & This indicates whether this call is to be treated as the first call to step\+\_\+\+M\+OM in a time-\/stepping cycle; missing is like true.\\
\hline
\mbox{\tt in}  & {\em end\+\_\+cycle} & This indicates whether this call is to be treated as the last call to step\+\_\+\+M\+OM in a time-\/stepping cycle; missing is like true.\\
\hline
\mbox{\tt in}  & {\em cycle\+\_\+length} & The amount of time in a coupled time stepping cycle \mbox{[}s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em reset\+\_\+therm} & This indicates whether the running sums of thermodynamic quantities should be reset. If missing, this is like start\+\_\+cycle. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l00422}{422} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_a16f7cc52cef3eb7a99687bf3d0694285}{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm()}, \hyperlink{namespacemom_a699d6c5bfb5b9dcdaa03c18806fa824e}{extract\+\_\+surface\+\_\+state()}, \hyperlink{namespacemom_aa773fddb51f99098d75304eb271270d4}{id\+\_\+clock\+\_\+diagnostics}, \hyperlink{namespacemom_ae1cf2d523679b925a5e5baa9d974968c}{id\+\_\+clock\+\_\+dynamics}, \hyperlink{namespacemom_a2e9f4b71ee77ba5bcb3f03a863948db3}{id\+\_\+clock\+\_\+ocean}, \hyperlink{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}{id\+\_\+clock\+\_\+other}, \hyperlink{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}{id\+\_\+clock\+\_\+pass}, \hyperlink{namespacemom_ada38a8329b76f9fa1685a230869a7647}{mom\+\_\+state\+\_\+is\+\_\+synchronized()}, \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}, \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}, and \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}.


\begin{DoxyCode}
00422   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: forces\_in\textcolor{comment}{ !< A structure with the driving mechanical forces}
00423   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: fluxes\_in\textcolor{comment}{  !< A structure with pointers to themodynamic,}
00424 \textcolor{comment}{                                                     !! tracer and mass exchange forcing fields}
00425   \textcolor{keywordtype}{type}(surface), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{  !< surface ocean state}
00426   \textcolor{keywordtype}{type}(time\_type),    \textcolor{keywordtype}{intent(in)}    :: time\_start\textcolor{comment}{    !< starting time of a segment, as a time type}
00427   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)}    :: time\_int\_in\textcolor{comment}{   !< time interval covered by this run segment [s].}
00428   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{            !< control structure from initialize\_MOM}
00429   \textcolor{keywordtype}{type}(wave\_parameters\_cs), &
00430             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: waves\textcolor{comment}{         !< An optional pointer to a wave property CS}
00431   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: do\_dynamics\textcolor{comment}{   !< Present and false, do not do updates due}
00432 \textcolor{comment}{                                                     !! to the dynamics.}
00433   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: do\_thermodynamics\textcolor{comment}{  !< Present and false, do not do updates due}
00434 \textcolor{comment}{                                                     !! to the thermodynamics or remapping.}
00435   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: start\_cycle\textcolor{comment}{   !< This indicates whether this call is to be}
00436 \textcolor{comment}{                                                     !! treated as the first call to step\_MOM in a}
00437 \textcolor{comment}{                                                     !! time-stepping cycle; missing is like true.}
00438   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: end\_cycle\textcolor{comment}{     !< This indicates whether this call is to be}
00439 \textcolor{comment}{                                                     !! treated as the last call to step\_MOM in a}
00440 \textcolor{comment}{                                                     !! time-stepping cycle; missing is like true.}
00441   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cycle\_length\textcolor{comment}{  !< The amount of time in a coupled time}
00442 \textcolor{comment}{                                                     !! stepping cycle [s].}
00443   \textcolor{keywordtype}{logical},  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: reset\_therm\textcolor{comment}{   !< This indicates whether the running sums of}
00444 \textcolor{comment}{                                                     !! thermodynamic quantities should be reset.}
00445 \textcolor{comment}{                                                     !! If missing, this is like start\_cycle.}
00446 
00447   \textcolor{comment}{! local variables}
00448   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer} :: g => null()  \textcolor{comment}{! pointer to a structure containing}
00449                                                    \textcolor{comment}{! metrics and related information}
00450   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer} :: g\_in => null()  \textcolor{comment}{! Input grid metric}
00451   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv => null() \textcolor{comment}{! Pointer to the vertical grid structure}
00452   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{! Pointer to a structure containing}
00453                                                    \textcolor{comment}{! various unit conversion factors}
00454   \textcolor{keywordtype}{integer}       :: ntstep \textcolor{comment}{! time steps between tracer updates or diabatic forcing}
00455   \textcolor{keywordtype}{integer}       :: n\_max  \textcolor{comment}{! number of steps to take in this call}
00456 
00457   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isq, ieq, jsq, jeq, nz, n
00458   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
00459 
00460   \textcolor{keywordtype}{real} :: time\_interval   \textcolor{comment}{! time interval covered by this run segment [T ~> s].}
00461   \textcolor{keywordtype}{real} :: dt              \textcolor{comment}{! baroclinic time step [T ~> s]}
00462   \textcolor{keywordtype}{real} :: dtdia           \textcolor{comment}{! time step for diabatic processes [T ~> s]}
00463   \textcolor{keywordtype}{real} :: dt\_therm        \textcolor{comment}{! a limited and quantized version of CS%dt\_therm [T ~> s]}
00464   \textcolor{keywordtype}{real} :: dt\_therm\_here   \textcolor{comment}{! a further limited value of dt\_therm [T ~> s]}
00465 
00466   \textcolor{keywordtype}{real} :: wt\_end, wt\_beg
00467   \textcolor{keywordtype}{real} :: bbl\_time\_int    \textcolor{comment}{! The amount of time over which the calculated BBL}
00468                           \textcolor{comment}{! properties will apply, for use in diagnostics, or 0}
00469                           \textcolor{comment}{! if it is not to be calculated anew [T ~> s].}
00470   \textcolor{keywordtype}{real} :: rel\_time = 0.0  \textcolor{comment}{! relative time since start of this call [T ~> s].}
00471 
00472   \textcolor{keywordtype}{logical} :: calc\_dtbt                 \textcolor{comment}{! Indicates whether the dynamically adjusted}
00473                                        \textcolor{comment}{! barotropic time step needs to be updated.}
00474   \textcolor{keywordtype}{logical} :: do\_advection              \textcolor{comment}{! If true, it is time to advect tracers.}
00475   \textcolor{keywordtype}{logical} :: do\_calc\_bbl               \textcolor{comment}{! If true, calculate the boundary layer properties.}
00476   \textcolor{keywordtype}{logical} :: thermo\_does\_span\_coupling \textcolor{comment}{! If true, thermodynamic forcing spans}
00477                                        \textcolor{comment}{! multiple dynamic timesteps.}
00478   \textcolor{keywordtype}{logical} :: do\_dyn     \textcolor{comment}{! If true, dynamics are updated with this call.}
00479   \textcolor{keywordtype}{logical} :: do\_thermo  \textcolor{comment}{! If true, thermodynamics and remapping may be applied with this call.}
00480   \textcolor{keywordtype}{logical} :: cycle\_start \textcolor{comment}{! If true, do calculations that are only done at the start of}
00481                         \textcolor{comment}{! a stepping cycle (whatever that may mean).}
00482   \textcolor{keywordtype}{logical} :: cycle\_end  \textcolor{comment}{! If true, do calculations and diagnostics that are only done at}
00483                         \textcolor{comment}{! the end of a stepping cycle (whatever that may mean).}
00484   \textcolor{keywordtype}{logical} :: therm\_reset \textcolor{comment}{! If true, reset running sums of thermodynamic quantities.}
00485   \textcolor{keywordtype}{real} :: cycle\_time    \textcolor{comment}{! The length of the coupled time-stepping cycle [T ~> s].}
00486   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(CS%G),SZJ\_(CS%G))} :: &
00487     ssh         \textcolor{comment}{! sea surface height, which may be based on eta\_av [m]}
00488 
00489   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: &
00490     u => null(), & \textcolor{comment}{! u : zonal velocity component [L T-1 ~> m s-1]}
00491     v => null(), & \textcolor{comment}{! v : meridional velocity component [L T-1 ~> m s-1]}
00492     h => null()    \textcolor{comment}{! h : layer thickness [H ~> m or kg m-2]}
00493   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: &
00494     p\_surf => null() \textcolor{comment}{! A pointer to the ocean surface pressure [R L2 T-2 ~> Pa].}
00495   \textcolor{keywordtype}{real} :: i\_wt\_ssh  \textcolor{comment}{! The inverse of the time weights [T-1 ~> s-1]}
00496 
00497   \textcolor{keywordtype}{type}(time\_type) :: time\_local, end\_time\_thermo, time\_temp
00498   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_tau\_ustar\_psurf
00499   \textcolor{keywordtype}{logical} :: showcalltree
00500 
00501   \textcolor{comment}{! External forcing fields on the model index map}
00502   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{pointer} :: forces     \textcolor{comment}{! Mechanical forcing}
00503   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{pointer} :: fluxes          \textcolor{comment}{! Boundary fluxes}
00504   \textcolor{keywordtype}{type}(surface), \textcolor{keywordtype}{pointer} :: sfc\_state\_diag  \textcolor{comment}{! Surface boundary fields}
00505   \textcolor{keywordtype}{integer} :: turns  \textcolor{comment}{! Number of quarter turns from input to model indexing}
00506 
00507   g => cs%G ; g\_in => cs%G\_in ; gv => cs%GV ; us => cs%US
00508   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec ; nz = g%ke
00509   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
00510   isd  = g%isd  ; ied  = g%ied  ; jsd  = g%jsd  ; jed  = g%jed
00511   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
00512   u => cs%u ; v => cs%v ; h => cs%h
00513 
00514   time\_interval = us%s\_to\_T*time\_int\_in
00515   do\_dyn = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(do\_dynamics)) do\_dyn = do\_dynamics
00516   do\_thermo = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(do\_thermodynamics)) do\_thermo = do\_thermodynamics
00517   \textcolor{keywordflow}{if} (.not.(do\_dyn .or. do\_thermo)) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"Step\_MOM: "}//&
00518     \textcolor{stringliteral}{"Both do\_dynamics and do\_thermodynamics are false, which makes no sense."})
00519   cycle\_start = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(start\_cycle)) cycle\_start = start\_cycle
00520   cycle\_end = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(end\_cycle)) cycle\_end = end\_cycle
00521   cycle\_time = time\_interval ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cycle\_length)) cycle\_time = us%s\_to\_T*cycle\_length
00522   therm\_reset = cycle\_start ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(reset\_therm)) therm\_reset = reset\_therm
00523 
00524   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_ocean)
00525   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_other)
00526 
00527   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00528     \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Beginning of step\_MOM "}, u, v, h, cs%uh, cs%vh, g, gv, us)
00529 \textcolor{keywordflow}{  endif}
00530 
00531   showcalltree = calltree\_showquery()
00532   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"step\_MOM(), MOM.F90"})
00533 
00534   \textcolor{comment}{! Rotate the forces from G\_in to G}
00535   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
00536     turns = g%HI%turns
00537     \textcolor{keyword}{allocate}(forces)
00538     \textcolor{keyword}{call }allocate\_mech\_forcing(forces\_in, g, forces)
00539     \textcolor{keyword}{call }rotate\_mech\_forcing(forces\_in, turns, forces)
00540 
00541     \textcolor{keyword}{allocate}(fluxes)
00542     \textcolor{keyword}{call }allocate\_forcing\_type(fluxes\_in, g, fluxes)
00543     \textcolor{keyword}{call }rotate\_forcing(fluxes\_in, fluxes, turns)
00544   \textcolor{keywordflow}{else}
00545     forces => forces\_in
00546     fluxes => fluxes\_in
00547 \textcolor{keywordflow}{  endif}
00548 
00549   \textcolor{comment}{! First determine the time step that is consistent with this call and an}
00550   \textcolor{comment}{! integer fraction of time\_interval.}
00551   \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
00552     n\_max = 1
00553     \textcolor{keywordflow}{if} (time\_interval > cs%dt) n\_max = ceiling(time\_interval/cs%dt - 0.001)
00554     dt = time\_interval / \textcolor{keywordtype}{real}(n\_max)
00555     thermo\_does\_span\_coupling = (cs%thermo\_spans\_coupling .and. &
00556                                 (cs%dt\_therm > 1.5*cycle\_time))
00557     \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keywordflow}{then}
00558       \textcolor{comment}{! Set dt\_therm to be an integer multiple of the coupling time step.}
00559       dt\_therm = cycle\_time * floor(cs%dt\_therm / cycle\_time + 0.001)
00560       ntstep = floor(dt\_therm/dt + 0.001)
00561     \textcolor{keywordflow}{elseif} (.not.do\_thermo) \textcolor{keywordflow}{then}
00562       dt\_therm = cs%dt\_therm
00563       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cycle\_length)) dt\_therm = min(cs%dt\_therm, us%s\_to\_T*cycle\_length)
00564       \textcolor{comment}{! ntstep is not used.}
00565     \textcolor{keywordflow}{else}
00566       ntstep = max(1, min(n\_max, floor(cs%dt\_therm/dt + 0.001)))
00567       dt\_therm = dt*ntstep
00568 \textcolor{keywordflow}{    endif}
00569 
00570     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf)) p\_surf => forces%p\_surf
00571     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(forces%p\_surf)) cs%interp\_p\_surf = .false.
00572     cs%tv%p\_surf => null()
00573     \textcolor{keywordflow}{if} (cs%use\_p\_surf\_in\_EOS .and. \textcolor{keyword}{associated}(forces%p\_surf)) cs%tv%p\_surf => forces%p\_surf
00574 
00575     \textcolor{comment}{!---------- Initiate group halo pass of the forcing fields}
00576     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)
00577     \textcolor{keyword}{call }create\_group\_pass(pass\_tau\_ustar\_psurf, forces%taux, forces%tauy, g%Domain)
00578     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) &
00579       \textcolor{keyword}{call }create\_group\_pass(pass\_tau\_ustar\_psurf, forces%ustar, g%Domain)
00580     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%p\_surf)) &
00581       \textcolor{keyword}{call }create\_group\_pass(pass\_tau\_ustar\_psurf, forces%p\_surf, g%Domain)
00582     \textcolor{keywordflow}{if} (g%nonblocking\_updates) \textcolor{keywordflow}{then}
00583       \textcolor{keyword}{call }start\_group\_pass(pass\_tau\_ustar\_psurf, g%Domain)
00584     \textcolor{keywordflow}{else}
00585       \textcolor{keyword}{call }do\_group\_pass(pass\_tau\_ustar\_psurf, g%Domain)
00586 \textcolor{keywordflow}{    endif}
00587     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)
00588   \textcolor{keywordflow}{else}
00589     \textcolor{comment}{! This step only updates the thermodynamics so setting timesteps is simpler.}
00590     n\_max = 1
00591     \textcolor{keywordflow}{if} ((time\_interval > cs%dt\_therm) .and. (cs%dt\_therm > 0.0)) &
00592       n\_max = ceiling(time\_interval/cs%dt\_therm - 0.001)
00593 
00594     dt = time\_interval / \textcolor{keywordtype}{real}(n\_max)
00595     dt\_therm = dt ; ntstep = 1
00596     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf)) p\_surf => fluxes%p\_surf
00597     cs%tv%p\_surf => null()
00598     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf)) \textcolor{keywordflow}{then}
00599       \textcolor{keywordflow}{if} (cs%use\_p\_surf\_in\_EOS) cs%tv%p\_surf => fluxes%p\_surf
00600 \textcolor{keywordflow}{    endif}
00601     \textcolor{keywordflow}{if} (cs%UseWaves) \textcolor{keyword}{call }pass\_var(fluxes%ustar, g%Domain, clock=id\_clock\_pass)
00602 \textcolor{keywordflow}{  endif}
00603 
00604   \textcolor{keywordflow}{if} (therm\_reset) \textcolor{keywordflow}{then}
00605     cs%time\_in\_thermo\_cycle = 0.0
00606     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%frazil))        cs%tv%frazil(:,:)        = 0.0
00607     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%salt\_deficit))  cs%tv%salt\_deficit(:,:)  = 0.0
00608     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%TempxPmE))      cs%tv%TempxPmE(:,:)      = 0.0
00609     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%internal\_heat)) cs%tv%internal\_heat(:,:) = 0.0
00610 \textcolor{keywordflow}{  endif}
00611 
00612   \textcolor{keywordflow}{if} (cycle\_start) \textcolor{keywordflow}{then}
00613     cs%time\_in\_cycle = 0.0
00614     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; cs%ssh\_rint(i,j) = 0.0 ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00615 
00616     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%VarMix)) \textcolor{keywordflow}{then}
00617       \textcolor{keyword}{call }enable\_averages(cycle\_time, time\_start + real\_to\_time(us%T\_to\_s*cycle\_time), cs%diag)
00618       \textcolor{keyword}{call }calc\_resoln\_function(h, cs%tv, g, gv, us, cs%VarMix)
00619       \textcolor{keyword}{call }calc\_depth\_function(g, cs%VarMix)
00620       \textcolor{keyword}{call }disable\_averaging(cs%diag)
00621 \textcolor{keywordflow}{    endif}
00622 \textcolor{keywordflow}{  endif}
00623 
00624   \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
00625     \textcolor{keywordflow}{if} (g%nonblocking\_updates) &
00626       \textcolor{keyword}{call }complete\_group\_pass(pass\_tau\_ustar\_psurf, g%Domain, clock=id\_clock\_pass)
00627 
00628     \textcolor{keywordflow}{if} (cs%interp\_p\_surf) \textcolor{keywordflow}{then}
00629       \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs%p\_surf\_end))   \textcolor{keyword}{allocate}(cs%p\_surf\_end(isd:ied,jsd:jed))
00630       \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs%p\_surf\_begin)) \textcolor{keyword}{allocate}(cs%p\_surf\_begin(isd:ied,jsd:jed))
00631       \textcolor{keywordflow}{if} (.not.cs%p\_surf\_prev\_set) \textcolor{keywordflow}{then}
00632         \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
00633           cs%p\_surf\_prev(i,j) = forces%p\_surf(i,j)
00634 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
00635         cs%p\_surf\_prev\_set = .true.
00636 \textcolor{keywordflow}{      endif}
00637     \textcolor{keywordflow}{else}
00638       cs%p\_surf\_end  => forces%p\_surf
00639 \textcolor{keywordflow}{    endif}
00640 
00641     \textcolor{keywordflow}{if} (cs%UseWaves) \textcolor{keywordflow}{then}
00642       \textcolor{comment}{! Update wave information, which is presently kept static over each call to step\_mom}
00643       \textcolor{keyword}{call }enable\_averages(time\_interval, time\_start + real\_to\_time(us%T\_to\_s*time\_interval), cs%diag)
00644       \textcolor{keyword}{call }update\_stokes\_drift(g, gv, us, waves, h, forces%ustar)
00645       \textcolor{keyword}{call }disable\_averaging(cs%diag)
00646 \textcolor{keywordflow}{    endif}
00647   \textcolor{keywordflow}{else} \textcolor{comment}{! not do\_dyn.}
00648     \textcolor{keywordflow}{if} (cs%UseWaves) & \textcolor{comment}{! Diagnostics are not enabled in this call.}
00649       \textcolor{keyword}{call }update\_stokes\_drift(g, gv, us, waves, h, fluxes%ustar)
00650 \textcolor{keywordflow}{  endif}
00651 
00652   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
00653     \textcolor{keywordflow}{if} (cycle\_start) &
00654       \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Before steps "}, u, v, h, cs%uh, cs%vh, g, gv, us)
00655     \textcolor{keywordflow}{if} (cycle\_start) \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Before steps "}, u, v, g)
00656     \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keyword}{call }mom\_mech\_forcing\_chksum(\textcolor{stringliteral}{"Before steps"}, forces, g, us, haloshift=0)
00657     \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Before steps "}, forces%taux, forces%tauy, g)
00658 \textcolor{keywordflow}{  endif}
00659   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_other)
00660 
00661   rel\_time = 0.0
00662   \textcolor{keywordflow}{do} n=1,n\_max
00663     rel\_time = rel\_time + dt \textcolor{comment}{! The relative time at the end of the step.}
00664     \textcolor{comment}{! Set the universally visible time to the middle of the time step.}
00665     cs%Time = time\_start + real\_to\_time(us%T\_to\_s*(rel\_time - 0.5*dt))
00666     \textcolor{comment}{! Set the local time to the end of the time step.}
00667     time\_local = time\_start + real\_to\_time(us%T\_to\_s*rel\_time)
00668 
00669     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"DT cycles (step\_MOM) n="},n)
00670 
00671     \textcolor{comment}{! Update the vertically extensive diagnostic grids so that they are}
00672     \textcolor{comment}{! referenced to the beginning timestep}
00673     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag, update\_intensive = .false., update\_extensive = .true. )
00674 
00675     \textcolor{comment}{!===========================================================================}
00676     \textcolor{comment}{! This is the first place where the diabatic processes and remapping could occur.}
00677     \textcolor{keywordflow}{if} (cs%diabatic\_first .and. (cs%t\_dyn\_rel\_adv==0.0) .and. do\_thermo) \textcolor{keywordflow}{then} \textcolor{comment}{! do thermodynamics.}
00678 
00679       \textcolor{keywordflow}{if} (.not.do\_dyn) \textcolor{keywordflow}{then}
00680         dtdia = dt
00681       \textcolor{keywordflow}{elseif} (thermo\_does\_span\_coupling) \textcolor{keywordflow}{then}
00682         dtdia = dt\_therm
00683         \textcolor{keywordflow}{if} ((fluxes%dt\_buoy\_accum > 0.0) .and. (dtdia > time\_interval) .and. &
00684             (abs(fluxes%dt\_buoy\_accum - dtdia) > 1e-6*dtdia)) \textcolor{keywordflow}{then}
00685           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"step\_MOM: Mismatch between long thermodynamic "}//&
00686             \textcolor{stringliteral}{"timestep and time over which buoyancy fluxes have been accumulated."})
00687 \textcolor{keywordflow}{        endif}
00688         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM is not yet set up to have restarts that work "}//&
00689           \textcolor{stringliteral}{"with THERMO\_SPANS\_COUPLING and DIABATIC\_FIRST."})
00690       \textcolor{keywordflow}{else}
00691         dtdia = dt*min(ntstep,n\_max-(n-1))
00692 \textcolor{keywordflow}{      endif}
00693 
00694 \textcolor{keyword}{      end}\_time\_thermo = time\_local
00695       \textcolor{keywordflow}{if} (dtdia > dt) \textcolor{keywordflow}{then}
00696         \textcolor{comment}{! If necessary, temporarily reset CS%Time to the center of the period covered}
00697         \textcolor{comment}{! by the call to step\_MOM\_thermo, noting that they begin at the same time.}
00698         cs%Time = cs%Time + real\_to\_time(0.5*us%T\_to\_s*(dtdia-dt))
00699         \textcolor{comment}{! The end-time of the diagnostic interval needs to be set ahead if there}
00700         \textcolor{comment}{! are multiple dynamic time steps worth of thermodynamics applied here.}
00701 \textcolor{keyword}{        end}\_time\_thermo = Time\_local + real\_to\_time(US%T\_to\_s*(dtdia-dt))
00702 \textcolor{keywordflow}{      endif}
00703 
00704       \textcolor{comment}{! Apply diabatic forcing, do mixing, and regrid.}
00705       \textcolor{keyword}{call }step\_mom\_thermo(cs, g, gv, us, u, v, h, cs%tv, fluxes, dtdia, &
00706 \textcolor{keyword}{                           end}\_time\_thermo, .true., Waves=Waves)
00707       cs%time\_in\_thermo\_cycle = cs%time\_in\_thermo\_cycle + dtdia
00708 
00709       \textcolor{comment}{! The diabatic processes are now ahead of the dynamics by dtdia.}
00710       cs%t\_dyn\_rel\_thermo = -dtdia
00711       \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished diabatic\_first (step\_MOM)"})
00712 
00713       \textcolor{keywordflow}{if} (dtdia > dt) & \textcolor{comment}{! Reset CS%Time to its previous value.}
00714         cs%Time = time\_start + real\_to\_time(us%T\_to\_s*(rel\_time - 0.5*dt))
00715 \textcolor{keywordflow}{    endif} \textcolor{comment}{! end of block "(CS%diabatic\_first .and. (CS%t\_dyn\_rel\_adv==0.0))"}
00716 
00717     \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
00718       \textcolor{comment}{! Store pre-dynamics thicknesses for proper diagnostic remapping for transports or}
00719       \textcolor{comment}{! advective tendencies.  If there are more than one dynamics steps per advective}
00720       \textcolor{comment}{! step (i.e DT\_THERM > DT), this needs to be stored at the first dynamics call.}
00721       \textcolor{keywordflow}{if} (.not.cs%preadv\_h\_stored .and. (cs%t\_dyn\_rel\_adv == 0.)) \textcolor{keywordflow}{then}
00722         \textcolor{keyword}{call }diag\_copy\_diag\_to\_storage(cs%diag\_pre\_dyn, h, cs%diag)
00723         cs%preadv\_h\_stored = .true.
00724 \textcolor{keywordflow}{      endif}
00725 
00726       \textcolor{comment}{! The pre-dynamics velocities might be stored for debugging truncations.}
00727       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%u\_prev) .and. \textcolor{keyword}{associated}(cs%v\_prev)) \textcolor{keywordflow}{then}
00728         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
00729           cs%u\_prev(i,j,k) = u(i,j,k)
00730 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00731         \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
00732           cs%v\_prev(i,j,k) = v(i,j,k)
00733 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00734 \textcolor{keywordflow}{      endif}
00735 
00736       dt\_therm\_here = dt\_therm
00737       \textcolor{keywordflow}{if} (do\_thermo .and. do\_dyn .and. .not.thermo\_does\_span\_coupling) &
00738         dt\_therm\_here = dt*min(ntstep, n\_max-n+1)
00739 
00740       \textcolor{comment}{! Indicate whether the bottom boundary layer properties need to be}
00741       \textcolor{comment}{! recalculated, and if so for how long an interval they are valid.}
00742       bbl\_time\_int = 0.0
00743       \textcolor{keywordflow}{if} (do\_thermo) \textcolor{keywordflow}{then}
00744         \textcolor{keywordflow}{if} ((cs%t\_dyn\_rel\_adv == 0.0) .or. (n==1)) &
00745           bbl\_time\_int = max(dt, min(dt\_therm - cs%t\_dyn\_rel\_adv, dt*(1+n\_max-n)) )
00746       \textcolor{keywordflow}{else}
00747         \textcolor{keywordflow}{if} ((cs%t\_dyn\_rel\_adv == 0.0) .or. ((n==1) .and. cycle\_start)) &
00748           bbl\_time\_int = min(dt\_therm, cycle\_time)
00749 \textcolor{keywordflow}{      endif}
00750 
00751       \textcolor{keywordflow}{if} (cs%interp\_p\_surf) \textcolor{keywordflow}{then}
00752         wt\_end = \textcolor{keywordtype}{real(n)} / \textcolor{keywordtype}{real}(n\_max)
00753         wt\_beg = \textcolor{keywordtype}{real(n-1)} / \textcolor{keywordtype}{real}(n\_max)
00754         \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
00755           cs%p\_surf\_end(i,j) = wt\_end * forces%p\_surf(i,j) + &
00756                           (1.0-wt\_end) * cs%p\_surf\_prev(i,j)
00757           cs%p\_surf\_begin(i,j) = wt\_beg * forces%p\_surf(i,j) + &
00758                           (1.0-wt\_beg) * cs%p\_surf\_prev(i,j)
00759 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
00760 \textcolor{keywordflow}{      endif}
00761 
00762       \textcolor{keyword}{call }step\_mom\_dynamics(forces, cs%p\_surf\_begin, cs%p\_surf\_end, dt, &
00763                              dt\_therm\_here, bbl\_time\_int, cs, &
00764                              time\_local, waves=waves)
00765 
00766       \textcolor{comment}{!===========================================================================}
00767       \textcolor{comment}{! This is the start of the tracer advection part of the algorithm.}
00768 
00769       \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling .or. .not.do\_thermo) \textcolor{keywordflow}{then}
00770         do\_advection = (cs%t\_dyn\_rel\_adv + 0.5*dt > dt\_therm)
00771       \textcolor{keywordflow}{else}
00772         do\_advection = ((mod(n,ntstep) == 0) .or. (n==n\_max))
00773 \textcolor{keywordflow}{      endif}
00774 
00775       \textcolor{keywordflow}{if} (do\_advection) \textcolor{keywordflow}{then} \textcolor{comment}{! Do advective transport and lateral tracer mixing.}
00776         \textcolor{keyword}{call }step\_mom\_tracer\_dyn(cs, g, gv, us, h, time\_local)
00777         \textcolor{keywordflow}{if} (cs%diabatic\_first .and. abs(cs%t\_dyn\_rel\_thermo) > 1e-6*dt) \textcolor{keyword}{call }mom\_error(fatal, &
00778                 \textcolor{stringliteral}{"step\_MOM: Mismatch between the dynamics and diabatic times "}//&
00779                 \textcolor{stringliteral}{"with DIABATIC\_FIRST."})
00780 \textcolor{keywordflow}{      endif}
00781 \textcolor{keywordflow}{    endif} \textcolor{comment}{! end of (do\_dyn)}
00782 
00783     \textcolor{comment}{!===========================================================================}
00784     \textcolor{comment}{! This is the second place where the diabatic processes and remapping could occur.}
00785     \textcolor{keywordflow}{if} ((cs%t\_dyn\_rel\_adv==0.0) .and. do\_thermo .and. (.not.cs%diabatic\_first)) \textcolor{keywordflow}{then}
00786 
00787       dtdia = cs%t\_dyn\_rel\_thermo
00788       \textcolor{comment}{! If the MOM6 dynamic and thermodynamic time stepping is being orchestrated}
00789       \textcolor{comment}{! by the coupler, the value of diabatic\_first does not matter.}
00790       \textcolor{keywordflow}{if} ((cs%t\_dyn\_rel\_thermo==0.0) .and. .not.do\_dyn) dtdia = dt
00791 
00792       \textcolor{keywordflow}{if} (cs%thermo\_spans\_coupling .and. (cs%dt\_therm > 1.5*cycle\_time) .and. &
00793           (abs(dt\_therm - dtdia) > 1e-6*dt\_therm)) \textcolor{keywordflow}{then}
00794         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"step\_MOM: Mismatch between dt\_therm and dtdia "}//&
00795                        \textcolor{stringliteral}{"before call to diabatic."})
00796 \textcolor{keywordflow}{      endif}
00797 
00798       \textcolor{comment}{! If necessary, temporarily reset CS%Time to the center of the period covered}
00799       \textcolor{comment}{! by the call to step\_MOM\_thermo, noting that they end at the same time.}
00800       \textcolor{keywordflow}{if} (dtdia > dt) cs%Time = cs%Time - real\_to\_time(0.5*us%T\_to\_s*(dtdia-dt))
00801 
00802       \textcolor{comment}{! Apply diabatic forcing, do mixing, and regrid.}
00803       \textcolor{keyword}{call }step\_mom\_thermo(cs, g, gv, us, u, v, h, cs%tv, fluxes, dtdia, &
00804                            time\_local, .false., waves=waves)
00805       cs%time\_in\_thermo\_cycle = cs%time\_in\_thermo\_cycle + dtdia
00806 
00807       \textcolor{keywordflow}{if} ((cs%t\_dyn\_rel\_thermo==0.0) .and. .not.do\_dyn) \textcolor{keywordflow}{then}
00808         \textcolor{comment}{! The diabatic processes are now ahead of the dynamics by dtdia.}
00809         cs%t\_dyn\_rel\_thermo = -dtdia
00810       \textcolor{keywordflow}{else} \textcolor{comment}{! The diabatic processes and the dynamics are synchronized.}
00811         cs%t\_dyn\_rel\_thermo = 0.0
00812 \textcolor{keywordflow}{      endif}
00813 
00814       \textcolor{keywordflow}{if} (dtdia > dt) & \textcolor{comment}{! Reset CS%Time to its previous value.}
00815         cs%Time = time\_start + real\_to\_time(us%T\_to\_s*(rel\_time - 0.5*dt))
00816 \textcolor{keywordflow}{    endif}
00817 
00818     \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
00819       \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_dynamics)
00820       \textcolor{comment}{! Determining the time-average sea surface height is part of the algorithm.}
00821       \textcolor{comment}{! This may be eta\_av if Boussinesq, or need to be diagnosed if not.}
00822       cs%time\_in\_cycle = cs%time\_in\_cycle + dt
00823       \textcolor{keyword}{call }find\_eta(h, cs%tv, g, gv, us, ssh, cs%eta\_av\_bc, eta\_to\_m=1.0)
00824       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
00825         cs%ssh\_rint(i,j) = cs%ssh\_rint(i,j) + dt*ssh(i,j)
00826 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
00827       \textcolor{keywordflow}{if} (cs%IDs%id\_ssh\_inst > 0) \textcolor{keyword}{call }post\_data(cs%IDs%id\_ssh\_inst, ssh, cs%diag)
00828       \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_dynamics)
00829 \textcolor{keywordflow}{    endif}
00830 
00831     \textcolor{comment}{!===========================================================================}
00832     \textcolor{comment}{! Calculate diagnostics at the end of the time step if the state is self-consistent.}
00833     \textcolor{keywordflow}{if} (mom\_state\_is\_synchronized(cs)) \textcolor{keywordflow}{then}
00834     \textcolor{comment}{!### Perhaps this should be if (CS%t\_dyn\_rel\_thermo == 0.0)}
00835       \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_other) ; \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diagnostics)
00836       \textcolor{comment}{! Diagnostics that require the complete state to be up-to-date can be calculated.}
00837 
00838       \textcolor{keyword}{call }enable\_averages(cs%t\_dyn\_rel\_diag, time\_local, cs%diag)
00839       \textcolor{keyword}{call }calculate\_diagnostic\_fields(u, v, h, cs%uh, cs%vh, cs%tv, cs%ADp,  &
00840                           cs%CDp, p\_surf, cs%t\_dyn\_rel\_diag, cs%diag\_pre\_sync,&
00841                           g, gv, us, cs%diagnostics\_CSp)
00842       \textcolor{keyword}{call }post\_tracer\_diagnostics\_at\_sync(cs%Tracer\_reg, h, cs%diag\_pre\_sync, cs%diag, g, gv, cs
      %t\_dyn\_rel\_diag)
00843       \textcolor{keyword}{call }diag\_copy\_diag\_to\_storage(cs%diag\_pre\_sync, h, cs%diag)
00844       \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished calculate\_diagnostic\_fields (step\_MOM)"})
00845       \textcolor{keyword}{call }disable\_averaging(cs%diag)
00846       cs%t\_dyn\_rel\_diag = 0.0
00847 
00848       \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diagnostics) ; \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_other)
00849 \textcolor{keywordflow}{    endif}
00850 
00851     \textcolor{keywordflow}{if} (do\_dyn .and. .not.cs%count\_calls) cs%nstep\_tot = cs%nstep\_tot + 1
00852     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"DT cycles (step\_MOM)"})
00853 
00854 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! complete the n loop}
00855 
00856   \textcolor{keywordflow}{if} (cs%count\_calls .and. cycle\_start) cs%nstep\_tot = cs%nstep\_tot + 1
00857 
00858   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_other)
00859 
00860   \textcolor{keywordflow}{if} (cs%time\_in\_cycle > 0.0) \textcolor{keywordflow}{then}
00861     i\_wt\_ssh = 1.0/cs%time\_in\_cycle
00862     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
00863       ssh(i,j) = cs%ssh\_rint(i,j)*i\_wt\_ssh
00864       cs%ave\_ssh\_ibc(i,j) = ssh(i,j)
00865 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00866     \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
00867       \textcolor{keyword}{call }adjust\_ssh\_for\_p\_atm(cs%tv, g, gv, us, cs%ave\_ssh\_ibc, forces%p\_surf\_SSH, &
00868                                 cs%calc\_rho\_for\_sea\_lev)
00869     \textcolor{keywordflow}{elseif} (do\_thermo) \textcolor{keywordflow}{then}
00870       \textcolor{keyword}{call }adjust\_ssh\_for\_p\_atm(cs%tv, g, gv, us, cs%ave\_ssh\_ibc, fluxes%p\_surf\_SSH, &
00871                                 cs%calc\_rho\_for\_sea\_lev)
00872 \textcolor{keywordflow}{    endif}
00873 \textcolor{keywordflow}{  endif}
00874 
00875   \textcolor{keywordflow}{if} (do\_dyn .and. cs%interp\_p\_surf) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
00876     cs%p\_surf\_prev(i,j) = forces%p\_surf(i,j)
00877 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
00878 
00879   \textcolor{keywordflow}{if} (cs%ensemble\_ocean) \textcolor{keywordflow}{then}
00880     \textcolor{comment}{! update the time for the next analysis step if needed}
00881     \textcolor{keyword}{call }set\_analysis\_time(cs%Time,cs%odaCS)
00882     \textcolor{comment}{! store ensemble vector in odaCS}
00883     \textcolor{keyword}{call }set\_prior\_tracer(cs%Time, g, gv, cs%h, cs%tv, cs%odaCS)
00884     \textcolor{comment}{! call DA interface}
00885     \textcolor{keyword}{call }oda(cs%Time,cs%odaCS)
00886 \textcolor{keywordflow}{  endif}
00887 
00888   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"calling extract\_surface\_state (step\_MOM)"})
00889   \textcolor{comment}{! NOTE: sfc\_state uses input indexing, since it is also used by drivers.}
00890   \textcolor{keyword}{call }extract\_surface\_state(cs, sfc\_state)
00891 
00892   \textcolor{comment}{! Do diagnostics that only occur at the end of a complete forcing step.}
00893   \textcolor{keywordflow}{if} (cycle\_end) \textcolor{keywordflow}{then}
00894     \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
00895       \textcolor{keyword}{allocate}(sfc\_state\_diag)
00896       \textcolor{keyword}{call }rotate\_surface\_state(sfc\_state, g\_in, sfc\_state\_diag, g, turns)
00897     \textcolor{keywordflow}{else}
00898       sfc\_state\_diag => sfc\_state
00899 \textcolor{keywordflow}{    endif}
00900 
00901     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diagnostics)
00902     \textcolor{keywordflow}{if} (cs%time\_in\_cycle > 0.0) \textcolor{keywordflow}{then}
00903       \textcolor{keyword}{call }enable\_averages(cs%time\_in\_cycle, time\_local, cs%diag)
00904       \textcolor{keyword}{call }post\_surface\_dyn\_diags(cs%sfc\_IDs, g, cs%diag, sfc\_state\_diag, ssh)
00905 \textcolor{keywordflow}{    endif}
00906     \textcolor{keywordflow}{if} (cs%time\_in\_thermo\_cycle > 0.0) \textcolor{keywordflow}{then}
00907       \textcolor{keyword}{call }enable\_averages(cs%time\_in\_thermo\_cycle, time\_local, cs%diag)
00908       \textcolor{keyword}{call }post\_surface\_thermo\_diags(cs%sfc\_IDs, g, gv, us, cs%diag, cs%time\_in\_thermo\_cycle, &
00909                                      sfc\_state\_diag, cs%tv, ssh, cs%ave\_ssh\_ibc)
00910 \textcolor{keywordflow}{    endif}
00911     \textcolor{keyword}{call }disable\_averaging(cs%diag)
00912     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diagnostics)
00913 \textcolor{keywordflow}{  endif}
00914 
00915   \textcolor{comment}{! Accumulate the surface fluxes for assessing conservation}
00916   \textcolor{keywordflow}{if} (do\_thermo .and. fluxes%fluxes\_used) &
00917     \textcolor{keyword}{call }accumulate\_net\_input(fluxes, sfc\_state, cs%tv, fluxes%dt\_buoy\_accum, &
00918                               g, us, cs%sum\_output\_CSp)
00919 
00920   \textcolor{keywordflow}{if} (mom\_state\_is\_synchronized(cs)) &
00921     \textcolor{keyword}{call }write\_energy(cs%u, cs%v, cs%h, cs%tv, time\_local, cs%nstep\_tot, &
00922                       g, gv, us, cs%sum\_output\_CSp, cs%tracer\_flow\_CSp, &
00923                       dt\_forcing=real\_to\_time(us%T\_to\_s*time\_interval) )
00924 
00925   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_other)
00926 
00927   \textcolor{comment}{! De-rotate fluxes and copy back to the input, since they can be changed.}
00928   \textcolor{keywordflow}{if} (cs%rotate\_index) \textcolor{keywordflow}{then}
00929     \textcolor{keyword}{call }rotate\_forcing(fluxes, fluxes\_in, -turns)
00930 
00931     \textcolor{keyword}{call }deallocate\_mech\_forcing(forces)
00932     \textcolor{keyword}{deallocate}(forces)
00933 
00934     \textcolor{keyword}{call }deallocate\_forcing\_type(fluxes)
00935     \textcolor{keyword}{deallocate}(fluxes)
00936 \textcolor{keywordflow}{  endif}
00937 
00938   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"step\_MOM()"})
00939   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_ocean)
00940 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}\label{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}} 
\index{mom@{mom}!step\+\_\+mom\+\_\+dynamics@{step\+\_\+mom\+\_\+dynamics}}
\index{step\+\_\+mom\+\_\+dynamics@{step\+\_\+mom\+\_\+dynamics}!mom@{mom}}
\subsubsection{\texorpdfstring{step\+\_\+mom\+\_\+dynamics()}{step\_mom\_dynamics()}}
{\footnotesize\ttfamily subroutine mom\+::step\+\_\+mom\+\_\+dynamics (\begin{DoxyParamCaption}\item[{type(mech\+\_\+forcing), intent(in)}]{forces,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf\+\_\+begin,  }\item[{real, dimension(\+:,\+:), pointer}]{p\+\_\+surf\+\_\+end,  }\item[{real, intent(in)}]{dt,  }\item[{real, intent(in)}]{dt\+\_\+thermo,  }\item[{real, intent(in)}]{bbl\+\_\+time\+\_\+int,  }\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+local,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Time step the ocean dynamics, including the momentum and continuity equations. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
 & {\em p\+\_\+surf\+\_\+begin} & A pointer (perhaps N\+U\+LL) to the surface pressure at the beginning of this dynamic step, intent in \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}.\\
\hline
 & {\em p\+\_\+surf\+\_\+end} & A pointer (perhaps N\+U\+LL) to the surface pressure at the end of this dynamic step, intent in \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em dt} & time interval covered by this call \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em dt\+\_\+thermo} & time interval covered by any updates that may span multiple dynamics steps \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em bbl\+\_\+time\+\_\+int} & time interval over which updates to the bottom boundary layer properties will apply \mbox{[}T $\sim$$>$ s\mbox{]}, or zero not to update the properties.\\
\hline
 & {\em cs} & control structure from initialize\+\_\+\+M\+OM\\
\hline
\mbox{\tt in}  & {\em time\+\_\+local} & End time of a segment, as a time type\\
\hline
 & {\em waves} & Container for wave related parameters; the \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l00946}{946} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_aa69e79e4c51e1c24c474b84311322251}{id\+\_\+clock\+\_\+bbl\+\_\+visc}, \hyperlink{namespacemom_aa773fddb51f99098d75304eb271270d4}{id\+\_\+clock\+\_\+diagnostics}, \hyperlink{namespacemom_ae1cf2d523679b925a5e5baa9d974968c}{id\+\_\+clock\+\_\+dynamics}, \hyperlink{namespacemom_a41b67fabfc13e52cf3a5d1c337c780eb}{id\+\_\+clock\+\_\+ml\+\_\+restrat}, \hyperlink{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}{id\+\_\+clock\+\_\+other}, \hyperlink{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}{id\+\_\+clock\+\_\+pass}, and \hyperlink{namespacemom_a8f5feb87a0cb40d9fcee00456e982b8a}{id\+\_\+clock\+\_\+thick\+\_\+diff}.



Referenced by \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}.


\begin{DoxyCode}
00946   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{     !< A structure with the driving mechanical forces}
00947   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer}     :: p\_surf\_begin\textcolor{comment}{ !< A pointer (perhaps NULL) to the surface}
00948 \textcolor{comment}{                                                  !! pressure at the beginning of this dynamic}
00949 \textcolor{comment}{                                                  !! step, intent in [R L2 T-2 ~> Pa].}
00950   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer}     :: p\_surf\_end\textcolor{comment}{ !< A pointer (perhaps NULL) to the surface}
00951 \textcolor{comment}{                                                  !! pressure at the end of this dynamic step,}
00952 \textcolor{comment}{                                                  !! intent in [R L2 T-2 ~> Pa].}
00953   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{         !< time interval covered by this call [T ~> s].}
00954   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)}    :: dt\_thermo\textcolor{comment}{  !< time interval covered by any updates that may}
00955 \textcolor{comment}{                                                  !! span multiple dynamics steps [T ~> s].}
00956   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)}    :: bbl\_time\_int\textcolor{comment}{ !< time interval over which updates to the}
00957 \textcolor{comment}{                                                  !! bottom boundary layer properties will apply [T ~> s],}
00958 \textcolor{comment}{                                                  !! or zero not to update the properties.}
00959   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{         !< control structure from initialize\_MOM}
00960   \textcolor{keywordtype}{type}(time\_type),    \textcolor{keywordtype}{intent(in)}    :: time\_local\textcolor{comment}{ !< End time of a segment, as a time type}
00961   \textcolor{keywordtype}{type}(wave\_parameters\_cs), &
00962             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: waves\textcolor{comment}{      !< Container for wave related parameters; the}
00963 \textcolor{comment}{                                                  !! fields in Waves are intent in here.}
00964 
00965   \textcolor{comment}{! local variables}
00966   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer} :: g => null()  \textcolor{comment}{! pointer to a structure containing}
00967                                                    \textcolor{comment}{! metrics and related information}
00968   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv => null() \textcolor{comment}{! Pointer to the vertical grid structure}
00969   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{! Pointer to a structure containing}
00970                                                    \textcolor{comment}{! various unit conversion factors}
00971   \textcolor{keywordtype}{type}(mom\_diag\_ids), \textcolor{keywordtype}{pointer} :: ids => null() \textcolor{comment}{! A structure with the diagnostic IDs.}
00972   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: &
00973     u => null(), & \textcolor{comment}{! u : zonal velocity component [L T-1 ~> m s-1]}
00974     v => null(), & \textcolor{comment}{! v : meridional velocity component [L T-1 ~> m s-1]}
00975     h => null()    \textcolor{comment}{! h : layer thickness [H ~> m or kg m-2]}
00976 
00977   \textcolor{keywordtype}{logical} :: calc\_dtbt  \textcolor{comment}{! Indicates whether the dynamically adjusted}
00978                         \textcolor{comment}{! barotropic time step needs to be updated.}
00979   \textcolor{keywordtype}{logical} :: showcalltree
00980 
00981   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isq, ieq, jsq, jeq, nz
00982   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
00983 
00984   g => cs%G ; gv => cs%GV ; us => cs%US ; ids => cs%IDs
00985   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec ; nz = g%ke
00986   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
00987   isd  = g%isd  ; ied  = g%ied  ; jsd  = g%jsd  ; jed  = g%jed
00988   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
00989   u => cs%u ; v => cs%v ; h => cs%h
00990   showcalltree = calltree\_showquery()
00991 
00992   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_dynamics)
00993 
00994   \textcolor{keywordflow}{if} ((cs%t\_dyn\_rel\_adv == 0.0) .and. cs%thickness\_diffuse .and. cs%thickness\_diffuse\_first) \textcolor{keywordflow}{then}
00995 
00996     \textcolor{keyword}{call }enable\_averages(dt\_thermo, time\_local+real\_to\_time(us%T\_to\_s*(dt\_thermo-dt)), cs%diag)
00997     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_thick\_diff)
00998     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%VarMix)) &
00999       \textcolor{keyword}{call }calc\_slope\_functions(h, cs%tv, dt, g, gv, us, cs%VarMix, obc=cs%OBC)
01000     \textcolor{keyword}{call }thickness\_diffuse(h, cs%uhtr, cs%vhtr, cs%tv, dt\_thermo, g, gv, us, &
01001                            cs%MEKE, cs%VarMix, cs%CDp, cs%thickness\_diffuse\_CSp)
01002     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_thick\_diff)
01003     \textcolor{keyword}{call }pass\_var(h, g%Domain, clock=id\_clock\_pass, halo=max(2,cs%cont\_stencil))
01004     \textcolor{keyword}{call }disable\_averaging(cs%diag)
01005     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished thickness\_diffuse\_first (step\_MOM)"})
01006 
01007     \textcolor{comment}{! Whenever thickness changes let the diag manager know, target grids}
01008     \textcolor{comment}{! for vertical remapping may need to be regenerated.}
01009     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
01010 \textcolor{keywordflow}{  endif}
01011 
01012   \textcolor{comment}{! The bottom boundary layer properties need to be recalculated.}
01013   \textcolor{keywordflow}{if} (bbl\_time\_int > 0.0) \textcolor{keywordflow}{then}
01014     \textcolor{keyword}{call }enable\_averages(bbl\_time\_int, &
01015               time\_local + real\_to\_time(us%T\_to\_s*(bbl\_time\_int-dt)), cs%diag)
01016     \textcolor{comment}{! Calculate the BBL properties and store them inside visc (u,h).}
01017     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_bbl\_visc)
01018     \textcolor{keyword}{call }set\_viscous\_bbl(cs%u, cs%v, cs%h, cs%tv, cs%visc, g, gv, us, &
01019                          cs%set\_visc\_CSp, symmetrize=.true.)
01020     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_bbl\_visc)
01021     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with set\_viscous\_BBL (step\_MOM)"})
01022     \textcolor{keyword}{call }disable\_averaging(cs%diag)
01023 \textcolor{keywordflow}{  endif}
01024 
01025 
01026   \textcolor{keywordflow}{if} (cs%do\_dynamics .and. cs%split) \textcolor{keywordflow}{then} \textcolor{comment}{!--------------------------- start SPLIT}
01027     \textcolor{comment}{! This section uses a split time stepping scheme for the dynamic equations,}
01028     \textcolor{comment}{! basically the stacked shallow water equations with viscosity.}
01029 
01030     calc\_dtbt = .false.
01031     \textcolor{keywordflow}{if} (cs%dtbt\_reset\_period == 0.0) calc\_dtbt = .true.
01032     \textcolor{keywordflow}{if} (cs%dtbt\_reset\_period > 0.0) \textcolor{keywordflow}{then}
01033       \textcolor{keywordflow}{if} (time\_local >= cs%dtbt\_reset\_time) \textcolor{keywordflow}{then}  \textcolor{comment}{!### Change >= to > here.}
01034         calc\_dtbt = .true.
01035         cs%dtbt\_reset\_time = cs%dtbt\_reset\_time + cs%dtbt\_reset\_interval
01036 \textcolor{keywordflow}{      endif}
01037 \textcolor{keywordflow}{    endif}
01038 
01039     \textcolor{keyword}{call }step\_mom\_dyn\_split\_rk2(u, v, h, cs%tv, cs%visc, time\_local, dt, forces, &
01040                 p\_surf\_begin, p\_surf\_end, cs%uh, cs%vh, cs%uhtr, cs%vhtr, &
01041                 cs%eta\_av\_bc, g, gv, us, cs%dyn\_split\_RK2\_CSp, calc\_dtbt, cs%VarMix, &
01042                 cs%MEKE, cs%thickness\_diffuse\_CSp, waves=waves)
01043     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished step\_MOM\_dyn\_split (step\_MOM)"})
01044 
01045   \textcolor{keywordflow}{elseif} (cs%do\_dynamics) \textcolor{keywordflow}{then} \textcolor{comment}{! ------------------------------------ not SPLIT}
01046     \textcolor{comment}{!   This section uses an unsplit stepping scheme for the dynamic}
01047     \textcolor{comment}{! equations; basically the stacked shallow water equations with viscosity.}
01048     \textcolor{comment}{! Because the time step is limited by CFL restrictions on the external}
01049     \textcolor{comment}{! gravity waves, the unsplit is usually much less efficient that the split}
01050     \textcolor{comment}{! approaches. But because of its simplicity, the unsplit method is very}
01051     \textcolor{comment}{! useful for debugging purposes.}
01052 
01053     \textcolor{keywordflow}{if} (cs%use\_RK2) \textcolor{keywordflow}{then}
01054       \textcolor{keyword}{call }step\_mom\_dyn\_unsplit\_rk2(u, v, h, cs%tv, cs%visc, time\_local, dt, forces, &
01055                p\_surf\_begin, p\_surf\_end, cs%uh, cs%vh, cs%uhtr, cs%vhtr, &
01056                cs%eta\_av\_bc, g, gv, us, cs%dyn\_unsplit\_RK2\_CSp, cs%VarMix, cs%MEKE)
01057     \textcolor{keywordflow}{else}
01058       \textcolor{keyword}{call }step\_mom\_dyn\_unsplit(u, v, h, cs%tv, cs%visc, time\_local, dt, forces, &
01059                p\_surf\_begin, p\_surf\_end, cs%uh, cs%vh, cs%uhtr, cs%vhtr, &
01060                cs%eta\_av\_bc, g, gv, us, cs%dyn\_unsplit\_CSp, cs%VarMix, cs%MEKE, waves=waves)
01061 \textcolor{keywordflow}{    endif}
01062     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished step\_MOM\_dyn\_unsplit (step\_MOM)"})
01063 
01064 \textcolor{keywordflow}{  endif} \textcolor{comment}{! -------------------------------------------------- end SPLIT}
01065 
01066   \textcolor{keywordflow}{if} (cs%thickness\_diffuse .and. .not.cs%thickness\_diffuse\_first) \textcolor{keywordflow}{then}
01067     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_thick\_diff)
01068 
01069     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keyword}{call }hchksum(h,\textcolor{stringliteral}{"Pre-thickness\_diffuse h"}, g%HI, haloshift=0, scale=gv%H\_to\_m)
01070 
01071     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%VarMix)) &
01072       \textcolor{keyword}{call }calc\_slope\_functions(h, cs%tv, dt, g, gv, us, cs%VarMix, obc=cs%OBC)
01073     \textcolor{keyword}{call }thickness\_diffuse(h, cs%uhtr, cs%vhtr, cs%tv, dt, g, gv, us, &
01074                            cs%MEKE, cs%VarMix, cs%CDp, cs%thickness\_diffuse\_CSp)
01075 
01076     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keyword}{call }hchksum(h,\textcolor{stringliteral}{"Post-thickness\_diffuse h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
01077     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_thick\_diff)
01078     \textcolor{keyword}{call }pass\_var(h, g%Domain, clock=id\_clock\_pass, halo=max(2,cs%cont\_stencil))
01079     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished thickness\_diffuse (step\_MOM)"})
01080 \textcolor{keywordflow}{  endif}
01081 
01082   \textcolor{comment}{! apply the submesoscale mixed layer restratification parameterization}
01083   \textcolor{keywordflow}{if} (cs%mixedlayer\_restrat) \textcolor{keywordflow}{then}
01084     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01085       \textcolor{keyword}{call }hchksum(h,\textcolor{stringliteral}{"Pre-mixedlayer\_restrat h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
01086       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Pre-mixedlayer\_restrat uhtr"}, &
01087                     cs%uhtr, cs%vhtr, g%HI, haloshift=0, scale=gv%H\_to\_m*us%L\_to\_m**2)
01088 \textcolor{keywordflow}{    endif}
01089     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_ml\_restrat)
01090     \textcolor{keyword}{call }mixedlayer\_restrat(h, cs%uhtr, cs%vhtr, cs%tv, forces, dt, cs%visc%MLD, &
01091                             cs%VarMix, g, gv, us, cs%mixedlayer\_restrat\_CSp)
01092     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_ml\_restrat)
01093     \textcolor{keyword}{call }pass\_var(h, g%Domain, clock=id\_clock\_pass, halo=max(2,cs%cont\_stencil))
01094     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01095       \textcolor{keyword}{call }hchksum(h,\textcolor{stringliteral}{"Post-mixedlayer\_restrat h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
01096       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Post-mixedlayer\_restrat [uv]htr"}, &
01097                     cs%uhtr, cs%vhtr, g%HI, haloshift=0, scale=gv%H\_to\_m*us%L\_to\_m**2)
01098 \textcolor{keywordflow}{    endif}
01099 \textcolor{keywordflow}{  endif}
01100 
01101   \textcolor{comment}{! Whenever thickness changes let the diag manager know, target grids}
01102   \textcolor{comment}{! for vertical remapping may need to be regenerated.}
01103   \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
01104 
01105   \textcolor{keywordflow}{if} (cs%useMEKE) \textcolor{keyword}{call }step\_forward\_meke(cs%MEKE, h, cs%VarMix%SN\_u, cs%VarMix%SN\_v, &
01106                                          cs%visc, dt, g, gv, us, cs%MEKE\_CSp, cs%uhtr, cs%vhtr)
01107   \textcolor{keyword}{call }disable\_averaging(cs%diag)
01108 
01109   \textcolor{comment}{! Advance the dynamics time by dt.}
01110   cs%t\_dyn\_rel\_adv = cs%t\_dyn\_rel\_adv + dt
01111   cs%t\_dyn\_rel\_thermo = cs%t\_dyn\_rel\_thermo + dt
01112   \textcolor{keywordflow}{if} (abs(cs%t\_dyn\_rel\_thermo) < 1e-6*dt) cs%t\_dyn\_rel\_thermo = 0.0
01113   cs%t\_dyn\_rel\_diag = cs%t\_dyn\_rel\_diag + dt
01114 
01115   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_dynamics)
01116 
01117   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_other) ; \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diagnostics)
01118   \textcolor{keyword}{call }enable\_averages(dt, time\_local, cs%diag)
01119   \textcolor{comment}{! These diagnostics are available after every time dynamics step.}
01120   \textcolor{keywordflow}{if} (ids%id\_u > 0) \textcolor{keyword}{call }post\_data(ids%id\_u, u, cs%diag)
01121   \textcolor{keywordflow}{if} (ids%id\_v > 0) \textcolor{keyword}{call }post\_data(ids%id\_v, v, cs%diag)
01122   \textcolor{keywordflow}{if} (ids%id\_h > 0) \textcolor{keyword}{call }post\_data(ids%id\_h, h, cs%diag)
01123   \textcolor{keyword}{call }disable\_averaging(cs%diag)
01124   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diagnostics) ; \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_other)
01125 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}\label{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}} 
\index{mom@{mom}!step\+\_\+mom\+\_\+thermo@{step\+\_\+mom\+\_\+thermo}}
\index{step\+\_\+mom\+\_\+thermo@{step\+\_\+mom\+\_\+thermo}!mom@{mom}}
\subsubsection{\texorpdfstring{step\+\_\+mom\+\_\+thermo()}{step\_mom\_thermo()}}
{\footnotesize\ttfamily subroutine mom\+::step\+\_\+mom\+\_\+thermo (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), intent(inout)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(inout)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{v,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{real, intent(in)}]{dtdia,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+end\+\_\+thermo,  }\item[{logical, intent(in)}]{update\+\_\+\+B\+BL,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



M\+O\+M\+\_\+step\+\_\+thermo orchestrates the thermodynamic time stepping and vertical remapping, via calls to diabatic (or adiabatic) and A\+L\+E\+\_\+main. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & Master M\+OM control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in,out}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em u} & zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v} & meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em tv} & A structure pointing to various thermodynamic variables\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & pointers to forcing fields\\
\hline
\mbox{\tt in}  & {\em dtdia} & The time interval over which to advance \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time\+\_\+end\+\_\+thermo} & End of averaging interval for thermo diags\\
\hline
\mbox{\tt in}  & {\em update\+\_\+bbl} & If true, calculate the bottom boundary layer properties.\\
\hline
 & {\em waves} & Container for wave related parameters \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l01213}{1213} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_af865d838388a05163e8de8d266316d5f}{id\+\_\+clock\+\_\+adiabatic}, \hyperlink{namespacemom_a722ed13d0e6d76852e680054a0e3c964}{id\+\_\+clock\+\_\+ale}, \hyperlink{namespacemom_aa69e79e4c51e1c24c474b84311322251}{id\+\_\+clock\+\_\+bbl\+\_\+visc}, \hyperlink{namespacemom_a50edf00aa5998073d2db0360949253ba}{id\+\_\+clock\+\_\+diabatic}, \hyperlink{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}{id\+\_\+clock\+\_\+pass}, and \hyperlink{namespacemom_a052256dfa3e56390f62ef3a826d62617}{id\+\_\+clock\+\_\+thermo}.



Referenced by \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}.


\begin{DoxyCode}
01213   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{     !< Master MOM control structure}
01214   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< ocean grid structure}
01215   \textcolor{keywordtype}{type}(verticalgrid\_type),  \textcolor{keywordtype}{intent(inout)} :: gv\textcolor{comment}{     !< ocean vertical grid structure}
01216   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
01217   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, &
01218                             \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< zonal velocity [L T-1 ~> m s-1]}
01219   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, &
01220                             \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< meridional velocity [L T-1 ~> m s-1]}
01221   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  &
01222                             \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{      !< layer thickness [H ~> m or kg m-2]}
01223   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),    \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< A structure pointing to various thermodynamic
       variables}
01224   \textcolor{keywordtype}{type}(forcing),            \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< pointers to forcing fields}
01225   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{intent(in)}    :: dtdia\textcolor{comment}{  !< The time interval over which to advance [T ~> s]}
01226   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: time\_end\_thermo\textcolor{comment}{ !< End of averaging interval for thermo diags}
01227   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{intent(in)}    :: update\_bbl\textcolor{comment}{ !< If true, calculate the bottom boundary layer
       properties.}
01228   \textcolor{keywordtype}{type}(wave\_parameters\_cs), &
01229                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: waves\textcolor{comment}{  !< Container for wave related parameters}
01230 \textcolor{comment}{                                                    !! the fields in Waves are intent in here.}
01231 
01232   \textcolor{keywordtype}{logical} :: use\_ice\_shelf \textcolor{comment}{! Needed for selecting the right ALE interface.}
01233   \textcolor{keywordtype}{logical} :: showcalltree
01234   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_t\_s, pass\_t\_s\_h, pass\_uv\_t\_s\_h
01235   \textcolor{keywordtype}{integer} :: dynamics\_stencil  \textcolor{comment}{! The computational stencil for the calculations}
01236                                \textcolor{comment}{! in the dynamic core.}
01237   \textcolor{keywordtype}{integer} :: halo\_sz \textcolor{comment}{! The size of a halo where data must be valid.}
01238   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz
01239 
01240   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
01241   showcalltree = calltree\_showquery()
01242   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"step\_MOM\_thermo(), MOM.F90"})
01243 
01244   use\_ice\_shelf = .false.
01245   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%frac\_shelf\_h)) use\_ice\_shelf = .true.
01246 
01247   \textcolor{keyword}{call }enable\_averages(dtdia, time\_end\_thermo, cs%diag)
01248 
01249   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%odaCS)) \textcolor{keywordflow}{then}
01250     \textcolor{keyword}{call }apply\_oda\_tracer\_increments(us%T\_to\_s*dtdia,g,tv,h,cs%odaCS)
01251 \textcolor{keywordflow}{  endif}
01252 
01253   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf) .or. \textcolor{keyword}{associated}(fluxes%p\_surf\_full)) \textcolor{keywordflow}{then}
01254     \textcolor{keyword}{call }extract\_diabatic\_member(cs%diabatic\_CSp, diabatic\_halo=halo\_sz)
01255     \textcolor{keywordflow}{if} (halo\_sz > 0) \textcolor{keywordflow}{then}
01256       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%p\_surf\_full)) &
01257         \textcolor{keyword}{call }pass\_var(fluxes%p\_surf\_full, g%Domain, &
01258                       clock=id\_clock\_pass, halo=halo\_sz, complete=.not.\textcolor{keyword}{associated}(fluxes%p\_surf))
01259       \textcolor{keyword}{call }pass\_var(fluxes%p\_surf, g%Domain, clock=id\_clock\_pass, halo=halo\_sz, complete=.true.)
01260 \textcolor{keywordflow}{    endif}
01261 \textcolor{keywordflow}{  endif}
01262 
01263   \textcolor{keywordflow}{if} (update\_bbl) \textcolor{keywordflow}{then}
01264     \textcolor{comment}{!   Calculate the BBL properties and store them inside visc (u,h).}
01265     \textcolor{comment}{! This is here so that CS%visc is updated before diabatic() when}
01266     \textcolor{comment}{! DIABATIC\_FIRST=True. Otherwise diabatic() is called after the dynamics}
01267     \textcolor{comment}{! and set\_viscous\_BBL is called as a part of the dynamic stepping.}
01268     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_bbl\_visc)
01269     \textcolor{keyword}{call }set\_viscous\_bbl(u, v, h, tv, cs%visc, g, gv, us, cs%set\_visc\_CSp, symmetrize=.true.)
01270     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_bbl\_visc)
01271     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"done with set\_viscous\_BBL (step\_MOM\_thermo)"})
01272 \textcolor{keywordflow}{  endif}
01273 
01274   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_thermo)
01275   \textcolor{keywordflow}{if} (.not.cs%adiabatic) \textcolor{keywordflow}{then}
01276     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01277       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Pre-diabatic [uv]"}, u, v, g%HI, haloshift=2, scale=us%L\_T\_to\_m\_s)
01278       \textcolor{keyword}{call }hchksum(h,\textcolor{stringliteral}{"Pre-diabatic h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
01279       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Pre-diabatic [uv]h"}, cs%uhtr, cs%vhtr, g%HI, &
01280                     haloshift=0, scale=gv%H\_to\_m*us%L\_to\_m**2)
01281     \textcolor{comment}{! call MOM\_state\_chksum("Pre-diabatic ", u, v, h, CS%uhtr, CS%vhtr, G, GV, vel\_scale=1.0)}
01282       \textcolor{keyword}{call }mom\_thermo\_chksum(\textcolor{stringliteral}{"Pre-diabatic "}, tv, g, us, haloshift=0)
01283       \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Pre-diabatic "}, u, v, g)
01284       \textcolor{keyword}{call }mom\_forcing\_chksum(\textcolor{stringliteral}{"Pre-diabatic"}, fluxes, g, us, haloshift=0)
01285 \textcolor{keywordflow}{    endif}
01286 
01287     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diabatic)
01288 
01289     \textcolor{keyword}{call }diabatic(u, v, h, tv, cs%Hml, fluxes, cs%visc, cs%ADp, cs%CDp, dtdia, &
01290                   time\_end\_thermo, g, gv, us, cs%diabatic\_CSp, obc=cs%OBC, waves=waves)
01291     fluxes%fluxes\_used = .true.
01292 
01293     \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished diabatic (step\_MOM\_thermo)"})
01294 
01295     \textcolor{comment}{! Regridding/remapping is done here, at end of thermodynamics time step}
01296     \textcolor{comment}{! (that may comprise several dynamical time steps)}
01297     \textcolor{comment}{! The routine 'ALE\_main' can be found in 'MOM\_ALE.F90'.}
01298     \textcolor{keywordflow}{if} ( cs%use\_ALE\_algorithm ) \textcolor{keywordflow}{then}
01299       \textcolor{keyword}{call }enable\_averages(dtdia, time\_end\_thermo, cs%diag)
01300 \textcolor{comment}{!         call pass\_vector(u, v, G%Domain)}
01301       \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_pass)
01302       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%T)) &
01303         \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, tv%T, g%Domain, to\_all+omit\_corners, halo=1)
01304       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%S)) &
01305         \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, tv%S, g%Domain, to\_all+omit\_corners, halo=1)
01306       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, h, g%Domain, to\_all+omit\_corners, halo=1)
01307       \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s\_h, g%Domain)
01308       \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_pass)
01309 
01310       \textcolor{keyword}{call }preale\_tracer\_diagnostics(cs%tracer\_Reg, g, gv)
01311 
01312       \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01313         \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Pre-ALE "}, u, v, h, cs%uh, cs%vh, g, gv, us)
01314         \textcolor{keyword}{call }hchksum(tv%T,\textcolor{stringliteral}{"Pre-ALE T"}, g%HI, haloshift=1)
01315         \textcolor{keyword}{call }hchksum(tv%S,\textcolor{stringliteral}{"Pre-ALE S"}, g%HI, haloshift=1)
01316         \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Pre-ALE "}, u, v, g)
01317 \textcolor{keywordflow}{      endif}
01318       \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_ale)
01319       \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}
01320         \textcolor{keyword}{call }ale\_main(g, gv, us, h, u, v, tv, cs%tracer\_Reg, cs%ALE\_CSp, cs%OBC, &
01321                       dtdia, fluxes%frac\_shelf\_h)
01322       \textcolor{keywordflow}{else}
01323         \textcolor{keyword}{call }ale\_main(g, gv, us, h, u, v, tv, cs%tracer\_Reg, cs%ALE\_CSp, cs%OBC, dtdia)
01324 \textcolor{keywordflow}{      endif}
01325 
01326       \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished ALE\_main (step\_MOM\_thermo)"})
01327       \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_ale)
01328 \textcolor{keywordflow}{    endif}   \textcolor{comment}{! endif for the block "if ( CS%use\_ALE\_algorithm )"}
01329 
01330     dynamics\_stencil = min(3, g%Domain%nihalo, g%Domain%njhalo)
01331     \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, u, v, g%Domain, halo=dynamics\_stencil)
01332     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%T)) &
01333       \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, tv%T, g%Domain, halo=dynamics\_stencil)
01334     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%S)) &
01335       \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, tv%S, g%Domain, halo=dynamics\_stencil)
01336     \textcolor{keyword}{call }create\_group\_pass(pass\_uv\_t\_s\_h, h, g%Domain, halo=dynamics\_stencil)
01337     \textcolor{keyword}{call }do\_group\_pass(pass\_uv\_t\_s\_h, g%Domain, clock=id\_clock\_pass)
01338 
01339     \textcolor{keywordflow}{if} (cs%debug .and. cs%use\_ALE\_algorithm) \textcolor{keywordflow}{then}
01340       \textcolor{keyword}{call }mom\_state\_chksum(\textcolor{stringliteral}{"Post-ALE "}, u, v, h, cs%uh, cs%vh, g, gv, us)
01341       \textcolor{keyword}{call }hchksum(tv%T, \textcolor{stringliteral}{"Post-ALE T"}, g%HI, haloshift=1)
01342       \textcolor{keyword}{call }hchksum(tv%S, \textcolor{stringliteral}{"Post-ALE S"}, g%HI, haloshift=1)
01343       \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Post-ALE "}, u, v, g)
01344 \textcolor{keywordflow}{    endif}
01345 
01346     \textcolor{comment}{! Whenever thickness changes let the diag manager know, target grids}
01347     \textcolor{comment}{! for vertical remapping may need to be regenerated. This needs to}
01348     \textcolor{comment}{! happen after the H update and before the next post\_data.}
01349     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
01350 
01351     \textcolor{comment}{!### Consider moving this up into the if ALE block.}
01352     \textcolor{keyword}{call }postale\_tracer\_diagnostics(cs%tracer\_Reg, g, gv, cs%diag, dtdia)
01353 
01354     \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01355       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Post-diabatic u"}, u, v, g%HI, haloshift=2, scale=us%L\_T\_to\_m\_s)
01356       \textcolor{keyword}{call }hchksum(h, \textcolor{stringliteral}{"Post-diabatic h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
01357       \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Post-diabatic [uv]h"}, cs%uhtr, cs%vhtr, g%HI, &
01358                     haloshift=0, scale=gv%H\_to\_m*us%L\_to\_m**2)
01359     \textcolor{comment}{! call MOM\_state\_chksum("Post-diabatic ", u, v, &}
01360     \textcolor{comment}{!                       h, CS%uhtr, CS%vhtr, G, GV, haloshift=1)}
01361       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%T)) \textcolor{keyword}{call }hchksum(tv%T, \textcolor{stringliteral}{"Post-diabatic T"}, g%HI, haloshift=1)
01362       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%S)) \textcolor{keyword}{call }hchksum(tv%S, \textcolor{stringliteral}{"Post-diabatic S"}, g%HI, haloshift=1)
01363       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%frazil)) \textcolor{keyword}{call }hchksum(tv%frazil, \textcolor{stringliteral}{"Post-diabatic frazil"}, g%HI, haloshift=0, &
01364                                               scale=g%US%Q\_to\_J\_kg*g%US%RZ\_to\_kg\_m2)
01365       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%salt\_deficit)) \textcolor{keyword}{call }hchksum(tv%salt\_deficit, &
01366                                \textcolor{stringliteral}{"Post-diabatic salt deficit"}, g%HI, haloshift=0, scale=us%RZ\_to\_kg\_m2)
01367     \textcolor{comment}{! call MOM\_thermo\_chksum("Post-diabatic ", tv, G, US)}
01368       \textcolor{keyword}{call }check\_redundant(\textcolor{stringliteral}{"Post-diabatic "}, u, v, g)
01369 \textcolor{keywordflow}{    endif}
01370     \textcolor{keyword}{call }disable\_averaging(cs%diag)
01371 
01372     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diabatic)
01373   \textcolor{keywordflow}{else}   \textcolor{comment}{! complement of "if (.not.CS%adiabatic)"}
01374 
01375     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_adiabatic)
01376     \textcolor{keyword}{call }adiabatic(h, tv, fluxes, dtdia, g, gv, us, cs%diabatic\_CSp)
01377     fluxes%fluxes\_used = .true.
01378     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_adiabatic)
01379 
01380     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%T)) \textcolor{keywordflow}{then}
01381       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s, tv%T, g%Domain, to\_all+omit\_corners, halo=1)
01382       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s, tv%S, g%Domain, to\_all+omit\_corners, halo=1)
01383       \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s, g%Domain, clock=id\_clock\_pass)
01384       \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01385         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%T)) \textcolor{keyword}{call }hchksum(tv%T, \textcolor{stringliteral}{"Post-diabatic T"}, g%HI, haloshift=1)
01386         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv%S)) \textcolor{keyword}{call }hchksum(tv%S, \textcolor{stringliteral}{"Post-diabatic S"}, g%HI, haloshift=1)
01387 \textcolor{keywordflow}{      endif}
01388 \textcolor{keywordflow}{    endif}
01389 
01390 \textcolor{keywordflow}{  endif}   \textcolor{comment}{! endif for the block "if (.not.CS%adiabatic)"}
01391   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_thermo)
01392 
01393   \textcolor{keyword}{call }disable\_averaging(cs%diag)
01394 
01395   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"step\_MOM\_thermo(), MOM.F90"})
01396 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a0a07938ed3127b70bab5d466967aec80}\label{namespacemom_a0a07938ed3127b70bab5d466967aec80}} 
\index{mom@{mom}!step\+\_\+mom\+\_\+tracer\+\_\+dyn@{step\+\_\+mom\+\_\+tracer\+\_\+dyn}}
\index{step\+\_\+mom\+\_\+tracer\+\_\+dyn@{step\+\_\+mom\+\_\+tracer\+\_\+dyn}!mom@{mom}}
\subsubsection{\texorpdfstring{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}{step\_mom\_tracer\_dyn()}}
{\footnotesize\ttfamily subroutine mom\+::step\+\_\+mom\+\_\+tracer\+\_\+dyn (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), intent(inout)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+local }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



step\+\_\+\+M\+O\+M\+\_\+tracer\+\_\+dyn does tracer advection and lateral diffusion, bringing the tracers up to date with the changes in state due to the dynamics. Surface sources and sinks and remapping are handled via step\+\_\+\+M\+O\+M\+\_\+thermo. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em cs} & control structure\\
\hline
\mbox{\tt in,out}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em h} & layer thicknesses after the transports \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em time\+\_\+local} & The model time at the end of the time step. \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l01132}{1132} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_aa773fddb51f99098d75304eb271270d4}{id\+\_\+clock\+\_\+diagnostics}, \hyperlink{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}{id\+\_\+clock\+\_\+other}, \hyperlink{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}{id\+\_\+clock\+\_\+pass}, \hyperlink{namespacemom_a052256dfa3e56390f62ef3a826d62617}{id\+\_\+clock\+\_\+thermo}, and \hyperlink{namespacemom_a0fa4debacd02de6fcd066066c232adf3}{id\+\_\+clock\+\_\+tracer}.



Referenced by \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}.


\begin{DoxyCode}
01132   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{     !< control structure}
01133   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< ocean grid structure}
01134   \textcolor{keywordtype}{type}(verticalgrid\_type),  \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{     !< ocean vertical grid structure}
01135   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
01136   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  &
01137                             \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{      !< layer thicknesses after the transports [H ~> m or kg
       m-2]}
01138   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: time\_local\textcolor{comment}{ !< The model time at the end}
01139 \textcolor{comment}{                                                    !! of the time step.}
01140   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_t\_s
01141   \textcolor{keywordtype}{integer} :: halo\_sz \textcolor{comment}{! The size of a halo where data must be valid.}
01142   \textcolor{keywordtype}{logical} :: showcalltree
01143   showcalltree = calltree\_showquery()
01144 
01145   \textcolor{keywordflow}{if} (cs%debug) \textcolor{keywordflow}{then}
01146     \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_other)
01147     \textcolor{keyword}{call }hchksum(h,\textcolor{stringliteral}{"Pre-advection h"}, g%HI, haloshift=1, scale=gv%H\_to\_m)
01148     \textcolor{keyword}{call }uvchksum(\textcolor{stringliteral}{"Pre-advection uhtr"}, cs%uhtr, cs%vhtr, g%HI, &
01149                   haloshift=0, scale=gv%H\_to\_m*us%L\_to\_m**2)
01150     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%T)) \textcolor{keyword}{call }hchksum(cs%tv%T, \textcolor{stringliteral}{"Pre-advection T"}, g%HI, haloshift=1)
01151     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%S)) \textcolor{keyword}{call }hchksum(cs%tv%S, \textcolor{stringliteral}{"Pre-advection S"}, g%HI, haloshift=1)
01152     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%frazil)) \textcolor{keyword}{call }hchksum(cs%tv%frazil, \textcolor{stringliteral}{"Pre-advection frazil"}, g%HI, haloshift=0, &
01153                                                scale=g%US%Q\_to\_J\_kg*g%US%RZ\_to\_kg\_m2)
01154     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%salt\_deficit)) \textcolor{keyword}{call }hchksum(cs%tv%salt\_deficit, &
01155                    \textcolor{stringliteral}{"Pre-advection salt deficit"}, g%HI, haloshift=0, scale=us%RZ\_to\_kg\_m2)
01156   \textcolor{comment}{! call MOM\_thermo\_chksum("Pre-advection ", CS%tv, G, US)}
01157     \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_other)
01158 \textcolor{keywordflow}{  endif}
01159 
01160   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_thermo) ; \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_tracer)
01161   \textcolor{keyword}{call }enable\_averages(cs%t\_dyn\_rel\_adv, time\_local, cs%diag)
01162 
01163   \textcolor{keyword}{call }advect\_tracer(h, cs%uhtr, cs%vhtr, cs%OBC, cs%t\_dyn\_rel\_adv, g, gv, us, &
01164                      cs%tracer\_adv\_CSp, cs%tracer\_Reg)
01165   \textcolor{keyword}{call }tracer\_hordiff(h, cs%t\_dyn\_rel\_adv, cs%MEKE, cs%VarMix, g, gv, us, &
01166                       cs%tracer\_diff\_CSp, cs%tracer\_Reg, cs%tv)
01167   \textcolor{keywordflow}{if} (showcalltree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"finished tracer advection/diffusion (step\_MOM)"})
01168   \textcolor{keyword}{call }update\_segment\_tracer\_reservoirs(g, gv, cs%uhtr, cs%vhtr, h, cs%OBC, &
01169                      cs%t\_dyn\_rel\_adv, cs%tracer\_Reg)
01170   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_tracer) ; \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_thermo)
01171 
01172   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_other) ; \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_diagnostics)
01173   \textcolor{keyword}{call }post\_transport\_diagnostics(g, gv, us, cs%uhtr, cs%vhtr, h, cs%transport\_IDs, &
01174            cs%diag\_pre\_dyn, cs%diag, cs%t\_dyn\_rel\_adv, cs%tracer\_reg)
01175   \textcolor{comment}{! Rebuild the remap grids now that we've posted the fields which rely on thicknesses}
01176   \textcolor{comment}{! from before the dynamics calls}
01177   \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
01178 
01179   \textcolor{keyword}{call }disable\_averaging(cs%diag)
01180   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_diagnostics) ; \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_other)
01181 
01182   \textcolor{comment}{! Reset the accumulated transports to 0 and record that the dynamics}
01183   \textcolor{comment}{! and advective times now agree.}
01184   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_thermo) ; \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_tracer)
01185   cs%uhtr(:,:,:) = 0.0
01186   cs%vhtr(:,:,:) = 0.0
01187   cs%t\_dyn\_rel\_adv = 0.0
01188   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_tracer) ; \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_thermo)
01189 
01190   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tv%T)) \textcolor{keywordflow}{then}
01191     \textcolor{keyword}{call }extract\_diabatic\_member(cs%diabatic\_CSp, diabatic\_halo=halo\_sz)
01192     \textcolor{keywordflow}{if} (halo\_sz > 0) \textcolor{keywordflow}{then}
01193       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s, cs%tv%T, g%Domain, to\_all, halo=halo\_sz)
01194       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s, cs%tv%S, g%Domain, to\_all, halo=halo\_sz)
01195       \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s, g%Domain, clock=id\_clock\_pass)
01196     \textcolor{keywordflow}{elseif} (cs%diabatic\_first) \textcolor{keywordflow}{then}
01197       \textcolor{comment}{! Temperature and salinity need halo updates because they will be used}
01198       \textcolor{comment}{! in the dynamics before they are changed again.}
01199       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s, cs%tv%T, g%Domain, to\_all+omit\_corners, halo=1)
01200       \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s, cs%tv%S, g%Domain, to\_all+omit\_corners, halo=1)
01201       \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s, g%Domain, clock=id\_clock\_pass)
01202 \textcolor{keywordflow}{    endif}
01203 \textcolor{keywordflow}{  endif}
01204 
01205   cs%preadv\_h\_stored = .false.
01206 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}\label{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}} 
\index{mom@{mom}!step\+\_\+offline@{step\+\_\+offline}}
\index{step\+\_\+offline@{step\+\_\+offline}!mom@{mom}}
\subsubsection{\texorpdfstring{step\+\_\+offline()}{step\_offline()}}
{\footnotesize\ttfamily subroutine, public mom\+::step\+\_\+offline (\begin{DoxyParamCaption}\item[{type(mech\+\_\+forcing), intent(in)}]{forces,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+start,  }\item[{real, intent(in)}]{time\+\_\+interval,  }\item[{type(\hyperlink{structmom_1_1mom__control__struct}{mom\+\_\+control\+\_\+struct}), pointer}]{CS }\end{DoxyParamCaption})}



step\+\_\+offline is the main driver for running tracers offline in M\+O\+M6. This has been primarily developed with A\+LE configurations in mind. Some work has been done in isopycnal configuration, but the work is very preliminary. Some more detail about this capability along with some of the subroutines called here can be found in tracers/\+M\+O\+M\+\_\+offline\+\_\+control.\+F90 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & pointers to forcing fields\\
\hline
\mbox{\tt in,out}  & {\em sfc\+\_\+state} & surface ocean state\\
\hline
\mbox{\tt in}  & {\em time\+\_\+start} & starting time of a segment, as a time type\\
\hline
\mbox{\tt in}  & {\em time\+\_\+interval} & time interval\\
\hline
 & {\em cs} & control structure from initialize\+\_\+\+M\+OM \\
\hline
\end{DoxyParams}


Definition at line \hyperlink{MOM_8F90_source_l01405}{1405} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



References \hyperlink{namespacemom_a16f7cc52cef3eb7a99687bf3d0694285}{adjust\+\_\+ssh\+\_\+for\+\_\+p\+\_\+atm()}, \hyperlink{namespacemom_a699d6c5bfb5b9dcdaa03c18806fa824e}{extract\+\_\+surface\+\_\+state()}, \hyperlink{namespacemom_a722ed13d0e6d76852e680054a0e3c964}{id\+\_\+clock\+\_\+ale}, and \hyperlink{namespacemom_a2ab767469f0d918b9e479d8e0fde44b0}{id\+\_\+clock\+\_\+offline\+\_\+tracer}.


\begin{DoxyCode}
01405   \textcolor{keywordtype}{type}(mech\_forcing), \textcolor{keywordtype}{intent(in)}    :: forces\textcolor{comment}{        !< A structure with the driving mechanical forces}
01406   \textcolor{keywordtype}{type}(forcing),      \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{        !< pointers to forcing fields}
01407   \textcolor{keywordtype}{type}(surface),      \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{     !< surface ocean state}
01408   \textcolor{keywordtype}{type}(time\_type),    \textcolor{keywordtype}{intent(in)}    :: time\_start\textcolor{comment}{    !< starting time of a segment, as a time type}
01409   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)}    :: time\_interval\textcolor{comment}{ !< time interval}
01410   \textcolor{keywordtype}{type}(mom\_control\_struct), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{            !< control structure from initialize\_MOM}
01411 
01412   \textcolor{comment}{! Local pointers}
01413   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{pointer} :: g  => null() \textcolor{comment}{! Pointer to a structure containing}
01414                                                       \textcolor{comment}{! metrics and related information}
01415   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{pointer} :: gv => null() \textcolor{comment}{! Pointer to structure containing information}
01416                                                       \textcolor{comment}{! about the vertical grid}
01417   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{pointer} :: us => null() \textcolor{comment}{! Pointer to a structure containing}
01418                                                       \textcolor{comment}{! various unit conversion factors}
01419 
01420   \textcolor{keywordtype}{logical} :: first\_iter\textcolor{comment}{    !< True if this is the first time step\_offline has been called in a given
       interval}
01421   \textcolor{keywordtype}{logical} :: last\_iter\textcolor{comment}{     !< True if this is the last time step\_tracer is to be called in an offline
       interval}
01422   \textcolor{keywordtype}{logical} :: do\_vertical\textcolor{comment}{   !< If enough time has elapsed, do the diabatic tracer sources/sinks}
01423   \textcolor{keywordtype}{logical} :: adv\_converged\textcolor{comment}{ !< True if all the horizontal fluxes have been used}
01424 
01425   \textcolor{keywordtype}{real} :: dt\_offline          \textcolor{comment}{! The offline timestep for advection [T ~> s]}
01426   \textcolor{keywordtype}{real} :: dt\_offline\_vertical \textcolor{comment}{! The offline timestep for vertical fluxes and remapping [T ~> s]}
01427   \textcolor{keywordtype}{logical} :: skip\_diffusion
01428   \textcolor{keywordtype}{integer} :: id\_eta\_diff\_end
01429 
01430   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{pointer} :: accumulated\_time => null()
01431   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{pointer} :: vertical\_time => null()
01432   \textcolor{keywordtype}{integer} :: i,j,k
01433   \textcolor{keywordtype}{integer} :: is, ie, js, je, isd, ied, jsd, jed
01434 
01435   \textcolor{comment}{! 3D pointers}
01436   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: &
01437     uhtr => null(), vhtr => null(), &
01438     eatr => null(), ebtr => null(), &
01439     h\_end => null()
01440 
01441   \textcolor{comment}{! 2D Array for diagnostics}
01442   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(CS%G),SZJ\_(CS%G))} :: eta\_pre, eta\_end
01443   \textcolor{keywordtype}{type}(time\_type) :: time\_end    \textcolor{comment}{! End time of a segment, as a time type}
01444 
01445   \textcolor{comment}{! Grid-related pointer assignments}
01446   g => cs%G ; gv => cs%GV ; us => cs%US
01447 
01448   is  = g%isc  ; ie  = g%iec  ; js  = g%jsc  ; je  = g%jec
01449   isd = g%isd  ; ied = g%ied  ; jsd = g%jsd  ; jed = g%jed
01450 
01451   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_offline\_tracer)
01452   \textcolor{keyword}{call }extract\_offline\_main(cs%offline\_CSp, uhtr, vhtr, eatr, ebtr, h\_end, accumulated\_time, &
01453                             vertical\_time, dt\_offline, dt\_offline\_vertical, skip\_diffusion)
01454   time\_end = increment\_date(time\_start, seconds=floor(time\_interval+0.001))
01455 
01456   \textcolor{keyword}{call }enable\_averaging(time\_interval, time\_end, cs%diag)
01457 
01458   \textcolor{comment}{! Check to see if this is the first iteration of the offline interval}
01459   \textcolor{keywordflow}{if} (accumulated\_time == real\_to\_time(0.0)) \textcolor{keywordflow}{then}
01460     first\_iter = .true.
01461   \textcolor{keywordflow}{else} \textcolor{comment}{! This is probably unnecessary but is used to guard against unwanted behavior}
01462     first\_iter = .false.
01463 \textcolor{keywordflow}{  endif}
01464 
01465   \textcolor{comment}{! Check to see if vertical tracer functions should be done}
01466   \textcolor{keywordflow}{if} (first\_iter .or. (accumulated\_time >= vertical\_time)) \textcolor{keywordflow}{then}
01467     do\_vertical = .true.
01468     vertical\_time = accumulated\_time + real\_to\_time(us%T\_to\_s*dt\_offline\_vertical)
01469   \textcolor{keywordflow}{else}
01470     do\_vertical = .false.
01471 \textcolor{keywordflow}{  endif}
01472 
01473   \textcolor{comment}{! Increment the amount of time elapsed since last read and check if it's time to roll around}
01474   accumulated\_time = accumulated\_time + real\_to\_time(time\_interval)
01475 
01476   last\_iter = (accumulated\_time >= real\_to\_time(us%T\_to\_s*dt\_offline))
01477 
01478   \textcolor{keywordflow}{if} (cs%use\_ALE\_algorithm) \textcolor{keywordflow}{then}
01479     \textcolor{comment}{! If this is the first iteration in the offline timestep, then we need to read in fields and}
01480     \textcolor{comment}{! perform the main advection.}
01481     \textcolor{keywordflow}{if} (first\_iter) \textcolor{keywordflow}{then}
01482       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"Reading in new offline fields"})
01483       \textcolor{comment}{! Read in new transport and other fields}
01484       \textcolor{comment}{! call update\_transport\_from\_files(G, GV, CS%offline\_CSp, h\_end, eatr, ebtr, uhtr, vhtr, &}
01485       \textcolor{comment}{!     CS%tv%T, CS%tv%S, fluxes, CS%use\_ALE\_algorithm)}
01486       \textcolor{comment}{! call update\_transport\_from\_arrays(CS%offline\_CSp)}
01487       \textcolor{keyword}{call }update\_offline\_fields(cs%offline\_CSp, cs%h, fluxes, cs%use\_ALE\_algorithm)
01488 
01489       \textcolor{comment}{! Apply any fluxes into the ocean}
01490       \textcolor{keyword}{call }offline\_fw\_fluxes\_into\_ocean(g, gv, cs%offline\_CSp, fluxes, cs%h)
01491 
01492       \textcolor{keywordflow}{if} (.not.cs%diabatic\_first) \textcolor{keywordflow}{then}
01493         \textcolor{keyword}{call }offline\_advection\_ale(fluxes, time\_start, time\_interval, cs%offline\_CSp, id\_clock\_ale, &
01494             cs%h, uhtr, vhtr, converged=adv\_converged)
01495 
01496         \textcolor{comment}{! Redistribute any remaining transport}
01497         \textcolor{keyword}{call }offline\_redistribute\_residual(cs%offline\_CSp, cs%h, uhtr, vhtr, adv\_converged)
01498 
01499         \textcolor{comment}{! Perform offline diffusion if requested}
01500         \textcolor{keywordflow}{if} (.not. skip\_diffusion) \textcolor{keywordflow}{then}
01501           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%VarMix)) \textcolor{keywordflow}{then}
01502             \textcolor{keyword}{call }pass\_var(cs%h, g%Domain)
01503             \textcolor{keyword}{call }calc\_resoln\_function(cs%h, cs%tv, g, gv, us, cs%VarMix)
01504             \textcolor{keyword}{call }calc\_depth\_function(g, cs%VarMix)
01505             \textcolor{keyword}{call }calc\_slope\_functions(cs%h, cs%tv, dt\_offline, g, gv, us, cs%VarMix, obc=cs%OBC)
01506 \textcolor{keywordflow}{          endif}
01507           \textcolor{keyword}{call }tracer\_hordiff(cs%h, dt\_offline, cs%MEKE, cs%VarMix, g, gv, us, &
01508               cs%tracer\_diff\_CSp, cs%tracer\_Reg, cs%tv)
01509 \textcolor{keywordflow}{        endif}
01510 \textcolor{keywordflow}{      endif}
01511 \textcolor{keywordflow}{    endif}
01512     \textcolor{comment}{! The functions related to column physics of tracers is performed separately in ALE mode}
01513     \textcolor{keywordflow}{if} (do\_vertical) \textcolor{keywordflow}{then}
01514       \textcolor{keyword}{call }offline\_diabatic\_ale(fluxes, time\_start, time\_end, cs%offline\_CSp, cs%h, eatr, ebtr)
01515 \textcolor{keywordflow}{    endif}
01516 
01517     \textcolor{comment}{! Last thing that needs to be done is the final ALE remapping}
01518     \textcolor{keywordflow}{if} (last\_iter) \textcolor{keywordflow}{then}
01519       \textcolor{keywordflow}{if} (cs%diabatic\_first) \textcolor{keywordflow}{then}
01520         \textcolor{keyword}{call }offline\_advection\_ale(fluxes, time\_start, time\_interval, cs%offline\_CSp, id\_clock\_ale, &
01521             cs%h, uhtr, vhtr, converged=adv\_converged)
01522 
01523         \textcolor{comment}{! Redistribute any remaining transport and perform the remaining advection}
01524         \textcolor{keyword}{call }offline\_redistribute\_residual(cs%offline\_CSp, cs%h, uhtr, vhtr, adv\_converged)
01525                 \textcolor{comment}{! Perform offline diffusion if requested}
01526         \textcolor{keywordflow}{if} (.not. skip\_diffusion) \textcolor{keywordflow}{then}
01527           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%VarMix)) \textcolor{keywordflow}{then}
01528             \textcolor{keyword}{call }pass\_var(cs%h, g%Domain)
01529             \textcolor{keyword}{call }calc\_resoln\_function(cs%h, cs%tv, g, gv, us, cs%VarMix)
01530             \textcolor{keyword}{call }calc\_depth\_function(g, cs%VarMix)
01531             \textcolor{keyword}{call }calc\_slope\_functions(cs%h, cs%tv, dt\_offline, g, gv, us, cs%VarMix, obc=cs%OBC)
01532 \textcolor{keywordflow}{          endif}
01533           \textcolor{keyword}{call }tracer\_hordiff(cs%h, dt\_offline, cs%MEKE, cs%VarMix, g, gv, us, &
01534               cs%tracer\_diff\_CSp, cs%tracer\_Reg, cs%tv)
01535 \textcolor{keywordflow}{        endif}
01536 \textcolor{keywordflow}{      endif}
01537 
01538       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"Last iteration of offline interval"})
01539 
01540       \textcolor{comment}{! Apply freshwater fluxes out of the ocean}
01541       \textcolor{keyword}{call }offline\_fw\_fluxes\_out\_ocean(g, gv, cs%offline\_CSp, fluxes, cs%h)
01542       \textcolor{comment}{! These diagnostic can be used to identify which grid points did not converge within}
01543       \textcolor{comment}{! the specified number of advection sub iterations}
01544       \textcolor{keyword}{call }post\_offline\_convergence\_diags(cs%offline\_CSp, cs%h, h\_end, uhtr, vhtr)
01545 
01546       \textcolor{comment}{! Call ALE one last time to make sure that tracers are remapped onto the layer thicknesses}
01547       \textcolor{comment}{! stored from the forward run}
01548       \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_ale)
01549       \textcolor{keyword}{call }ale\_offline\_tracer\_final( g, gv, cs%h, cs%tv, h\_end, cs%tracer\_Reg, cs%ALE\_CSp, cs%OBC)
01550       \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_ale)
01551       \textcolor{keyword}{call }pass\_var(cs%h, g%Domain)
01552 \textcolor{keywordflow}{    endif}
01553   \textcolor{keywordflow}{else} \textcolor{comment}{! NON-ALE MODE...NOT WELL TESTED}
01554     \textcolor{keyword}{call }mom\_error(warning, &
01555         \textcolor{stringliteral}{"Offline tracer mode in non-ALE configuration has not been thoroughly tested"})
01556     \textcolor{comment}{! Note that for the layer mode case, the calls to tracer sources and sinks is embedded in}
01557     \textcolor{comment}{! main\_offline\_advection\_layer. Warning: this may not be appropriate for tracers that}
01558     \textcolor{comment}{! exchange with the atmosphere}
01559     \textcolor{keywordflow}{if} (abs(time\_interval - us%T\_to\_s*dt\_offline) > 1.0e-6) \textcolor{keywordflow}{then}
01560       \textcolor{keyword}{call }mom\_error(fatal, &
01561           \textcolor{stringliteral}{"For offline tracer mode in a non-ALE configuration, dt\_offline must equal time\_interval"})
01562 \textcolor{keywordflow}{    endif}
01563     \textcolor{keyword}{call }update\_offline\_fields(cs%offline\_CSp, cs%h, fluxes, cs%use\_ALE\_algorithm)
01564     \textcolor{keyword}{call }offline\_advection\_layer(fluxes, time\_start, time\_interval, cs%offline\_CSp, &
01565         cs%h, eatr, ebtr, uhtr, vhtr)
01566     \textcolor{comment}{! Perform offline diffusion if requested}
01567     \textcolor{keywordflow}{if} (.not. skip\_diffusion) \textcolor{keywordflow}{then}
01568       \textcolor{keyword}{call }tracer\_hordiff(h\_end, dt\_offline, cs%MEKE, cs%VarMix, g, gv, us, &
01569                           cs%tracer\_diff\_CSp, cs%tracer\_Reg, cs%tv)
01570 \textcolor{keywordflow}{    endif}
01571 
01572     cs%h = h\_end
01573 
01574     \textcolor{keyword}{call }pass\_var(cs%tv%T, g%Domain)
01575     \textcolor{keyword}{call }pass\_var(cs%tv%S, g%Domain)
01576     \textcolor{keyword}{call }pass\_var(cs%h, g%Domain)
01577 
01578 \textcolor{keywordflow}{  endif}
01579 
01580   \textcolor{keyword}{call }adjust\_ssh\_for\_p\_atm(cs%tv, g, gv, us, cs%ave\_ssh\_ibc, forces%p\_surf\_SSH, &
01581                             cs%calc\_rho\_for\_sea\_lev)
01582   \textcolor{keyword}{call }extract\_surface\_state(cs, sfc\_state)
01583 
01584   \textcolor{keyword}{call }disable\_averaging(cs%diag)
01585   \textcolor{keyword}{call }pass\_var(cs%tv%T, g%Domain)
01586   \textcolor{keyword}{call }pass\_var(cs%tv%S, g%Domain)
01587   \textcolor{keyword}{call }pass\_var(cs%h, g%Domain)
01588 
01589   fluxes%fluxes\_used = .true.
01590 
01591   \textcolor{keywordflow}{if} (last\_iter) \textcolor{keywordflow}{then}
01592     accumulated\_time = real\_to\_time(0.0)
01593 \textcolor{keywordflow}{  endif}
01594 
01595   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_offline\_tracer)
01596 
\end{DoxyCode}


\subsection{Variable Documentation}
\mbox{\Hypertarget{namespacemom_af865d838388a05163e8de8d266316d5f}\label{namespacemom_af865d838388a05163e8de8d266316d5f}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+adiabatic@{id\+\_\+clock\+\_\+adiabatic}}
\index{id\+\_\+clock\+\_\+adiabatic@{id\+\_\+clock\+\_\+adiabatic}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+adiabatic}{id\_clock\_adiabatic}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+adiabatic\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00395}{395} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}.


\begin{DoxyCode}
00395 \textcolor{keywordtype}{integer} :: id\_clock\_adiabatic
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a722ed13d0e6d76852e680054a0e3c964}\label{namespacemom_a722ed13d0e6d76852e680054a0e3c964}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+ale@{id\+\_\+clock\+\_\+ale}}
\index{id\+\_\+clock\+\_\+ale@{id\+\_\+clock\+\_\+ale}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+ale}{id\_clock\_ale}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+ale\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00406}{406} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}, and \hyperlink{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}{step\+\_\+offline()}.


\begin{DoxyCode}
00406 \textcolor{keywordtype}{integer} :: id\_clock\_ale
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_aa69e79e4c51e1c24c474b84311322251}\label{namespacemom_aa69e79e4c51e1c24c474b84311322251}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+bbl\+\_\+visc@{id\+\_\+clock\+\_\+bbl\+\_\+visc}}
\index{id\+\_\+clock\+\_\+bbl\+\_\+visc@{id\+\_\+clock\+\_\+bbl\+\_\+visc}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+bbl\+\_\+visc}{id\_clock\_bbl\_visc}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+bbl\+\_\+visc\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00398}{398} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}, and \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}.


\begin{DoxyCode}
00398 \textcolor{keywordtype}{integer} :: id\_clock\_bbl\_visc
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_aa512b2d8dd73b02634e772701be07a87}\label{namespacemom_aa512b2d8dd73b02634e772701be07a87}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+continuity@{id\+\_\+clock\+\_\+continuity}}
\index{id\+\_\+clock\+\_\+continuity@{id\+\_\+clock\+\_\+continuity}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+continuity}{id\_clock\_continuity}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+continuity\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00396}{396} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}.


\begin{DoxyCode}
00396 \textcolor{keywordtype}{integer} :: id\_clock\_continuity  \textcolor{comment}{! also in dynamics s/r}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a50edf00aa5998073d2db0360949253ba}\label{namespacemom_a50edf00aa5998073d2db0360949253ba}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+diabatic@{id\+\_\+clock\+\_\+diabatic}}
\index{id\+\_\+clock\+\_\+diabatic@{id\+\_\+clock\+\_\+diabatic}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+diabatic}{id\_clock\_diabatic}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+diabatic\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00394}{394} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}.


\begin{DoxyCode}
00394 \textcolor{keywordtype}{integer} :: id\_clock\_diabatic
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_aa773fddb51f99098d75304eb271270d4}\label{namespacemom_aa773fddb51f99098d75304eb271270d4}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+diagnostics@{id\+\_\+clock\+\_\+diagnostics}}
\index{id\+\_\+clock\+\_\+diagnostics@{id\+\_\+clock\+\_\+diagnostics}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+diagnostics}{id\_clock\_diagnostics}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+diagnostics\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00400}{400} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}, \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}, and \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}.


\begin{DoxyCode}
00400 \textcolor{keywordtype}{integer} :: id\_clock\_diagnostics
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_ae1cf2d523679b925a5e5baa9d974968c}\label{namespacemom_ae1cf2d523679b925a5e5baa9d974968c}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+dynamics@{id\+\_\+clock\+\_\+dynamics}}
\index{id\+\_\+clock\+\_\+dynamics@{id\+\_\+clock\+\_\+dynamics}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+dynamics}{id\_clock\_dynamics}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+dynamics\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00391}{391} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}, and \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}.


\begin{DoxyCode}
00391 \textcolor{keywordtype}{integer} :: id\_clock\_dynamics
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a7cf03c18244d0630616e925bab1841a2}\label{namespacemom_a7cf03c18244d0630616e925bab1841a2}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+init@{id\+\_\+clock\+\_\+init}}
\index{id\+\_\+clock\+\_\+init@{id\+\_\+clock\+\_\+init}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+init}{id\_clock\_init}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+init\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00402}{402} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a2269d5cd79625cbf16cb916346379207}{finish\+\_\+mom\+\_\+initialization()}, and \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}.


\begin{DoxyCode}
00402 \textcolor{keywordtype}{integer} :: id\_clock\_init
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a41b67fabfc13e52cf3a5d1c337c780eb}\label{namespacemom_a41b67fabfc13e52cf3a5d1c337c780eb}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+ml\+\_\+restrat@{id\+\_\+clock\+\_\+ml\+\_\+restrat}}
\index{id\+\_\+clock\+\_\+ml\+\_\+restrat@{id\+\_\+clock\+\_\+ml\+\_\+restrat}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+ml\+\_\+restrat}{id\_clock\_ml\_restrat}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+ml\+\_\+restrat\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00399}{399} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}.


\begin{DoxyCode}
00399 \textcolor{keywordtype}{integer} :: id\_clock\_ml\_restrat
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a4180eb85bab39df7cbb72bb8e5b19fd4}\label{namespacemom_a4180eb85bab39df7cbb72bb8e5b19fd4}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+mom\+\_\+init@{id\+\_\+clock\+\_\+mom\+\_\+init}}
\index{id\+\_\+clock\+\_\+mom\+\_\+init@{id\+\_\+clock\+\_\+mom\+\_\+init}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+mom\+\_\+init}{id\_clock\_mom\_init}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+mom\+\_\+init\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00403}{403} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}, and \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}.


\begin{DoxyCode}
00403 \textcolor{keywordtype}{integer} :: id\_clock\_mom\_init
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a2e9f4b71ee77ba5bcb3f03a863948db3}\label{namespacemom_a2e9f4b71ee77ba5bcb3f03a863948db3}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+ocean@{id\+\_\+clock\+\_\+ocean}}
\index{id\+\_\+clock\+\_\+ocean@{id\+\_\+clock\+\_\+ocean}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+ocean}{id\_clock\_ocean}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+ocean}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00390}{390} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}.


\begin{DoxyCode}
00390 \textcolor{keywordtype}{integer} :: id\_clock\_ocean
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a2ab767469f0d918b9e479d8e0fde44b0}\label{namespacemom_a2ab767469f0d918b9e479d8e0fde44b0}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+offline\+\_\+tracer@{id\+\_\+clock\+\_\+offline\+\_\+tracer}}
\index{id\+\_\+clock\+\_\+offline\+\_\+tracer@{id\+\_\+clock\+\_\+offline\+\_\+tracer}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+offline\+\_\+tracer}{id\_clock\_offline\_tracer}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+offline\+\_\+tracer\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00408}{408} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_ade4f7557fcda73ffc12284d3cecf4182}{step\+\_\+offline()}.


\begin{DoxyCode}
00408 \textcolor{keywordtype}{integer} :: id\_clock\_offline\_tracer
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}\label{namespacemom_a283a5d32d799a3cd11113a05dcae2d56}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+other@{id\+\_\+clock\+\_\+other}}
\index{id\+\_\+clock\+\_\+other@{id\+\_\+clock\+\_\+other}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+other}{id\_clock\_other}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+other\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00407}{407} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}, \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}, and \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}.


\begin{DoxyCode}
00407 \textcolor{keywordtype}{integer} :: id\_clock\_other
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}\label{namespacemom_a7af2f783166f32739569e4ed6ed6a98f}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+pass@{id\+\_\+clock\+\_\+pass}}
\index{id\+\_\+clock\+\_\+pass@{id\+\_\+clock\+\_\+pass}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+pass}{id\_clock\_pass}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+pass\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00404}{404} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_adf54a4e3a72611aa2088f46076e56e53}{step\+\_\+mom()}, \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}, \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}, and \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}.


\begin{DoxyCode}
00404 \textcolor{keywordtype}{integer} :: id\_clock\_pass       \textcolor{comment}{! also in dynamics d/r}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_ac4d20612cad32d412dae492fedc2e971}\label{namespacemom_ac4d20612cad32d412dae492fedc2e971}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+pass\+\_\+init@{id\+\_\+clock\+\_\+pass\+\_\+init}}
\index{id\+\_\+clock\+\_\+pass\+\_\+init@{id\+\_\+clock\+\_\+pass\+\_\+init}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+pass\+\_\+init}{id\_clock\_pass\_init}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+pass\+\_\+init\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00405}{405} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}, and \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}.


\begin{DoxyCode}
00405 \textcolor{keywordtype}{integer} :: id\_clock\_pass\_init  \textcolor{comment}{! also in dynamics d/r}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a052256dfa3e56390f62ef3a826d62617}\label{namespacemom_a052256dfa3e56390f62ef3a826d62617}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+thermo@{id\+\_\+clock\+\_\+thermo}}
\index{id\+\_\+clock\+\_\+thermo@{id\+\_\+clock\+\_\+thermo}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+thermo}{id\_clock\_thermo}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+thermo\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00392}{392} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, \hyperlink{namespacemom_a1a81ea749a309f10f5c3c7a17efa3606}{step\+\_\+mom\+\_\+thermo()}, and \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}.


\begin{DoxyCode}
00392 \textcolor{keywordtype}{integer} :: id\_clock\_thermo
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a8f5feb87a0cb40d9fcee00456e982b8a}\label{namespacemom_a8f5feb87a0cb40d9fcee00456e982b8a}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+thick\+\_\+diff@{id\+\_\+clock\+\_\+thick\+\_\+diff}}
\index{id\+\_\+clock\+\_\+thick\+\_\+diff@{id\+\_\+clock\+\_\+thick\+\_\+diff}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+thick\+\_\+diff}{id\_clock\_thick\_diff}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+thick\+\_\+diff\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00397}{397} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_a42ee7e91ffcf1340679e29ab28d9b41d}{step\+\_\+mom\+\_\+dynamics()}.


\begin{DoxyCode}
00397 \textcolor{keywordtype}{integer} :: id\_clock\_thick\_diff
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a0fa4debacd02de6fcd066066c232adf3}\label{namespacemom_a0fa4debacd02de6fcd066066c232adf3}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+tracer@{id\+\_\+clock\+\_\+tracer}}
\index{id\+\_\+clock\+\_\+tracer@{id\+\_\+clock\+\_\+tracer}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+tracer}{id\_clock\_tracer}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+tracer\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00393}{393} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}, and \hyperlink{namespacemom_a0a07938ed3127b70bab5d466967aec80}{step\+\_\+mom\+\_\+tracer\+\_\+dyn()}.


\begin{DoxyCode}
00393 \textcolor{keywordtype}{integer} :: id\_clock\_tracer
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a785851181d2a3db5a938322d2ff9498a}\label{namespacemom_a785851181d2a3db5a938322d2ff9498a}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+unit\+\_\+tests@{id\+\_\+clock\+\_\+unit\+\_\+tests}}
\index{id\+\_\+clock\+\_\+unit\+\_\+tests@{id\+\_\+clock\+\_\+unit\+\_\+tests}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+unit\+\_\+tests}{id\_clock\_unit\_tests}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+unit\+\_\+tests\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00409}{409} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_a96708b16215666edbfa5b46228f3a200}{initialize\+\_\+mom()}.


\begin{DoxyCode}
00409 \textcolor{keywordtype}{integer} :: id\_clock\_unit\_tests
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom_a09f2ac3470372b9ee233f4cc5a7a0da1}\label{namespacemom_a09f2ac3470372b9ee233f4cc5a7a0da1}} 
\index{mom@{mom}!id\+\_\+clock\+\_\+z\+\_\+diag@{id\+\_\+clock\+\_\+z\+\_\+diag}}
\index{id\+\_\+clock\+\_\+z\+\_\+diag@{id\+\_\+clock\+\_\+z\+\_\+diag}!mom@{mom}}
\subsubsection{\texorpdfstring{id\+\_\+clock\+\_\+z\+\_\+diag}{id\_clock\_z\_diag}}
{\footnotesize\ttfamily integer mom\+::id\+\_\+clock\+\_\+z\+\_\+diag\hspace{0.3cm}{\ttfamily [private]}}



C\+PU time clock I\+Ds. 



Definition at line \hyperlink{MOM_8F90_source_l00401}{401} of file \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}.



Referenced by \hyperlink{namespacemom_ab57e47834591c651339770f7e51efe57}{mom\+\_\+timing\+\_\+init()}.


\begin{DoxyCode}
00401 \textcolor{keywordtype}{integer} :: id\_clock\_z\_diag
\end{DoxyCode}
