Skip to content

Commit

Permalink
Merge pull request NOAA-EMC#65 from NOAA-GFDL/dev/gfdl
Browse files Browse the repository at this point in the history
Sync with NOAA-GFDL
  • Loading branch information
wrongkindofdoctor authored Aug 17, 2020
2 parents 0cf3cb9 + 068c3cb commit c8695c6
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 155 deletions.
4 changes: 1 addition & 3 deletions config_src/coupled_driver/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ module MOM_surface_forcing_gfdl
use MOM_constants, only : hlv, hlf
use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end
use MOM_cpu_clock, only : CLOCK_SUBCOMPONENT
use MOM_diag_mediator, only : diag_ctrl
use MOM_diag_mediator, only : safe_alloc_ptr, time_type
use MOM_diag_mediator, only : diag_ctrl, safe_alloc_ptr, time_type
use MOM_domains, only : pass_vector, pass_var, fill_symmetric_edges
use MOM_domains, only : global_field_sum, BITWISE_EXACT_SUM
use MOM_domains, only : AGRID, BGRID_NE, CGRID_NE, To_All
use MOM_domains, only : To_North, To_East, Omit_Corners
use MOM_error_handler, only : MOM_error, WARNING, FATAL, is_root_pe, MOM_mesg
Expand Down
89 changes: 48 additions & 41 deletions src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module MOM_open_boundary
public update_OBC_ramp
public rotate_OBC_config
public rotate_OBC_init
public initialize_segment_data

integer, parameter, public :: OBC_NONE = 0 !< Indicates the use of no open boundary
integer, parameter, public :: OBC_SIMPLE = 1 !< Indicates the use of a simple inflow open boundary
Expand Down Expand Up @@ -268,7 +269,7 @@ module MOM_open_boundary
real :: rx_max !< The maximum magnitude of the baroclinic radiation velocity (or speed of
!! characteristics) in units of grid points per timestep [nondim].
logical :: OBC_pe !< Is there an open boundary on this tile?
type(remapping_CS), pointer :: remap_CS !< ALE remapping control structure for segments only
type(remapping_CS), pointer :: remap_CS=> NULL() !< ALE remapping control structure for segments only
type(OBC_registry_type), pointer :: OBC_Reg => NULL() !< Registry type for boundaries
real, pointer, dimension(:,:,:) :: &
rx_normal => NULL(), & !< Array storage for normal phase speed for EW radiation OBCs in units of
Expand Down Expand Up @@ -341,6 +342,11 @@ subroutine open_boundary_config(G, US, param_file, OBC)
character(len=100) :: segment_str ! The contents (rhs) for parameter "segment_param_str"
character(len=200) :: config1 ! String for OBC_USER_CONFIG
real :: Lscale_in, Lscale_out ! parameters controlling tracer values at the boundaries [L ~> m]
character(len=128) :: inputdir
logical :: answers_2018, default_2018_answers
logical :: check_reconstruction, check_remapping, force_bounds_in_subcell
character(len=32) :: remappingScheme

allocate(OBC)

call get_param(param_file, mdl, "OBC_NUMBER_OF_SEGMENTS", OBC%number_of_segments, &
Expand Down Expand Up @@ -497,7 +503,7 @@ subroutine open_boundary_config(G, US, param_file, OBC)
enddo

! if (open_boundary_query(OBC, needs_ext_seg_data=.true.)) &
call initialize_segment_data(G, OBC, param_file)
! call initialize_segment_data(G, OBC, param_file)

if (open_boundary_query(OBC, apply_open_OBC=.true.)) then
call get_param(param_file, mdl, "OBC_RADIATION_MAX", OBC%rx_max, &
Expand Down Expand Up @@ -540,6 +546,39 @@ subroutine open_boundary_config(G, US, param_file, OBC)
if (Lscale_out>0.) OBC%segment(l)%Tr_InvLscale_out = 1.0/Lscale_out
enddo

call get_param(param_file, mdl, "REMAPPING_SCHEME", remappingScheme, &
"This sets the reconstruction scheme used "//&
"for vertical remapping for all variables. "//&
"It can be one of the following schemes: \n"//&
trim(remappingSchemesDoc), default=remappingDefaultScheme,do_not_log=.true.)
call get_param(param_file, mdl, "FATAL_CHECK_RECONSTRUCTIONS", check_reconstruction, &
"If true, cell-by-cell reconstructions are checked for "//&
"consistency and if non-monotonicity or an inconsistency is "//&
"detected then a FATAL error is issued.", default=.false.,do_not_log=.true.)
call get_param(param_file, mdl, "FATAL_CHECK_REMAPPING", check_remapping, &
"If true, the results of remapping are checked for "//&
"conservation and new extrema and if an inconsistency is "//&
"detected then a FATAL error is issued.", default=.false.,do_not_log=.true.)
call get_param(param_file, mdl, "BRUSHCUTTER_MODE", OBC%brushcutter_mode, &
"If true, read external OBC data on the supergrid.", &
default=.false.)
call get_param(param_file, mdl, "REMAP_BOUND_INTERMEDIATE_VALUES", force_bounds_in_subcell, &
"If true, the values on the intermediate grid used for remapping "//&
"are forced to be bounded, which might not be the case due to "//&
"round off.", default=.false.,do_not_log=.true.)
call get_param(param_file, mdl, "DEFAULT_2018_ANSWERS", default_2018_answers, &
"This sets the default value for the various _2018_ANSWERS parameters.", &
default=.false.)
call get_param(param_file, mdl, "REMAPPING_2018_ANSWERS", answers_2018, &
"If true, use the order of arithmetic and expressions that recover the "//&
"answers from the end of 2018. Otherwise, use updated and more robust "//&
"forms of the same expressions.", default=default_2018_answers)

allocate(OBC%remap_CS)
call initialize_remapping(OBC%remap_CS, remappingScheme, boundary_extrapolation = .false., &
check_reconstruction=check_reconstruction, check_remapping=check_remapping, &
force_bounds_in_subcell=force_bounds_in_subcell, answers_2018=answers_2018)

endif ! OBC%number_of_segments > 0

! Safety check
Expand All @@ -564,7 +603,7 @@ end subroutine open_boundary_config
subroutine initialize_segment_data(G, OBC, PF)
use mpp_mod, only : mpp_pe, mpp_set_current_pelist, mpp_get_current_pelist,mpp_npes

type(dyn_horgrid_type), intent(in) :: G !< Ocean grid structure
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
type(ocean_OBC_type), intent(inout) :: OBC !< Open boundary control structure
type(param_file_type), intent(in) :: PF !< Parameter file handle

Expand All @@ -576,10 +615,7 @@ subroutine initialize_segment_data(G, OBC, PF)
character(len=32), dimension(MAX_OBC_FIELDS) :: fields ! segment field names
character(len=128) :: inputdir
type(OBC_segment_type), pointer :: segment => NULL() ! pointer to segment type list
character(len=32) :: remappingScheme
character(len=256) :: mesg ! Message for error messages.
logical :: check_reconstruction, check_remapping, force_bounds_in_subcell
logical :: answers_2018, default_2018_answers
integer, dimension(4) :: siz,siz2
integer :: is, ie, js, je
integer :: isd, ied, jsd, jed
Expand All @@ -599,39 +635,6 @@ subroutine initialize_segment_data(G, OBC, PF)
call get_param(PF, mdl, "INPUTDIR", inputdir, default=".")
inputdir = slasher(inputdir)

call get_param(PF, mdl, "REMAPPING_SCHEME", remappingScheme, &
"This sets the reconstruction scheme used "//&
"for vertical remapping for all variables. "//&
"It can be one of the following schemes: \n"//&
trim(remappingSchemesDoc), default=remappingDefaultScheme,do_not_log=.true.)
call get_param(PF, mdl, "FATAL_CHECK_RECONSTRUCTIONS", check_reconstruction, &
"If true, cell-by-cell reconstructions are checked for "//&
"consistency and if non-monotonicity or an inconsistency is "//&
"detected then a FATAL error is issued.", default=.false.,do_not_log=.true.)
call get_param(PF, mdl, "FATAL_CHECK_REMAPPING", check_remapping, &
"If true, the results of remapping are checked for "//&
"conservation and new extrema and if an inconsistency is "//&
"detected then a FATAL error is issued.", default=.false.,do_not_log=.true.)
call get_param(PF, mdl, "REMAP_BOUND_INTERMEDIATE_VALUES", force_bounds_in_subcell, &
"If true, the values on the intermediate grid used for remapping "//&
"are forced to be bounded, which might not be the case due to "//&
"round off.", default=.false.,do_not_log=.true.)
call get_param(PF, mdl, "BRUSHCUTTER_MODE", OBC%brushcutter_mode, &
"If true, read external OBC data on the supergrid.", &
default=.false.)
call get_param(PF, mdl, "DEFAULT_2018_ANSWERS", default_2018_answers, &
"This sets the default value for the various _2018_ANSWERS parameters.", &
default=.false.)
call get_param(PF, mdl, "REMAPPING_2018_ANSWERS", answers_2018, &
"If true, use the order of arithmetic and expressions that recover the "//&
"answers from the end of 2018. Otherwise, use updated and more robust "//&
"forms of the same expressions.", default=default_2018_answers)

allocate(OBC%remap_CS)
call initialize_remapping(OBC%remap_CS, remappingScheme, boundary_extrapolation = .false., &
check_reconstruction=check_reconstruction, check_remapping=check_remapping, &
force_bounds_in_subcell=force_bounds_in_subcell, answers_2018=answers_2018)

if (OBC%user_BCs_set_globally) return

! Try this here just for the documentation. It is repeated below.
Expand Down Expand Up @@ -4966,6 +4969,8 @@ subroutine rotate_OBC_config(OBC_in, G_in, OBC, G, turns)

integer :: l

if (OBC_in%number_of_segments==0) return

! Scalar and logical transfer
OBC%number_of_segments = OBC_in%number_of_segments
OBC%ke = OBC_in%ke
Expand Down Expand Up @@ -5023,8 +5028,10 @@ subroutine rotate_OBC_config(OBC_in, G_in, OBC, G, turns)
OBC%OBC_pe = OBC_in%OBC_pe

! remap_CS is set up by initialize_segment_data, so we copy the fields here.
allocate(OBC%remap_CS)
OBC%remap_CS = OBC_in%remap_CS
if (ASSOCIATED(OBC_in%remap_CS)) then
allocate(OBC%remap_CS)
OBC%remap_CS = OBC_in%remap_CS
endif

! TODO: The OBC registry seems to be a list of "registered" OBC types.
! It does not appear to be used, so for now we skip this record.
Expand Down
2 changes: 1 addition & 1 deletion src/equation_of_state/MOM_EOS_linear.F90
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ subroutine int_density_dz_linear(T, S, z_t, z_b, rho_ref, rho_0_pres, G_e, HI, &
hWt_LL = (hWght*hL + hR*hL) * iDenom ; hWt_LR = (hWght*hR) * iDenom
hWt_RR = (hWght*hR + hR*hL) * iDenom ; hWt_RL = (hWght*hL) * iDenom

intz(1) = dpa(i,j) ; intz(5) = dpa(i+1,j)
intz(1) = dpa(i,j) ; intz(5) = dpa(i,j+1)
do m=2,4
wt_L = 0.25*real(5-m) ; wt_R = 1.0-wt_L
wtT_L = wt_L*hWt_LL + wt_R*hWt_RL ; wtT_R = wt_L*hWt_LR + wt_R*hWt_RR
Expand Down
1 change: 0 additions & 1 deletion src/ice_shelf/MOM_ice_shelf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module MOM_ice_shelf
use MOM_checksums, only : hchksum, qchksum, chksum, uchksum, vchksum, uvchksum
use time_interp_external_mod, only : init_external_field, time_interp_external
use time_interp_external_mod, only : time_interp_external_init
use time_manager_mod, only : print_time
implicit none ; private

#include <MOM_memory.h>
Expand Down
1 change: 0 additions & 1 deletion src/ice_shelf/MOM_ice_shelf_state.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module MOM_ice_shelf_state
use MOM_file_parser, only : read_param, get_param, log_param, log_version, param_file_type
use MOM_grid, only : MOM_grid_init, ocean_grid_type
use MOM_get_input, only : directories, Get_MOM_input
use mpp_mod, only : mpp_sum, mpp_max, mpp_min, mpp_pe, mpp_npes, mpp_sync
use MOM_coms, only : reproducing_sum
use MOM_checksums, only : hchksum, qchksum, chksum, uchksum, vchksum, uvchksum

Expand Down
17 changes: 7 additions & 10 deletions src/initialization/MOM_state_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ module MOM_state_initialization
use MOM_get_input, only : directories
use MOM_grid, only : ocean_grid_type, isPointInCell
use MOM_interface_heights, only : find_eta
use MOM_io, only : file_exists
use MOM_io, only : MOM_read_data, MOM_read_vector
use MOM_io, only : slasher
use MOM_open_boundary, only : ocean_OBC_type, open_boundary_init
use MOM_io, only : file_exists, field_size, MOM_read_data, MOM_read_vector, slasher
use MOM_open_boundary, only : ocean_OBC_type, open_boundary_init, set_tracer_data
use MOM_open_boundary, only : OBC_NONE, OBC_SIMPLE
use MOM_open_boundary, only : open_boundary_query
use MOM_open_boundary, only : set_tracer_data
use MOM_open_boundary, only : set_tracer_data, initialize_segment_data
use MOM_open_boundary, only : open_boundary_test_extern_h
use MOM_open_boundary, only : fill_temp_salt_segments
use MOM_open_boundary, only : update_OBC_segment_data
Expand All @@ -33,8 +31,7 @@ module MOM_state_initialization
use MOM_restart, only : restore_state, determine_is_new_run, MOM_restart_CS
use MOM_sponge, only : set_up_sponge_field, set_up_sponge_ML_density
use MOM_sponge, only : initialize_sponge, sponge_CS
use MOM_ALE_sponge, only : set_up_ALE_sponge_field, initialize_ALE_sponge
use MOM_ALE_sponge, only : ALE_sponge_CS
use MOM_ALE_sponge, only : set_up_ALE_sponge_field, initialize_ALE_sponge, ALE_sponge_CS
use MOM_string_functions, only : uppercase, lowercase
use MOM_time_manager, only : time_type
use MOM_tracer_registry, only : tracer_registry_type
Expand All @@ -44,8 +41,7 @@ module MOM_state_initialization
use MOM_EOS, only : calculate_density, calculate_density_derivs, EOS_type, EOS_domain
use MOM_EOS, only : convert_temp_salt_for_TEOS10
use user_initialization, only : user_initialize_thickness, user_initialize_velocity
use user_initialization, only : user_init_temperature_salinity
use user_initialization, only : user_set_OBC_data
use user_initialization, only : user_init_temperature_salinity, user_set_OBC_data
use user_initialization, only : user_initialize_sponges
use DOME_initialization, only : DOME_initialize_thickness
use DOME_initialization, only : DOME_set_OBC_data
Expand Down Expand Up @@ -97,7 +93,6 @@ module MOM_state_initialization
use MOM_remapping, only : remapping_CS, initialize_remapping
use MOM_remapping, only : remapping_core_h
use MOM_horizontal_regridding, only : horiz_interp_and_extrap_tracer
use fms_io_mod, only : field_size

implicit none ; private

Expand Down Expand Up @@ -563,6 +558,8 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, &

! This controls user code for setting open boundary data
if (associated(OBC)) then
call initialize_segment_data(G, OBC, PF) ! call initialize_segment_data(G, OBC, param_file)
! call open_boundary_config(G, US, PF, OBC)
! Call this once to fill boundary arrays from fixed values
if (.not. OBC%needs_IO_for_data) &
call update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)
Expand Down
21 changes: 12 additions & 9 deletions src/parameterizations/vertical/MOM_diabatic_aux.F90
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ subroutine make_frazil(h, tv, G, GV, US, CS, p_surf, halo)
endif

hc = (tv%C_p*GV%H_to_RZ) * h(i,j,k)
if (h(i,j,k) <= 10.0*GV%Angstrom_H) then
if (h(i,j,k) <= 10.0*(GV%Angstrom_H + GV%H_subroundoff)) then
! Very thin layers should not be cooled by the frazil flux.
if (tv%T(i,j,k) < T_freeze(i)) then
fraz_col(i) = fraz_col(i) + hc * (T_freeze(i) - tv%T(i,j,k))
tv%T(i,j,k) = T_freeze(i)
endif
else
if (fraz_col(i) + hc * (T_freeze(i) - tv%T(i,j,k)) <= 0.0) then
elseif ((fraz_col(i) > 0.0) .or. (tv%T(i,j,k) < T_freeze(i))) then
if (fraz_col(i) + hc * (T_freeze(i) - tv%T(i,j,k)) < 0.0) then
tv%T(i,j,k) = tv%T(i,j,k) - fraz_col(i) / hc
fraz_col(i) = 0.0
else
Expand Down Expand Up @@ -822,19 +822,18 @@ subroutine applyBoundaryFluxesInOut(CS, G, GV, US, dt, fluxes, optics, nsw, h, t

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke

! Only apply forcing if fluxes%sw is associated.
if (.not.associated(fluxes%sw)) return

#define _OLD_ALG_
Idt = 1.0 / dt

calculate_energetics = (present(cTKE) .and. present(dSV_dT) .and. present(dSV_dS))
calculate_buoyancy = present(SkinBuoyFlux)
if (calculate_buoyancy) SkinBuoyFlux(:,:) = 0.0
if (present(cTKE)) cTKE(:,:,:) = 0.0
g_Hconv2 = (US%L_to_Z**2*GV%g_Earth * GV%H_to_RZ) * GV%H_to_RZ
EOSdom(:) = EOS_domain(G%HI)

if (present(cTKE)) cTKE(:,:,:) = 0.0
! Only apply forcing if fluxes%sw is associated.
if (.not.associated(fluxes%sw) .and. .not.calculate_energetics) return

if (calculate_buoyancy) then
SurfPressure(:) = 0.0
GoRho = US%L_to_Z**2*GV%g_Earth / GV%Rho0
Expand Down Expand Up @@ -874,7 +873,6 @@ subroutine applyBoundaryFluxesInOut(CS, G, GV, US, dt, fluxes, optics, nsw, h, t
h2d(i,k) = h(i,j,k)
T2d(i,k) = tv%T(i,j,k)
enddo ; enddo
if (nsw>0) call extract_optics_slice(optics, j, G, GV, opacity=opacityBand, opacity_scale=(1.0/GV%m_to_H))

if (calculate_energetics) then
! The partial derivatives of specific volume with temperature and
Expand All @@ -898,6 +896,11 @@ subroutine applyBoundaryFluxesInOut(CS, G, GV, US, dt, fluxes, optics, nsw, h, t
pen_TKE_2d(:,:) = 0.0
endif

! 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))

! The surface forcing is contained in the fluxes type.
! We aggregate the thermodynamic forcing for a time step into the following:
! netMassInOut = surface water fluxes [H ~> m or kg m-2] over time step
Expand Down
2 changes: 1 addition & 1 deletion src/parameterizations/vertical/MOM_vert_friction.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1143,12 +1143,12 @@ subroutine find_coupling_coef(a_cpl, hvel, do_i, h_harm, bbl_thick, kv_bbl, z_i,
real :: h_neglect ! A thickness that is so small it is usually lost
! in roundoff and can be neglected [H ~> m or kg m-2].
real :: z2 ! A copy of z_i [nondim]
real :: botfn ! A function that is 1 at the bottom and small far from it [nondim]
real :: topfn ! A function that is 1 at the top and small far from it [nondim]
real :: kv_top ! A viscosity associated with the top boundary layer [Z2 T-1 ~> m2 s-1]
logical :: do_shelf, do_OBCs
integer :: i, k, is, ie, max_nk
integer :: nz
real :: botfn

a_cpl(:,:) = 0.0
Kv_tot(:,:) = 0.0
Expand Down
Loading

0 comments on commit c8695c6

Please sign in to comment.