Skip to content

Commit

Permalink
Merge pull request #31 from NOAA-GFDL/dev/gfdl
Browse files Browse the repository at this point in the history
Merge in latest dev/gfdl updates
  • Loading branch information
wrongkindofdoctor authored Oct 4, 2019
2 parents a5386da + ceaca56 commit 0b874f3
Show file tree
Hide file tree
Showing 8 changed files with 1,004 additions and 1,168 deletions.
6 changes: 5 additions & 1 deletion .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ MKMF_TEMPLATE ?= $(DEPS)/mkmf/templates/ncrc-gnu.mk
# Test configuration

# Executables
BUILDS = symmetric asymmetric repro
BUILDS = symmetric asymmetric repro openmp
CONFIGS := $(wildcard tc*)
TESTS = grids layouts restarts repros nans dims

Expand Down Expand Up @@ -85,6 +85,7 @@ $(BUILD)/target/MOM6: MOMFLAGS=NETCDF=3 DEBUG=1
$(BUILD)/symmetric/MOM6: MOMFLAGS=NETCDF=3 DEBUG=1 $(COVFLAG)
$(BUILD)/asymmetric/MOM6: MOMFLAGS=NETCDF=3 DEBUG=1
$(BUILD)/repro/MOM6: MOMFLAGS=NETCDF=3 REPRO=1
$(BUILD)/openmp/MOM6: MOMFLAGS=NETCDF=3 OPENMP=1

$(BUILD)/asymmetric/path_names: GRID_SRC=config_src/dynamic
$(BUILD)/%/path_names: GRID_SRC=config_src/dynamic_symmetric
Expand Down Expand Up @@ -170,6 +171,7 @@ test.grids: $(foreach c,$(filter-out tc3,$(CONFIGS)),$(c).grid $(c).grid.diag)
test.layouts: $(foreach c,$(CONFIGS),$(c).layout $(c).layout.diag)
test.restarts: $(foreach c,$(CONFIGS),$(c).restart)
test.repros: $(foreach c,$(CONFIGS),$(c).repro $(c).repro.diag)
test.openmps: $(foreach c,$(CONFIGS),$(c).openmp $(c).openmp.diag)
test.nans: $(foreach c,$(CONFIGS),$(c).nan $(c).nan.diag)
test.dims: $(foreach c,$(CONFIGS),$(foreach d,t l h z,$(c).dim.$(d) $(c).dim.$(d).diag))

Expand All @@ -188,6 +190,7 @@ $(eval $(call CMP_RULE,regression,symmetric target))
$(eval $(call CMP_RULE,grid,symmetric asymmetric))
$(eval $(call CMP_RULE,layout,symmetric layout))
$(eval $(call CMP_RULE,repro,symmetric repro))
$(eval $(call CMP_RULE,openmp,symmetric openmp))
$(eval $(call CMP_RULE,nan,symmetric nan))
$(foreach d,t l h z,$(eval $(call CMP_RULE,dim.$(d),symmetric dim.$(d))))

Expand Down Expand Up @@ -243,6 +246,7 @@ $(eval $(call STAT_RULE,symmetric,symmetric,$(REPORT_COVERAGE),,,1))
$(eval $(call STAT_RULE,asymmetric,asymmetric,,,,1))
$(eval $(call STAT_RULE,target,target,,,,1))
$(eval $(call STAT_RULE,repro,repro,,,,1))
$(eval $(call STAT_RULE,openmp,openmp,,,,1))
$(eval $(call STAT_RULE,layout,symmetric,,LAYOUT=2$(,)1,,2))
$(eval $(call STAT_RULE,nan,symmetric,,,MALLOC_PERTURB_=256,1))
$(eval $(call STAT_RULE,dim.t,symmetric,,T_RESCALE_POWER=11,,1))
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1674,8 +1674,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
"faster by eliminating subroutine calls.", default=.false.)
call get_param(param_file, "MOM", "DO_DYNAMICS", CS%do_dynamics, &
"If False, skips the dynamics calls that update u & v, as well as "//&
"the gravity wave adjustment to h. This is a fragile feature and "//&
"thus undocumented.", default=.true., do_not_log=.true. )
"the gravity wave adjustment to h. This may be a fragile feature, "//&
"but can be useful during development", default=.true.)
call get_param(param_file, "MOM", "ADVECT_TS", advect_TS, &
"If True, advect temperature and salinity horizontally "//&
"If False, T/S are registered for advection. "//&
Expand Down
46 changes: 36 additions & 10 deletions src/equation_of_state/MOM_EOS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ module MOM_EOS
module procedure calculate_TFreeze_scalar, calculate_TFreeze_array
end interface calculate_TFreeze

!> Calculates the compressibility of water from T, S, and P
interface calculate_compress
module procedure calculate_compress_scalar, calculate_compress_array
end interface calculate_compress

!> A control structure for the equation of state
type, public :: EOS_type ; private
integer :: form_of_EOS = 0 !< The equation of state to use.
Expand Down Expand Up @@ -523,16 +528,16 @@ subroutine calculate_specific_vol_derivs(T, S, pressure, dSV_dT, dSV_dS, start,
end subroutine calculate_specific_vol_derivs

!> Calls the appropriate subroutine to calculate the density and compressibility for 1-D array inputs.
subroutine calculate_compress(T, S, pressure, rho, drho_dp, start, npts, EOS)
real, dimension(:), intent(in) :: T !< Potential temperature referenced to the surface [degC]
real, dimension(:), intent(in) :: S !< Salinity [ppt]
subroutine calculate_compress_array(T, S, pressure, rho, drho_dp, start, npts, EOS)
real, dimension(:), intent(in) :: T !< Potential temperature referenced to the surface [degC]
real, dimension(:), intent(in) :: S !< Salinity [PSU]
real, dimension(:), intent(in) :: pressure !< Pressure [Pa]
real, dimension(:), intent(out) :: rho !< In situ density [kg m-3].
real, dimension(:), intent(out) :: drho_dp !< The partial derivative of density with pressure
!! (also the inverse of the square of sound speed) in s2 m-2.
integer, intent(in) :: start !< Starting index within the array
integer, intent(in) :: npts !< The number of values to calculate
type(EOS_type), pointer :: EOS !< Equation of state structure
real, dimension(:), intent(out) :: rho !< In situ density [kg m-3].
real, dimension(:), intent(out) :: drho_dp !< The partial derivative of density with pressure
!! (also the inverse of the square of sound speed) [s2 m-2].
integer, intent(in) :: start !< Starting index within the array
integer, intent(in) :: npts !< The number of values to calculate
type(EOS_type), pointer :: EOS !< Equation of state structure

if (.not.associated(EOS)) call MOM_error(FATAL, &
"calculate_compress called with an unassociated EOS_type EOS.")
Expand All @@ -554,8 +559,29 @@ subroutine calculate_compress(T, S, pressure, rho, drho_dp, start, npts, EOS)
"calculate_compress: EOS%form_of_EOS is not valid.")
end select

end subroutine calculate_compress
end subroutine calculate_compress_array

!> Calculate density and compressibility for a scalar. This just promotes the scalar to an array with a singleton
!! dimension and calls calculate_compress_array
subroutine calculate_compress_scalar(T, S, pressure, rho, drho_dp, EOS)
real, intent(in) :: T !< Potential temperature referenced to the surface (degC)
real, intent(in) :: S !< Salinity (PSU)
real, intent(in) :: pressure !< Pressure (Pa)
real, intent(out) :: rho !< In situ density in kg m-3.
real, intent(out) :: drho_dp !< The partial derivative of density with pressure
!! (also the inverse of the square of sound speed) in s2 m-2.
type(EOS_type), pointer :: EOS !< Equation of state structure

real, dimension(1) :: Ta, Sa, pa, rhoa, drho_dpa

if (.not.associated(EOS)) call MOM_error(FATAL, &
"calculate_compress called with an unassociated EOS_type EOS.")
Ta(1) = T ; Sa(1) = S; pa(1) = pressure

call calculate_compress_array(Ta, Sa, pa, rhoa, drho_dpa, 1, 1, EOS)
rho = rhoa(1) ; drho_dp = drho_dpa(1)

end subroutine calculate_compress_scalar
!> Calls the appropriate subroutine to alculate analytical and nearly-analytical
!! integrals in pressure across layers of geopotential anomalies, which are
!! required for calculating the finite-volume form pressure accelerations in a
Expand Down
28 changes: 24 additions & 4 deletions src/parameterizations/lateral/MOM_MEKE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ subroutine step_forward_MEKE(MEKE, h, SN_u, SN_v, visc, dt, G, GV, US, CS, hu, h
del4MEKE, & ! Time-integrated MEKE tendency arising from the biharmonic of MEKE [L2 T-2 ~> m2 s-2].
LmixScale, & ! Eddy mixing length [L ~> m].
barotrFac2, & ! Ratio of EKE_barotropic / EKE [nondim]
bottomFac2 ! Ratio of EKE_bottom / EKE [nondim]
bottomFac2, & ! Ratio of EKE_bottom / EKE [nondim]
tmp ! Temporary variable for diagnostic computation

real, dimension(SZIB_(G),SZJ_(G)) :: &
MEKE_uflux, & ! The zonal advective and diffusive flux of MEKE with different units in different
Expand Down Expand Up @@ -575,10 +576,29 @@ subroutine step_forward_MEKE(MEKE, h, SN_u, SN_v, visc, dt, G, GV, US, CS, hu, h
endif

! Offer fields for averaging.

if (any([CS%id_Ue, CS%id_Ub, CS%id_Ut] > 0)) &
tmp(:,:) = 0.

if (CS%id_MEKE>0) call post_data(CS%id_MEKE, MEKE%MEKE, CS%diag)
if (CS%id_Ue>0) call post_data(CS%id_Ue, sqrt(max(0.,2.0*MEKE%MEKE)), CS%diag)
if (CS%id_Ub>0) call post_data(CS%id_Ub, sqrt(max(0.,2.0*MEKE%MEKE*bottomFac2)), CS%diag)
if (CS%id_Ut>0) call post_data(CS%id_Ut, sqrt(max(0.,2.0*MEKE%MEKE*barotrFac2)), CS%diag)
if (CS%id_Ue>0) then
do j=js,je ; do i=is,ie
tmp(i,j) = sqrt(max(0., 2. * MEKE%MEKE(i,j)))
enddo ; enddo
call post_data(CS%id_Ue, tmp, CS%diag)
endif
if (CS%id_Ub>0) then
do j=js,je ; do i=is,ie
tmp(i,j) = sqrt(max(0., 2. * MEKE%MEKE(i,j) * bottomFac2(i,j)))
enddo ; enddo
call post_data(CS%id_Ub, tmp, CS%diag)
endif
if (CS%id_Ut>0) then
do j=js,je ; do i=is,ie
tmp(i,j) = sqrt(max(0., 2. * MEKE%MEKE(i,j) * barotrFac2(i,j)))
enddo ; enddo
call post_data(CS%id_Ut, tmp, CS%diag)
endif
if (CS%id_Kh>0) call post_data(CS%id_Kh, MEKE%Kh, CS%diag)
if (CS%id_Ku>0) call post_data(CS%id_Ku, MEKE%Ku, CS%diag)
if (CS%id_Au>0) call post_data(CS%id_Au, MEKE%Au, CS%diag)
Expand Down
53 changes: 28 additions & 25 deletions src/parameterizations/lateral/MOM_hor_visc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -506,31 +506,34 @@ subroutine horizontal_viscosity(u, v, h, diffu, diffv, MEKE, VarMix, G, GV, US,

endif ! use_GME

!$OMP parallel do default(none) shared(Isq,Ieq,Jsq,Jeq,nz,CS,G,GV,US,u,v,is,js,ie,je, &
!$OMP h,rescale_Kh,VarMix,h_neglect,h_neglect3, &
!$OMP Kh_h,Ah_h,Kh_q,Ah_q,diffu,diffv,apply_OBC,OBC, &
!$OMP find_FrictWork,FrictWork,use_MEKE_Ku, &
!$OMP use_MEKE_Au, MEKE,sh_xx_3d,sh_xy_3d, &
!$OMP GME_coeff_limiter,boundary_mask,FWfrac,backscat_subround,&
!$OMP mod_Leith, legacy_bound, div_xx_h, vort_xy_q) &
!$OMP private(Del2u, Del2v, sh_xx, str_xx, visc_bound_rem, &
!$OMP dudx,dvdy,DX_dyBu,DY_dxBu, &
!$OMP grad_div_mag_h,grad_div_mag_q, &
!$OMP grad_vort_mag_h_2d,grad_vort_mag_q_2d, &
!$OMP grad_vort_mag_h,grad_vort_mag_q,vert_vort_mag, &
!$OMP inv_PI3,inv_PI5,grad_vel_mag_h, &
!$OMP grad_d2vel_mag_h,diss_rate,max_diss_rate, &
!$OMP FrictWork_diss,FrictWorkMax, &
!$OMP target_diss_rate_GME,GME_coeff, &
!$OMP grad_vel_mag_bt_h,H0_GME,GME_coeff_h, &
!$OMP str_xx_GME,grad_vel_mag_bt_q,GME_coeff_q,str_xy_GME,FrictWork_GME,&
!$OMP sh_xy,str_xy,Ah,Kh,AhSm,dvdx,dudy,dDel2udy, &
!$OMP dDel2vdx,sh_xx_bt, sh_xy_bt, dvdx_bt, dudy_bt, &
!$OMP bhstr_xx, bhstr_xy,FatH,RoScl, hu, hv,h_u,h_v, &
!$OMP vort_xy,vort_xy_dx,vort_xy_dy,AhLth, &
!$OMP div_xx, div_xx_dx, div_xx_dy, local_strain, &
!$OMP meke_res_fn,Sh_F_pow, &
!$OMP Shear_mag, h2uq, h2vq, hq, Kh_scale, hrat_min)
!$OMP parallel do default(none) &
!$OMP shared( &
!$OMP CS, G, GV, US, OBC, VarMix, MEKE, u, v, h, &
!$OMP is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz, &
!$OMP apply_OBC, rescale_Kh, legacy_bound, find_FrictWork, &
!$OMP use_MEKE_Ku, use_MEKE_Au, boundary_mask, GME_coeff_limiter, &
!$OMP backscat_subround, &
!$OMP h_neglect, h_neglect3, FWfrac, inv_PI3, inv_PI5, H0_GME, &
!$OMP diffu, diffv, diss_rate, max_diss_rate, target_diss_rate_GME, &
!$OMP Kh_h, Kh_q, Ah_h, Ah_q, &
!$OMP FrictWork, FrictWork_diss, FrictWorkMax, FrictWork_GME, &
!$OMP div_xx_h, sh_xx_3d, sh_xy_3d, vort_xy_q, &
!$OMP GME_coeff_h, GME_coeff_q &
!$OMP ) &
!$OMP private( &
!$OMP i, j, k, n, &
!$OMP dudx, dudy, dvdx, dvdy, sh_xx, sh_xy, h_u, h_v, &
!$OMP Del2u, Del2v, DY_dxBu, DX_dyBu, sh_xx_bt, sh_xy_bt, &
!$OMP str_xx, str_xy, bhstr_xx, bhstr_xy, str_xx_GME, str_xy_GME, &
!$OMP vort_xy, vort_xy_dx, vort_xy_dy, div_xx, div_xx_dx, div_xx_dy, &
!$OMP grad_div_mag_h, grad_div_mag_q, grad_vort_mag_h, grad_vort_mag_q, &
!$OMP grad_vort_mag_h_2d, grad_vort_mag_q_2d, grad_vel_mag_h, &
!$OMP grad_vel_mag_bt_h, grad_vel_mag_bt_q, grad_d2vel_mag_h, &
!$OMP meke_res_fn, Shear_mag, vert_vort_mag, hrat_min, visc_bound_rem, &
!$OMP Kh, Ah, AhSm, AhLth, local_strain, Sh_F_pow, &
!$OMP dDel2vdx, dDel2udy, &
!$OMP h2uq, h2vq, hu, hv, hq, FatH, RoScl, GME_coeff &
!$OMP )
do k=1,nz

! The following are the forms of the horizontal tension and horizontal
Expand Down
Loading

0 comments on commit 0b874f3

Please sign in to comment.