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


\subsection{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}{\tt http\+://www.\+geosci-\/model-\/dev-\/discuss.\+net/8/9859/2015/gmdd-\/8-\/9859-\/2015.\+pdf}. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \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 \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 \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 \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}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceisomip__initialization_a17eb636ac16e051364e1a96cc860d8e8}\label{namespaceisomip__initialization_a17eb636ac16e051364e1a96cc860d8e8}} 
character(len=40) \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}


\subsection{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}}
\subsubsection{\texorpdfstring{isomip\+\_\+initialize\+\_\+sponges()}{isomip\_initialize\_sponges()}}
{\footnotesize\ttfamily subroutine, public isomip\+\_\+initialization\+::isomip\+\_\+initialize\+\_\+sponges (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF,  }\item[{logical, intent(in)}]{use\+\_\+\+A\+LE,  }\item[{type(sponge\+\_\+cs), pointer}]{C\+Sp,  }\item[{type(ale\+\_\+sponge\+\_\+cs), pointer}]{A\+C\+Sp }\end{DoxyParamCaption})}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt 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{\tt in}  & {\em pf} & A structure indicating the open file to parse for model parameter values.\\
\hline
\mbox{\tt 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 425 of file I\+S\+O\+M\+I\+P\+\_\+initialization.\+F90.


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


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



Initialization of thicknesses. 


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


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


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


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


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