Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new loss term for internal waves: scattering to higher modes #33

Closed
wants to merge 98 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
36d4f7f
Bugfix: cpu clock sync error
marshallward Dec 4, 2021
e48f4a7
+Add the new routine unit_no_scaling_init
Hallberg-NOAA Dec 6, 2021
59c5926
(*)Provide US arguments to 4 existing calls
Hallberg-NOAA Dec 6, 2021
3162bd0
+Make US arguments non-optional for 28 routines
Hallberg-NOAA Dec 6, 2021
763ddab
Docs: Add NASA-GMAO to consortium figure
marshallward Dec 6, 2021
582de2e
add infrastructure for residual term
Nov 29, 2021
196586d
add residual term loss on flux
Dec 8, 2021
6807892
clean up/ move to implicit update
Dec 8, 2021
3ce6a31
Merge branch 'dev/gfdl' into cpu_clock_sync_bugfix
Hallberg-NOAA Dec 9, 2021
833cd30
+Remove clocks inside of j-loops
Hallberg-NOAA Dec 5, 2021
8b5c1c8
Deallocate eta_PF_start to avoid a memory leak
Hallberg-NOAA Dec 5, 2021
3f46b6a
+Set find_salt_root if SHELF_THREE_EQN = .False.
Hallberg-NOAA Dec 5, 2021
ec553aa
+Obsolete ETA_TOLERANCE_AUX
Hallberg-NOAA Dec 5, 2021
d733714
(*)Fix extract_diabatic_member
Hallberg-NOAA Dec 10, 2021
5172c49
Warn if opacity_from_chl is called without fluxes
Hallberg-NOAA Dec 10, 2021
90739be
Correct comments describing advect_tracer args
Hallberg-NOAA Dec 10, 2021
3364af1
Update indexing of array passed to data_override.
wfcooke Dec 6, 2021
2319139
Correct out of bounds index (por_face_areaU) bug
Hallberg-NOAA Dec 7, 2021
05edb63
(*)Offline tracer read bug fix
Hallberg-NOAA Dec 10, 2021
fcfd238
+Refactored and rescaled the offline tracer code
Hallberg-NOAA Dec 11, 2021
09bcea2
Merge branch 'dev/gfdl' into cpu_clock_sync_bugfix
Hallberg-NOAA Dec 11, 2021
112ac49
+(*)Revised offline tracer algorithms
Hallberg-NOAA Dec 11, 2021
0895fe3
Merge branch 'dev/gfdl' into offline_tracer_fix
Hallberg-NOAA Dec 11, 2021
fbafcb1
Merge branch 'dev/gfdl' into mandatory_US_args
Hallberg-NOAA Dec 11, 2021
86b91dc
Merge pull request #29 from Hallberg-NOAA/mandatory_US_args
marshallward Dec 12, 2021
e452a29
Merge branch 'dev/gfdl' into cpu_clock_sync_bugfix
Hallberg-NOAA Dec 12, 2021
7ae28b8
Merge pull request #27 from marshallward/cpu_clock_sync_bugfix
Hallberg-NOAA Dec 13, 2021
8824671
Merge branch 'dev/gfdl' into consortium_fig_update
Hallberg-NOAA Dec 13, 2021
8f5dc28
Merge pull request #31 from marshallward/consortium_fig_update
Hallberg-NOAA Dec 13, 2021
cf931b1
Eliminate unneeded diagnostic arrays
Hallberg-NOAA Dec 9, 2021
170fffd
MOM_sponge cleanup
Hallberg-NOAA Dec 9, 2021
6feadd0
Use G%Rad_Earth_L in mct and NUOPC cap code
Hallberg-NOAA Dec 11, 2021
bbb9753
+Rescale some sea-surface height variables to [Z]
Hallberg-NOAA Dec 11, 2021
86eb106
Correct the units in two comments
Hallberg-NOAA Dec 15, 2021
049241c
+Rescaled optics%opacity_band
Hallberg-NOAA Dec 16, 2021
08cd63b
Merge branch 'dev/gfdl' into opacity_rescale
Hallberg-NOAA Dec 16, 2021
0544f9f
+(*)Avoid segmentation faults if PEN_SW_NBANDS = 0
Hallberg-NOAA Dec 16, 2021
50df270
Ice dynamics (#35)
OlgaSergienko Dec 17, 2021
12f29f6
Adding temperature restore capability for SPEAR. (#36)
wfcooke Dec 18, 2021
a902e75
+Add US args and rescale dt arg to generic tracers
Hallberg-NOAA Dec 13, 2021
9cb9304
EMC stochastic candidate 20211028 (#1538)
jiandewang Dec 20, 2021
986bc8c
Corrected the unit documentation for 31 variables
Hallberg-NOAA Dec 14, 2021
d244246
+Rescale tides and ramp-up times
Hallberg-NOAA Dec 14, 2021
9a5e218
Merge branch 'main' into main_to_dev_gfdl
marshallward Dec 21, 2021
bf43fd8
Merge pull request #47 from marshallward/main_to_dev_gfdl
adcroft Dec 21, 2021
5d4e8a1
(*)Removed problematic offline tracer lines
Hallberg-NOAA Dec 22, 2021
dad675a
Fix badge URL for codecov
adcroft Dec 22, 2021
34554d0
Merge branch 'dev/gfdl' into offline_tracer_fix
Hallberg-NOAA Dec 22, 2021
e3c0b72
Merge branch 'dev/gfdl' into offline_tracer_fix
Hallberg-NOAA Dec 22, 2021
f35edbd
Bugfix - calculate density integrals in ALE mode w/ pressure_reconstr…
MJHarrison-GFDL Dec 17, 2021
f865b24
Update MOM_PressureForce_FV.F90
marshallward Dec 23, 2021
b628748
Correct comments describing generic_tracer args
Hallberg-NOAA Dec 16, 2021
6bcea76
Fixes an uninitialized logical in FMS_cap
adcroft Dec 22, 2021
d9d82e3
Eliminate unneeded diagnostic arrays in CorAdCalc
Hallberg-NOAA Dec 23, 2021
a8a2039
Merge branch 'dev/gfdl' into opacity_rescale
Hallberg-NOAA Dec 27, 2021
1028ee0
Merge pull request #43 from Hallberg-NOAA/opacity_rescale
marshallward Dec 29, 2021
c32ec97
Merge branch 'dev/gfdl' into offline_tracer_fix
Hallberg-NOAA Dec 29, 2021
5ad8a2c
Deleted commented out offline tracer lines
Hallberg-NOAA Dec 29, 2021
2b2214d
(*)Use por_face_area in zonal_face_thickness
Hallberg-NOAA Dec 23, 2021
e5a5407
Merge branch 'dev/gfdl' into offline_tracer_fix
marshallward Dec 29, 2021
71cf831
Merge pull request #37 from Hallberg-NOAA/offline_tracer_fix
marshallward Dec 29, 2021
2d32631
Option to homogenize forces and fluxes (#51)
breichl Jan 3, 2022
df46be4
Hydrostatic initialization in ice cavities (#41)
MJHarrison-GFDL Jan 6, 2022
f7a2254
Rewrite horizontal regridding to use netCDF wrapper functions (#48)
marshallward Jan 8, 2022
d838ccd
Clean up non-standard syntax and whitespace
Hallberg-NOAA Jan 8, 2022
6da5c9b
Standardize code in calc_sfc_displacement
Hallberg-NOAA Jan 8, 2022
9f0018f
+(*)Change the remapping dzInterface argument sign
Hallberg-NOAA Jan 18, 2022
03a247e
Avoid divide by zero in horizontal_viscosity() with better_bound_kh
adcroft Jan 21, 2022
e63c405
Fix soft-conventional index capitalization in horizontal_viscosity()
adcroft Jan 21, 2022
65998cd
Esmg docs (#57)
kshedstrom Jan 26, 2022
3f58f8a
read_variable_2d modified to accept 3 or 4 dims
marshallward Feb 3, 2022
56401b6
+Add MOM_check_scaling.F90 and MOM_scaling_check.F90
Hallberg-NOAA Dec 22, 2021
75bf521
+Move MOM_scaling_check.F90 to MOM_unique_scales.F90
Hallberg-NOAA Jan 24, 2022
64f432f
Diabatic driver: energetic_PBL -> ePBL, flag check
marshallward Feb 16, 2022
fc5253f
(*)Correct memory declarations in MOM_regridding
Hallberg-NOAA Jan 24, 2022
c166358
Add optional argument to FMS2 version of get_field_size
MJHarrison-GFDL Feb 1, 2022
e841609
remove unnecessary optional flag
MJHarrison-GFDL Feb 2, 2022
6f6d4d6
Merge pull request #1556 from NOAA-GFDL/dev-gfdl-main-candidate-2022-…
marshallward Feb 17, 2022
5f56798
Merge branch 'main' into main_to_dev
marshallward Feb 18, 2022
32e1ecf
Fixes issues with the GME code and get_param calls for Leith options …
gustavo-marques Feb 20, 2022
149073f
Remove hard-wired parameter in adjustEtaToFitBathymetry (#69)
gustavo-marques Feb 20, 2022
712ff9e
Merge branch 'dev/gfdl' into main_to_dev
Hallberg-NOAA Feb 20, 2022
2e72b88
Merge pull request #71 from NOAA-GFDL/main_to_dev
Hallberg-NOAA Feb 21, 2022
d46dbc7
Report mean temperature from MOM_state_stats()
Hallberg-NOAA Dec 16, 2021
9c7bf29
+Add global_mass_int_EFP
Hallberg-NOAA Dec 16, 2021
8197cea
Use global_mass_integral in lateral_bdry_diff
Hallberg-NOAA Dec 16, 2021
1bf8220
(*)+Reproducing tracer stocks
Hallberg-NOAA Dec 16, 2021
a0d0238
(*)+Use reproducing stocks for all tracer packages
Hallberg-NOAA Feb 21, 2022
a468bee
Removed trailing white space
Hallberg-NOAA Feb 23, 2022
9caa701
(+) Refactor of MOM_file_parser
marshallward Feb 23, 2022
cf193a8
Merge pull request #74 from marshallward/file_parser_refactor
Hallberg-NOAA Feb 28, 2022
9a01cd5
+Add ALE options mimicking Hycom
Hallberg-NOAA Feb 26, 2022
4640461
(*)Avoid negative thicknesses in mixed_layer_restrat
Hallberg-NOAA Feb 24, 2022
dadd182
add infrastructure for residual term
Nov 29, 2021
b671a87
add residual term loss on flux
Dec 8, 2021
46d292c
clean up/ move to implicit update
Dec 8, 2021
0120792
parenthesis
Mar 9, 2022
6a208f1
Merge branch 'residualIW' of github.com:raphaeldussin/MOM6 into resid…
Mar 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add infrastructure for residual term
Raphael Dussin authored and Raphael Dussin committed Mar 9, 2022
commit dadd18251317247b4d371dbabd694ac6feb16f7f
79 changes: 74 additions & 5 deletions src/parameterizations/lateral/MOM_internal_tides.F90
Original file line number Diff line number Diff line change
@@ -65,6 +65,10 @@ module MOM_internal_tides
!< identifies reflection cells where double reflection
!! is possible (i.e. ridge cells)
! (could be in G control structure)
real, allocatable, dimension(:,:) :: trans
!< partial transmission coeff for each "coast cell"
real, allocatable, dimension(:,:) :: residual
!< residual of reflection and transmission coeff for each "coast cell"
real, allocatable, dimension(:,:,:,:) :: cp
!< horizontal phase speed [L T-1 ~> m s-1]
real, allocatable, dimension(:,:,:,:,:) :: TKE_leak_loss
@@ -79,6 +83,8 @@ module MOM_internal_tides
!! the energy losses in [R Z3 T-3 ~> W m-2]
real, allocatable, dimension(:,:,:,:,:) :: TKE_itidal_loss
!< energy lost due to small-scale wave drag [R Z3 T-3 ~> W m-2]
real, allocatable, dimension(:,:,:,:,:) :: TKE_residual_loss

real, allocatable, dimension(:,:) :: tot_leak_loss !< Energy loss rates due to misc bakground processes,
!! summed over angle, frequency and mode [R Z3 T-3 ~> W m-2]
real, allocatable, dimension(:,:) :: tot_quad_loss !< Energy loss rates due to quadratic bottom drag,
@@ -87,6 +93,8 @@ module MOM_internal_tides
!! summed over angle, frequency and mode [R Z3 T-3 ~> W m-2]
real, allocatable, dimension(:,:) :: tot_Froude_loss !< Energy loss rates due to wave breaking,
!! summed over angle, frequency and mode [R Z3 T-3 ~> W m-2]
real, allocatable, dimension(:,:) :: tot_residual_loss !< Energy loss rates due to wave breaking,

real, allocatable, dimension(:,:) :: tot_allprocesses_loss !< Energy loss rates due to all processes,
!! summed over angle, frequency and mode [R Z3 T-3 ~> W m-2]
real :: q_itides !< fraction of local dissipation [nondim]
@@ -107,6 +115,8 @@ module MOM_internal_tides
!< If true, apply scattering due to small-scale roughness as a sink.
logical :: apply_Froude_drag
!< If true, apply wave breaking as a sink.
logical :: apply_residual_drag
!< If true, apply sink from residual term of reflection/transmission.
real, allocatable :: En(:,:,:,:,:)
!< The internal wave energy density as a function of (i,j,angle,frequency,mode)
!! integrated within an angular and frequency band [R Z3 T-2 ~> J m-2]
@@ -122,10 +132,11 @@ module MOM_internal_tides
! Diag handles relevant to all modes, frequencies, and angles
integer :: id_tot_En = -1, id_TKE_itidal_input = -1, id_itide_drag = -1
integer :: id_refl_pref = -1, id_refl_ang = -1, id_land_mask = -1
integer :: id_trans = -1, id_residual = -1
integer :: id_dx_Cv = -1, id_dy_Cu = -1
! Diag handles considering: sums over all modes, frequencies, and angles
integer :: id_tot_leak_loss = -1, id_tot_quad_loss = -1, id_tot_itidal_loss = -1
integer :: id_tot_Froude_loss = -1, id_tot_allprocesses_loss = -1
integer :: id_tot_Froude_loss = -1, id_tot_residual_loss = -1, id_tot_allprocesses_loss = -1
! Diag handles considering: all modes & freqs; summed over angles
integer, allocatable, dimension(:,:) :: &
id_En_mode, &
@@ -184,7 +195,7 @@ subroutine propagate_int_tide(h, tv, cn, TKE_itidal_input, vel_btTide, Nb, dt, &
flux_prec_y
real, dimension(SZI_(G),SZJ_(G)) :: &
tot_En, & ! energy summed over angles, modes, frequencies [R Z3 T-2 ~> J m-2]
tot_leak_loss, tot_quad_loss, tot_itidal_loss, tot_Froude_loss, tot_allprocesses_loss, &
tot_leak_loss, tot_quad_loss, tot_itidal_loss, tot_Froude_loss, tot_residual_loss, tot_allprocesses_loss, &
! energy loss rates summed over angle, freq, and mode [R Z3 T-3 ~> W m-2]
htot, & ! The vertical sum of the layer thicknesses [H ~> m or kg m-2]
drag_scale, & ! bottom drag scale [T-1 ~> s-1]
@@ -502,6 +513,16 @@ subroutine propagate_int_tide(h, tv, cn, TKE_itidal_input, vel_btTide, Nb, dt, &
enddo ; enddo
enddo ; enddo ; enddo

! loss from residual of reflection/transmission coefficients
if (CS%apply_residual_drag) then
do m=1,CS%nMode ; do fr=1,CS%nFreq ; do a=1,CS%nAngle ; do j=jsd,jed ; do i=isd,ied

CS%TKE_residual_loss(i,j,a,fr,m) = CS%En(i,j,a,fr,m) * CS%residual(i,j) * CS%decay_rate ! loss rate [R Z3 T-3 ~> W m-2] RD???
CS%En(i,j,a,fr,m) = CS%En(i,j,a,fr,m) / (1.0 + dt * CS%residual(i,j) * CS%decay_rate) ! implicit update
enddo ; enddo ; enddo ; enddo ; enddo
endif


! Check for energy conservation on computational domain.*************************
do m=1,CS%NMode ; do fr=1,CS%Nfreq
call sum_En(G,CS,CS%En(:,:,:,fr,m),'prop_int_tide')
@@ -537,21 +558,25 @@ subroutine propagate_int_tide(h, tv, cn, TKE_itidal_input, vel_btTide, Nb, dt, &
tot_quad_loss(:,:) = 0.0
tot_itidal_loss(:,:) = 0.0
tot_Froude_loss(:,:) = 0.0
tot_residual_loss(:,:) = 0.0
tot_allprocesses_loss(:,:) = 0.0
do m=1,CS%NMode ; do fr=1,CS%Nfreq ; do a=1,CS%nAngle ; do j=js,je ; do i=is,ie
tot_leak_loss(i,j) = tot_leak_loss(i,j) + CS%TKE_leak_loss(i,j,a,fr,m)
tot_quad_loss(i,j) = tot_quad_loss(i,j) + CS%TKE_quad_loss(i,j,a,fr,m)
tot_itidal_loss(i,j) = tot_itidal_loss(i,j) + CS%TKE_itidal_loss(i,j,a,fr,m)
tot_Froude_loss(i,j) = tot_Froude_loss(i,j) + CS%TKE_Froude_loss(i,j,a,fr,m)
tot_residual_loss(i,j) = tot_residual_loss(i,j) + CS%TKE_residual_loss(i,j,a,fr,m)
enddo ; enddo ; enddo ; enddo ; enddo
do j=js,je ; do i=is,ie
tot_allprocesses_loss(i,j) = tot_leak_loss(i,j) + tot_quad_loss(i,j) + &
tot_itidal_loss(i,j) + tot_Froude_loss(i,j)
tot_itidal_loss(i,j) + tot_Froude_loss(i,j) + &
tot_residual_loss(i,j)
enddo ; enddo
CS%tot_leak_loss = tot_leak_loss
CS%tot_quad_loss = tot_quad_loss
CS%tot_itidal_loss = tot_itidal_loss
CS%tot_Froude_loss = tot_Froude_loss
CS%tot_residual_loss = tot_residual_loss
CS%tot_allprocesses_loss = tot_allprocesses_loss
if (CS%id_tot_leak_loss > 0) then
call post_data(CS%id_tot_leak_loss, tot_leak_loss, CS%diag)
@@ -565,6 +590,9 @@ subroutine propagate_int_tide(h, tv, cn, TKE_itidal_input, vel_btTide, Nb, dt, &
if (CS%id_tot_Froude_loss > 0) then
call post_data(CS%id_tot_Froude_loss, tot_Froude_loss, CS%diag)
endif
if (CS%id_tot_residual_loss > 0) then
call post_data(CS%id_tot_residual_loss, tot_residual_loss, CS%diag)
endif
if (CS%id_tot_allprocesses_loss > 0) then
call post_data(CS%id_tot_allprocesses_loss, tot_allprocesses_loss, CS%diag)
endif
@@ -578,7 +606,8 @@ subroutine propagate_int_tide(h, tv, cn, TKE_itidal_input, vel_btTide, Nb, dt, &
itidal_loss_mode(i,j) = itidal_loss_mode(i,j) + CS%TKE_itidal_loss(i,j,a,fr,m)
allprocesses_loss_mode(i,j) = allprocesses_loss_mode(i,j) + &
CS%TKE_leak_loss(i,j,a,fr,m) + CS%TKE_quad_loss(i,j,a,fr,m) + &
CS%TKE_itidal_loss(i,j,a,fr,m) + CS%TKE_Froude_loss(i,j,a,fr,m)
CS%TKE_itidal_loss(i,j,a,fr,m) + CS%TKE_Froude_loss(i,j,a,fr,m) + &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be sure to add parentheses specifying the order of sums of 3 or more terms, here and elsewhere in this module.
The expressions A+(B+C) and (A+B)+C are not the same at the level of roundoff, and the differences can be very significant if they are of opposite signs and diversion magnitudes. Consider the sum of 1, -1 and 1e-20, which for double precision floating point numbers could give 0 or 1e-20, depending on the order in which the sums are done.
We have often found it very helpful for debugging enforce the order of these sums with parentheses. (In fact, we are thinking of using Marshall's Flint capabilities to detect and replace every instance where the code does not specify the order of 2 or more sums.)

CS%TKE_residual_loss(i,j,a,fr,m)
enddo ; enddo ; enddo
call post_data(CS%id_itidal_loss_mode(fr,m), itidal_loss_mode, CS%diag)
call post_data(CS%id_allprocesses_loss_mode(fr,m), allprocesses_loss_mode, CS%diag)
@@ -2150,7 +2179,7 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
character(len=160) :: var_descript
character(len=200) :: filename
character(len=200) :: refl_angle_file, land_mask_file
character(len=200) :: refl_pref_file, refl_dbl_file
character(len=200) :: refl_pref_file, refl_dbl_file, trans_file
character(len=200) :: dy_Cu_file, dx_Cv_file
character(len=200) :: h2_file

@@ -2269,6 +2298,9 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
call get_param(param_file, mdl, "INTERNAL_TIDE_WAVE_DRAG", CS%apply_wave_drag, &
"If true, apply scattering due to small-scale roughness as a sink.", &
default=.false.)
call get_param(param_file, mdl, "INTERNAL_TIDE_RESIDUAL_DRAG", CS%apply_residual_drag, &
"If true, TBD", &
default=.false.)
call get_param(param_file, mdl, "INTERNAL_TIDE_DRAG_MIN_DEPTH", CS%drag_min_depth, &
"The minimum total ocean thickness that will be used in the denominator "//&
"of the quadratic drag terms for internal tides.", &
@@ -2307,10 +2339,12 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
allocate(CS%TKE_quad_loss(isd:ied,jsd:jed,num_angle,num_freq,num_mode), source=0.0)
allocate(CS%TKE_itidal_loss(isd:ied,jsd:jed,num_angle,num_freq,num_mode), source=0.0)
allocate(CS%TKE_Froude_loss(isd:ied,jsd:jed,num_angle,num_freq,num_mode), source=0.0)
allocate(CS%TKE_residual_loss(isd:ied,jsd:jed,num_angle,num_freq,num_mode), source=0.0)
allocate(CS%tot_leak_loss(isd:ied,jsd:jed), source=0.0)
allocate(CS%tot_quad_loss(isd:ied,jsd:jed), source=0.0)
allocate(CS%tot_itidal_loss(isd:ied,jsd:jed), source=0.0)
allocate(CS%tot_Froude_loss(isd:ied,jsd:jed), source=0.0)
allocate(CS%tot_residual_loss(isd:ied,jsd:jed), source=0.0)

! Compute the fixed part of the bottom drag loss from baroclinic modes
call get_param(param_file, mdl, "H2_FILE", h2_file, &
@@ -2406,6 +2440,32 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
else ; CS%refl_dbl(i,j) = .false. ; endif
enddo ; enddo

! Read in the transmission coefficient and infer the residual
call get_param(param_file, mdl, "TRANS_FILE", trans_file, &
"The path to the file containing the transmission coefficent for internal tides.", &
fail_if_missing=.false., default='')
filename = trim(CS%inputdir) // trim(trans_file)
allocate(CS%trans(isd:ied,jsd:jed), source=0.0)
if (file_exists(filename, G%domain)) then
call log_param(param_file, mdl, "INPUTDIR/TRANS_FILE", filename)
call MOM_read_data(filename, 'trans', CS%trans, G%domain)
else
if (trim(trans_file) /= '' ) call MOM_error(FATAL, &
"TRANS_FILE: "//trim(filename)//" not found")
endif

call pass_var(CS%trans,G%domain)
! residual
allocate(CS%residual(isd:ied,jsd:jed), source=0.0)
do j=jsd,jed
do i=isd,ied
if (CS%refl_pref_logical(i,j)) then
CS%residual(i,j) = 1. - CS%refl_pref(i,j) - CS%trans(i,j)
endif
enddo
enddo
call pass_var(CS%residual,G%domain)

! Read in prescribed land mask from file (if overwriting -BDM).
! This should be done in MOM_initialize_topography subroutine
! defined in MOM_fixed_initialization.F90 (BDM)
@@ -2445,6 +2505,10 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
Time, 'Local angle of coastline/ridge/shelf with respect to equator', 'rad')
CS%id_refl_pref = register_diag_field('ocean_model', 'refl_pref', diag%axesT1, &
Time, 'Partial reflection coefficients', '')
CS%id_trans = register_diag_field('ocean_model', 'trans', diag%axesT1, &
Time, 'Partial transmission coefficients', '')
CS%id_residual = register_diag_field('ocean_model', 'residual', diag%axesT1, &
Time, 'Residual of reflection and transmission coefficients', '')
CS%id_dx_Cv = register_diag_field('ocean_model', 'dx_Cv', diag%axesT1, &
Time, 'North face unblocked width', 'm', conversion=US%L_to_m)
CS%id_dy_Cu = register_diag_field('ocean_model', 'dy_Cu', diag%axesT1, &
@@ -2454,6 +2518,8 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
! Output reflection parameters as diags here (not needed every timestep)
if (CS%id_refl_ang > 0) call post_data(CS%id_refl_ang, CS%refl_angle, CS%diag)
if (CS%id_refl_pref > 0) call post_data(CS%id_refl_pref, CS%refl_pref, CS%diag)
if (CS%id_trans > 0) call post_data(CS%id_trans, CS%trans, CS%diag)
if (CS%id_residual > 0) call post_data(CS%id_residual, CS%residual, CS%diag)
if (CS%id_dx_Cv > 0) call post_data(CS%id_dx_Cv, G%dx_Cv, CS%diag)
if (CS%id_dy_Cu > 0) call post_data(CS%id_dy_Cu, G%dy_Cu, CS%diag)
if (CS%id_land_mask > 0) call post_data(CS%id_land_mask, G%mask2dT, CS%diag)
@@ -2483,6 +2549,9 @@ subroutine internal_tides_init(Time, G, GV, US, param_file, diag, CS)
CS%id_tot_Froude_loss = register_diag_field('ocean_model', 'ITide_tot_Froude_loss', diag%axesT1, &
Time, 'Internal tide energy loss to wave breaking', &
'W m-2', conversion=US%RZ3_T3_to_W_m2)
CS%id_tot_residual_loss = register_diag_field('ocean_model', 'ITide_tot_residual_loss', diag%axesT1, &
Time, 'Internal tide energy loss to residual on slopes', &
'W m-2', conversion=US%RZ3_T3_to_W_m2)
CS%id_tot_allprocesses_loss = register_diag_field('ocean_model', 'ITide_tot_allprocesses_loss', diag%axesT1, &
Time, 'Internal tide energy loss summed over all processes', &
'W m-2', conversion=US%RZ3_T3_to_W_m2)