src: Ticket #627: VERY IMPORTANT, Please READ: Overhaul of sponges, climatology, and nudging
https://www.myroms.org/projects/src/ticket/627
<p>
<strong>This is a very important update</strong>. Please read careful since it is loaded with information that will be useful when setting realistic applications.
</p>
<p>
It includes changes on how sponge areas are specified. A sponge is an area of increased horizontal viscosity and/or diffusivity. It also includes changes to the processing of climatology fields and nudging of climatology fields. These changes are made <strong>to activate or not</strong> such capabilities during nesting over multiple grids. Several C-preprocessing options are eliminated and replaced with logical switches that read from standard input <strong>ocean.in</strong> and, if appropriate, from biology and sediment input scripts.
</p>
<hr />
<ul><li><strong>Sponge areas:</strong> The CPP option <strong>SPONGE</strong> is eliminated and replaced with logical switches <strong>LuvSponge</strong> and <strong>LtracerSponge</strong>, which are set in input script <strong>ocean.in</strong>:
<pre class="wiki">! Logical switches (TRUE/FALSE) to increase/decrease horizontal viscosity
! and/or diffusivity in specific areas of the application domain (like
! sponge areas) for the desired application grid.
LuvSponge == F ! horizontal momentum
LtracerSponge == F F ! temperature, salinity, inert
</pre><strong>LuvSponge</strong> are logical switches to increase/decrease the horizontal viscosity in specific areas of the domain for a particular grid. It can be used to set sponge areas with larger viscosity coefficients for the damping of high frequency noise due to open boundary conditions or nesting. The horizontal viscosity distribution is set in <strong>ini_hmixcoef.F</strong> as, if <strong>UV_VIS2</strong> or <strong>UV_VIS4</strong> are activated:
<pre class="wiki"> visc2_r(i,j) = visc_factor(i,j) * visc2_r(i,j)
visc4_r(i,j) = visc_factor(i,j) * visc4_r(i,j)
</pre>The new variable <strong>visc_factor</strong> can be read from the application <strong>GRID</strong> NetCDF file. Alternatively, the horizontal viscosity in the sponge area can be set-up with analytical functions in the new header file <strong>ana_sponge.h</strong> using new CPP option <strong>ANA_SPONGE</strong> when the switch <strong>LuvSponge</strong> is turned <strong>ON</strong> for a particular grid. Check the examples in <strong>ana_sponge.h</strong> to see how this is done. <strong>However</strong>, I highly recommend users to add the variable <strong>visc_factor</strong> to their <strong>GRID</strong> NetCDF file to facilitate complex sponges and avoid parallel coding errors:
<pre class="wiki"> double visc_factor(eta_rho, xi_rho) ;
visc_factor:long_name = "horizontal viscosity sponge factor" ;
visc_factor:valid_min = 0. ;
visc_factor:coordinates = "lon_rho lat_rho" ;
</pre>Users may use new Matlab script <strong>add_sponge.m</strong> to append the sponge variables to their application <strong>GRID</strong> NetCDF file. Notice that you can easily plot their values to verify the desired distribution. The values of <strong>visc_factor</strong> must be positive and defined at <strong>RHO</strong>-points. Usually their values are linearly tapered from <strong>one</strong> or <strong>zero</strong> at the inner sponge edge (interior points) to the desired maximum factor (>1) at the outer sponge edge (like domain perimeter). If a factor of <strong>zero</strong> is set over the interior points, the viscosity will be turned <strong>OFF</strong> over such points. Contrarily if a factor of <strong>one</strong> is set over the interior points, the viscosity will be that set in <strong>ocean.in</strong> (<strong>visc2</strong>/<strong>visc4</strong>) and post-processed in <strong>ini_hmixcoef.F</strong> (if scaled by grid size with <strong>VISC_GRID</strong>).
</li></ul><p>
<br />
</p>
<blockquote>
<p>
<strong>LtracerSponge</strong> are logical switches to increase/decrease the horizontal diffusivity in specific areas of the domain for a particular tracer and grid. It can be used to set sponge areas with larger diffusivity coefficients for the desired tracer(s) in order to damp high frequency noise due to open boundary conditions or nesting. The switches for biological and sediment tracer are specified in their respective input scripts. The horizontal diffusivity distribution is set in <strong>ini_hmixcoef.F</strong> as, if <strong>TS_DIF2</strong> or <strong>TS_DIF4</strong> are activated:
</p>
<pre class="wiki"> diff2(i,j,itrc) = diff_factor(i,j) * diff2(i,j,itrc)
diff4(i,j,itrc) = diff_factor(i,j) * diff4(i,j,itrc)
</pre><p>
The new variable <strong>diff_factor</strong> can be read from the application <strong>GRID</strong> NetCDF file. Alternatively, the horizontal diffusivity in the sponge area can be set-up with analytical functions in the new header file <strong>ana_sponge.h</strong> using new CPP option <strong>ANA_SPONGE</strong> when the switches <strong>LtracerSponge</strong> are turned <strong>ON</strong> for a particular tracer and grid. Notice that the <strong>diff_factor</strong> is the same for all active and passive tracers. Check the examples in <strong>ana_sponge.h</strong> to see how this is done. <strong>However</strong>, I highly recommend users to add the variable <strong>diff_factor</strong> to their <strong>GRID</strong> NetCDF file to facilitate complex sponges and avoid parallel coding errors:
</p>
<pre class="wiki"> double diff_factor(eta_rho, xi_rho) ;
diff_factor:long_name = "horizontal diffusivity sponge factor" ;
diff_factor:valid_min = 0. ;
diff_factor:coordinates = "lon_rho lat_rho" ;
</pre><p>
Again, users may use new Matlab script <strong>add_sponge.m</strong> to append the sponge variables to their application <strong>GRID</strong> NetCDF file. Notice that you can easily plot their values to verify the desired distribution. The values of <strong>diff_factor</strong> must be positive and defined at <strong>RHO</strong>-points. Usually their values are linearly tapered from <strong>one</strong> or <strong>zero</strong> at the inner sponge edge (interior points) to the desired maximum factor (>1) at the outer sponge edge (like domain perimeter). If a factor of <strong>zero</strong> is set over the interior points, the viscosity will be turned <strong>OFF</strong> over such points. Contrarily if a factor of <strong>one</strong> is set over the interior points, the diffusivity will be that set in <strong>ocean.in</strong> and passive models (biology, sediment) input scripts (<strong>tnu2</strong>/<strong>tnu4</strong>) and post-processed in <strong>ini_hmixcoef.F</strong> (if scaled by grid size with <strong>DIFF_GRID</strong>).
</p>
</blockquote>
<blockquote>
<p>
<strong>WARNING</strong>: The routine <strong>ini_hmixcoef.F</strong> was modified. It initializes the viscosity and diffusion arrays with the constant (uniform) values specified in standard input file(s). Then if <strong>VISC_GRID</strong> and/or <strong>DIFF_GRID</strong> are activated, it scales the horizontal mixing values according to the maximum grid size; the value read from standard input is assigned to cell with the larger area. Finally, if <strong>LuvSponge(ng)</strong> and/or <strong>LtracerSponge(itrc,ng)</strong> are turned <strong>ON</strong> and <strong>ANA_SPONGE</strong> is not defined, it multiples the horizontal mixing arrays with the sponge factors <strong>visc_factor</strong> and <strong>diff_factor</strong> described above. Check routine for more details.
</p>
</blockquote>
<blockquote>
<p>
Consequently, the header file <strong>ana_hmixcoef.h</strong> is deprecated and replaced with <strong>ana_sponge.h</strong>. So if you were using this capability before with older ROMS versions, you need to code your sponge areas in the new header file <strong>ana_sponge.h</strong>. This is a much simpler file. Notice that the routine <strong>ini_hmixcoef</strong> is called before than <strong>ana_sponge</strong> is called. Therefore, users have two options: (<strong>1</strong>) completely overwrite the horizontal mixing coefficient assigned earlier in <strong>ini_hmixcoef</strong>, or (<strong>2</strong>) only increase horizontal mixing in the sponge areas. The sponge areas in <strong>ana_sponge</strong> can be coded as a non-dimensional factor as it is done in <strong>ini_hmixcoef</strong> with <strong>visc_factor</strong> and <strong>diff_factor</strong>. Or a complete overwrite, which is not recommended if either <strong>VISC_GRID</strong> and <strong>DIFF_GRID</strong> are activated.
</p>
</blockquote>
<blockquote>
<p>
Again, it is much easier to add the sponge scales <strong>visc_factor</strong> and <strong>diff_factor</strong> to the application GRID NetCDF file. <strong>Please follow this advice.
</p>
</blockquote>
<p>
</strong>
</p>
<hr />
<ul><li><strong>Climatology Fields</strong>: The CPP options <strong>ZCLIMATOLOGY</strong>, <strong>M2CLIMATOLOGY</strong>, <strong>M3CLIMATOLOGY</strong>, and <strong>TCLIMATOLOGY</strong> used to process climatology fields are eliminated and replaced with logical switches <strong>LsshCLM</strong>, <strong>Lm2CLM</strong>, <strong>Lm3CLM</strong>, and <strong>LtracerCLM</strong>, respectively. They are set in input script <strong>ocean.in</strong>:
<pre class="wiki">! Logical switches (TRUE/FALSE) to read and process climatology fields.
! See glossary below for details.
LsshCLM == F ! sea-surface height
Lm2CLM == F ! 2D momentum
Lm3CLM == F ! 3D momentum
LtracerCLM == F F ! temperature, salinity, inert
</pre>The switches for the biological and sediment tracers are specified in their respective input scripts. These climatology processing switches are either used to read climatology from a NetCDF file or to set their values with analytical functions. The climatology fields can be used for open boundary conditions, nudging in sponge areas, nudging relaxation terms, and horizontal mixing (tracers only).
</li></ul><blockquote>
<p>
The sea-surface height (SSH) climatology. <strong>CLIMA(ng)%ssh</strong>, is not used but it is kept for future use. The nudging of SSH on the free-surface governing equation (vertically integrated continuity equation) is <strong>not</strong> allowed because it violates mass/volume conservation. Recall that the time rate of change of free-surface is computed from the divergence of <strong>ubar</strong> and <strong>vbar</strong>. If such nudging term is required, it needs to be specified on the momentum equations for (<strong>u</strong>,<strong>v</strong>) and/or (<strong>ubar</strong>,<strong>vbar</strong>). If done on (<strong>u</strong>,<strong>v</strong>) only, its effects enter the 2D momentum equations via the residual vertically integrated forcing terms (<strong>rufrc</strong>, <strong>rvfrc</strong>).
</p>
</blockquote>
<blockquote>
<p>
The <strong>LtracerCLM</strong> switches determine which tracer to process and the size of the fourth dimension of <strong>CLIMA(ng)%tclm</strong>. It is only dimensioned to the number of tracers to process, <strong>NTCLM(ng)</strong>, in order to reduce memory usage. An internal counter, <strong>ic</strong>, is used in the code to use the correct tracer. For example, in <strong>step3d_t</strong> we have:
</p>
<pre class="wiki"> ic=0
DO itrc=1,NT(ng)
IF (LtracerCLM(itrc,ng).and.LnudgeTCLM(itrc,ng)) THEN
ic=ic+1
DO k=1,N(ng)
DO j=JstrR,JendR
DO i=IstrR,IendR
t(i,j,k,nnew,itrc)=t(i,j,k,nnew,itrc)+ &
& dt(ng)* &
& CLIMA(ng)%Tnudgcof(i,j,k,ic)* &
& (CLIMA(ng)%tclm(i,j,k,ic)- &
& t(i,j,k,nnew,itrc))
END DO
END DO
END DO
END IF
END DO
</pre></blockquote>
<hr />
<ul><li><strong>Nudging</strong>: The nudging to climatology CPP options <strong>M2CLM_NUDGING</strong>, <strong>M3CLM_NUDGING</strong>, <strong>TCLM_NUDGING</strong> are eliminated and replaced with logical switches <strong>LnudgeM2CLM</strong>, <strong>LnudgeM3CLM</strong>, and <strong>LnudgeTCLM</strong>, respectively. They are set in input script <strong>ocean.in</strong>:
<pre class="wiki">! Logical switches (TRUE/FALSE) to nudge the desired climatology field(s).
! If not analytical climatology fields, users need to turn ON the logical
! switches above to process the fields from the climatology NetCDF file
! that are needed for nudging. See glossary below for details.
LnudgeM2CLM == F ! 2D momentum
LnudgeM3CLM == F ! 3D momentum
LnudgeTCLM == F F ! temperature, salinity, inert
</pre>The switches for biological and sediment tracers are specified in their respective input scripts. Users also need activate the respective switches to process the climatology fields to nudge: <strong>Lm2CLM</strong>, <strong>Lm3CLM</strong>, and <strong>LtracerCLM</strong>, respectively. This is done with two switches because the processing of climatology in ROMS is used for various options and not just nudging.
</li></ul><blockquote>
<p>
<strong>Nudging Inverse Time Scales</strong>: The inverse nudging scales (1/time) can be read from new NetCDF file <strong>NUDNAME</strong> in <strong>ocean.in</strong>:
</p>
<pre class="wiki">! Input climatology nudging coefficients file name.
NUDNAME == ocean_nud.nc
</pre><p>
or set with analytical functions when the <strong>new</strong> CPP option <strong>ANA_NUDGCOEF</strong> is activated. The inverse nudging scales are stored in ROMS in the following variables:
</p>
<pre class="wiki"> CLIMA(ng) % M2nudgcof(i,j) 2D momentum
CLIMA(ng) % M3nudgcof(i,j,k) 3D momentum
CLIMA(ng) % Tnudgcof(i,j,k,itrc) Tracers
</pre><p>
Notice that now the nudging scales for 3D momentum and tracers <strong>has a depth dependency</strong>. This will be handy, for example, when relaxing temperature and salinity to climatology below a specific depth (say, z=-2000m).
</p>
</blockquote>
<blockquote>
<p>
In order to allow complex nudging distributions, I <strong>highly recommend</strong> users to set the nudging inverse time scales outside of ROMS and write into the new <strong>NUDNAME</strong> NetCDF file. The metadata for the NetCDF variables is as follows:
</p>
<pre class="wiki"> double M2_NudgeCoef(eta_rho, xi_rho) ;
M2_NudgeCoef:long_name = "2D momentum inverse nudging coefficients" ;
M2_NudgeCoef:units = "day-1" ;
M2_NudgeCoef:coordinates = "xi_rho eta_rho " ;
double M3_NudgeCoef(s_rho, eta_rho, xi_rho) ;
M3_NudgeCoef:long_name = "3D momentum inverse nudging coefficients" ;
M3_NudgeCoef:units = "day-1" ;
M3_NudgeCoef:coordinates = "xi_rho eta_rho s_rho " ;
double tracer_NudgeCoef(s_rho, eta_rho, xi_rho) ;
tracer_NudgeCoef:long_name = "generic tracer inverse nudging coefficients" ;
tracer_NudgeCoef:units = "day-1" ;
tracer_NudgeCoef:coordinates = "xi_rho eta_rho s_rho " ;
double temp_NudgeCoef(s_rho, eta_rho, xi_rho) ;
temp_NudgeCoef:long_name = "temp inverse nudging coefficients" ;
temp_NudgeCoef:units = "day-1" ;
temp_NudgeCoef:coordinates = "xi_rho eta_rho s_rho " ;
double salt_NudgeCoef(s_rho, eta_rho, xi_rho) ;
salt_NudgeCoef:long_name = "salt inverse nudging coefficients" ;
salt_NudgeCoef:units = "day-1" ;
salt_NudgeCoef:coordinates = "xi_rho eta_rho s_rho " ;
</pre><p>
A template script <strong>d_nudgcoef.m</strong> is provided in the matlab/initial repository to create this new NetCDF file.
</p>
</blockquote>
<blockquote>
<p>
A new routine <strong>get_nudgcoef.F</strong> is added to read these nudging inverse time scales. This routine will check the <strong>units</strong> attribute to convert the scales to 1/second. If the nudging scales for a specific tracer are available (say <strong>salt_NudgCoef</strong>) it will read that NetCDF variable. If <strong>not and</strong> the generic scales are available (<strong>tracer_NudgeCoef</strong>), it will process those values instead. This strategy give us a lot of flexibility when setting nudging for a particular application. The generic <strong>tracer_NudgeCoef</strong> variable is useful when nudging passive (biology and sediment) tracers.
</p>
</blockquote>
<blockquote>
<p>
<strong> WARNING:</strong> The header file <strong>ana_nudgcoef.h</strong> was modified to include depth dependency in the nudging inverse time scales. The routine is simpler now. However, please use the NetCDF file instead to avoid parallel coding errors. Recall that you can plot and fine tune the variables outside of ROMS.
</p>
</blockquote>
<blockquote>
<p>
If passive/active radiation open boundary conditions and activated climatology nudging, the inverse time scales are used directly in the open boundary conditions routines instead of the uniform variables <strong>*obc_out</strong> and <strong>*obc_in</strong>. Notice that this logic was removed from <strong>ana_nudgcoef.h</strong>.
</p>
</blockquote>
<hr />
<blockquote>
<p>
<strong>WARNING</strong>: all the input scripts for <strong>ocean_*.in</strong>, biological input scripts, and sediment input scripts were updated to include all the new switches described above. The <strong>test repository</strong> was also updated.
</p>
</blockquote>
<hr />
<p>
Again, please use the NetCDF options discussed above instead of coding with analytical functions. We keep these analytical functions as part of the legacy code. Coding such routines require extensive parallel expertise. So if you are in doubt, set a NetCDF file instead. It is much easier. I will ignore forum messages asking for help or guidance how to code such analytical functions.
</p>
<p>
This constitutes the final piece in the nesting algorithms. I have seen some nesting inquires in the forum. Nesting requires expertise to set-up and a lot of patience. There are a lot things that you need to think when setting a nesting application: dynamical regimes, atmospheric forcing, volume/mass conservation, grid topology, bathymetry, land/sea masking, and so on. You just cannot put a nesting grid anywhere! Many users think about nesting as a grid generation problem, but it is much more than that. We cannot provide you with a cooking recipe for nesting so you just need to get your hands dirty and try various strategies until you find one that works for your particular application.
</p>
en-ussrc/content/trac/src/htdocs/src_banner.png
https://www.myroms.org/projects/src/ticket/627
Trac 1.0.13arangoThu, 13 Mar 2014 17:31:32 GMTdescription changed
https://www.myroms.org/projects/src/ticket/627#comment:1
https://www.myroms.org/projects/src/ticket/627#comment:1
<ul>
<li><strong>description</strong>
modified (<a href="/projects/src/ticket/627?action=diff&version=1">diff</a>)
</li>
</ul>
TicketarangoThu, 13 Mar 2014 17:32:53 GMTdescription changed
https://www.myroms.org/projects/src/ticket/627#comment:2
https://www.myroms.org/projects/src/ticket/627#comment:2
<ul>
<li><strong>description</strong>
modified (<a href="/projects/src/ticket/627?action=diff&version=2">diff</a>)
</li>
</ul>
TicketarangoThu, 13 Mar 2014 18:44:26 GMTdescription changed
https://www.myroms.org/projects/src/ticket/627#comment:3
https://www.myroms.org/projects/src/ticket/627#comment:3
<ul>
<li><strong>description</strong>
modified (<a href="/projects/src/ticket/627?action=diff&version=3">diff</a>)
</li>
</ul>
TicketarangoThu, 13 Mar 2014 23:03:22 GMTstatus, description changed; resolution set
https://www.myroms.org/projects/src/ticket/627#comment:4
https://www.myroms.org/projects/src/ticket/627#comment:4
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>Done</em>
</li>
<li><strong>description</strong>
modified (<a href="/projects/src/ticket/627?action=diff&version=4">diff</a>)
</li>
</ul>
Ticket