\hypertarget{MOM__ALE_8F90_source}{}\section{M\+O\+M\+\_\+\+A\+L\+E.\+F90}
\label{MOM__ALE_8F90_source}\index{/home/cermak/src/\+M\+O\+M6/src/\+A\+L\+E/\+M\+O\+M\+\_\+\+A\+L\+E.\+F90@{/home/cermak/src/\+M\+O\+M6/src/\+A\+L\+E/\+M\+O\+M\+\_\+\+A\+L\+E.\+F90}}

\begin{DoxyCode}
00001 \textcolor{comment}{!> This module contains the main regridding routines.}
00002 \textcolor{comment}{!!}
00003 \textcolor{comment}{!! Regridding comprises two steps:}
00004 \textcolor{comment}{!! 1. Interpolation and creation of a new grid based on target interface}
00005 \textcolor{comment}{!!    densities (or any other criterion).}
00006 \textcolor{comment}{!! 2. Remapping of quantities between old grid and new grid.}
00007 \textcolor{comment}{!!}
00008 \textcolor{comment}{!! Original module written by Laurent White, 2008.06.09}
\Hypertarget{MOM__ALE_8F90_source_l00009}\hyperlink{namespacemom__ale}{00009} \textcolor{keyword}{module} \hyperlink{namespacemom__ale}{mom\_ale}
00010 
00011 \textcolor{comment}{! This file is part of MOM6. See LICENSE.md for the license.}
00012 
00013 \textcolor{keywordtype}{use }mom\_debugging\textcolor{keywordtype}{,        only} : check\_column\_integrals
00014 \textcolor{keywordtype}{use }mom\_diag\_mediator\textcolor{keywordtype}{,    only} : register\_diag\_field, post\_data, diag\_ctrl
00015 \textcolor{keywordtype}{use }mom\_diag\_mediator\textcolor{keywordtype}{,    only} : time\_type, diag\_update\_remap\_grids
00016 \textcolor{keywordtype}{use }mom\_diag\_vkernels\textcolor{keywordtype}{,    only} : interpolate\_column, reintegrate\_column
00017 \textcolor{keywordtype}{use }mom\_domains\textcolor{keywordtype}{,          only} : create\_group\_pass, do\_group\_pass, group\_pass\_type
00018 \textcolor{keywordtype}{use }\hyperlink{namespacemom__eos}{mom\_eos}\textcolor{keywordtype}{,              only} : \hyperlink{interfacemom__eos_1_1calculate__density}{calculate\_density}
00019 \textcolor{keywordtype}{use }mom\_domains\textcolor{keywordtype}{,          only} : create\_group\_pass, do\_group\_pass, group\_pass\_type
00020 \textcolor{keywordtype}{use }mom\_error\_handler\textcolor{keywordtype}{,    only} : mom\_error, fatal, warning
00021 \textcolor{keywordtype}{use }mom\_error\_handler\textcolor{keywordtype}{,    only} : calltree\_showquery
00022 \textcolor{keywordtype}{use }mom\_error\_handler\textcolor{keywordtype}{,    only} : calltree\_enter, calltree\_leave, calltree\_waypoint
00023 \textcolor{keywordtype}{use }mom\_file\_parser\textcolor{keywordtype}{,      only} : get\_param, param\_file\_type, log\_param
00024 \textcolor{keywordtype}{use }mom\_io\textcolor{keywordtype}{,               only} : vardesc, var\_desc, fieldtype, single\_file
00025 \textcolor{keywordtype}{use }mom\_io\textcolor{keywordtype}{,               only} : create\_file, write\_field, close\_file
00026 \textcolor{keywordtype}{use }mom\_interface\_heights\textcolor{keywordtype}{,only} : find\_eta
00027 \textcolor{keywordtype}{use }mom\_open\_boundary\textcolor{keywordtype}{,    only} : ocean\_obc\_type, obc\_direction\_e, obc\_direction\_w
00028 \textcolor{keywordtype}{use }mom\_open\_boundary\textcolor{keywordtype}{,    only} : obc\_direction\_n, obc\_direction\_s
00029 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : initialize\_regridding, regridding\_main, end\_regridding
00030 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : uniformresolution
00031 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : inflate\_vanished\_layers\_old
00032 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : set\_target\_densities\_from\_gv, set\_target\_densities
00033 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : regriddingcoordinatemodedoc, default\_coordinate\_mode
00034 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : regriddinginterpschemedoc, regriddingdefaultinterpscheme
00035 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : regriddingdefaultboundaryextrapolation
00036 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : regriddingdefaultminthickness
00037 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : regridding\_cs, set\_regrid\_params
00038 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : getcoordinateinterfaces, getcoordinateresolution
00039 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : getcoordinateunits, getcoordinateshortname
00040 \textcolor{keywordtype}{use }mom\_regridding\textcolor{keywordtype}{,       only} : getstaticthickness
00041 \textcolor{keywordtype}{use }mom\_remapping\textcolor{keywordtype}{,        only} : initialize\_remapping, end\_remapping
00042 \textcolor{keywordtype}{use }mom\_remapping\textcolor{keywordtype}{,        only} : remapping\_core\_h, remapping\_core\_w
00043 \textcolor{keywordtype}{use }mom\_remapping\textcolor{keywordtype}{,        only} : remappingschemesdoc, remappingdefaultscheme
00044 \textcolor{keywordtype}{use }mom\_remapping\textcolor{keywordtype}{,        only} : remapping\_cs, dzfromh1h2
00045 \textcolor{keywordtype}{use }mom\_string\_functions\textcolor{keywordtype}{, only} : uppercase, extractword, extract\_integer
00046 \textcolor{keywordtype}{use }mom\_tracer\_registry\textcolor{keywordtype}{,  only} : tracer\_registry\_type, tracer\_type, mom\_tracer\_chkinv
00047 \textcolor{keywordtype}{use }\hyperlink{namespacemom__unit__scaling}{mom\_unit\_scaling}\textcolor{keywordtype}{,     only} : \hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}
00048 \textcolor{keywordtype}{use }mom\_variables\textcolor{keywordtype}{,        only} : ocean\_grid\_type, thermo\_var\_ptrs
00049 \textcolor{keywordtype}{use }mom\_verticalgrid\textcolor{keywordtype}{,     only} : get\_thickness\_units, verticalgrid\_type
00050 
00051 \textcolor{comment}{!use regrid\_consts,       only : coordinateMode, DEFAULT\_COORDINATE\_MODE}
00052 \textcolor{keywordtype}{use }regrid\_consts\textcolor{keywordtype}{,        only} : coordinateunits, coordinatemode, state\_dependent
00053 \textcolor{keywordtype}{use }regrid\_edge\_values\textcolor{keywordtype}{,   only} : edge\_values\_implicit\_h4
00054 \textcolor{keywordtype}{use }plm\_functions\textcolor{keywordtype}{,        only} : plm\_reconstruction, plm\_boundary\_extrapolation
00055 \textcolor{keywordtype}{use }plm\_functions\textcolor{keywordtype}{,        only} : plm\_extrapolate\_slope, plm\_monotonized\_slope, plm\_slope\_wa
00056 \textcolor{keywordtype}{use }ppm\_functions\textcolor{keywordtype}{,        only} : ppm\_reconstruction, ppm\_boundary\_extrapolation
00057 
00058 \textcolor{keywordtype}{implicit none} ; \textcolor{keywordtype}{private}
00059 \textcolor{preprocessor}{#include <MOM\_memory.h>}
00060 \textcolor{preprocessor}{}
00061 \textcolor{comment}{}
00062 \textcolor{comment}{!> ALE control structure}
\Hypertarget{MOM__ALE_8F90_source_l00063}\hyperlink{structmom__ale_1_1ale__cs}{00063} \textcolor{keyword}{type}, \textcolor{keyword}{public} :: \hyperlink{structmom__ale_1_1ale__cs}{ale\_cs} ; \textcolor{keywordtype}{private}
\Hypertarget{MOM__ALE_8F90_source_l00064}\hyperlink{structmom__ale_1_1ale__cs_a52a017062606d96d14de227090d85d8f}{00064}   \textcolor{keywordtype}{logical} :: remap\_uv\_using\_old\_alg\textcolor{comment}{ !< If true, uses the old "remapping via a delta z"}
00065 \textcolor{comment}{                                    !! method. If False, uses the new method that}
00066 \textcolor{comment}{                                    !! remaps between grids described by h.}
00067 
\Hypertarget{MOM__ALE_8F90_source_l00068}\hyperlink{structmom__ale_1_1ale__cs_a2b99af769873e03fb4af22e34ad2dbf6}{00068}   \textcolor{keywordtype}{real} :: regrid\_time\_scale\textcolor{comment}{ !< The time-scale used in blending between the current (old) grid}
00069 \textcolor{comment}{                            !! and the target (new) grid [T ~> s]}
00070 
\Hypertarget{MOM__ALE_8F90_source_l00071}\hyperlink{structmom__ale_1_1ale__cs_a161dc0ea45776b4cf41ccc2483faee92}{00071}   \textcolor{keywordtype}{type}(regridding\_cs) :: regridcs\textcolor{comment}{ !< Regridding parameters and work arrays}
\Hypertarget{MOM__ALE_8F90_source_l00072}\hyperlink{structmom__ale_1_1ale__cs_ad2f81c455ca72b611b2ae489ac83e3d2}{00072}   \textcolor{keywordtype}{type}(remapping\_cs)  :: remapcs\textcolor{comment}{  !< Remapping parameters and work arrays}
00073 
\Hypertarget{MOM__ALE_8F90_source_l00074}\hyperlink{structmom__ale_1_1ale__cs_a5df67f4add4f4cf6acf4a948c5cb4651}{00074}   \textcolor{keywordtype}{integer} :: nk\textcolor{comment}{             !< Used only for queries, not directly by this module}
00075 
\Hypertarget{MOM__ALE_8F90_source_l00076}\hyperlink{structmom__ale_1_1ale__cs_aec77a94648a600f69bcaf4eee636589e}{00076}   \textcolor{keywordtype}{logical} :: remap\_after\_initialization\textcolor{comment}{ !< Indicates whether to regrid/remap after initializing the state.}
00077 
\Hypertarget{MOM__ALE_8F90_source_l00078}\hyperlink{structmom__ale_1_1ale__cs_a4f5f9c5434cc5f162cf6c3042f72aee5}{00078}   \textcolor{keywordtype}{logical} :: answers\_2018\textcolor{comment}{   !< If true, use the order of arithmetic and expressions for remapping}
00079 \textcolor{comment}{                            !! that recover the answers from the end of 2018.  Otherwise, use more}
00080 \textcolor{comment}{                            !! robust and accurate forms of mathematically equivalent expressions.}
00081 
\Hypertarget{MOM__ALE_8F90_source_l00082}\hyperlink{structmom__ale_1_1ale__cs_af9bbc9d9a09b20959005900488dba7d6}{00082}   \textcolor{keywordtype}{logical} :: show\_call\_tree\textcolor{comment}{ !< For debugging}
00083 
00084   \textcolor{comment}{! for diagnostics}
\Hypertarget{MOM__ALE_8F90_source_l00085}\hyperlink{structmom__ale_1_1ale__cs_a4fc6ae9f6eaf7ce50d5ffc58bd1beeae}{00085}   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{pointer}           :: diag\textcolor{comment}{                          !< structure to regulate output}
\Hypertarget{MOM__ALE_8F90_source_l00086}\hyperlink{structmom__ale_1_1ale__cs_a26e1b976214057231484ce35a83c0fb4}{00086}   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: id\_tracer\_remap\_tendency\textcolor{comment}{      !< diagnostic id}
\Hypertarget{MOM__ALE_8F90_source_l00087}\hyperlink{structmom__ale_1_1ale__cs_ac2e23c2af8033aa8300e14e7560599f2}{00087}   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: id\_htracer\_remap\_tendency\textcolor{comment}{     !< diagnostic id}
\Hypertarget{MOM__ALE_8F90_source_l00088}\hyperlink{structmom__ale_1_1ale__cs_aa4cd6c01c0c35db270ae5d3e5629774a}{00088}   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: id\_htracer\_remap\_tendency\_2d\textcolor{comment}{  !< diagnostic id}
\Hypertarget{MOM__ALE_8F90_source_l00089}\hyperlink{structmom__ale_1_1ale__cs_a5ea678e5fa4e137c8096f7ebd508155a}{00089}   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: do\_tendency\_diag\textcolor{comment}{              !< flag for doing diagnostics}
\Hypertarget{MOM__ALE_8F90_source_l00090}\hyperlink{structmom__ale_1_1ale__cs_ad6f31ab7a30c7683f51a007165fe7639}{00090}   \textcolor{keywordtype}{integer}                            :: id\_dzregrid = -1\textcolor{comment}{              !< diagnostic id}
00091 
00092   \textcolor{comment}{! diagnostic for fields prior to applying ALE remapping}
\Hypertarget{MOM__ALE_8F90_source_l00093}\hyperlink{structmom__ale_1_1ale__cs_a10cfa343cd42477f7d341c912076dac6}{00093}   \textcolor{keywordtype}{integer} :: id\_u\_preale = -1\textcolor{comment}{ !< diagnostic id for zonal velocity before ALE.}
\Hypertarget{MOM__ALE_8F90_source_l00094}\hyperlink{structmom__ale_1_1ale__cs_afb33dbd3eafd12f5c6bb017b8976e298}{00094}   \textcolor{keywordtype}{integer} :: id\_v\_preale = -1\textcolor{comment}{ !< diagnostic id for meridional velocity before ALE.}
\Hypertarget{MOM__ALE_8F90_source_l00095}\hyperlink{structmom__ale_1_1ale__cs_ac2a354f2b69b96c1f3dc133ec65388f0}{00095}   \textcolor{keywordtype}{integer} :: id\_h\_preale = -1\textcolor{comment}{ !< diagnostic id for layer thicknesses before ALE.}
\Hypertarget{MOM__ALE_8F90_source_l00096}\hyperlink{structmom__ale_1_1ale__cs_ab7a26b94bac9e488d0fe59ddcf3d73f5}{00096}   \textcolor{keywordtype}{integer} :: id\_t\_preale = -1\textcolor{comment}{ !< diagnostic id for temperatures before ALE.}
\Hypertarget{MOM__ALE_8F90_source_l00097}\hyperlink{structmom__ale_1_1ale__cs_ac32331a3d7a425b6a99636e24d8d8612}{00097}   \textcolor{keywordtype}{integer} :: id\_s\_preale = -1\textcolor{comment}{ !< diagnostic id for salinities before ALE.}
\Hypertarget{MOM__ALE_8F90_source_l00098}\hyperlink{structmom__ale_1_1ale__cs_aeeae8ed6c7a4381bb7ed133e3be60159}{00098}   \textcolor{keywordtype}{integer} :: id\_e\_preale = -1\textcolor{comment}{ !< diagnostic id for interface heights before ALE.}
\Hypertarget{MOM__ALE_8F90_source_l00099}\hyperlink{structmom__ale_1_1ale__cs_aeadf73439f8499445c6b750099a70b48}{00099}   \textcolor{keywordtype}{integer} :: id\_vert\_remap\_h = -1\textcolor{comment}{      !< diagnostic id for layer thicknesses used for remapping}
\Hypertarget{MOM__ALE_8F90_source_l00100}\hyperlink{structmom__ale_1_1ale__cs_a1e837e000a4d699349c2ee7b0518a5db}{00100}   \textcolor{keywordtype}{integer} :: id\_vert\_remap\_h\_tendency = -1\textcolor{comment}{ !< diagnostic id for layer thickness tendency due to ALE}
00101 
00102 \textcolor{keyword}{end type}
00103 
00104 \textcolor{comment}{! Publicly available functions}
00105 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}{ale\_init}
00106 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}{ale\_end}
00107 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\_main}
00108 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\_main\_offline}
00109 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\_offline\_inputs}
00110 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{ale\_offline\_tracer\_final}
00111 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}{ale\_build\_grid}
00112 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{ale\_regrid\_accelerated}
00113 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\_remap\_scalar}
00114 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\_plm\_edge\_values}
00115 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_abedb087c760a6ac146735275638db58a}{ts\_plm\_edge\_values}
00116 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}{ts\_ppm\_edge\_values}
00117 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}{adjustgridforintegrity}
00118 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{ale\_initregridding}
00119 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}{ale\_getcoordinate}
00120 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}{ale\_getcoordinateunits}
00121 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}{ale\_writecoordinatefile}
00122 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}{ale\_updateverticalgridtype}
00123 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}{ale\_initthicknesstocoord}
00124 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\_update\_regrid\_weights}
00125 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{ale\_remap\_init\_conds}
00126 \textcolor{keywordtype}{public} \hyperlink{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}{ale\_register\_diags}
00127 
00128 \textcolor{comment}{! A note on unit descriptions in comments: MOM6 uses units that can be rescaled for dimensional}
00129 \textcolor{comment}{! consistency testing. These are noted in comments with units like Z, H, L, and T, along with}
00130 \textcolor{comment}{! their mks counterparts with notation like "a velocity [Z T-1 ~> m s-1]".  If the units}
00131 \textcolor{comment}{! vary with the Boussinesq approximation, the Boussinesq variant is given first.}
00132 
00133 \textcolor{keyword}{contains}
00134 \textcolor{comment}{}
00135 \textcolor{comment}{!> This routine is typically called (from initialize\_MOM in file MOM.F90)}
00136 \textcolor{comment}{!! before the main time integration loop to initialize the regridding stuff.}
00137 \textcolor{comment}{!! We read the MOM\_input file to register the values of different}
00138 \textcolor{comment}{!! regridding/remapping parameters.}
00139 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}{ale\_init}( param\_file, GV, US, max\_depth, CS)
\Hypertarget{MOM__ALE_8F90_source_l00140}\hyperlink{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}{00140}   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file}
00141   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{         !< Ocean vertical grid structure}
00142   \textcolor{keywordtype}{type}(\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{         !< A dimensional unit scaling type}
00143   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)} :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z ~> m].}
00144   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< Module control structure}
00145 
00146   \textcolor{comment}{! Local variables}
00147   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: dz
00148   \textcolor{keywordtype}{character(len=40)}               :: mdl = \textcolor{stringliteral}{"MOM\_ALE"} \textcolor{comment}{! This module's name.}
00149   \textcolor{keywordtype}{character(len=80)}               :: string \textcolor{comment}{! Temporary strings}
00150   \textcolor{keywordtype}{real}                            :: filter\_shallow\_depth, filter\_deep\_depth
00151   \textcolor{keywordtype}{logical}       :: default\_2018\_answers
00152   \textcolor{keywordtype}{logical}                         :: check\_reconstruction
00153   \textcolor{keywordtype}{logical}                         :: check\_remapping
00154   \textcolor{keywordtype}{logical}                         :: force\_bounds\_in\_subcell
00155   \textcolor{keywordtype}{logical}                         :: local\_logical
00156   \textcolor{keywordtype}{logical}                         :: remap\_boundary\_extrap
00157 
00158   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
00159     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ALE\_init called with an associated "}// &
00160                             \textcolor{stringliteral}{"control structure."})
00161     \textcolor{keywordflow}{return}
00162 \textcolor{keywordflow}{  endif}
00163   \textcolor{keyword}{allocate}(cs)
00164 
00165   cs%show\_call\_tree = calltree\_showquery()
00166   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_init(), MOM\_ALE.F90"})
00167 
00168   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_UV\_USING\_OLD\_ALG"}, cs%remap\_uv\_using\_old\_alg, &
00169                  \textcolor{stringliteral}{"If true, uses the old remapping-via-a-delta-z method for "}//&
00170                  \textcolor{stringliteral}{"remapping u and v. If false, uses the new method that remaps "}//&
00171                  \textcolor{stringliteral}{"between grids described by an old and new thickness."}, &
00172                  default=.false.)
00173 
00174   \textcolor{comment}{! Initialize and configure regridding}
00175   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{ale\_initregridding}(gv, us, max\_depth, param\_file, mdl, cs%regridCS)
00176 
00177   \textcolor{comment}{! Initialize and configure remapping}
00178   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, string, &
00179                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//&
00180                  \textcolor{stringliteral}{"for vertical remapping for all variables. "}//&
00181                  \textcolor{stringliteral}{"It can be one of the following schemes: "}//&
00182                  trim(remappingschemesdoc), default=remappingdefaultscheme)
00183   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_RECONSTRUCTIONS"}, check\_reconstruction, &
00184                  \textcolor{stringliteral}{"If true, cell-by-cell reconstructions are checked for "}//&
00185                  \textcolor{stringliteral}{"consistency and if non-monotonicity or an inconsistency is "}//&
00186                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)
00187   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_REMAPPING"}, check\_remapping, &
00188                  \textcolor{stringliteral}{"If true, the results of remapping are checked for "}//&
00189                  \textcolor{stringliteral}{"conservation and new extrema and if an inconsistency is "}//&
00190                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)
00191   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUND\_INTERMEDIATE\_VALUES"}, force\_bounds\_in\_subcell, &
00192                  \textcolor{stringliteral}{"If true, the values on the intermediate grid used for remapping "}//&
00193                  \textcolor{stringliteral}{"are forced to be bounded, which might not be the case due to "}//&
00194                  \textcolor{stringliteral}{"round off."}, default=.false.)
00195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUNDARY\_EXTRAP"}, remap\_boundary\_extrap, &
00196                  \textcolor{stringliteral}{"If true, values at the interfaces of boundary cells are "}//&
00197                  \textcolor{stringliteral}{"extrapolated instead of piecewise constant"}, default=.false.)
00198   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
00199                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
00200                  default=.false.)
00201   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs%answers\_2018, &
00202                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
00203                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
00204                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
00205   \textcolor{keyword}{call }initialize\_remapping( cs%remapCS, string, &
00206                              boundary\_extrapolation=remap\_boundary\_extrap, &
00207                              check\_reconstruction=check\_reconstruction, &
00208                              check\_remapping=check\_remapping, &
00209                              force\_bounds\_in\_subcell=force\_bounds\_in\_subcell, &
00210                              answers\_2018=cs%answers\_2018)
00211 
00212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_AFTER\_INITIALIZATION"}, cs%remap\_after\_initialization, &
00213                  \textcolor{stringliteral}{"If true, applies regridding and remapping immediately after "}//&
00214                  \textcolor{stringliteral}{"initialization so that the state is ALE consistent. This is a "}//&
00215                  \textcolor{stringliteral}{"legacy step and should not be needed if the initialization is "}//&
00216                  \textcolor{stringliteral}{"consistent with the coordinate mode."}, default=.true.)
00217 
00218   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_TIME\_SCALE"}, cs%regrid\_time\_scale, &
00219                  \textcolor{stringliteral}{"The time-scale used in blending between the current (old) grid "}//&
00220                  \textcolor{stringliteral}{"and the target (new) grid. A short time-scale favors the target "}//&
00221                  \textcolor{stringliteral}{"grid (0. or anything less than DT\_THERM) has no memory of the old "}//&
00222                  \textcolor{stringliteral}{"grid. A very long time-scale makes the model more Lagrangian."}, &
00223                  units=\textcolor{stringliteral}{"s"}, default=0., scale=us%s\_to\_T)
00224   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH"}, filter\_shallow\_depth, &
00225                  \textcolor{stringliteral}{"The depth above which no time-filtering is applied. Above this depth "}//&
00226                  \textcolor{stringliteral}{"final grid exactly matches the target (new) grid."}, &
00227                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv%m\_to\_H)
00228   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_DEEP\_DEPTH"}, filter\_deep\_depth, &
00229                  \textcolor{stringliteral}{"The depth below which full time-filtering is applied with time-scale "}//&
00230                  \textcolor{stringliteral}{"REGRID\_TIME\_SCALE. Between depths REGRID\_FILTER\_SHALLOW\_DEPTH and "}//&
00231                  \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH the filter weights adopt a cubic profile."}, &
00232                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv%m\_to\_H)
00233   \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, depth\_of\_time\_filter\_shallow=filter\_shallow\_depth, &
00234                          depth\_of\_time\_filter\_deep=filter\_deep\_depth)
00235   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_USE\_OLD\_DIRECTION"}, local\_logical, &
00236                  \textcolor{stringliteral}{"If true, the regridding ntegrates upwards from the bottom for "}//&
00237                  \textcolor{stringliteral}{"interface positions, much as the main model does. If false "}//&
00238                  \textcolor{stringliteral}{"regridding integrates downward, consistant with the remapping "}//&
00239                  \textcolor{stringliteral}{"code."}, default=.true., do\_not\_log=.true.)
00240   \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, integrate\_downward\_for\_e=.not.local\_logical)
00241 
00242   \textcolor{comment}{! Keep a record of values for subsequent queries}
00243   cs%nk = gv%ke
00244 
00245   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_init()"})
00246 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}{ale\_init}
00247 \textcolor{comment}{}
00248 \textcolor{comment}{!> Initialize diagnostics for the ALE module.}
00249 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}{ale\_register\_diags}(Time, G, GV, US, diag, CS)
\Hypertarget{MOM__ALE_8F90_source_l00250}\hyperlink{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}{00250}   \textcolor{keywordtype}{type}(time\_type),\textcolor{keywordtype}{target},     \textcolor{keywordtype}{intent(in)}  :: Time\textcolor{comment}{  !< Time structure}
00251   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{     !< Grid structure}
00252   \textcolor{keywordtype}{type}(\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}),      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{    !< A dimensional unit scaling type}
00253   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{    !< Ocean vertical grid structure}
00254   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(in)}  :: diag\textcolor{comment}{  !< Diagnostics control structure}
00255   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{pointer}                   :: CS\textcolor{comment}{    !< Module control structure}
00256 
00257   cs%diag => diag
00258 
00259   \textcolor{comment}{! These diagnostics of the state variables before ALE are useful for}
00260   \textcolor{comment}{! debugging the ALE code.}
00261   cs%id\_u\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_preale'}, diag%axesCuL, time, &
00262       \textcolor{stringliteral}{'Zonal velocity before remapping'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
00263   cs%id\_v\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_preale'}, diag%axesCvL, time, &
00264       \textcolor{stringliteral}{'Meridional velocity before remapping'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
00265   cs%id\_h\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_preale'}, diag%axesTL, time, &
00266       \textcolor{stringliteral}{'Layer Thickness before remapping'}, get\_thickness\_units(gv), &
00267       conversion=gv%H\_to\_MKS, v\_extensive=.true.)
00268   cs%id\_T\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'T\_preale'}, diag%axesTL, time, &
00269       \textcolor{stringliteral}{'Temperature before remapping'}, \textcolor{stringliteral}{'degC'})
00270   cs%id\_S\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'S\_preale'}, diag%axesTL, time, &
00271       \textcolor{stringliteral}{'Salinity before remapping'}, \textcolor{stringliteral}{'PSU'})
00272   cs%id\_e\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e\_preale'}, diag%axesTi, time, &
00273       \textcolor{stringliteral}{'Interface Heights before remapping'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
00274 
00275   cs%id\_dzRegrid = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'dzRegrid'},diag%axesTi,time, &
00276       \textcolor{stringliteral}{'Change in interface height due to ALE regridding'}, \textcolor{stringliteral}{'m'}, &
00277       conversion=gv%H\_to\_m)
00278   cs%id\_vert\_remap\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vert\_remap\_h'}, &
00279       diag%axestl, time, \textcolor{stringliteral}{'layer thicknesses after ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, &
00280       conversion=gv%H\_to\_m, v\_extensive=.true.)
00281   cs%id\_vert\_remap\_h\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'vert\_remap\_h\_tendency'},diag%axestl,time,
       &
00282       \textcolor{stringliteral}{'Layer thicknesses tendency due to ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, &
00283       conversion=gv%H\_to\_m*us%s\_to\_T, v\_extensive = .true.)
00284 
00285 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}{ale\_register\_diags}
00286 \textcolor{comment}{}
00287 \textcolor{comment}{!> Crudely adjust (initial) grid for integrity.}
00288 \textcolor{comment}{!! This routine is typically called (from initialize\_MOM in file MOM.F90)}
00289 \textcolor{comment}{!! before the main time integration loop to initialize the regridding stuff.}
00290 \textcolor{comment}{!! We read the MOM\_input file to register the values of different}
00291 \textcolor{comment}{!! regridding/remapping parameters.}
00292 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}{adjustgridforintegrity}( CS, G, GV, h )
\Hypertarget{MOM__ALE_8F90_source_l00293}\hyperlink{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}{00293}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),                              \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and
       options}
00294   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}
00295   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}
00296   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid thickness that}
00297 \textcolor{comment}{                                                                  !! are to be adjusted [H ~> m or kg-2]}
00298   \textcolor{keyword}{call }inflate\_vanished\_layers\_old( cs%regridCS, g, gv, h(:,:,:) )
00299 
00300 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}{adjustgridforintegrity}
00301 
00302 \textcolor{comment}{}
00303 \textcolor{comment}{!> End of regridding (memory deallocation).}
00304 \textcolor{comment}{!! This routine is typically called (from MOM\_end in file MOM.F90)}
00305 \textcolor{comment}{!! after the main time integration loop to deallocate the regridding stuff.}
00306 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}{ale\_end}(CS)
\Hypertarget{MOM__ALE_8F90_source_l00307}\hyperlink{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}{00307}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{  !< module control structure}
00308 
00309   \textcolor{comment}{! Deallocate memory used for the regridding}
00310   \textcolor{keyword}{call }end\_remapping( cs%remapCS )
00311   \textcolor{keyword}{call }end\_regridding( cs%regridCS )
00312 
00313   \textcolor{keyword}{deallocate}(cs)
00314 
00315 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}{ale\_end}
00316 \textcolor{comment}{}
00317 \textcolor{comment}{!> Takes care of (1) building a new grid and (2) remapping all variables between}
00318 \textcolor{comment}{!! the old grid and the new grid. The creation of the new grid can be based}
00319 \textcolor{comment}{!! on z coordinates, target interface densities, sigma coordinates or any}
00320 \textcolor{comment}{!! arbitrary coordinate system.}
00321 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\_main}( G, GV, US, h, u, v, tv, Reg, CS, OBC, dt, frac\_shelf\_h)
\Hypertarget{MOM__ALE_8F90_source_l00322}\hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{00322}   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}
00323   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}
00324   \textcolor{keywordtype}{type}(\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit
       scaling type}
00325   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid obtained after the}
00326 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg m-2]}
00327   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{   !< Zonal velocity field [L T-1 ~> m s-1]}
00328   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{   !< Meridional velocity field [L T-1 ~> m
       s-1]}
00329   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
00330   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{ !< Tracer registry structure}
00331   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),                               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and
       options}
00332   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}
00333   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main
       [T ~> s]}
00334   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf
       coverage}
00335   \textcolor{comment}{! Local variables}
00336   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}
00337   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: eta\_preale
00338   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: h\_new \textcolor{comment}{! New 3D grid obtained after last time step [H ~> m or
       kg-2]}
00339   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00340   \textcolor{keywordtype}{logical} :: ice\_shelf
00341 
00342   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00343 
00344   ice\_shelf = .false.
00345   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}
00346     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) ice\_shelf = .true.
00347 \textcolor{keywordflow}{  endif}
00348 
00349   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main(), MOM\_ALE.F90"})
00350 
00351   \textcolor{comment}{! These diagnostics of the state before ALE is applied are mostly used for debugging.}
00352   \textcolor{keywordflow}{if} (cs%id\_u\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_preale, u,    cs%diag)
00353   \textcolor{keywordflow}{if} (cs%id\_v\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_preale, v,    cs%diag)
00354   \textcolor{keywordflow}{if} (cs%id\_h\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_preale, h,    cs%diag)
00355   \textcolor{keywordflow}{if} (cs%id\_T\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_T\_preale, tv%T, cs%diag)
00356   \textcolor{keywordflow}{if} (cs%id\_S\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_S\_preale, tv%S, cs%diag)
00357   \textcolor{keywordflow}{if} (cs%id\_e\_preale > 0) \textcolor{keywordflow}{then}
00358     \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, eta\_preale)
00359     \textcolor{keyword}{call }post\_data(cs%id\_e\_preale, eta\_preale, cs%diag)
00360 \textcolor{keywordflow}{  endif}
00361 
00362   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00363     \textcolor{keyword}{call }\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\_update\_regrid\_weights}( dt, cs )
00364 \textcolor{keywordflow}{  endif}
00365   dzregrid(:,:,:) = 0.0
00366 
00367   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
00368   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
00369   \textcolor{keywordflow}{if} (ice\_shelf) \textcolor{keywordflow}{then}
00370      \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h)
00371   \textcolor{keywordflow}{else}
00372      \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid)
00373 \textcolor{keywordflow}{  endif}
00374 
00375   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\_grid}( g, gv, h, 0. )
00376 
00377   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})
00378 
00379   \textcolor{comment}{! The presence of dt is used for expediency to distinguish whether ALE\_main is being called during init}
00380   \textcolor{comment}{! or in the main loop. Tendency diagnostics in remap\_all\_state\_vars also rely on this logic.}
00381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00382     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
00383 \textcolor{keywordflow}{  endif}
00384   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00385   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, -dzregrid, &
00386                              u, v, cs%show\_call\_tree, dt )
00387 
00388   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})
00389 
00390   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00391   \textcolor{comment}{! one of the 'build\_...' routines above.}
00392   \textcolor{comment}{!$OMP parallel do default(shared)}
00393   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00394     h(i,j,k) = h\_new(i,j,k)
00395 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00396 
00397   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})
00398 
00399   \textcolor{keywordflow}{if} (cs%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs%id\_dzRegrid, dzregrid, cs%diag)
00400 
00401 
00402 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\_main}
00403 \textcolor{comment}{}
00404 \textcolor{comment}{!> Takes care of (1) building a new grid and (2) remapping all variables between}
00405 \textcolor{comment}{!! the old grid and the new grid. The creation of the new grid can be based}
00406 \textcolor{comment}{!! on z coordinates, target interface densities, sigma coordinates or any}
00407 \textcolor{comment}{!! arbitrary coordinate system.}
00408 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\_main\_offline}( G, GV, h, tv, Reg, CS, OBC, dt)
\Hypertarget{MOM__ALE_8F90_source_l00409}\hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{00409}   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}
00410   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}
00411   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid obtained after the}
00412 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg-2]}
00413   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
00414   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{ !< Tracer registry structure}
00415   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),                               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and
       options}
00416   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}
00417   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main
       [T ~> s]}
00418   \textcolor{comment}{! Local variables}
00419   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}
00420   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: h\_new \textcolor{comment}{! New 3D grid obtained after last time step [H ~> m or
       kg-2]}
00421   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00422 
00423   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00424 
00425   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main\_offline(), MOM\_ALE.F90"})
00426 
00427   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00428     \textcolor{keyword}{call }\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\_update\_regrid\_weights}( dt, cs )
00429 \textcolor{keywordflow}{  endif}
00430   dzregrid(:,:,:) = 0.0
00431 
00432   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
00433   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
00434   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid )
00435 
00436   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\_grid}( g, gv, h, 0. )
00437 
00438   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})
00439 
00440   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00441 
00442   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}(cs%remapCS, cs, g, gv, h, h\_new, reg, obc, &
00443                             debug=cs%show\_call\_tree, dt=dt )
00444 
00445   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})
00446 
00447   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00448   \textcolor{comment}{! one of the 'build\_...' routines above.}
00449   \textcolor{comment}{!$OMP parallel do default(shared)}
00450   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00451     h(i,j,k) = h\_new(i,j,k)
00452 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00453 
00454   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})
00455   \textcolor{keywordflow}{if} (cs%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs%id\_dzRegrid, dzregrid, cs%diag)
00456 
00457 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\_main\_offline}
00458 \textcolor{comment}{}
00459 \textcolor{comment}{!> Regrid/remap stored fields used for offline tracer integrations. These input fields are assumed to have}
00460 \textcolor{comment}{!! the same layer thicknesses at the end of the last offline interval (which should be a Zstar grid). This}
00461 \textcolor{comment}{!! routine builds a grid on the runtime specified vertical coordinate}
00462 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\_offline\_inputs}(CS, G, GV, h, tv, Reg, uhtr, vhtr, Kd, debug, OBC)
\Hypertarget{MOM__ALE_8F90_source_l00463}\hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{00463}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),                                 \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{    !< Regridding parameters and
       options}
00464   \textcolor{keywordtype}{type}(ocean\_grid\_type),                        \textcolor{keywordtype}{intent(in   )} :: G\textcolor{comment}{     !< Ocean grid informations}
00465   \textcolor{keywordtype}{type}(verticalgrid\_type),                      \textcolor{keywordtype}{intent(in   )} :: GV\textcolor{comment}{    !< Ocean vertical grid structure}
00466   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},    \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{     !< Layer thicknesses}
00467   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                        \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{    !< Thermodynamic variable structure}
00468   \textcolor{keywordtype}{type}(tracer\_registry\_type),                   \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{   !< Tracer registry structure}
00469   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{  !< Zonal mass fluxes}
00470   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{  !< Meridional mass fluxes}
00471   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)},  \textcolor{keywordtype}{intent(inout)} :: Kd\textcolor{comment}{    !< Input diffusivites}
00472   \textcolor{keywordtype}{logical},                                      \textcolor{keywordtype}{intent(in   )} :: debug\textcolor{comment}{ !< If true, then turn checksums}
00473   \textcolor{keywordtype}{type}(ocean\_obc\_type),                         \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{   !< Open boundary structure}
00474   \textcolor{comment}{! Local variables}
00475   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00476   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new    \textcolor{comment}{! Layer thicknesses after regridding}
00477   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}
00478   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_src
00479   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_dest, uh\_dest
00480   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: temp\_vec
00481 
00482   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00483   dzregrid(:,:,:) = 0.0
00484   h\_new(:,:,:) = 0.0
00485 
00486   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"Before ALE\_offline\_inputs"}, g, h, reg%Tr, reg%ntr)
00487 
00488   \textcolor{comment}{! Build new grid from the Zstar state onto the requested vertical coordinate. The new grid is stored}
00489   \textcolor{comment}{! in h\_new. The old grid is h. Both are needed for the subsequent remapping of variables. Convective}
00490   \textcolor{comment}{! adjustment right now is not used because it is unclear what to do with vanished layers}
00491   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid, conv\_adjust = .false. )
00492   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\_grid}( g, gv, h\_new, 0. )
00493   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_offline\_inputs)"})
00494 
00495   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00496   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs
      %show\_call\_tree )
00497   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_inputs)"})
00498 
00499   \textcolor{comment}{! Reintegrate mass transports from Zstar to the offline vertical coordinate}
00500   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=g%iscB,g%iecB
00501     \textcolor{keywordflow}{if} (g%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}
00502       h\_src(:) = 0.5 * (h(i,j,:) + h(i+1,j,:))
00503       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i+1,j,:))
00504       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, uhtr(i,j,:), nk, h\_dest, 0., temp\_vec)
00505       uhtr(i,j,:) = temp\_vec
00506 \textcolor{keywordflow}{    endif}
00507 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00508   \textcolor{keywordflow}{do} j=g%jscB,g%jecB ; \textcolor{keywordflow}{do} i=isc,iec
00509     \textcolor{keywordflow}{if} (g%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}
00510       h\_src(:) = 0.5 * (h(i,j,:) + h(i,j+1,:))
00511       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i,j+1,:))
00512       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, vhtr(i,j,:), nk, h\_dest, 0., temp\_vec)
00513       vhtr(i,j,:) = temp\_vec
00514 \textcolor{keywordflow}{    endif}
00515 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00516 
00517   \textcolor{keywordflow}{do} j = jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
00518     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
00519       \textcolor{keywordflow}{if} (check\_column\_integrals(nk, h\_src, nk, h\_dest)) \textcolor{keywordflow}{then}
00520         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ALE\_offline\_inputs: Kd interpolation columns do not match"})
00521 \textcolor{keywordflow}{      endif}
00522       \textcolor{keyword}{call }interpolate\_column(nk, h(i,j,:), kd(i,j,:), nk, h\_new(i,j,:), 0., kd(i,j,:))
00523 \textcolor{keywordflow}{    endif}
00524 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00525 
00526   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\_remap\_scalar}(cs%remapCS, g, gv, nk, h, tv%T, h\_new, tv%T, answers\_2018=cs
      %answers\_2018)
00527   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\_remap\_scalar}(cs%remapCS, g, gv, nk, h, tv%S, h\_new, tv%S, answers\_2018=cs
      %answers\_2018)
00528 
00529   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"After ALE\_offline\_inputs"}, g, h\_new, reg%Tr, reg%ntr)
00530 
00531   \textcolor{comment}{! Copy over the new layer thicknesses}
00532   \textcolor{keywordflow}{do} k = 1,nk  ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00533       h(i,j,k) = h\_new(i,j,k)
00534 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00535 
00536   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_offline\_inputs()"})
00537 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\_offline\_inputs}
00538 
00539 \textcolor{comment}{}
00540 \textcolor{comment}{!> Remaps all tracers from h onto h\_target. This is intended to be called when tracers}
00541 \textcolor{comment}{!! are done offline. In the case where transports don't quite conserve, we still want to}
00542 \textcolor{comment}{!! make sure that layer thicknesses offline do not drift too far away from the online model}
00543 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{ale\_offline\_tracer\_final}( G, GV, h, tv, h\_target, Reg, CS, OBC)
\Hypertarget{MOM__ALE_8F90_source_l00544}\hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{00544}   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}
00545   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}
00546   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid obtained after the}
00547 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg-2]}
00548   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
00549   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\_target\textcolor{comment}{ !< Current 3D grid obtained after}
00550 \textcolor{comment}{                                                                        !! last time step  [H ~> m or kg-2]}
00551   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{ !< Tracer registry structure}
00552   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),                               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and
       options}
00553   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}
00554   \textcolor{comment}{! Local variables}
00555 
00556   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid\textcolor{comment}{ !< The change in grid interface positions}
00557   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new\textcolor{comment}{    !< Regridded target thicknesses}
00558   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00559 
00560   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00561 
00562   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_offline\_tracer\_final(), MOM\_ALE.F90"})
00563   \textcolor{comment}{! Need to make sure that h\_target is consistent with the current offline ALE confiuration}
00564   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h\_target, tv, h\_new, dzregrid )
00565   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\_grid}( g, gv, h\_target, 0. )
00566 
00567 
00568   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"Source and target grids checked
       (ALE\_offline\_tracer\_final)"})
00569 
00570   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00571 
00572   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs
      %show\_call\_tree )
00573 
00574   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_offline\_tracer\_final)"})
00575 
00576   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00577   \textcolor{comment}{! one of the 'build\_...' routines above.}
00578   \textcolor{comment}{!$OMP parallel do default(shared)}
00579   \textcolor{keywordflow}{do} k = 1,nk
00580     \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00581       h(i,j,k) = h\_new(i,j,k)
00582 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00583 \textcolor{keywordflow}{  enddo}
00584   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_offline\_tracer\_final()"})
00585 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{ale\_offline\_tracer\_final}
00586 \textcolor{comment}{}
00587 \textcolor{comment}{!> Check grid for negative thicknesses}
00588 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\_grid}( G, GV, h, threshold )
\Hypertarget{MOM__ALE_8F90_source_l00589}\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{00589}   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< Ocean grid structure}
00590   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< Ocean vertical grid structure}
00591   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{  !< Current 3D grid obtained after the}
00592 \textcolor{comment}{                                                              !! last time step [H ~> m or kg m-2]}
00593   \textcolor{keywordtype}{real},                                      \textcolor{keywordtype}{intent(in)} :: threshold\textcolor{comment}{ !< Value below which to flag issues,}
00594 \textcolor{comment}{                                                              !! [H ~> m or kg m-2]}
00595   \textcolor{comment}{! Local variables}
00596   \textcolor{keywordtype}{integer} :: i, j
00597 
00598   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00599     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
00600       \textcolor{keywordflow}{if} (minval(h(i,j,:)) < threshold) \textcolor{keywordflow}{then}
00601         \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'check\_grid: i,j='},i,j,\textcolor{stringliteral}{'h(i,j,:)='},h(i,j,:)
00602         \textcolor{keywordflow}{if} (threshold <= 0.) \textcolor{keywordflow}{then}
00603           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: negative thickness encountered."})
00604         \textcolor{keywordflow}{else}
00605           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: too tiny thickness encountered."})
00606 \textcolor{keywordflow}{        endif}
00607 \textcolor{keywordflow}{      endif}
00608 \textcolor{keywordflow}{    endif}
00609 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00610 
00611 
00612 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\_grid}
00613 \textcolor{comment}{}
00614 \textcolor{comment}{!> Generates new grid}
00615 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}{ale\_build\_grid}( G, GV, regridCS, remapCS, h, tv, debug, frac\_shelf\_h )
\Hypertarget{MOM__ALE_8F90_source_l00616}\hyperlink{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}{00616}   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< Ocean grid structure}
00617   \textcolor{keywordtype}{type}(verticalgrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{       !< Ocean vertical grid structure}
00618   \textcolor{keywordtype}{type}(regridding\_cs),                     \textcolor{keywordtype}{intent(in)}    :: regridCS\textcolor{comment}{ !< Regridding parameters and options}
00619   \textcolor{keywordtype}{type}(remapping\_cs),                      \textcolor{keywordtype}{intent(in)}    :: remapCS\textcolor{comment}{  !< Remapping parameters and options}
00620   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{       !< Thermodynamical variable structure}
00621   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{     !< Current 3D grid obtained after the}
00622 \textcolor{comment}{                                                                     !! last time step [H ~> m or kg-2]}
00623   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{    !< If true, show the call tree}
00624   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf coverage}
00625   \textcolor{comment}{! Local variables}
00626   \textcolor{keywordtype}{integer} :: nk, i, j, k
00627   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}
00628   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: h\_new \textcolor{comment}{! The new grid thicknesses}
00629   \textcolor{keywordtype}{logical} :: show\_call\_tree, use\_ice\_shelf
00630 
00631   show\_call\_tree = .false.
00632   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug
00633   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_build\_grid(), MOM\_ALE.F90"})
00634   use\_ice\_shelf = .false.
00635   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}
00636     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) use\_ice\_shelf = .true.
00637 \textcolor{keywordflow}{  endif}
00638 
00639   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
00640   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
00641   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}
00642      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h )
00643   \textcolor{keywordflow}{else}
00644      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid )
00645 \textcolor{keywordflow}{  endif}
00646 
00647   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00648   \textcolor{comment}{! one of the 'build\_...' routines above.}
00649 \textcolor{comment}{!$OMP parallel do default(none) shared(G,h,h\_new)}
00650   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00651     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) h(i,j,:) = h\_new(i,j,:)
00652 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00653 
00654   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_build\_grid()"})
00655 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}{ale\_build\_grid}
00656 \textcolor{comment}{}
00657 \textcolor{comment}{!> For a state-based coordinate, accelerate the process of regridding by}
00658 \textcolor{comment}{!! repeatedly applying the grid calculation algorithm}
00659 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{ale\_regrid\_accelerated}(CS, G, GV, h, tv, n, u, v, OBC, Reg, dt, dzRegrid,
       initial)
\Hypertarget{MOM__ALE_8F90_source_l00660}\hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{00660}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< ALE control structure}
00661   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< Ocean grid}
00662   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< Vertical grid}
00663   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
00664                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{      !< Original thicknesses [H ~> m or kg-2]}
00665   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< Thermo vars (T/S/EOS)}
00666   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)}    :: n\textcolor{comment}{      !< Number of times to regrid}
00667   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, &
00668                            \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-1 ~> m s-1]}
00669   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, &
00670                            \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-1 ~> m s-1]}
00671   \textcolor{keywordtype}{type}(ocean\_obc\_type),    \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{    !< Open boundary structure}
00672   \textcolor{keywordtype}{type}(tracer\_registry\_type), &
00673                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{    !< Tracer registry to remap onto new grid}
00674   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Model timestep to provide a timescale for regridding
       [T ~> s]}
00675   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
00676                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: dzRegrid\textcolor{comment}{ !< Final change in interface positions}
00677   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: initial\textcolor{comment}{ !< Whether we're being called from an initialization}
00678 \textcolor{comment}{                                                    !! routine (and expect diagnostics to work)}
00679 
00680   \textcolor{comment}{! Local variables}
00681   \textcolor{keywordtype}{integer} :: i, j, k, nz
00682   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_local \textcolor{comment}{! local/intermediate temp/salt}
00683   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_T\_S\_h \textcolor{comment}{! group pass if the coordinate has a stencil}
00684   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}         :: h\_loc, h\_orig \textcolor{comment}{! A working copy of layer thicknesses}
00685   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{target} :: T, S \textcolor{comment}{! local temporary state}
00686   \textcolor{comment}{! we have to keep track of the total dzInterface if for some reason}
00687   \textcolor{comment}{! we're using the old remapping algorithm for u/v}
00688   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzInterface, dzIntTotal
00689 
00690   nz = gv%ke
00691 
00692   \textcolor{comment}{! initial total interface displacement due to successive regridding}
00693   dzinttotal(:,:,:) = 0.
00694 
00695   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, t, g%domain)
00696   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, s, g%domain)
00697   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, h\_loc, g%domain)
00698 
00699   \textcolor{comment}{! copy original temp/salt and set our local tv\_pointers to them}
00700   tv\_local = tv
00701   t(:,:,:) = tv%T(:,:,:)
00702   s(:,:,:) = tv%S(:,:,:)
00703   tv\_local%T => t
00704   tv\_local%S => s
00705 
00706   \textcolor{comment}{! get local copy of thickness and save original state for remapping}
00707   h\_loc(:,:,:) = h(:,:,:)
00708   h\_orig(:,:,:) = h(:,:,:)
00709 
00710   \textcolor{comment}{! Apply timescale to regridding (for e.g. filtered\_grid\_motion)}
00711   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) &
00712     \textcolor{keyword}{call }\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\_update\_regrid\_weights}(dt, cs)
00713 
00714   \textcolor{keywordflow}{do} k = 1, n
00715     \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s\_h, g%domain)
00716 
00717     \textcolor{comment}{! generate new grid}
00718     \textcolor{keyword}{call }regridding\_main(cs%remapCS, cs%regridCS, g, gv, h\_loc, tv\_local, h, dzinterface)
00719     dzinttotal(:,:,:) = dzinttotal(:,:,:) + dzinterface(:,:,:)
00720 
00721     \textcolor{comment}{! remap from original grid onto new grid}
00722     \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
00723       \textcolor{keyword}{call }remapping\_core\_h(cs%remapCS, nz, h\_orig(i,j,:), tv%S(i,j,:), nz, h(i,j,:), tv\_local%S(i,j,:))
00724       \textcolor{keyword}{call }remapping\_core\_h(cs%remapCS, nz, h\_orig(i,j,:), tv%T(i,j,:), nz, h(i,j,:), tv\_local%T(i,j,:))
00725 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00726 
00727     \textcolor{comment}{! starting grid for next iteration}
00728     h\_loc(:,:,:) = h(:,:,:)
00729 \textcolor{keywordflow}{  enddo}
00730 
00731   \textcolor{comment}{! remap all state variables (including those that weren't needed for regridding)}
00732   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}(cs%remapCS, cs, g, gv, h\_orig, h, reg, obc, dzinttotal, u, 
      v)
00733 
00734   \textcolor{comment}{! save total dzregrid for diags if needed?}
00735   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dzregrid)) dzregrid(:,:,:) = dzinttotal(:,:,:)
00736 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{ale\_regrid\_accelerated}
00737 \textcolor{comment}{}
00738 \textcolor{comment}{!> This routine takes care of remapping all variable between the old and the}
00739 \textcolor{comment}{!! new grids. When velocity components need to be remapped, thicknesses at}
00740 \textcolor{comment}{!! velocity points are taken to be arithmetic averages of tracer thicknesses.}
00741 \textcolor{comment}{!! This routine is called during initialization of the model at time=0, to}
00742 \textcolor{comment}{!! remap initiali conditions to the model grid.  It is also called during a}
00743 \textcolor{comment}{!! time step to update the state.}
00744 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}(CS\_remapping, CS\_ALE, G, GV, h\_old, h\_new, Reg, OBC, &
00745                                 dxInterface, u, v, debug, dt)
\Hypertarget{MOM__ALE_8F90_source_l00746}\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{00746}   \textcolor{keywordtype}{type}(remapping\_cs),                        \textcolor{keywordtype}{intent(in)}    :: CS\_remapping\textcolor{comment}{ !< Remapping control structure}
00747   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),                              \textcolor{keywordtype}{intent(in)}    :: CS\_ALE\textcolor{comment}{       !< ALE control structure}
00748   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{            !< Ocean grid structure}
00749   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{           !< Ocean vertical grid structure}
00750   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}    :: h\_old\textcolor{comment}{        !< Thickness of source grid}
00751 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
00752   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}    :: h\_new\textcolor{comment}{        !< Thickness of destination grid}
00753 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
00754   \textcolor{keywordtype}{type}(tracer\_registry\_type),                \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{          !< Tracer registry structure}
00755   \textcolor{keywordtype}{type}(ocean\_obc\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{          !< Open boundary structure}
00756   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
00757                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dxInterface\textcolor{comment}{  !< Change in interface position}
00758 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
00759   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, &
00760                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-1 ~> m s-1]}
00761   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, &
00762                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-1 ~> m
       s-1]}
00763   \textcolor{keywordtype}{logical},                         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{  !< If true, show the call tree}
00764   \textcolor{keywordtype}{real},                            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< time step for diagnostics [T ~> s]}
00765   \textcolor{comment}{! Local variables}
00766   \textcolor{keywordtype}{integer}                                     :: i, j, k, m
00767   \textcolor{keywordtype}{integer}                                     :: nz, ntr
00768   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke+1)}                    :: dx
00769   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)}                      :: h1, u\_column
00770   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_conc
00771   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_cont
00772   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))}           :: work\_2d
00773   \textcolor{keywordtype}{real}                                        :: Idt \textcolor{comment}{! The inverse of the timestep [T-1 ~> s-1]}
00774   \textcolor{keywordtype}{real}                                        :: ppt2mks
00775   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)}                      :: h2
00776   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge
00777   \textcolor{keywordtype}{logical}                                     :: show\_call\_tree
00778   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}                  :: Tr => null()
00779 
00780   show\_call\_tree = .false.
00781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug
00782   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"remap\_all\_state\_vars(), MOM\_ALE.F90"})
00783 
00784   \textcolor{comment}{! If remap\_uv\_using\_old\_alg is .true. and u or v is requested, then we must have dxInterface. Otherwise,}
00785   \textcolor{comment}{! u and v can be remapped without dxInterface}
00786   \textcolor{keywordflow}{if} ( .not. \textcolor{keyword}{present}(dxinterface) .and. (cs\_ale%remap\_uv\_using\_old\_alg .and. (\textcolor{keyword}{present}(u) .or. \textcolor{keyword}{present}(v))) 
      ) \textcolor{keywordflow}{then}
00787     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"remap\_all\_state\_vars: dxInterface must be present if using old algorithm "}// &
00788                           \textcolor{stringliteral}{"and u/v are to be remapped"})
00789 \textcolor{keywordflow}{  endif}
00790 
00791   \textcolor{keywordflow}{if} (.not.cs\_ale%answers\_2018) \textcolor{keywordflow}{then}
00792     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
00793   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
00794     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
00795   \textcolor{keywordflow}{else}
00796     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
00797 \textcolor{keywordflow}{  endif}
00798 
00799   nz      = gv%ke
00800   ppt2mks = 0.001
00801 
00802   ntr = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg)) ntr = reg%ntr
00803 
00804   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00805     idt = 1.0/dt
00806     work\_conc(:,:,:) = 0.0
00807     work\_cont(:,:,:) = 0.0
00808 \textcolor{keywordflow}{  endif}
00809 
00810   \textcolor{comment}{! Remap tracer}
00811   \textcolor{keywordflow}{if} (ntr>0) \textcolor{keywordflow}{then}
00812     \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"remapping tracers (remap\_all\_state\_vars)"})
00813     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,u\_column,Tr)}
00814     \textcolor{keywordflow}{do} m=1,ntr \textcolor{comment}{! For each tracer}
00815       tr => reg%Tr(m)
00816       \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec ; \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
00817         \textcolor{comment}{! Build the start and final grids}
00818         h1(:) = h\_old(i,j,:)
00819         h2(:) = h\_new(i,j,:)
00820         \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, tr%t(i,j,:), nz, h2, &
00821                               u\_column, h\_neglect, h\_neglect\_edge)
00822 
00823         \textcolor{comment}{! Intermediate steps for tendency of tracer concentration and tracer content.}
00824         \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00825           \textcolor{keywordflow}{if} (tr%id\_remap\_conc > 0) \textcolor{keywordflow}{then}
00826             \textcolor{keywordflow}{do} k=1,gv%ke
00827               work\_conc(i,j,k) = (u\_column(k) - tr%t(i,j,k)) * idt
00828 \textcolor{keywordflow}{            enddo}
00829 \textcolor{keywordflow}{          endif}
00830           \textcolor{keywordflow}{if} (tr%id\_remap\_cont > 0 .or. tr%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}
00831             \textcolor{keywordflow}{do} k=1,gv%ke
00832               work\_cont(i,j,k) = (u\_column(k)*h2(k) - tr%t(i,j,k)*h1(k)) * idt
00833 \textcolor{keywordflow}{            enddo}
00834 \textcolor{keywordflow}{          endif}
00835 \textcolor{keywordflow}{        endif}
00836         \textcolor{comment}{! update tracer concentration}
00837         tr%t(i,j,:) = u\_column(:)
00838 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00839 
00840       \textcolor{comment}{! tendency diagnostics.}
00841       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00842         \textcolor{keywordflow}{if} (tr%id\_remap\_conc > 0) \textcolor{keywordflow}{then}
00843           \textcolor{keyword}{call }post\_data(tr%id\_remap\_conc, work\_conc, cs\_ale%diag)
00844 \textcolor{keywordflow}{        endif}
00845         \textcolor{keywordflow}{if} (tr%id\_remap\_cont > 0) \textcolor{keywordflow}{then}
00846           \textcolor{keyword}{call }post\_data(tr%id\_remap\_cont, work\_cont, cs\_ale%diag)
00847 \textcolor{keywordflow}{        endif}
00848         \textcolor{keywordflow}{if} (tr%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}
00849           \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00850             work\_2d(i,j) = 0.0
00851             \textcolor{keywordflow}{do} k = 1,gv%ke
00852               work\_2d(i,j) = work\_2d(i,j) + work\_cont(i,j,k)
00853 \textcolor{keywordflow}{            enddo}
00854 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
00855           \textcolor{keyword}{call }post\_data(tr%id\_remap\_cont\_2d, work\_2d, cs\_ale%diag)
00856 \textcolor{keywordflow}{        endif}
00857 \textcolor{keywordflow}{      endif}
00858 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! m=1,ntr}
00859 
00860 \textcolor{keywordflow}{  endif}   \textcolor{comment}{! endif for ntr > 0}
00861 
00862   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"tracers remapped (remap\_all\_state\_vars)"})
00863 
00864   \textcolor{comment}{! Remap u velocity component}
00865   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(u) ) \textcolor{keywordflow}{then}
00866     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}
00867     \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%iscB,g%iecB ; \textcolor{keywordflow}{if} (g%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}
00868       \textcolor{comment}{! Build the start and final grids}
00869       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i+1,j,:) )
00870       \textcolor{keywordflow}{if} (cs\_ale%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}
00871         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i+1,j,:) )
00872         \textcolor{keywordflow}{do} k = 1, nz
00873           h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
00874 \textcolor{keywordflow}{        enddo}
00875       \textcolor{keywordflow}{else}
00876         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i+1,j,:) )
00877 \textcolor{keywordflow}{      endif}
00878       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
00879         \textcolor{keywordflow}{if} (obc%segnum\_u(i,j) .ne. 0) \textcolor{keywordflow}{then}
00880           \textcolor{keywordflow}{if} (obc%segment(obc%segnum\_u(i,j))%direction == obc\_direction\_e) \textcolor{keywordflow}{then}
00881             h1(:) = h\_old(i,j,:)
00882             h2(:) = h\_new(i,j,:)
00883           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC%segment(n)%direction == OBC\_DIRECTION\_W)}
00884             h1(:) = h\_old(i+1,j,:)
00885             h2(:) = h\_new(i+1,j,:)
00886 \textcolor{keywordflow}{          endif}
00887 \textcolor{keywordflow}{        endif}
00888 \textcolor{keywordflow}{      endif}
00889       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, u(i,j,:), nz, h2, &
00890                             u\_column, h\_neglect, h\_neglect\_edge)
00891       u(i,j,:) = u\_column(:)
00892 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00893 \textcolor{keywordflow}{  endif}
00894 
00895   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"u remapped (remap\_all\_state\_vars)"})
00896 
00897   \textcolor{comment}{! Remap v velocity component}
00898   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(v) ) \textcolor{keywordflow}{then}
00899     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}
00900     \textcolor{keywordflow}{do} j = g%jscB,g%jecB ; \textcolor{keywordflow}{do} i = g%isc,g%iec ; \textcolor{keywordflow}{if} (g%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}
00901       \textcolor{comment}{! Build the start and final grids}
00902       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i,j+1,:) )
00903       \textcolor{keywordflow}{if} (cs\_ale%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}
00904         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i,j+1,:) )
00905         \textcolor{keywordflow}{do} k = 1, nz
00906           h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
00907 \textcolor{keywordflow}{        enddo}
00908       \textcolor{keywordflow}{else}
00909         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i,j+1,:) )
00910 \textcolor{keywordflow}{      endif}
00911       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
00912         \textcolor{keywordflow}{if} (obc%segnum\_v(i,j) .ne. 0) \textcolor{keywordflow}{then}
00913           \textcolor{keywordflow}{if} (obc%segment(obc%segnum\_v(i,j))%direction == obc\_direction\_n) \textcolor{keywordflow}{then}
00914             h1(:) = h\_old(i,j,:)
00915             h2(:) = h\_new(i,j,:)
00916           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC%segment(n)%direction == OBC\_DIRECTION\_S)}
00917             h1(:) = h\_old(i,j+1,:)
00918             h2(:) = h\_new(i,j+1,:)
00919 \textcolor{keywordflow}{          endif}
00920 \textcolor{keywordflow}{        endif}
00921 \textcolor{keywordflow}{      endif}
00922       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, v(i,j,:), nz, h2, &
00923                             u\_column, h\_neglect, h\_neglect\_edge)
00924       v(i,j,:) = u\_column(:)
00925 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00926 \textcolor{keywordflow}{  endif}
00927 
00928   \textcolor{keywordflow}{if} (cs\_ale%id\_vert\_remap\_h > 0) \textcolor{keyword}{call }post\_data(cs\_ale%id\_vert\_remap\_h, h\_old, cs\_ale%diag)
00929   \textcolor{keywordflow}{if} ((cs\_ale%id\_vert\_remap\_h\_tendency > 0) .and. \textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00930     \textcolor{keywordflow}{do} k = 1, nz ; \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00931       work\_cont(i,j,k) = (h\_new(i,j,k) - h\_old(i,j,k))*idt
00932 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00933     \textcolor{keyword}{call }post\_data(cs\_ale%id\_vert\_remap\_h\_tendency, work\_cont, cs\_ale%diag)
00934 \textcolor{keywordflow}{  endif}
00935   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"v remapped (remap\_all\_state\_vars)"})
00936   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"remap\_all\_state\_vars()"})
00937 
00938 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\_all\_state\_vars}
00939 
00940 \textcolor{comment}{}
00941 \textcolor{comment}{!> Remaps a single scalar between grids described by thicknesses h\_src and h\_dst.}
00942 \textcolor{comment}{!! h\_dst must be dimensioned as a model array with GV%ke layers while h\_src can}
00943 \textcolor{comment}{!! have an arbitrary number of layers specified by nk\_src.}
00944 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\_remap\_scalar}(CS, G, GV, nk\_src, h\_src, s\_src, h\_dst, s\_dst, all\_cells,
       old\_remap, answers\_2018 )
\Hypertarget{MOM__ALE_8F90_source_l00945}\hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{00945}   \textcolor{keywordtype}{type}(remapping\_cs),                      \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{        !< Remapping control structure}
00946   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{         !< Ocean grid structure}
00947   \textcolor{keywordtype}{type}(verticalgrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{        !< Ocean vertical grid structure}
00948   \textcolor{keywordtype}{integer},                                 \textcolor{keywordtype}{intent(in)}    :: nk\_src\textcolor{comment}{    !< Number of levels on source grid}
00949   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nk\_src)}, \textcolor{keywordtype}{intent(in)}    :: h\_src\textcolor{comment}{     !< Level thickness of source grid}
00950 \textcolor{comment}{                                                                      !! [H ~> m or kg-2]}
00951   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nk\_src)}, \textcolor{keywordtype}{intent(in)}    :: s\_src\textcolor{comment}{     !< Scalar on source grid}
00952   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},\textcolor{keywordtype}{intent(in)}   :: h\_dst\textcolor{comment}{     !< Level thickness of destination
       grid}
00953 \textcolor{comment}{                                                                      !! [H ~> m or kg-2]}
00954   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},\textcolor{keywordtype}{intent(inout)} :: s\_dst\textcolor{comment}{    !< Scalar on destination grid}
00955   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: all\_cells\textcolor{comment}{ !< If false, only reconstruct for}
00956 \textcolor{comment}{                                                                      !! non-vanished cells. Use all
       vanished}
00957 \textcolor{comment}{                                                                      !! layers otherwise (default).}
00958   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: old\_remap\textcolor{comment}{ !< If true, use the old
       "remapping\_core\_w"}
00959 \textcolor{comment}{                                                                      !! method, otherwise use
       "remapping\_core\_h".}
00960   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true, use the order of
       arithmetic}
00961 \textcolor{comment}{                                                                      !! and expressions that recover the
       answers for}
00962 \textcolor{comment}{                                                                      !! remapping from the end of 2018.
       Otherwise,}
00963 \textcolor{comment}{                                                                      !! use more robust forms of the same
       expressions.}
00964   \textcolor{comment}{! Local variables}
00965   \textcolor{keywordtype}{integer} :: i, j, k, n\_points
00966   \textcolor{keywordtype}{real} :: dx(gv%ke+1)
00967   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge
00968   \textcolor{keywordtype}{logical} :: ignore\_vanished\_layers, use\_remapping\_core\_w, use\_2018\_remap
00969 
00970   ignore\_vanished\_layers = .false.
00971   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(all\_cells)) ignore\_vanished\_layers = .not. all\_cells
00972   use\_remapping\_core\_w = .false.
00973   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(old\_remap)) use\_remapping\_core\_w = old\_remap
00974   n\_points = nk\_src
00975   use\_2018\_remap = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(answers\_2018)) use\_2018\_remap = answers\_2018
00976 
00977   \textcolor{keywordflow}{if} (.not.use\_2018\_remap) \textcolor{keywordflow}{then}
00978     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
00979   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
00980     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
00981   \textcolor{keywordflow}{else}
00982     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
00983 \textcolor{keywordflow}{  endif}
00984 
00985   \textcolor{comment}{!$OMP parallel do default(shared) firstprivate(n\_points,dx)}
00986   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00987     \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0.) \textcolor{keywordflow}{then}
00988       \textcolor{keywordflow}{if} (ignore\_vanished\_layers) \textcolor{keywordflow}{then}
00989         n\_points = 0
00990         \textcolor{keywordflow}{do} k = 1, nk\_src
00991           \textcolor{keywordflow}{if} (h\_src(i,j,k)>0.) n\_points = n\_points + 1
00992 \textcolor{keywordflow}{        enddo}
00993         s\_dst(i,j,:) = 0.
00994 \textcolor{keywordflow}{      endif}
00995       \textcolor{keywordflow}{if} (use\_remapping\_core\_w) \textcolor{keywordflow}{then}
00996         \textcolor{keyword}{call }dzfromh1h2( n\_points, h\_src(i,j,1:n\_points), gv%ke, h\_dst(i,j,:), dx )
00997         \textcolor{keyword}{call }remapping\_core\_w(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), &
00998                               gv%ke, dx, s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)
00999       \textcolor{keywordflow}{else}
01000         \textcolor{keyword}{call }remapping\_core\_h(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), &
01001                               gv%ke, h\_dst(i,j,:), s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)
01002 \textcolor{keywordflow}{      endif}
01003     \textcolor{keywordflow}{else}
01004       s\_dst(i,j,:) = 0.
01005 \textcolor{keywordflow}{    endif}
01006 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01007 
01008 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\_remap\_scalar}
01009 
01010 \textcolor{comment}{}
01011 \textcolor{comment}{!> Calculate edge values (top and bottom of layer) for T and S consistent with a PLM reconstruction}
01012 \textcolor{comment}{!! in the vertical direction. Boundary reconstructions are PCM unless bdry\_extrap is true.}
01013 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_abedb087c760a6ac146735275638db58a}{ts\_plm\_edge\_values}( CS, S\_t, S\_b, T\_t, T\_b, G, GV, tv, h, bdry\_extrap )
\Hypertarget{MOM__ALE_8F90_source_l01014}\hyperlink{namespacemom__ale_abedb087c760a6ac146735275638db58a}{01014}   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}
01015   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Ocean vertical grid structure}
01016   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< module control structure}
01017   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01018                            \textcolor{keywordtype}{intent(inout)} :: S\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}
01019   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01020                            \textcolor{keywordtype}{intent(inout)} :: S\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}
01021   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01022                            \textcolor{keywordtype}{intent(inout)} :: T\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}
01023   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01024                            \textcolor{keywordtype}{intent(inout)} :: T\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}
01025   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}
01026   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01027                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H ~> m or kg m-2]}
01028   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
01029 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
01030 
01031   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\_plm\_edge\_values}( cs, g, gv, h, tv%S, bdry\_extrap, s\_t, s\_b )
01032   \textcolor{keyword}{call }\hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\_plm\_edge\_values}( cs, g, gv, h, tv%T, bdry\_extrap, t\_t, t\_b )
01033 
01034 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_abedb087c760a6ac146735275638db58a}{ts\_plm\_edge\_values}
01035 \textcolor{comment}{}
01036 \textcolor{comment}{!> Calculate edge values (top and bottom of layer) 3d scalar array.}
01037 \textcolor{comment}{!! Boundary reconstructions are PCM unless bdry\_extrap is true.}
01038 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\_plm\_edge\_values}( CS, G, GV, h, Q, bdry\_extrap, Q\_t, Q\_b )
\Hypertarget{MOM__ALE_8F90_source_l01039}\hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{01039}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{   !< module control structure}
01040   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}
01041   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Ocean vertical grid structure}
01042   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01043                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H ~> m or kg m-2]}
01044   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01045                            \textcolor{keywordtype}{intent(in)}    :: Q\textcolor{comment}{    !< 3d scalar array}
01046   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
01047 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
01048   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01049                            \textcolor{keywordtype}{intent(inout)} :: Q\_t\textcolor{comment}{  !< Scalar at the top edge of each layer}
01050   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01051                            \textcolor{keywordtype}{intent(inout)} :: Q\_b\textcolor{comment}{  !< Scalar at the bottom edge of each layer}
01052   \textcolor{comment}{! Local variables}
01053   \textcolor{keywordtype}{integer} :: i, j, k
01054   \textcolor{keywordtype}{real} :: slp(gv%ke)
01055   \textcolor{keywordtype}{real} :: mslp
01056   \textcolor{keywordtype}{real} :: h\_neglect
01057 
01058   \textcolor{keywordflow}{if} (.not.cs%answers\_2018) \textcolor{keywordflow}{then}
01059     h\_neglect = gv%H\_subroundoff
01060   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
01061     h\_neglect = gv%m\_to\_H*1.0e-30
01062   \textcolor{keywordflow}{else}
01063     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30
01064 \textcolor{keywordflow}{  endif}
01065 
01066   \textcolor{comment}{!$OMP parallel do default(shared) private(slp,mslp)}
01067   \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
01068     slp(1) = 0.
01069     \textcolor{keywordflow}{do} k = 2, gv%ke-1
01070       slp(k) = plm\_slope\_wa(h(i,j,k-1), h(i,j,k), h(i,j,k+1), h\_neglect, q(i,j,k-1), q(i,j,k), q(i,j,k+1))
01071 \textcolor{keywordflow}{    enddo}
01072     slp(gv%ke) = 0.
01073 
01074     \textcolor{keywordflow}{do} k = 2, gv%ke-1
01075       mslp = plm\_monotonized\_slope(q(i,j,k-1), q(i,j,k), q(i,j,k+1), slp(k-1), slp(k), slp(k+1))
01076       q\_t(i,j,k) = q(i,j,k) - 0.5 * mslp
01077       q\_b(i,j,k) = q(i,j,k) + 0.5 * mslp
01078 \textcolor{keywordflow}{    enddo}
01079     \textcolor{keywordflow}{if} (bdry\_extrap) \textcolor{keywordflow}{then}
01080       mslp = - plm\_extrapolate\_slope(h(i,j,2), h(i,j,1), h\_neglect, q(i,j,2), q(i,j,1))
01081       q\_t(i,j,1) = q(i,j,1) - 0.5 * mslp
01082       q\_b(i,j,1) = q(i,j,1) + 0.5 * mslp
01083       mslp = plm\_extrapolate\_slope(h(i,j,gv%ke-1), h(i,j,gv%ke), h\_neglect, q(i,j,gv%ke-1), q(i,j,gv%ke))
01084       q\_t(i,j,gv%ke) = q(i,j,gv%ke) - 0.5 * mslp
01085       q\_b(i,j,gv%ke) = q(i,j,gv%ke) + 0.5 * mslp
01086     \textcolor{keywordflow}{else}
01087       q\_t(i,j,1) = q(i,j,1)
01088       q\_b(i,j,1) = q(i,j,1)
01089       q\_t(i,j,gv%ke) = q(i,j,gv%ke)
01090       q\_b(i,j,gv%ke) = q(i,j,gv%ke)
01091 \textcolor{keywordflow}{    endif}
01092 
01093 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01094 
01095 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\_plm\_edge\_values}
01096 \textcolor{comment}{}
01097 \textcolor{comment}{!> Calculate edge values (top and bottom of layer) for T and S consistent with a PPM reconstruction}
01098 \textcolor{comment}{!! in the vertical direction. Boundary reconstructions are PCM unless bdry\_extrap is true.}
01099 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}{ts\_ppm\_edge\_values}( CS, S\_t, S\_b, T\_t, T\_b, G, GV, tv, h, bdry\_extrap )
\Hypertarget{MOM__ALE_8F90_source_l01100}\hyperlink{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}{01100}   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}
01101   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Ocean vertical grid structure}
01102   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< module control structure}
01103   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01104                            \textcolor{keywordtype}{intent(inout)} :: S\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}
01105   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01106                            \textcolor{keywordtype}{intent(inout)} :: S\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}
01107   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01108                            \textcolor{keywordtype}{intent(inout)} :: T\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}
01109   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01110                            \textcolor{keywordtype}{intent(inout)} :: T\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}
01111   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}
01112   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01113                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thicknesses [H ~> m or kg m-2]}
01114   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
01115 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
01116 
01117   \textcolor{comment}{! Local variables}
01118   \textcolor{keywordtype}{integer} :: i, j, k
01119   \textcolor{keywordtype}{real}    :: hTmp(gv%ke) \textcolor{comment}{! A 1-d copy of h [H ~> m or kg m-2]}
01120   \textcolor{keywordtype}{real}    :: tmp(gv%ke)  \textcolor{comment}{! A 1-d copy of a column of temperature [degC] or salinity [ppt]}
01121   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk,2)} :: &
01122       ppol\_E            \textcolor{comment}{! Edge value of polynomial in [degC] or [ppt]}
01123   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk,3)} :: &
01124       ppol\_coefs        \textcolor{comment}{! Coefficients of polynomial, all in [degC] or [ppt]}
01125   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge \textcolor{comment}{! Tiny thicknesses [H ~> m or kg m-2]}
01126 
01127   \textcolor{keywordflow}{if} (.not.cs%answers\_2018) \textcolor{keywordflow}{then}
01128     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
01129   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
01130     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
01131   \textcolor{keywordflow}{else}
01132     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
01133 \textcolor{keywordflow}{  endif}
01134 
01135   \textcolor{comment}{! Determine reconstruction within each column}
01136   \textcolor{comment}{!$OMP parallel do default(shared) private(hTmp,tmp,ppol\_E,ppol\_coefs)}
01137   \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
01138 
01139     \textcolor{comment}{! Build current grid}
01140     htmp(:) = h(i,j,:)
01141     tmp(:) = tv%S(i,j,:)
01142 
01143     \textcolor{comment}{! Reconstruct salinity profile}
01144     ppol\_e(:,:) = 0.0
01145     ppol\_coefs(:,:) = 0.0
01146     \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=h\_neglect\_edge, &
01147                                   answers\_2018=cs%answers\_2018 )
01148     \textcolor{keyword}{call }ppm\_reconstruction( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, &
01149                                   answers\_2018=cs%answers\_2018 )
01150     \textcolor{keywordflow}{if} (bdry\_extrap) &
01151       \textcolor{keyword}{call }ppm\_boundary\_extrapolation( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )
01152 
01153     \textcolor{keywordflow}{do} k = 1,gv%ke
01154       s\_t(i,j,k) = ppol\_e(k,1)
01155       s\_b(i,j,k) = ppol\_e(k,2)
01156 \textcolor{keywordflow}{    enddo}
01157 
01158     \textcolor{comment}{! Reconstruct temperature profile}
01159     ppol\_e(:,:) = 0.0
01160     ppol\_coefs(:,:) = 0.0
01161     tmp(:) = tv%T(i,j,:)
01162     \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
01163       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=1.0e-10*gv%m\_to\_H, &
01164                                   answers\_2018=cs%answers\_2018 )
01165     \textcolor{keywordflow}{else}
01166       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=gv%H\_subroundoff, &
01167                                   answers\_2018=cs%answers\_2018 )
01168 \textcolor{keywordflow}{    endif}
01169     \textcolor{keyword}{call }ppm\_reconstruction( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, &
01170                                   answers\_2018=cs%answers\_2018 )
01171     \textcolor{keywordflow}{if} (bdry\_extrap) &
01172       \textcolor{keyword}{call }ppm\_boundary\_extrapolation(gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )
01173 
01174     \textcolor{keywordflow}{do} k = 1,gv%ke
01175       t\_t(i,j,k) = ppol\_e(k,1)
01176       t\_b(i,j,k) = ppol\_e(k,2)
01177 \textcolor{keywordflow}{    enddo}
01178 
01179 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01180 
01181 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}{ts\_ppm\_edge\_values}
01182 
01183 \textcolor{comment}{}
01184 \textcolor{comment}{!> Initializes regridding for the main ALE algorithm}
01185 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{ale\_initregridding}(GV, US, max\_depth, param\_file, mdl, regridCS)
\Hypertarget{MOM__ALE_8F90_source_l01186}\hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{01186}   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{         !< Ocean vertical grid structure}
01187   \textcolor{keywordtype}{type}(\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{         !< A dimensional unit scaling type}
01188   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z ~> m].}
01189   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< parameter file}
01190   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: mdl\textcolor{comment}{        !< Name of calling module}
01191   \textcolor{keywordtype}{type}(regridding\_cs),     \textcolor{keywordtype}{intent(out)} :: regridCS\textcolor{comment}{   !< Regridding parameters and work arrays}
01192   \textcolor{comment}{! Local variables}
01193   \textcolor{keywordtype}{character(len=30)} :: coord\_mode
01194 
01195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"}, coord\_mode, &
01196                  \textcolor{stringliteral}{"Coordinate mode for vertical regridding. "}//&
01197                  \textcolor{stringliteral}{"Choose among the following possibilities: "}//&
01198                  trim(regriddingcoordinatemodedoc), &
01199                  default=default\_coordinate\_mode, fail\_if\_missing=.true.)
01200 
01201   \textcolor{keyword}{call }initialize\_regridding(regridcs, gv, us, max\_depth, param\_file, mdl, coord\_mode, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''})
01202 
01203 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{ale\_initregridding}
01204 \textcolor{comment}{}
01205 \textcolor{comment}{!> Query the target coordinate interfaces positions}
01206 \textcolor{keyword}{function }\hyperlink{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}{ale\_getcoordinate}( CS )
\Hypertarget{MOM__ALE_8F90_source_l01207}\hyperlink{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}{01207}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{                  !< module control structure}
01208 
01209   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk+1)} :: ALE\_getCoordinate
01210   ale\_getcoordinate(:) = getcoordinateinterfaces( cs%regridCS, undo\_scaling=.true. )
01211 
01212 \textcolor{keyword}{end function }\hyperlink{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}{ale\_getcoordinate}
01213 
01214 \textcolor{comment}{}
01215 \textcolor{comment}{!> Query the target coordinate units}
01216 \textcolor{keyword}{function }\hyperlink{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}{ale\_getcoordinateunits}( CS )
\Hypertarget{MOM__ALE_8F90_source_l01217}\hyperlink{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}{01217}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< module control structure}
01218 
01219   \textcolor{keywordtype}{character(len=20)}     :: ALE\_getCoordinateUnits
01220 
01221   ale\_getcoordinateunits = getcoordinateunits( cs%regridCS )
01222 
01223 \textcolor{keyword}{end function }\hyperlink{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}{ale\_getcoordinateunits}
01224 
01225 \textcolor{comment}{}
01226 \textcolor{comment}{!> Returns true if initial conditions should be regridded and remapped}
01227 \textcolor{keyword}{logical }\textcolor{keyword}{function }\hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{ale\_remap\_init\_conds}( CS )
\Hypertarget{MOM__ALE_8F90_source_l01228}\hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{01228}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< module control structure}
01229 
01230   \hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{ale\_remap\_init\_conds} = .false.
01231   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{ale\_remap\_init\_conds} = cs%remap\_after\_initialization
01232 \textcolor{keyword}{end function }\hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{ale\_remap\_init\_conds}
01233 \textcolor{comment}{}
01234 \textcolor{comment}{!> Updates the weights for time filtering the new grid generated in regridding}
01235 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\_update\_regrid\_weights}( dt, CS )
\Hypertarget{MOM__ALE_8F90_source_l01236}\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{01236}   \textcolor{keywordtype}{real},         \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{ !< Time-step used between ALE calls [T ~> s]}
01237   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< ALE control structure}
01238   \textcolor{comment}{! Local variables}
01239   \textcolor{keywordtype}{real} :: w  \textcolor{comment}{! An implicit weighting estimate.}
01240 
01241   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
01242     w = 0.0
01243     \textcolor{keywordflow}{if} (cs%regrid\_time\_scale > 0.0) \textcolor{keywordflow}{then}
01244       w = cs%regrid\_time\_scale / (cs%regrid\_time\_scale + dt)
01245 \textcolor{keywordflow}{    endif}
01246     \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, old\_grid\_weight=w)
01247 \textcolor{keywordflow}{  endif}
01248 
01249 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\_update\_regrid\_weights}
01250 \textcolor{comment}{}
01251 \textcolor{comment}{!> Update the vertical grid type with ALE information.}
01252 \textcolor{comment}{!! This subroutine sets information in the verticalGrid\_type to be}
01253 \textcolor{comment}{!! consistent with the use of ALE mode.}
01254 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}{ale\_updateverticalgridtype}(CS, GV)
\Hypertarget{MOM__ALE_8F90_source_l01255}\hyperlink{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}{01255}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{  !< ALE control structure}
01256   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: GV\textcolor{comment}{  !< vertical grid information}
01257 
01258   \textcolor{keywordtype}{integer} :: nk
01259 
01260   nk = gv%ke
01261   gv%sInterface(1:nk+1) = getcoordinateinterfaces( cs%regridCS, undo\_scaling=.true. )
01262   gv%sLayer(1:nk) = 0.5*( gv%sInterface(1:nk) + gv%sInterface(2:nk+1) )
01263   gv%zAxisUnits = getcoordinateunits( cs%regridCS )
01264   gv%zAxisLongName = getcoordinateshortname( cs%regridCS )
01265   gv%direction = -1 \textcolor{comment}{! Because of ferret in z* mode. Need method to set}
01266                     \textcolor{comment}{! as function of coordinae mode.}
01267 
01268 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}{ale\_updateverticalgridtype}
01269 
01270 \textcolor{comment}{}
01271 \textcolor{comment}{!> Write the vertical coordinate information into a file.}
01272 \textcolor{comment}{!! This subroutine writes out a file containing any available data related}
01273 \textcolor{comment}{!! to the vertical grid used by the MOM ocean model when in ALE mode.}
01274 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}{ale\_writecoordinatefile}( CS, GV, directory )
\Hypertarget{MOM__ALE_8F90_source_l01275}\hyperlink{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}{01275}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}),            \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{         !< module control structure}
01276   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{         !< ocean vertical grid structure}
01277   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: directory\textcolor{comment}{  !< directory for writing grid info}
01278 
01279   \textcolor{keywordtype}{character(len=240)} :: filepath
01280   \textcolor{keywordtype}{type}(vardesc)      :: vars(2)
01281   \textcolor{keywordtype}{type}(fieldtype)    :: fields(2)
01282   \textcolor{keywordtype}{integer}            :: unit
01283   \textcolor{keywordtype}{real}               :: ds(gv%ke), dsi(gv%ke+1)
01284 
01285   filepath    = trim(directory) // trim(\textcolor{stringliteral}{"Vertical\_coordinate"})
01286   ds(:)       = getcoordinateresolution( cs%regridCS, undo\_scaling=.true. )
01287   dsi(1)      = 0.5*ds(1)
01288   dsi(2:gv%ke) = 0.5*( ds(1:gv%ke-1) + ds(2:gv%ke) )
01289   dsi(gv%ke+1) = 0.5*ds(gv%ke)
01290 
01291   vars(1) = var\_desc(\textcolor{stringliteral}{'ds'}, getcoordinateunits( cs%regridCS ), &
01292                     \textcolor{stringliteral}{'Layer Coordinate Thickness'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'L'},\textcolor{stringliteral}{'1'})
01293   vars(2) = var\_desc(\textcolor{stringliteral}{'ds\_interface'}, getcoordinateunits( cs%regridCS ), &
01294                     \textcolor{stringliteral}{'Layer Center Coordinate Separation'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'i'},\textcolor{stringliteral}{'1'})
01295 
01296   \textcolor{keyword}{call }create\_file(unit, trim(filepath), vars, 2, fields, single\_file, gv=gv)
01297   \textcolor{keyword}{call }write\_field(unit, fields(1), ds)
01298   \textcolor{keyword}{call }write\_field(unit, fields(2), dsi)
01299   \textcolor{keyword}{call }close\_file(unit)
01300 
01301 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}{ale\_writecoordinatefile}
01302 
01303 \textcolor{comment}{}
01304 \textcolor{comment}{!> Set h to coordinate values for fixed coordinate systems}
01305 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}{ale\_initthicknesstocoord}( CS, G, GV, h )
\Hypertarget{MOM__ALE_8F90_source_l01306}\hyperlink{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}{01306}   \textcolor{keywordtype}{type}(\hyperlink{structmom__ale_1_1ale__cs}{ale\_cs}), \textcolor{keywordtype}{intent(inout)}                            :: CS\textcolor{comment}{  !< module control structure}
01307   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}                      :: G\textcolor{comment}{   !< module grid structure}
01308   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}                    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}
01309   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{   !< layer thickness [H ~> m or kg m-2]}
01310 
01311   \textcolor{comment}{! Local variables}
01312   \textcolor{keywordtype}{integer} :: i, j, k
01313 
01314   \textcolor{keywordflow}{do} j = g%jsd,g%jed ; \textcolor{keywordflow}{do} i = g%isd,g%ied
01315     h(i,j,:) = gv%Z\_to\_H * getstaticthickness( cs%regridCS, 0., g%bathyT(i,j) )
01316 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01317 
01318 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}{ale\_initthicknesstocoord}
01319 
01320 \textcolor{keyword}{end module }\hyperlink{namespacemom__ale}{mom\_ale}
\end{DoxyCode}
