\hypertarget{namespaceisomip__initialization}{}\doxysection{isomip\+\_\+initialization Module Reference}
\label{namespaceisomip__initialization}\index{isomip\_initialization@{isomip\_initialization}}


\doxysubsection{Detailed Description}
Configures the I\+S\+O\+M\+IP test case. 

See this paper for details\+: \href{http://www.geosci-model-dev-discuss.net/8/9859/2015/gmdd-8-9859-2015.pdf}{\texttt{ http\+://www.\+geosci-\/model-\/dev-\/discuss.\+net/8/9859/2015/gmdd-\/8-\/9859-\/2015.\+pdf}}. \doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespaceisomip__initialization_a7292729944785b82fbeb51a27029b1b3}{isomip\+\_\+initialize\+\_\+topography}} (D, G, param\+\_\+file, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em Initialization of topography for the I\+S\+O\+M\+IP configuration. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceisomip__initialization_a748a8a53677059ad0c1c88ff5d0339aa}{isomip\+\_\+initialize\+\_\+thickness}} (h, G, GV, US, param\+\_\+file, tv, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initialization of thicknesses. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceisomip__initialization_ac90d1dbdbf22f4cf30de1452efd29d52}{isomip\+\_\+initialize\+\_\+temperature\+\_\+salinity}} (T, S, h, G, GV, US, param\+\_\+file, eqn\+\_\+of\+\_\+state, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initial values for temperature and salinity. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceisomip__initialization_a5605d312795e2d4770571052da07859f}{isomip\+\_\+initialize\+\_\+sponges}} (G, GV, US, tv, PF, use\+\_\+\+A\+LE, C\+Sp, A\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Sets up the the inverse restoration time (Idamp), and. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceisomip__initialization_a17eb636ac16e051364e1a96cc860d8e8}\label{namespaceisomip__initialization_a17eb636ac16e051364e1a96cc860d8e8}} 
character(len=40) \mbox{\hyperlink{namespaceisomip__initialization_a17eb636ac16e051364e1a96cc860d8e8}{mdl}} = \char`\"{}I\+S\+O\+M\+I\+P\+\_\+initialization\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceisomip__initialization_a5605d312795e2d4770571052da07859f}\label{namespaceisomip__initialization_a5605d312795e2d4770571052da07859f}} 
\index{isomip\_initialization@{isomip\_initialization}!isomip\_initialize\_sponges@{isomip\_initialize\_sponges}}
\index{isomip\_initialize\_sponges@{isomip\_initialize\_sponges}!isomip\_initialization@{isomip\_initialization}}
\doxysubsubsection{\texorpdfstring{isomip\_initialize\_sponges()}{isomip\_initialize\_sponges()}}
{\footnotesize\ttfamily subroutine, public isomip\+\_\+initialization\+::isomip\+\_\+initialize\+\_\+sponges (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{PF,  }\item[{logical, intent(in)}]{use\+\_\+\+A\+LE,  }\item[{type(\mbox{\hyperlink{structmom__sponge_1_1sponge__cs}{sponge\+\_\+cs}}), pointer}]{C\+Sp,  }\item[{type(\mbox{\hyperlink{structmom__ale__sponge_1_1ale__sponge__cs}{ale\+\_\+sponge\+\_\+cs}}), pointer}]{A\+C\+Sp }\end{DoxyParamCaption})}



Sets up the the inverse restoration time (Idamp), and. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure containing pointers to any available thermodynamic fields, potential temperature and salinity or mixed layer density. Absent fields have N\+U\+LL ptrs. \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+ale} & If true, indicates model is in A\+LE mode \\
\hline
 & {\em csp} & Layer-\/mode sponge structure \\
\hline
 & {\em acsp} & A\+L\+E-\/mode sponge structure \\
\hline
\end{DoxyParams}


Definition at line 424 of file I\+S\+O\+M\+I\+P\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{425   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{    !< The ocean's grid structure.}}
\DoxyCodeLine{426   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean's vertical grid structure.}}
\DoxyCodeLine{427   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{428   \textcolor{keywordtype}{type}(thermo\_var\_ptrs), \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure containing pointers}}
\DoxyCodeLine{429 \textcolor{comment}{                                            !! to any available thermodynamic}}
\DoxyCodeLine{430 \textcolor{comment}{                                            !! fields, potential temperature and}}
\DoxyCodeLine{431 \textcolor{comment}{                                            !! salinity or mixed layer density.}}
\DoxyCodeLine{432 \textcolor{comment}{                                            !! Absent fields have NULL ptrs.}}
\DoxyCodeLine{433   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: PF\textcolor{comment}{   !< A structure indicating the}}
\DoxyCodeLine{434 \textcolor{comment}{                                            !! open file to parse for model}}
\DoxyCodeLine{435 \textcolor{comment}{                                            !! parameter values.}}
\DoxyCodeLine{436   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: use\_ALE\textcolor{comment}{            !< If true, indicates model is in ALE mode}}
\DoxyCodeLine{437   \textcolor{keywordtype}{type}(sponge\_CS),   \textcolor{keywordtype}{pointer}    :: CSp\textcolor{comment}{      !< Layer-\/mode sponge structure}}
\DoxyCodeLine{438   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),   \textcolor{keywordtype}{pointer}    :: ACSp\textcolor{comment}{ !< ALE-\/mode sponge structure}}
\DoxyCodeLine{439   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{440 \textcolor{keywordtype}{  real} :: T(SZI\_(G),SZJ\_(G),SZK\_(G))  \textcolor{comment}{! A temporary array for temp [degC]}}
\DoxyCodeLine{441 \textcolor{keywordtype}{  real} :: S(SZI\_(G),SZJ\_(G),SZK\_(G))  \textcolor{comment}{! A temporary array for salt [ppt]}}
\DoxyCodeLine{442   \textcolor{comment}{! real :: RHO(SZI\_(G),SZJ\_(G),SZK\_(G))  ! A temporary array for RHO [R \string~> kg m-\/3]}}
\DoxyCodeLine{443 \textcolor{keywordtype}{  real} :: h(SZI\_(G),SZJ\_(G),SZK\_(G))  \textcolor{comment}{! A temporary array for thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{444 \textcolor{keywordtype}{  real} :: Idamp(SZI\_(G),SZJ\_(G))    \textcolor{comment}{! The inverse damping rate [T-\/1 \string~> s-\/1].}}
\DoxyCodeLine{445 \textcolor{keywordtype}{  real} :: TNUDG                     \textcolor{comment}{! Nudging time scale [T \string~> s]}}
\DoxyCodeLine{446 \textcolor{keywordtype}{  real} :: S\_sur, T\_sur              \textcolor{comment}{! Surface salinity and temerature in sponge}}
\DoxyCodeLine{447 \textcolor{keywordtype}{  real} :: S\_bot, T\_bot              \textcolor{comment}{! Bottom salinity and temerature in sponge}}
\DoxyCodeLine{448 \textcolor{keywordtype}{  real} :: t\_ref, s\_ref              \textcolor{comment}{! reference T and S}}
\DoxyCodeLine{449 \textcolor{keywordtype}{  real} :: rho\_sur, rho\_bot          \textcolor{comment}{! Surface and bottom densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{450 \textcolor{keywordtype}{  real} :: rho\_range                 \textcolor{comment}{! The range of densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{451 \textcolor{keywordtype}{  real} :: dT\_dz, dS\_dz              \textcolor{comment}{! Gradients of T and S in degC/Z and PPT/Z.}}
\DoxyCodeLine{452 }
\DoxyCodeLine{453 \textcolor{keywordtype}{  real} :: e0(SZK\_(G)+1)             \textcolor{comment}{! The resting interface heights [Z \string~> m], usually}}
\DoxyCodeLine{454                                     \textcolor{comment}{! negative because it is positive upward.}}
\DoxyCodeLine{455 \textcolor{keywordtype}{  real} :: eta1D(SZK\_(G)+1)          \textcolor{comment}{! Interface height relative to the sea surface, positive upward [Z \string~> m].}}
\DoxyCodeLine{456 \textcolor{keywordtype}{  real} :: eta(SZI\_(G),SZJ\_(G),SZK\_(G)+1) \textcolor{comment}{! A temporary array for eta [Z \string~> m].}}
\DoxyCodeLine{457 \textcolor{keywordtype}{  real} :: min\_depth, dummy1, z}
\DoxyCodeLine{458 \textcolor{keywordtype}{  real} :: rho\_dummy, min\_thickness, rho\_tmp, xi0}
\DoxyCodeLine{459   \textcolor{keywordtype}{character(len=40)} :: verticalCoordinate, filename, state\_file}
\DoxyCodeLine{460   \textcolor{keywordtype}{character(len=40)} :: temp\_var, salt\_var, eta\_var, inputdir}
\DoxyCodeLine{461 }
\DoxyCodeLine{462   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}ISOMIP\_initialize\_sponges"{}} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{463   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, isd, ied, jsd, jed, nz}
\DoxyCodeLine{464 }
\DoxyCodeLine{465   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{466   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{467 }
\DoxyCodeLine{468   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}MIN\_THICKNESS"{}}, min\_thickness, \textcolor{stringliteral}{"{}Minimum layer thickness"{}}, \&}
\DoxyCodeLine{469                  units=\textcolor{stringliteral}{"{}m"{}}, default=1.e-\/3, scale=us\%m\_to\_Z)}
\DoxyCodeLine{470 }
\DoxyCodeLine{471   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}REGRIDDING\_COORDINATE\_MODE"{}}, verticalcoordinate, \&}
\DoxyCodeLine{472             default=default\_coordinate\_mode)}
\DoxyCodeLine{473 }
\DoxyCodeLine{474   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}ISOMIP\_TNUDG"{}}, tnudg, \textcolor{stringliteral}{"{}Nudging time scale for sponge layers (days)"{}}, \&}
\DoxyCodeLine{475                  default=0.0, scale=86400.0*us\%s\_to\_T)}
\DoxyCodeLine{476 }
\DoxyCodeLine{477   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}T\_REF"{}}, t\_ref, \textcolor{stringliteral}{"{}Reference temperature"{}}, default=10.0, \&}
\DoxyCodeLine{478                  do\_not\_log=.true.)}
\DoxyCodeLine{479 }
\DoxyCodeLine{480   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}S\_REF"{}}, s\_ref, \textcolor{stringliteral}{"{}Reference salinity"{}}, default=35.0, \&}
\DoxyCodeLine{481                  do\_not\_log=.true.)}
\DoxyCodeLine{482 }
\DoxyCodeLine{483   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}ISOMIP\_S\_SUR\_SPONGE"{}}, s\_sur, \&}
\DoxyCodeLine{484                  \textcolor{stringliteral}{"{}Surface salinity in sponge layer."{}}, units=\textcolor{stringliteral}{"{}ppt"{}}, default=s\_ref) \textcolor{comment}{! units="{}ppt"{})}}
\DoxyCodeLine{485 }
\DoxyCodeLine{486   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}ISOMIP\_S\_BOT\_SPONGE"{}}, s\_bot, \&}
\DoxyCodeLine{487                  \textcolor{stringliteral}{"{}Bottom salinity in sponge layer."{}}, units=\textcolor{stringliteral}{"{}ppt"{}}, default=s\_ref) \textcolor{comment}{! units="{}ppt"{})}}
\DoxyCodeLine{488 }
\DoxyCodeLine{489   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}ISOMIP\_T\_SUR\_SPONGE"{}}, t\_sur, \&}
\DoxyCodeLine{490                  \textcolor{stringliteral}{"{}Surface temperature in sponge layer."{}}, units=\textcolor{stringliteral}{"{}degC"{}}, default=t\_ref) \textcolor{comment}{! units="{}degC"{})}}
\DoxyCodeLine{491 }
\DoxyCodeLine{492   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}ISOMIP\_T\_BOT\_SPONGE"{}}, t\_bot, \&}
\DoxyCodeLine{493                  \textcolor{stringliteral}{"{}Bottom temperature in sponge layer."{}}, units=\textcolor{stringliteral}{"{}degC"{}}, default=t\_ref) \textcolor{comment}{! units="{}degC"{})}}
\DoxyCodeLine{494 }
\DoxyCodeLine{495   t(:,:,:) = 0.0 ; s(:,:,:) = 0.0 ; idamp(:,:) = 0.0 \textcolor{comment}{!; RHO(:,:,:) = 0.0}}
\DoxyCodeLine{496 }
\DoxyCodeLine{497 \textcolor{comment}{!   Set up sponges for ISOMIP configuration}}
\DoxyCodeLine{498   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}MINIMUM\_DEPTH"{}}, min\_depth, \&}
\DoxyCodeLine{499                  \textcolor{stringliteral}{"{}The minimum depth of the ocean."{}}, units=\textcolor{stringliteral}{"{}m"{}}, default=0.0, scale=us\%m\_to\_Z)}
\DoxyCodeLine{500 }
\DoxyCodeLine{501   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(csp)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{502         \textcolor{stringliteral}{"{}ISOMIP\_initialize\_sponges called with an associated control structure."{}})}
\DoxyCodeLine{503   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(acsp)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{504         \textcolor{stringliteral}{"{}ISOMIP\_initialize\_sponges called with an associated ALE-\/sponge control structure."{}})}
\DoxyCodeLine{505 }
\DoxyCodeLine{506   \textcolor{comment}{!  Here the inverse damping time [T-\/1 \string~> s-\/1], is set. Set Idamp to 0}}
\DoxyCodeLine{507   \textcolor{comment}{!  wherever there is no sponge, and the subroutines that are called}}
\DoxyCodeLine{508   \textcolor{comment}{!  will automatically set up the sponges only where Idamp is positive}}
\DoxyCodeLine{509   \textcolor{comment}{!  and mask2dT is 1.}}
\DoxyCodeLine{510 }
\DoxyCodeLine{511   \textcolor{keywordflow}{do} i=is,ie; \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{512     \textcolor{keywordflow}{if} (g\%bathyT(i,j) <= min\_depth) \textcolor{keywordflow}{then}}
\DoxyCodeLine{513       idamp(i,j) = 0.0}
\DoxyCodeLine{514     \textcolor{keywordflow}{elseif} (g\%geoLonT(i,j) >= 790.0 .AND. g\%geoLonT(i,j) <= 800.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{515       dummy1 = (g\%geoLonT(i,j)-\/790.0)/(800.0-\/790.0)}
\DoxyCodeLine{516       idamp(i,j) = (1.0/tnudg) * max(0.0,dummy1)}
\DoxyCodeLine{517     \textcolor{keywordflow}{else}}
\DoxyCodeLine{518       idamp(i,j) = 0.0}
\DoxyCodeLine{519 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{520 }
\DoxyCodeLine{521 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{522 }
\DoxyCodeLine{523   \textcolor{comment}{! Compute min/max density using T\_SUR/S\_SUR and T\_BOT/S\_BOT}}
\DoxyCodeLine{524   \textcolor{keyword}{call }calculate\_density(t\_sur, s\_sur, 0.0, rho\_sur, tv\%eqn\_of\_state)}
\DoxyCodeLine{525   \textcolor{comment}{!write (mesg,*) 'Surface density in sponge:', rho\_sur}}
\DoxyCodeLine{526   \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{527   \textcolor{keyword}{call }calculate\_density(t\_bot, s\_bot, 0.0, rho\_bot, tv\%eqn\_of\_state)}
\DoxyCodeLine{528   \textcolor{comment}{!write (mesg,*) 'Bottom density in sponge:', rho\_bot}}
\DoxyCodeLine{529   \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{530   rho\_range = rho\_bot -\/ rho\_sur}
\DoxyCodeLine{531   \textcolor{comment}{!write (mesg,*) 'Density range in sponge:', rho\_range}}
\DoxyCodeLine{532   \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{533 }
\DoxyCodeLine{534   \textcolor{keywordflow}{if} (use\_ale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{535 }
\DoxyCodeLine{536     \textcolor{keywordflow}{select case} ( coordinatemode(verticalcoordinate) )}
\DoxyCodeLine{537 }
\DoxyCodeLine{538      \textcolor{keywordflow}{case} ( regridding\_rho )}
\DoxyCodeLine{539        \textcolor{comment}{! Construct notional interface positions}}
\DoxyCodeLine{540        e0(1) = 0.}
\DoxyCodeLine{541        \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{542          e0(k) = -\/g\%max\_depth * ( 0.5 * ( gv\%Rlay(k-\/1) + gv\%Rlay(k) ) -\/ rho\_sur ) / rho\_range}
\DoxyCodeLine{543          e0(k) = min( 0., e0(k) ) \textcolor{comment}{! Bound by surface}}
\DoxyCodeLine{544          e0(k) = max( -\/g\%max\_depth, e0(k) ) \textcolor{comment}{! Bound by possible deepest point in model}}
\DoxyCodeLine{545          \textcolor{comment}{! write(mesg,*) 'G\%max\_depth,GV\%Rlay(k-\/1),GV\%Rlay(k),e0(k)',\&}}
\DoxyCodeLine{546          \textcolor{comment}{!       G\%max\_depth,GV\%Rlay(k-\/1),GV\%Rlay(k),e0(k)}}
\DoxyCodeLine{547          \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{548 \textcolor{keywordflow}{       enddo}}
\DoxyCodeLine{549        e0(nz+1) = -\/g\%max\_depth}
\DoxyCodeLine{550 }
\DoxyCodeLine{551        \textcolor{comment}{! Calculate thicknesses}}
\DoxyCodeLine{552        \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{553          eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{554          \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{555            eta1d(k) = e0(k)}
\DoxyCodeLine{556            \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{557              eta1d(k) = eta1d(k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{558              h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{559            \textcolor{keywordflow}{else}}
\DoxyCodeLine{560              h(i,j,k) = gv\%Z\_to\_H*(eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{561 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{562 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{563 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{564 }
\DoxyCodeLine{565      \textcolor{keywordflow}{case} ( regridding\_zstar, regridding\_sigma\_shelf\_zstar )   \textcolor{comment}{! Initial thicknesses for z coordinates}}
\DoxyCodeLine{566        \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{567          eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{568          \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{569            eta1d(k) =  -\/g\%max\_depth * real(k-\/1) / real(nz)}
\DoxyCodeLine{570            \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + min\_thickness)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{571              eta1d(k) = eta1d(k+1) + min\_thickness}
\DoxyCodeLine{572              h(i,j,k) = min\_thickness * gv\%Z\_to\_H}
\DoxyCodeLine{573            \textcolor{keywordflow}{else}}
\DoxyCodeLine{574              h(i,j,k) = gv\%Z\_to\_H*(eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{575 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{576 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{577 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{578 }
\DoxyCodeLine{579       \textcolor{keywordflow}{case} ( regridding\_sigma )             \textcolor{comment}{! Initial thicknesses for sigma coordinates}}
\DoxyCodeLine{580         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{581           h(i,j,:) = gv\%Z\_to\_H * (g\%bathyT(i,j) / dfloat(nz))}
\DoxyCodeLine{582 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{583 }
\DoxyCodeLine{584 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{585          \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"{}ISOMIP\_initialize\_sponges: "{}}// \&}
\DoxyCodeLine{586          \textcolor{stringliteral}{"{}Unrecognized i.c. setup -\/ set REGRIDDING\_COORDINATE\_MODE"{}})}
\DoxyCodeLine{587 }
\DoxyCodeLine{588 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{589 }
\DoxyCodeLine{590     \textcolor{comment}{!  This call sets up the damping rates and interface heights.}}
\DoxyCodeLine{591     \textcolor{comment}{!  This sets the inverse damping timescale fields in the sponges.}}
\DoxyCodeLine{592     \textcolor{keyword}{call }initialize\_ale\_sponge(idamp, g, pf, acsp, h, nz)}
\DoxyCodeLine{593 }
\DoxyCodeLine{594     ds\_dz = (s\_sur -\/ s\_bot) / g\%max\_depth}
\DoxyCodeLine{595     dt\_dz = (t\_sur -\/ t\_bot) / g\%max\_depth}
\DoxyCodeLine{596     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{597       xi0 = -\/g\%bathyT(i,j)}
\DoxyCodeLine{598       \textcolor{keywordflow}{do} k = nz,1,-\/1}
\DoxyCodeLine{599         xi0 = xi0 + 0.5 * h(i,j,k) * gv\%H\_to\_Z \textcolor{comment}{! Depth in middle of layer}}
\DoxyCodeLine{600         s(i,j,k) = s\_sur + ds\_dz * xi0}
\DoxyCodeLine{601         t(i,j,k) = t\_sur + dt\_dz * xi0}
\DoxyCodeLine{602         xi0 = xi0 + 0.5 * h(i,j,k) * gv\%H\_to\_Z \textcolor{comment}{! Depth at top of layer}}
\DoxyCodeLine{603 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{604 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{605     \textcolor{comment}{! for debugging}}
\DoxyCodeLine{606     \textcolor{comment}{!i=G\%iec; j=G\%jec}}
\DoxyCodeLine{607     \textcolor{comment}{!do k = 1,nz}}
\DoxyCodeLine{608     \textcolor{comment}{!  call calculate\_density(T(i,j,k),S(i,j,k),0.0,rho\_tmp,tv\%eqn\_of\_state, scale=US\%kg\_m3\_to\_R)}}
\DoxyCodeLine{609     \textcolor{comment}{!  write(mesg,*) 'Sponge -\/ k,h,T,S,rho,Rlay',k,h(i,j,k),T(i,j,k),S(i,j,k),rho\_tmp,GV\%Rlay(k)}}
\DoxyCodeLine{610     \textcolor{comment}{!  call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{611     \textcolor{comment}{!enddo}}
\DoxyCodeLine{612 }
\DoxyCodeLine{613     \textcolor{comment}{!   Now register all of the fields which are damped in the sponge.   !}}
\DoxyCodeLine{614     \textcolor{comment}{! By default, momentum is advected vertically within the sponge, but !}}
\DoxyCodeLine{615     \textcolor{comment}{! momentum is typically not damped within the sponge.                !}}
\DoxyCodeLine{616 }
\DoxyCodeLine{617     \textcolor{comment}{!  The remaining calls to set\_up\_sponge\_field can be in any order. !}}
\DoxyCodeLine{618     \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(tv\%T) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{619       \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(t, g, tv\%T, acsp)}
\DoxyCodeLine{620 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{621     \textcolor{keywordflow}{if} ( \textcolor{keyword}{associated}(tv\%S) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{622       \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(s, g, tv\%S, acsp)}
\DoxyCodeLine{623 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{624 }
\DoxyCodeLine{625   \textcolor{keywordflow}{else} \textcolor{comment}{! layer mode}}
\DoxyCodeLine{626     \textcolor{comment}{! 1) Read eta, salt and temp from IC file}}
\DoxyCodeLine{627     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}INPUTDIR"{}}, inputdir, default=\textcolor{stringliteral}{"{}."{}})}
\DoxyCodeLine{628     inputdir = slasher(inputdir)}
\DoxyCodeLine{629     \textcolor{comment}{! GM: get two different files, one with temp and one with salt values}}
\DoxyCodeLine{630     \textcolor{comment}{! this is work around to avoid having wrong values near the surface}}
\DoxyCodeLine{631     \textcolor{comment}{! because of the FIT\_SALINITY option. To get salt values right in the}}
\DoxyCodeLine{632     \textcolor{comment}{! sponge, FIT\_SALINITY=False. The oposite is true for temp. One can}}
\DoxyCodeLine{633     \textcolor{comment}{! combined the *correct* temp and salt values in one file instead.}}
\DoxyCodeLine{634     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}ISOMIP\_SPONGE\_FILE"{}}, state\_file, \&}
\DoxyCodeLine{635               \textcolor{stringliteral}{"{}The name of the file with temps., salts. and interfaces to "{}}//\&}
\DoxyCodeLine{636               \textcolor{stringliteral}{"{}damp toward."{}}, fail\_if\_missing=.true.)}
\DoxyCodeLine{637     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}SPONGE\_PTEMP\_VAR"{}}, temp\_var, \&}
\DoxyCodeLine{638               \textcolor{stringliteral}{"{}The name of the potential temperature variable in "{}}//\&}
\DoxyCodeLine{639               \textcolor{stringliteral}{"{}SPONGE\_STATE\_FILE."{}}, default=\textcolor{stringliteral}{"{}Temp"{}})}
\DoxyCodeLine{640     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}SPONGE\_SALT\_VAR"{}}, salt\_var, \&}
\DoxyCodeLine{641               \textcolor{stringliteral}{"{}The name of the salinity variable in "{}}//\&}
\DoxyCodeLine{642               \textcolor{stringliteral}{"{}SPONGE\_STATE\_FILE."{}}, default=\textcolor{stringliteral}{"{}Salt"{}})}
\DoxyCodeLine{643     \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}SPONGE\_ETA\_VAR"{}}, eta\_var, \&}
\DoxyCodeLine{644               \textcolor{stringliteral}{"{}The name of the interface height variable in "{}}//\&}
\DoxyCodeLine{645               \textcolor{stringliteral}{"{}SPONGE\_STATE\_FILE."{}}, default=\textcolor{stringliteral}{"{}eta"{}})}
\DoxyCodeLine{646 }
\DoxyCodeLine{647     \textcolor{comment}{!read temp and eta}}
\DoxyCodeLine{648     filename = trim(inputdir)//trim(state\_file)}
\DoxyCodeLine{649     \textcolor{keywordflow}{if} (.not.file\_exists(filename, g\%Domain)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{650           \textcolor{stringliteral}{"{}ISOMIP\_initialize\_sponges: Unable to open "{}}//trim(filename))}
\DoxyCodeLine{651     \textcolor{keyword}{call }mom\_read\_data(filename, eta\_var, eta(:,:,:), g\%Domain, scale=us\%m\_to\_Z)}
\DoxyCodeLine{652     \textcolor{keyword}{call }mom\_read\_data(filename, temp\_var, t(:,:,:), g\%Domain)}
\DoxyCodeLine{653     \textcolor{keyword}{call }mom\_read\_data(filename, salt\_var, s(:,:,:), g\%Domain)}
\DoxyCodeLine{654 }
\DoxyCodeLine{655     \textcolor{comment}{! for debugging}}
\DoxyCodeLine{656     \textcolor{comment}{!i=G\%iec; j=G\%jec}}
\DoxyCodeLine{657     \textcolor{comment}{!do k = 1,nz}}
\DoxyCodeLine{658     \textcolor{comment}{!  call calculate\_density(T(i,j,k),S(i,j,k),0.0,rho\_tmp,tv\%eqn\_of\_state, scale=US\%kg\_m3\_to\_R)}}
\DoxyCodeLine{659     \textcolor{comment}{!  write(mesg,*) 'Sponge -\/ k,eta,T,S,rho,Rlay',k,eta(i,j,k),T(i,j,k),\&}}
\DoxyCodeLine{660     \textcolor{comment}{!              S(i,j,k),rho\_tmp,GV\%Rlay(k)}}
\DoxyCodeLine{661     \textcolor{comment}{!  call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{662     \textcolor{comment}{!enddo}}
\DoxyCodeLine{663 }
\DoxyCodeLine{664     \textcolor{comment}{! Set the inverse damping rates so that the model will know where to}}
\DoxyCodeLine{665     \textcolor{comment}{! apply the sponges, along with the interface heights.}}
\DoxyCodeLine{666     \textcolor{keyword}{call }initialize\_sponge(idamp, eta, g, pf, csp, gv)}
\DoxyCodeLine{667     \textcolor{comment}{! Apply sponge in tracer fields}}
\DoxyCodeLine{668     \textcolor{keyword}{call }set\_up\_sponge\_field(t, tv\%T, g, nz, csp)}
\DoxyCodeLine{669     \textcolor{keyword}{call }set\_up\_sponge\_field(s, tv\%S, g, nz, csp)}
\DoxyCodeLine{670 }
\DoxyCodeLine{671 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{672 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceisomip__initialization_ac90d1dbdbf22f4cf30de1452efd29d52}\label{namespaceisomip__initialization_ac90d1dbdbf22f4cf30de1452efd29d52}} 
\index{isomip\_initialization@{isomip\_initialization}!isomip\_initialize\_temperature\_salinity@{isomip\_initialize\_temperature\_salinity}}
\index{isomip\_initialize\_temperature\_salinity@{isomip\_initialize\_temperature\_salinity}!isomip\_initialization@{isomip\_initialization}}
\doxysubsubsection{\texorpdfstring{isomip\_initialize\_temperature\_salinity()}{isomip\_initialize\_temperature\_salinity()}}
{\footnotesize\ttfamily subroutine, public isomip\+\_\+initialization\+::isomip\+\_\+initialize\+\_\+temperature\+\_\+salinity (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,  g \%ke), intent(out)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,  g \%ke), intent(out)}]{S,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,  g \%ke), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}}), pointer}]{eqn\+\_\+of\+\_\+state,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



Initial values for temperature and salinity. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em t} & Potential temperature \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em s} & Salinity \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
 & {\em eqn\+\_\+of\+\_\+state} & Equation of state structure \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing T \& S. \\
\hline
\end{DoxyParams}


Definition at line 253 of file I\+S\+O\+M\+I\+P\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{255   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< Ocean grid structure}}
\DoxyCodeLine{256   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{ !< Vertical grid structure}}
\DoxyCodeLine{257   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{258 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{  !< Potential temperature [degC]}}
\DoxyCodeLine{259 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{  !< Salinity [ppt]}}
\DoxyCodeLine{260 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{  !< Layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{261   \textcolor{keywordtype}{type}(param\_file\_type),                     \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{262   \textcolor{keywordtype}{type}(EOS\_type),                            \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< Equation of state structure}}
\DoxyCodeLine{263   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{264 \textcolor{comment}{                                                      !! only read parameters without changing T \& S.}}
\DoxyCodeLine{265   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{266   \textcolor{keywordtype}{integer}   :: i, j, k, is, ie, js, je, nz, itt}
\DoxyCodeLine{267 \textcolor{keywordtype}{  real}      :: x, ds, dt}
\DoxyCodeLine{268 \textcolor{keywordtype}{  real}      :: rho\_sur, rho\_bot  \textcolor{comment}{! Surface and bottom densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{269 \textcolor{keywordtype}{  real}      :: xi0, xi1 \textcolor{comment}{! Heights in depth units [Z \string~> m].}}
\DoxyCodeLine{270 \textcolor{keywordtype}{  real}      :: S\_sur, S\_bot \textcolor{comment}{! Salinity at the surface and bottom [ppt]}}
\DoxyCodeLine{271 \textcolor{keywordtype}{  real}      :: T\_sur, T\_bot \textcolor{comment}{! Temperature at the bottom [degC]}}
\DoxyCodeLine{272 \textcolor{keywordtype}{  real}      :: dT\_dz  \textcolor{comment}{! Vertical gradient of temperature [degC Z-\/1 \string~> degC m-\/1].}}
\DoxyCodeLine{273 \textcolor{keywordtype}{  real}      :: dS\_dz  \textcolor{comment}{! Vertical gradient of salinity [ppt Z-\/1 \string~> ppt m-\/1].}}
\DoxyCodeLine{274 \textcolor{keywordtype}{  real}      :: z            \textcolor{comment}{! vertical position in z space [Z \string~> m]}}
\DoxyCodeLine{275   \textcolor{keywordtype}{character(len=256)} :: mesg \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{276   \textcolor{keywordtype}{character(len=40)} :: verticalCoordinate, density\_profile}
\DoxyCodeLine{277 \textcolor{keywordtype}{  real} :: rho\_tmp}
\DoxyCodeLine{278   \textcolor{keywordtype}{logical} :: just\_read       \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{279   \textcolor{keywordtype}{logical} :: fit\_salin       \textcolor{comment}{! If true, accept the prescribed temperature and fit the salinity.}}
\DoxyCodeLine{280 \textcolor{keywordtype}{  real} :: T0(SZK\_(G)), S0(SZK\_(G))}
\DoxyCodeLine{281 \textcolor{keywordtype}{  real} :: drho\_dT(SZK\_(G))   \textcolor{comment}{! Derivative of density with temperature [R degC-\/1 \string~> kg m-\/3 degC-\/1].}}
\DoxyCodeLine{282 \textcolor{keywordtype}{  real} :: drho\_dS(SZK\_(G))   \textcolor{comment}{! Derivative of density with salinity [R ppt-\/1 \string~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{283 \textcolor{keywordtype}{  real} :: rho\_guess(SZK\_(G)) \textcolor{comment}{! Potential density at T0 \& S0 [R \string~> kg m-\/3].}}
\DoxyCodeLine{284 \textcolor{keywordtype}{  real} :: pres(SZK\_(G))      \textcolor{comment}{! An array of the reference pressure [R L2 T-\/2 \string~> Pa]. (zero here)}}
\DoxyCodeLine{285 \textcolor{keywordtype}{  real} :: drho\_dT1           \textcolor{comment}{! A prescribed derivative of density with temperature [R degC-\/1 \string~> kg m-\/3 degC-\/1]}}
\DoxyCodeLine{286 \textcolor{keywordtype}{  real} :: drho\_dS1           \textcolor{comment}{! A prescribed derivative of density with salinity [R ppt-\/1 \string~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{287 \textcolor{keywordtype}{  real} :: T\_Ref, S\_Ref}
\DoxyCodeLine{288   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{289   pres(:) = 0.0}
\DoxyCodeLine{290 }
\DoxyCodeLine{291   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{292 }
\DoxyCodeLine{293   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}REGRIDDING\_COORDINATE\_MODE"{}}, verticalcoordinate, \&}
\DoxyCodeLine{294                  default=default\_coordinate\_mode, do\_not\_log=just\_read)}
\DoxyCodeLine{295   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_T\_SUR"{}},t\_sur, \&}
\DoxyCodeLine{296                  \textcolor{stringliteral}{"{}Temperature at the surface (interface)"{}}, units=\textcolor{stringliteral}{"{}degC"{}}, default=-\/1.9, do\_not\_log=just\_read)}
\DoxyCodeLine{297   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_S\_SUR"{}}, s\_sur, \&}
\DoxyCodeLine{298                  \textcolor{stringliteral}{"{}Salinity at the surface (interface)"{}}, units=\textcolor{stringliteral}{"{}ppt"{}}, default=33.8, do\_not\_log=just\_read)}
\DoxyCodeLine{299   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_T\_BOT"{}}, t\_bot, \&}
\DoxyCodeLine{300                  \textcolor{stringliteral}{"{}Temperature at the bottom (interface)"{}}, units=\textcolor{stringliteral}{"{}degC"{}}, default=-\/1.9, do\_not\_log=just\_read)}
\DoxyCodeLine{301   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_S\_BOT"{}}, s\_bot, \&}
\DoxyCodeLine{302                  \textcolor{stringliteral}{"{}Salinity at the bottom (interface)"{}}, units=\textcolor{stringliteral}{"{}ppt"{}}, default=34.55, do\_not\_log=just\_read)}
\DoxyCodeLine{303 }
\DoxyCodeLine{304   \textcolor{keyword}{call }calculate\_density(t\_sur, s\_sur, 0.0, rho\_sur, eqn\_of\_state)}
\DoxyCodeLine{305   \textcolor{comment}{! write(mesg,*) 'Density in the surface layer:', rho\_sur}}
\DoxyCodeLine{306   \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{307   \textcolor{keyword}{call }calculate\_density(t\_bot, s\_bot, 0.0, rho\_bot, eqn\_of\_state)}
\DoxyCodeLine{308   \textcolor{comment}{! write(mesg,*) 'Density in the bottom layer::', rho\_bot}}
\DoxyCodeLine{309   \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{310 }
\DoxyCodeLine{311   \textcolor{keywordflow}{select case} ( coordinatemode(verticalcoordinate) )}
\DoxyCodeLine{312 }
\DoxyCodeLine{313     \textcolor{keywordflow}{case} (  regridding\_rho, regridding\_zstar, regridding\_sigma\_shelf\_zstar, regridding\_sigma )}
\DoxyCodeLine{314       \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{315 }
\DoxyCodeLine{316       ds\_dz = (s\_sur -\/ s\_bot) / g\%max\_depth}
\DoxyCodeLine{317       dt\_dz = (t\_sur -\/ t\_bot) / g\%max\_depth}
\DoxyCodeLine{318       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{319         xi0 = -\/g\%bathyT(i,j)}
\DoxyCodeLine{320         \textcolor{keywordflow}{do} k = nz,1,-\/1}
\DoxyCodeLine{321           xi0 = xi0 + 0.5 * h(i,j,k) * gv\%H\_to\_Z \textcolor{comment}{! Depth in middle of layer}}
\DoxyCodeLine{322           s(i,j,k) = s\_sur + ds\_dz * xi0}
\DoxyCodeLine{323           t(i,j,k) = t\_sur + dt\_dz * xi0}
\DoxyCodeLine{324           xi0 = xi0 + 0.5 * h(i,j,k) * gv\%H\_to\_Z \textcolor{comment}{! Depth at top of layer}}
\DoxyCodeLine{325 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{326 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{327 }
\DoxyCodeLine{328     \textcolor{keywordflow}{case} ( regridding\_layer )}
\DoxyCodeLine{329       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}FIT\_SALINITY"{}}, fit\_salin, \&}
\DoxyCodeLine{330                   \textcolor{stringliteral}{"{}If true, accept the prescribed temperature and fit the "{}}//\&}
\DoxyCodeLine{331                   \textcolor{stringliteral}{"{}salinity; otherwise take salinity and fit temperature."{}}, \&}
\DoxyCodeLine{332                   default=.false., do\_not\_log=just\_read)}
\DoxyCodeLine{333       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DRHO\_DS"{}}, drho\_ds1, \&}
\DoxyCodeLine{334                   \textcolor{stringliteral}{"{}Partial derivative of density with salinity."{}}, \&}
\DoxyCodeLine{335                   units=\textcolor{stringliteral}{"{}kg m-\/3 PSU-\/1"{}}, scale=us\%kg\_m3\_to\_R, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{336       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DRHO\_DT"{}}, drho\_dt1, \&}
\DoxyCodeLine{337                   \textcolor{stringliteral}{"{}Partial derivative of density with temperature."{}}, \&}
\DoxyCodeLine{338                   units=\textcolor{stringliteral}{"{}kg m-\/3 K-\/1"{}}, scale=us\%kg\_m3\_to\_R, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{339       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}T\_REF"{}}, t\_ref, \&}
\DoxyCodeLine{340                   \textcolor{stringliteral}{"{}A reference temperature used in initialization."{}}, \&}
\DoxyCodeLine{341                   units=\textcolor{stringliteral}{"{}degC"{}}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{342       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}S\_REF"{}}, s\_ref, \&}
\DoxyCodeLine{343                   \textcolor{stringliteral}{"{}A reference salinity used in initialization."{}}, units=\textcolor{stringliteral}{"{}PSU"{}}, \&}
\DoxyCodeLine{344                   default=35.0, do\_not\_log=just\_read)}
\DoxyCodeLine{345       \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{346 }
\DoxyCodeLine{347       \textcolor{comment}{! write(mesg,*) 'read drho\_dS, drho\_dT', drho\_dS1, drho\_dT1}}
\DoxyCodeLine{348       \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{349 }
\DoxyCodeLine{350       ds\_dz = (s\_sur -\/ s\_bot) / g\%max\_depth}
\DoxyCodeLine{351       dt\_dz = (t\_sur -\/ t\_bot) / g\%max\_depth}
\DoxyCodeLine{352 }
\DoxyCodeLine{353       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{354         xi0 = 0.0}
\DoxyCodeLine{355         \textcolor{keywordflow}{do} k = 1,nz}
\DoxyCodeLine{356           \textcolor{comment}{!T0(k) = T\_Ref; S0(k) = S\_Ref}}
\DoxyCodeLine{357           xi1 = xi0 + 0.5 * h(i,j,k) * gv\%H\_to\_Z}
\DoxyCodeLine{358           s0(k) = s\_sur -\/ ds\_dz * xi1}
\DoxyCodeLine{359           t0(k) = t\_sur -\/ dt\_dz * xi1}
\DoxyCodeLine{360           xi0 = xi0 + h(i,j,k) * gv\%H\_to\_Z}
\DoxyCodeLine{361           \textcolor{comment}{! write(mesg,*) 'S,T,xi0,xi1,k',S0(k),T0(k),xi0,xi1,k}}
\DoxyCodeLine{362           \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{363 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{364 }
\DoxyCodeLine{365         \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state, (/1,1/) )}
\DoxyCodeLine{366         \textcolor{comment}{! write(mesg,*) 'computed drho\_dS, drho\_dT', drho\_dS(1), drho\_dT(1)}}
\DoxyCodeLine{367         \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{368         \textcolor{keyword}{call }calculate\_density(t0(1), s0(1), pres(1), rho\_guess(1), eqn\_of\_state)}
\DoxyCodeLine{369 }
\DoxyCodeLine{370         \textcolor{keywordflow}{if} (fit\_salin) \textcolor{keywordflow}{then}}
\DoxyCodeLine{371           \textcolor{comment}{! A first guess of the layers' salinity.}}
\DoxyCodeLine{372           \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{373             s0(k) = max(0.0, s0(1) + (gv\%Rlay(k) -\/ rho\_guess(1)) / drho\_ds1)}
\DoxyCodeLine{374 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{375           \textcolor{comment}{! Refine the guesses for each layer.}}
\DoxyCodeLine{376           \textcolor{keywordflow}{do} itt=1,6}
\DoxyCodeLine{377             \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, eqn\_of\_state)}
\DoxyCodeLine{378             \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state)}
\DoxyCodeLine{379             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{380               s0(k) = max(0.0, s0(k) + (gv\%Rlay(k) -\/ rho\_guess(k)) / drho\_ds1)}
\DoxyCodeLine{381 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{382 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{383 }
\DoxyCodeLine{384         \textcolor{keywordflow}{else}}
\DoxyCodeLine{385           \textcolor{comment}{! A first guess of the layers' temperatures.}}
\DoxyCodeLine{386           \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{387             t0(k) = t0(1) + (gv\%Rlay(k) -\/ rho\_guess(1)) / drho\_dt1}
\DoxyCodeLine{388 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{389 }
\DoxyCodeLine{390           \textcolor{keywordflow}{do} itt=1,6}
\DoxyCodeLine{391             \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, eqn\_of\_state)}
\DoxyCodeLine{392             \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state)}
\DoxyCodeLine{393             \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{394               t0(k) = t0(k) + (gv\%Rlay(k) -\/ rho\_guess(k)) / drho\_dt(k)}
\DoxyCodeLine{395 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{396 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{397 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{398 }
\DoxyCodeLine{399         \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{400           t(i,j,k) = t0(k) ; s(i,j,k) = s0(k)}
\DoxyCodeLine{401 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{402 }
\DoxyCodeLine{403 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{404 }
\DoxyCodeLine{405 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{406       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"{}isomip\_initialize: "{}}// \&}
\DoxyCodeLine{407       \textcolor{stringliteral}{"{}Unrecognized i.c. setup -\/ set REGRIDDING\_COORDINATE\_MODE"{}})}
\DoxyCodeLine{408 }
\DoxyCodeLine{409 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{410 }
\DoxyCodeLine{411   \textcolor{comment}{! for debugging}}
\DoxyCodeLine{412   \textcolor{comment}{!i=G\%iec; j=G\%jec}}
\DoxyCodeLine{413   \textcolor{comment}{!do k = 1,nz}}
\DoxyCodeLine{414   \textcolor{comment}{!  call calculate\_density(T(i,j,k),S(i,j,k),0.0,rho\_tmp,eqn\_of\_state, scale=US\%kg\_m3\_to\_R)}}
\DoxyCodeLine{415   \textcolor{comment}{!  write(mesg,*) 'k,h,T,S,rho,Rlay',k,h(i,j,k),T(i,j,k),S(i,j,k),rho\_tmp,GV\%Rlay(k)}}
\DoxyCodeLine{416   \textcolor{comment}{!  call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{417   \textcolor{comment}{!enddo}}
\DoxyCodeLine{418 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceisomip__initialization_a748a8a53677059ad0c1c88ff5d0339aa}\label{namespaceisomip__initialization_a748a8a53677059ad0c1c88ff5d0339aa}} 
\index{isomip\_initialization@{isomip\_initialization}!isomip\_initialize\_thickness@{isomip\_initialize\_thickness}}
\index{isomip\_initialize\_thickness@{isomip\_initialize\_thickness}!isomip\_initialization@{isomip\_initialization}}
\doxysubsubsection{\texorpdfstring{isomip\_initialize\_thickness()}{isomip\_initialize\_thickness()}}
{\footnotesize\ttfamily subroutine, public isomip\+\_\+initialization\+::isomip\+\_\+initialize\+\_\+thickness (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



Initialization of thicknesses. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure containing pointers to any available thermodynamic fields, including the eqn. of state. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 133 of file I\+S\+O\+M\+I\+P\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{134   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}}
\DoxyCodeLine{135   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}}
\DoxyCodeLine{136   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{          !< A dimensional unit scaling type}}
\DoxyCodeLine{137 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{138                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{139   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}}
\DoxyCodeLine{140 \textcolor{comment}{                                                      !! to parse for model parameter values.}}
\DoxyCodeLine{141   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}  :: tv\textcolor{comment}{          !< A structure containing pointers to any}}
\DoxyCodeLine{142 \textcolor{comment}{                                                      !! available thermodynamic fields, including}}
\DoxyCodeLine{143 \textcolor{comment}{                                                      !! the eqn. of state.}}
\DoxyCodeLine{144   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{145 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{146   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{147 \textcolor{keywordtype}{  real} :: e0(SZK\_(G)+1)   \textcolor{comment}{! The resting interface heights, in depth units [Z \string~> m],}}
\DoxyCodeLine{148                           \textcolor{comment}{!  usually negative because it is positive upward.}}
\DoxyCodeLine{149 \textcolor{keywordtype}{  real} :: eta1D(SZK\_(G)+1)\textcolor{comment}{! Interface height relative to the sea surface}}
\DoxyCodeLine{150                           \textcolor{comment}{! positive upward, in depth units [Z \string~> m].}}
\DoxyCodeLine{151   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, tmp1}
\DoxyCodeLine{152 \textcolor{keywordtype}{  real}    :: x}
\DoxyCodeLine{153 \textcolor{keywordtype}{  real}    :: min\_thickness, s\_sur, s\_bot, t\_sur, t\_bot}
\DoxyCodeLine{154 \textcolor{keywordtype}{  real}    :: rho\_sur, rho\_bot  \textcolor{comment}{! Surface and bottom densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{155 \textcolor{keywordtype}{  real}    :: rho\_range    \textcolor{comment}{! The range of densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{156   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{157   \textcolor{keywordtype}{character(len=256)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{158   \textcolor{keywordtype}{character(len=40)} :: verticalCoordinate}
\DoxyCodeLine{159 }
\DoxyCodeLine{160   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{161 }
\DoxyCodeLine{162   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{163 }
\DoxyCodeLine{164   \textcolor{keywordflow}{if} (.not.just\_read) \&}
\DoxyCodeLine{165     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"{}MOM\_initialization.F90, initialize\_thickness\_uniform: setting thickness"{}})}
\DoxyCodeLine{166 }
\DoxyCodeLine{167   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"{}MIN\_THICKNESS"{}}, min\_thickness, \&}
\DoxyCodeLine{168                  \textcolor{stringliteral}{'Minimum layer thickness'}, units=\textcolor{stringliteral}{'m'}, default=1.e-\/3, do\_not\_log=just\_read, scale=us\%m\_to\_Z)}
\DoxyCodeLine{169   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"{}REGRIDDING\_COORDINATE\_MODE"{}}, verticalcoordinate, \&}
\DoxyCodeLine{170                  default=default\_coordinate\_mode, do\_not\_log=just\_read)}
\DoxyCodeLine{171 }
\DoxyCodeLine{172   \textcolor{keywordflow}{select case} ( coordinatemode(verticalcoordinate) )}
\DoxyCodeLine{173 }
\DoxyCodeLine{174   \textcolor{keywordflow}{case} ( regridding\_layer, regridding\_rho ) \textcolor{comment}{! Initial thicknesses for isopycnal coordinates}}
\DoxyCodeLine{175     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_T\_SUR"{}}, t\_sur, \&}
\DoxyCodeLine{176                    \textcolor{stringliteral}{"{}Temperature at the surface (interface)"{}}, units=\textcolor{stringliteral}{"{}degC"{}}, default=-\/1.9, do\_not\_log=just\_read)}
\DoxyCodeLine{177     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_S\_SUR"{}}, s\_sur, \&}
\DoxyCodeLine{178                    \textcolor{stringliteral}{"{}Salinity at the surface (interface)"{}}, units=\textcolor{stringliteral}{"{}ppt"{}},  default=33.8, do\_not\_log=just\_read)}
\DoxyCodeLine{179     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_T\_BOT"{}}, t\_bot, \&}
\DoxyCodeLine{180                    \textcolor{stringliteral}{"{}Temperature at the bottom (interface)"{}}, units=\textcolor{stringliteral}{"{}degC"{}}, default=-\/1.9, do\_not\_log=just\_read)}
\DoxyCodeLine{181     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_S\_BOT"{}}, s\_bot,\&}
\DoxyCodeLine{182                    \textcolor{stringliteral}{"{}Salinity at the bottom (interface)"{}}, units=\textcolor{stringliteral}{"{}ppt"{}}, default=34.55, do\_not\_log=just\_read)}
\DoxyCodeLine{183 }
\DoxyCodeLine{184     \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{185 }
\DoxyCodeLine{186     \textcolor{comment}{! Compute min/max density using T\_SUR/S\_SUR and T\_BOT/S\_BOT}}
\DoxyCodeLine{187     \textcolor{keyword}{call }calculate\_density(t\_sur, s\_sur, 0.0, rho\_sur, tv\%eqn\_of\_state)}
\DoxyCodeLine{188     \textcolor{comment}{! write(mesg,*) 'Surface density is:', rho\_sur}}
\DoxyCodeLine{189     \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{190     \textcolor{keyword}{call }calculate\_density(t\_bot, s\_bot, 0.0, rho\_bot, tv\%eqn\_of\_state)}
\DoxyCodeLine{191     \textcolor{comment}{! write(mesg,*) 'Bottom density is:', rho\_bot}}
\DoxyCodeLine{192     \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{193     rho\_range = rho\_bot -\/ rho\_sur}
\DoxyCodeLine{194     \textcolor{comment}{! write(mesg,*) 'Density range is:', rho\_range}}
\DoxyCodeLine{195     \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{196 }
\DoxyCodeLine{197     \textcolor{comment}{! Construct notional interface positions}}
\DoxyCodeLine{198     e0(1) = 0.}
\DoxyCodeLine{199     \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{200       e0(k) = -\/g\%max\_depth * ( 0.5 * ( gv\%Rlay(k-\/1) + gv\%Rlay(k) ) -\/ rho\_sur ) / rho\_range}
\DoxyCodeLine{201       e0(k) = min( 0., e0(k) ) \textcolor{comment}{! Bound by surface}}
\DoxyCodeLine{202       e0(k) = max( -\/g\%max\_depth, e0(k) ) \textcolor{comment}{! Bound by possible deepest point in model}}
\DoxyCodeLine{203       \textcolor{comment}{! write(mesg,*) 'G\%max\_depth,GV\%Rlay(k-\/1),GV\%Rlay(k),e0(k)', \&}}
\DoxyCodeLine{204       \textcolor{comment}{!     G\%max\_depth,GV\%Rlay(k-\/1),GV\%Rlay(k),e0(k)}}
\DoxyCodeLine{205       \textcolor{comment}{! call MOM\_mesg(mesg,5)}}
\DoxyCodeLine{206 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{207     e0(nz+1) = -\/g\%max\_depth}
\DoxyCodeLine{208 }
\DoxyCodeLine{209     \textcolor{comment}{! Calculate thicknesses}}
\DoxyCodeLine{210     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{211       eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{212       \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{213         eta1d(k) = e0(k)}
\DoxyCodeLine{214         \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{215           eta1d(k) = eta1d(k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{216           h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{217         \textcolor{keywordflow}{else}}
\DoxyCodeLine{218           h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{219 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{220 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{221 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   \textcolor{keywordflow}{case} ( regridding\_zstar, regridding\_sigma\_shelf\_zstar )   \textcolor{comment}{! Initial thicknesses for z coordinates}}
\DoxyCodeLine{224     \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{225     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{226       eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{227       \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{228         eta1d(k) =  -\/g\%max\_depth * real(k-\/1) / real(nz)}
\DoxyCodeLine{229         \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + min\_thickness)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{230           eta1d(k) = eta1d(k+1) + min\_thickness}
\DoxyCodeLine{231           h(i,j,k) = gv\%Z\_to\_H * min\_thickness}
\DoxyCodeLine{232         \textcolor{keywordflow}{else}}
\DoxyCodeLine{233           h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{234 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{235 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{236 \textcolor{keywordflow}{   enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{237 }
\DoxyCodeLine{238   \textcolor{keywordflow}{case} ( regridding\_sigma )             \textcolor{comment}{! Initial thicknesses for sigma coordinates}}
\DoxyCodeLine{239     \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{240     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{241       h(i,j,:) = gv\%Z\_to\_H * g\%bathyT(i,j) / dfloat(nz)}
\DoxyCodeLine{242 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{243 }
\DoxyCodeLine{244 \textcolor{keywordflow}{  case default}}
\DoxyCodeLine{245       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"{}isomip\_initialize: "{}}// \&}
\DoxyCodeLine{246       \textcolor{stringliteral}{"{}Unrecognized i.c. setup -\/ set REGRIDDING\_COORDINATE\_MODE"{}})}
\DoxyCodeLine{247 }
\DoxyCodeLine{248 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{249 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceisomip__initialization_a7292729944785b82fbeb51a27029b1b3}\label{namespaceisomip__initialization_a7292729944785b82fbeb51a27029b1b3}} 
\index{isomip\_initialization@{isomip\_initialization}!isomip\_initialize\_topography@{isomip\_initialize\_topography}}
\index{isomip\_initialize\_topography@{isomip\_initialize\_topography}!isomip\_initialization@{isomip\_initialization}}
\doxysubsubsection{\texorpdfstring{isomip\_initialize\_topography()}{isomip\_initialize\_topography()}}
{\footnotesize\ttfamily subroutine, public isomip\+\_\+initialization\+::isomip\+\_\+initialize\+\_\+topography (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{D,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{real, intent(in)}]{max\+\_\+depth,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in), optional}]{US }\end{DoxyParamCaption})}



Initialization of topography for the I\+S\+O\+M\+IP configuration. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The dynamic horizontal grid type \\
\hline
\mbox{\texttt{ out}}  & {\em d} & Ocean bottom depth in m or Z if US is present \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+depth} & Maximum model depth in the units of D \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 44 of file I\+S\+O\+M\+I\+P\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{45   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),          \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The dynamic horizontal grid type}}
\DoxyCodeLine{46 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied,G\%jsd:G\%jed)}, \&}
\DoxyCodeLine{47                                    \textcolor{keywordtype}{intent(out)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}}
\DoxyCodeLine{48   \textcolor{keywordtype}{type}(param\_file\_type),           \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{49 \textcolor{keywordtype}{  real},                            \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{ !< Maximum model depth in the units of D}}
\DoxyCodeLine{50   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{51 }
\DoxyCodeLine{52   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{53 \textcolor{keywordtype}{  real} :: min\_depth \textcolor{comment}{! The minimum and maximum depths [Z \string~> m].}}
\DoxyCodeLine{54 \textcolor{keywordtype}{  real} :: m\_to\_Z  \textcolor{comment}{! A dimensional rescaling factor.}}
\DoxyCodeLine{55   \textcolor{comment}{! The following variables are used to set up the bathymetry in the ISOMIP example.}}
\DoxyCodeLine{56 \textcolor{keywordtype}{  real} :: bmax            \textcolor{comment}{! max depth of bedrock topography}}
\DoxyCodeLine{57 \textcolor{keywordtype}{  real} :: b0,b2,b4,b6     \textcolor{comment}{! first, second, third and fourth bedrock topography coeff}}
\DoxyCodeLine{58 \textcolor{keywordtype}{  real} :: xbar            \textcolor{comment}{! characteristic along-\/flow lenght scale of the bedrock}}
\DoxyCodeLine{59 \textcolor{keywordtype}{  real} :: dc              \textcolor{comment}{! depth of the trough compared with side walls [Z \string~> m].}}
\DoxyCodeLine{60 \textcolor{keywordtype}{  real} :: fc              \textcolor{comment}{! characteristic width of the side walls of the channel}}
\DoxyCodeLine{61 \textcolor{keywordtype}{  real} :: wc              \textcolor{comment}{! half-\/width of the trough}}
\DoxyCodeLine{62 \textcolor{keywordtype}{  real} :: ly              \textcolor{comment}{! domain width (across ice flow)}}
\DoxyCodeLine{63 \textcolor{keywordtype}{  real} :: bx, by          \textcolor{comment}{! dummy vatiables [Z \string~> m].}}
\DoxyCodeLine{64 \textcolor{keywordtype}{  real} :: xtil            \textcolor{comment}{! dummy vatiable}}
\DoxyCodeLine{65   \textcolor{keywordtype}{logical} :: is\_2D         \textcolor{comment}{! If true, use 2D setup}}
\DoxyCodeLine{66 \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{67 \textcolor{preprocessor}{\#include "{}version\_variable.h"{}}}
\DoxyCodeLine{68 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}ISOMIP\_initialize\_topography"{}} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{69   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{70   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{71   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{72 }
\DoxyCodeLine{73   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"{}  ISOMIP\_initialization.F90, ISOMIP\_initialize\_topography: setting topography"{}}, 5)}
\DoxyCodeLine{74 }
\DoxyCodeLine{75   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us\%m\_to\_Z}
\DoxyCodeLine{76 }
\DoxyCodeLine{77   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{78   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}MINIMUM\_DEPTH"{}}, min\_depth, \&}
\DoxyCodeLine{79                  \textcolor{stringliteral}{"{}The minimum depth of the ocean."{}}, units=\textcolor{stringliteral}{"{}m"{}}, default=0.0, scale=m\_to\_z)}
\DoxyCodeLine{80   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}ISOMIP\_2D"{}},is\_2d,\textcolor{stringliteral}{'If true, use a 2D setup.'}, default=.false.)}
\DoxyCodeLine{81 }
\DoxyCodeLine{82   \textcolor{comment}{! The following variables should be transformed into runtime parameters?}}
\DoxyCodeLine{83   bmax = 720.0*m\_to\_z ; dc = 500.0*m\_to\_z}
\DoxyCodeLine{84   b0 = -\/150.0*m\_to\_z ; b2 = -\/728.8*m\_to\_z ; b4 = 343.91*m\_to\_z ; b6 = -\/50.57*m\_to\_z}
\DoxyCodeLine{85   xbar = 300.0e3 ; fc = 4.0e3 ; wc = 24.0e3 ; ly = 80.0e3}
\DoxyCodeLine{86   bx = 0.0 ; by = 0.0 ; xtil = 0.0}
\DoxyCodeLine{87 }
\DoxyCodeLine{88 }
\DoxyCodeLine{89   \textcolor{keywordflow}{if} (is\_2d) \textcolor{keywordflow}{then}}
\DoxyCodeLine{90     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{91       \textcolor{comment}{! 2D setup}}
\DoxyCodeLine{92       xtil = g\%geoLonT(i,j)*1.0e3/xbar}
\DoxyCodeLine{93       \textcolor{comment}{!xtil = 450*1.0e3/xbar}}
\DoxyCodeLine{94       bx = b0 + b2*xtil**2 + b4*xtil**4 + b6*xtil**6}
\DoxyCodeLine{95       \textcolor{comment}{!by = (dc/(1.+exp(-\/2.*(G\%geoLatT(i,j)*1.0e3-\/ ly/2. -\/ wc)/fc))) + \&}}
\DoxyCodeLine{96       \textcolor{comment}{!        (dc/(1.+exp(2.*(G\%geoLatT(i,j)*1.0e3-\/ ly/2. + wc)/fc)))}}
\DoxyCodeLine{97 }
\DoxyCodeLine{98       \textcolor{comment}{! slice at y = 40 km}}
\DoxyCodeLine{99       by = (dc / (1.+exp(-\/2.*(40.0*1.0e3-\/ ly/2. -\/ wc)/fc))) + \&}
\DoxyCodeLine{100            (dc / (1.+exp(2.*(40.0*1.0e3-\/ ly/2. + wc)/fc)))}
\DoxyCodeLine{101 }
\DoxyCodeLine{102       d(i,j) = -\/max(bx+by, -\/bmax)}
\DoxyCodeLine{103       \textcolor{keywordflow}{if} (d(i,j) > max\_depth) d(i,j) = max\_depth}
\DoxyCodeLine{104       \textcolor{keywordflow}{if} (d(i,j) < min\_depth) d(i,j) = 0.5*min\_depth}
\DoxyCodeLine{105 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{106 }
\DoxyCodeLine{107   \textcolor{keywordflow}{else}}
\DoxyCodeLine{108     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{109       \textcolor{comment}{! 3D setup}}
\DoxyCodeLine{110       \textcolor{comment}{! ===== TEST =====}}
\DoxyCodeLine{111       \textcolor{comment}{!if (G\%geoLonT(i,j)<500.) then}}
\DoxyCodeLine{112       \textcolor{comment}{!  xtil = 500.*1.0e3/xbar}}
\DoxyCodeLine{113       \textcolor{comment}{!else}}
\DoxyCodeLine{114       \textcolor{comment}{!  xtil = G\%geoLonT(i,j)*1.0e3/xbar}}
\DoxyCodeLine{115       \textcolor{comment}{!endif}}
\DoxyCodeLine{116       \textcolor{comment}{! ===== TEST =====}}
\DoxyCodeLine{117 }
\DoxyCodeLine{118       xtil = g\%geoLonT(i,j)*1.0e3/xbar}
\DoxyCodeLine{119 }
\DoxyCodeLine{120       bx = b0 + b2*xtil**2 + b4*xtil**4 + b6*xtil**6}
\DoxyCodeLine{121       by = (dc / (1.+exp(-\/2.*(g\%geoLatT(i,j)*1.0e3-\/ ly/2. -\/ wc)/fc))) + \&}
\DoxyCodeLine{122            (dc / (1.+exp(2.*(g\%geoLatT(i,j)*1.0e3-\/ ly/2. + wc)/fc)))}
\DoxyCodeLine{123 }
\DoxyCodeLine{124       d(i,j) = -\/max(bx+by, -\/bmax)}
\DoxyCodeLine{125       \textcolor{keywordflow}{if} (d(i,j) > max\_depth) d(i,j) = max\_depth}
\DoxyCodeLine{126       \textcolor{keywordflow}{if} (d(i,j) < min\_depth) d(i,j) = 0.5*min\_depth}
\DoxyCodeLine{127 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{128 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{129 }

\end{DoxyCode}
