Skip to content

Commit

Permalink
Merge pull request #43 from Hallberg-NOAA/opacity_rescale
Browse files Browse the repository at this point in the history
+(*)Rescale opacity and avoid segmentation faults
  • Loading branch information
marshallward authored Dec 29, 2021
2 parents d9d82e3 + a8a2039 commit 1028ee0
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/parameterizations/vertical/MOM_bulk_mixed_layer.F90
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ subroutine bulkmixedlayer(h_3d, u_3d, v_3d, tv, fluxes, dt, ea, eb, G, GV, US, C
eps(i,k) = 0.0 ; if (k > nkmb) eps(i,k) = GV%Angstrom_H
T(i,k) = tv%T(i,j,k) ; S(i,k) = tv%S(i,j,k)
enddo ; enddo
if (nsw>0) call extract_optics_slice(optics, j, G, GV, opacity=opacity_band, opacity_scale=GV%H_to_m)
if (nsw>0) call extract_optics_slice(optics, j, G, GV, opacity=opacity_band, opacity_scale=GV%H_to_Z)

do k=1,nz ; do i=is,ie
d_ea(i,k) = 0.0 ; d_eb(i,k) = 0.0
Expand Down
4 changes: 2 additions & 2 deletions src/parameterizations/vertical/MOM_diabatic_aux.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ subroutine applyBoundaryFluxesInOut(CS, G, GV, US, dt, fluxes, optics, nsw, h, t
! To accommodate vanishing upper layers, we need to allow for an instantaneous
! distribution of forcing over some finite vertical extent. The bulk mixed layer
! code handles this issue properly.
H_limit_fluxes = max(GV%Angstrom_H, 1.E-30*GV%m_to_H)
H_limit_fluxes = max(GV%Angstrom_H, 1.0e-30*GV%m_to_H)

! diagnostic to see if need to create mass to avoid grounding
if (CS%id_createdH>0) CS%createdH(:,:) = 0.
Expand Down Expand Up @@ -1160,7 +1160,7 @@ subroutine applyBoundaryFluxesInOut(CS, G, GV, US, dt, fluxes, optics, nsw, h, t
! Nothing more is done on this j-slice if there is no buoyancy forcing.
if (.not.associated(fluxes%sw)) cycle

if (nsw>0) call extract_optics_slice(optics, j, G, GV, opacity=opacityBand, opacity_scale=(1.0/GV%m_to_H))
if (nsw>0) call extract_optics_slice(optics, j, G, GV, opacity=opacityBand, opacity_scale=(1.0/GV%Z_to_H))

! The surface forcing is contained in the fluxes type.
! We aggregate the thermodynamic forcing for a time step into the following:
Expand Down
7 changes: 4 additions & 3 deletions src/parameterizations/vertical/MOM_diabatic_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &

! local variables
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: &
eta ! Interface heights before diapycnal mixing [m].
eta ! Interface heights before diapycnal mixing [Z ~> m]
real, dimension(SZI_(G),SZJ_(G),CS%nMode) :: &
cn_IGW ! baroclinic internal gravity wave speeds [L T-1 ~> m s-1]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: temp_diag ! Previous temperature for diagnostics [degC]
Expand Down Expand Up @@ -350,7 +350,7 @@ subroutine diabatic(u, v, h, tv, Hml, fluxes, visc, ADp, CDp, dt, Time_end, &
if (CS%id_T_predia > 0) call post_data(CS%id_T_predia, tv%T, CS%diag)
if (CS%id_S_predia > 0) call post_data(CS%id_S_predia, tv%S, CS%diag)
if (CS%id_e_predia > 0) then
call find_eta(h, tv, G, GV, US, eta, eta_to_m=1.0, dZref=G%Z_ref)
call find_eta(h, tv, G, GV, US, eta, dZref=G%Z_ref)
call post_data(CS%id_e_predia, eta, CS%diag)
endif

Expand Down Expand Up @@ -2590,6 +2590,7 @@ subroutine extract_diabatic_member(CS, opacity_CSp, optics_CSp, evap_CFL_limit,
if (present(optics_CSp)) optics_CSp => CS%optics
if (present(KPP_CSp)) KPP_CSp => CS%KPP_CSp
if (present(energetic_PBL_CSp)) energetic_PBL_CSp => CS%energetic_PBL
if (present(diabatic_aux_CSp)) diabatic_aux_CSp => CS%diabatic_aux_CSp

! Constants within diabatic_CS
if (present(evap_CFL_limit)) evap_CFL_limit = CS%evap_CFL_limit
Expand Down Expand Up @@ -3229,7 +3230,7 @@ subroutine diabatic_driver_init(Time, G, GV, US, param_file, useALEalgorithm, di
'Layer Thickness before diabatic forcing', &
trim(thickness_units), conversion=GV%H_to_MKS, v_extensive=.true.)
CS%id_e_predia = register_diag_field('ocean_model', 'e_predia', diag%axesTi, Time, &
'Interface Heights before diabatic forcing', 'm')
'Interface Heights before diabatic forcing', 'm', conversion=US%Z_to_m)
if (use_temperature) then
CS%id_T_predia = register_diag_field('ocean_model', 'temp_predia', diag%axesTL, Time, &
'Potential Temperature', 'degC')
Expand Down
Loading

0 comments on commit 1028ee0

Please sign in to comment.