Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into new_codecov_uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
Hallberg-NOAA authored Dec 6, 2021
2 parents d716745 + ad35e4a commit 7d80abc
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 374 deletions.
4 changes: 2 additions & 2 deletions config_src/drivers/solo_driver/MESO_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module MESO_surface_forcing
real :: G_Earth !< The gravitational acceleration [L2 Z-1 T-2 ~> m s-2].
real :: Flux_const !< The restoring rate at the surface [Z T-1 ~> m s-1].
real :: gust_const !< A constant unresolved background gustiness
!! that contributes to ustar [Pa].
!! that contributes to ustar [R L Z T-1 ~> Pa]
real, dimension(:,:), pointer :: &
T_Restore(:,:) => NULL(), & !< The temperature to restore the SST toward [degC].
S_Restore(:,:) => NULL(), & !< The salinity to restore the sea surface salnity toward [ppt]
Expand Down Expand Up @@ -138,7 +138,7 @@ subroutine MESO_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
! Set whichever fluxes are to be used here. Any fluxes that
! are always zero do not need to be changed here.
do j=js,je ; do i=is,ie
! Fluxes of fresh water through the surface are in units of [kg m-2 s-1]
! Fluxes of fresh water through the surface are in units of [R Z T-1 ~> kg m-2 s-1]
! and are positive downward - i.e. evaporation should be negative.
fluxes%evap(i,j) = -0.0 * G%mask2dT(i,j)
fluxes%lprec(i,j) = CS%PmE(i,j) * CS%Rho0 * G%mask2dT(i,j)
Expand Down
264 changes: 137 additions & 127 deletions config_src/drivers/solo_driver/MOM_surface_forcing.F90

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config_src/drivers/solo_driver/user_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module user_surface_forcing
!! It can be readily modified for a specific case, and because it is private there
!! will be no changes needed in other code (although they will have to be recompiled).
type, public :: user_surface_forcing_CS ; private
! The variables in the cannonical example are used for some common
! The variables in the canonical example are used for some common
! cases, but do not need to be used.

logical :: use_temperature !< If true, temperature and salinity are used as state variables.
Expand Down Expand Up @@ -221,7 +221,7 @@ subroutine USER_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
buoy_rest_const = -1.0 * (CS%G_Earth * CS%Flux_const) / CS%Rho0
do j=js,je ; do i=is,ie
! Set density_restore to an expression for the surface potential
! density [kg m-3] that is being restored toward.
! density [R ~> kg m-3] that is being restored toward.
density_restore = 1030.0*US%kg_m3_to_R

fluxes%buoy(i,j) = G%mask2dT(i,j) * buoy_rest_const * &
Expand Down
35 changes: 24 additions & 11 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1781,8 +1781,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
logical :: debug_truncations ! If true, turn on diagnostics useful for debugging truncations.
integer :: first_direction ! An integer that indicates which direction is to be
! updated first in directionally split parts of the
! calculation. This can be altered during the course
! of the run via calls to set_first_direction.
! calculation.
integer :: nkml, nkbl, verbosity, write_geom
integer :: dynamics_stencil ! The computational stencil for the calculations
! in the dynamic core.
Expand Down Expand Up @@ -2055,7 +2054,6 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
"direction updates occur first in directionally split parts of the calculation. "//&
"If this is true, FIRST_DIRECTION applies at the start of a new run or if "//&
"the next first direction can not be found in the restart file.", default=.false.)

call get_param(param_file, "MOM", "CHECK_BAD_SURFACE_VALS", CS%check_bad_sfc_vals, &
"If true, check the surface state for ridiculous values.", &
default=.false.)
Expand Down Expand Up @@ -2153,6 +2151,11 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
if (num_PEs() /= 1) &
call MOM_error(FATAL, "Index rotation is only supported on one PE.")

! Alternate_first_direction is not permitted with index rotation.
! This feature can be added later in the future if needed.
if (CS%alternate_first_direction) &
call MOM_error(FATAL, "Alternating_first_direction is not compatible with index rotation.")

call get_param(param_file, "MOM", "INDEX_TURNS", turns, &
"Number of counterclockwise quarter-turn index rotations.", &
default=1, debuggingParam=.true.)
Expand Down Expand Up @@ -2180,7 +2183,6 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
if (CS%rotate_index) then
allocate(CS%G)
call clone_MOM_domain(G_in%Domain, CS%G%Domain, turns=turns, domain_name="MOM_rot")
first_direction = modulo(first_direction + turns, 2)
else
CS%G => G_in
endif
Expand Down Expand Up @@ -2455,8 +2457,11 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
endif

! Set a few remaining fields that are specific to the ocean grid type.
call set_first_direction(G, first_direction)
CS%first_dir_restart = real(G%first_direction)
if (CS%rotate_index) then
call set_first_direction(G, modulo(first_direction + turns, 2))
else
call set_first_direction(G, modulo(first_direction, 2))
endif
! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.
if (CS%debug .or. G%symmetric) then
call clone_MOM_domain(G%Domain, G%Domain_aux, symmetric=.false.)
Expand Down Expand Up @@ -2505,11 +2510,12 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
CS%tv%S => CS%S
endif

! Reset the first direction if it was found in a restart file.
if (CS%first_dir_restart > -0.5) &
call set_first_direction(G, NINT(CS%first_dir_restart))
! Store the first direction for the next time a restart file is written.
CS%first_dir_restart = real(G%first_direction)
! Reset the first direction if it was found in a restart file
if (CS%first_dir_restart > -1.0) then
call set_first_direction(G, modulo(NINT(CS%first_dir_restart) + turns, 2))
else
CS%first_dir_restart = real(modulo(first_direction, 2))
endif

call rotate_initial_state(u_in, v_in, h_in, T_in, S_in, use_temperature, &
turns, CS%u, CS%v, CS%h, CS%T, CS%S)
Expand Down Expand Up @@ -2551,6 +2557,13 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
param_file, dirs, restart_CSp, CS%ALE_CSp, CS%tracer_Reg, &
CS%sponge_CSp, CS%ALE_sponge_CSp, CS%oda_incupd_CSp, CS%OBC, Time_in)
endif

! Reset the first direction if it was found in a restart file.
if (CS%first_dir_restart > -1.0) then
call set_first_direction(G, NINT(CS%first_dir_restart))
else
CS%first_dir_restart = real(modulo(first_direction, 2))
endif
endif

if (use_ice_shelf .and. CS%debug) &
Expand Down
20 changes: 10 additions & 10 deletions src/core/MOM_continuity_PPM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ subroutine zonal_mass_flux(u, h_in, uh, dt, G, GV, US, CS, LB, OBC, por_face_are
if (l_seg /= OBC_NONE) &
do_I(I) = OBC%segment(l_seg)%specified

if (do_I(I)) FAuI(I) = GV%H_subroundoff*(G%dy_Cu(I,j)*por_face_areaU(I,j,k))
if (do_I(I)) FAuI(I) = GV%H_subroundoff*G%dy_Cu(I,j)
enddo
! NOTE: do_I(I) should prevent access to segment OBC_NONE
do k=1,nz ; do I=ish-1,ieh ; if (do_I(I)) then
Expand Down Expand Up @@ -572,7 +572,7 @@ subroutine zonal_flux_layer(u, h, h_L, h_R, uh, duhdu, visc_rem, dt, G, US, j, &
if (vol_CFL) then ; CFL = (u(I) * dt) * (G%dy_Cu(I,j) * G%IareaT(i,j))
else ; CFL = u(I) * dt * G%IdxT(i,j) ; endif
curv_3 = h_L(i) + h_R(i) - 2.0*h(i)
uh(I) = (G%dy_Cu(I,j) * por_face_areaU(I))* u(I) * &
uh(I) = (G%dy_Cu(I,j) * por_face_areaU(I)) * u(I) * &
(h_R(i) + CFL * (0.5*(h_L(i) - h_R(i)) + curv_3*(CFL - 1.5)))
h_marg = h_R(i) + CFL * ((h_L(i) - h_R(i)) + 3.0*curv_3*(CFL - 1.0))
elseif (u(I) < 0.0) then
Expand All @@ -586,7 +586,7 @@ subroutine zonal_flux_layer(u, h, h_L, h_R, uh, duhdu, visc_rem, dt, G, US, j, &
uh(I) = 0.0
h_marg = 0.5 * (h_L(i+1) + h_R(i))
endif
duhdu(I) = (G%dy_Cu(I,j)* por_face_areaU(I)) * h_marg * visc_rem(I)
duhdu(I) = (G%dy_Cu(I,j) * por_face_areaU(I)) * h_marg * visc_rem(I)
endif ; enddo

if (local_open_BC) then
Expand All @@ -596,10 +596,10 @@ subroutine zonal_flux_layer(u, h, h_L, h_R, uh, duhdu, visc_rem, dt, G, US, j, &
if (l_seg /= OBC_NONE) then
if (OBC%segment(l_seg)%open) then
if (OBC%segment(l_seg)%direction == OBC_DIRECTION_E) then
uh(I) = (G%dy_Cu(I,j)* por_face_areaU(I)) * u(I) * h(i)
duhdu(I) = (G%dy_Cu(I,j)* por_face_areaU(I)) * h(i) * visc_rem(I)
uh(I) = (G%dy_Cu(I,j) * por_face_areaU(I)) * u(I) * h(i)
duhdu(I) = (G%dy_Cu(I,j) * por_face_areaU(I)) * h(i) * visc_rem(I)
else
uh(I) = (G%dy_Cu(I,j)* por_face_areaU(I)) * u(I) * h(i+1)
uh(I) = (G%dy_Cu(I,j) * por_face_areaU(I)) * u(I) * h(i+1)
duhdu(I) = (G%dy_Cu(I,j)* por_face_areaU(I)) * h(i+1) * visc_rem(I)
endif
endif
Expand Down Expand Up @@ -842,7 +842,7 @@ subroutine zonal_flux_adjust(u, h_in, h_L, h_R, uhbt, uh_tot_0, duhdu_tot_0, &
do I=ish-1,ieh ; u_new(I) = u(I,j,k) + du(I) * visc_rem(I,k) ; enddo
call zonal_flux_layer(u_new, h_in(:,j,k), h_L(:,j,k), h_R(:,j,k), &
uh_aux(:,k), duhdu(:,k), visc_rem(:,k), &
dt, G, US, j, ish, ieh, do_I, CS%vol_CFL,por_face_areaU(:,j,k),OBC)
dt, G, US, j, ish, ieh, do_I, CS%vol_CFL, por_face_areaU(:,j,k), OBC)
enddo ; endif

if (itt < max_itts) then
Expand Down Expand Up @@ -992,9 +992,9 @@ subroutine set_zonal_BT_cont(u, h_in, h_L, h_R, BT_cont, uh_tot_0, duhdu_tot_0,
call zonal_flux_layer(u_0, h_in(:,j,k), h_L(:,j,k), h_R(:,j,k), uh_0, duhdu_0, &
visc_rem(:,k), dt, G, US, j, ish, ieh, do_I, CS%vol_CFL, por_face_areaU(:,j,k))
call zonal_flux_layer(u_L, h_in(:,j,k), h_L(:,j,k), h_R(:,j,k), uh_L, duhdu_L, &
visc_rem(:,k), dt, G, US, j, ish, ieh, do_I, CS%vol_CFL,por_face_areaU(:,j,k))
visc_rem(:,k), dt, G, US, j, ish, ieh, do_I, CS%vol_CFL, por_face_areaU(:,j,k))
call zonal_flux_layer(u_R, h_in(:,j,k), h_L(:,j,k), h_R(:,j,k), uh_R, duhdu_R, &
visc_rem(:,k), dt, G, US, j, ish, ieh, do_I, CS%vol_CFL,por_face_areaU(:,j,k))
visc_rem(:,k), dt, G, US, j, ish, ieh, do_I, CS%vol_CFL, por_face_areaU(:,j,k))
do I=ish-1,ieh ; if (do_I(I)) then
FAmt_0(I) = FAmt_0(I) + duhdu_0(I)
FAmt_L(I) = FAmt_L(I) + duhdu_L(I)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ subroutine meridional_mass_flux(v, h_in, vh, dt, G, GV, US, CS, LB, OBC, por_fac
if(l_seg /= OBC_NONE) &
do_I(i) = (OBC%segment(l_seg)%specified)

if (do_I(i)) FAvi(i) = GV%H_subroundoff*(G%dx_Cv(i,J)*por_face_areaV(i,J,k))
if (do_I(i)) FAvi(i) = GV%H_subroundoff*G%dx_Cv(i,J)
enddo
! NOTE: do_I(I) should prevent access to segment OBC_NONE
do k=1,nz ; do i=ish,ieh ; if (do_I(i)) then
Expand Down
48 changes: 21 additions & 27 deletions src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ module MOM_forcing_type
vprec => NULL(), & !< virtual liquid precip associated w/ SSS restoring [R Z T-1 ~> kg m-2 s-1]
lrunoff => NULL(), & !< liquid river runoff entering ocean [R Z T-1 ~> kg m-2 s-1]
frunoff => NULL(), & !< frozen river runoff (calving) entering ocean [R Z T-1 ~> kg m-2 s-1]
seaice_melt => NULL(), & !< snow/seaice melt (positive) or formation (negative) [R Z T-1 ~> kg m-2 s-1]
netMassIn => NULL(), & !< Sum of water mass flux out of the ocean integrated over a
!! forcing timestep [H ~> m or kg m-2]
netMassOut => NULL(), & !< Net water mass flux into of the ocean integrated over a
seaice_melt => NULL() !< snow/seaice melt (positive) or formation (negative) [R Z T-1 ~> kg m-2 s-1]

! Integrated water mass fluxes into the ocean, used for passive tracer sources [H ~> m or kg m-2]
real, pointer, dimension(:,:) :: &
netMassIn => NULL(), & !< Sum of water mass fluxes into the ocean integrated over a
!! forcing timestep [H ~> m or kg m-2]
!### Net salt is used with inconsistent units and only in one place and should be eliminated as unneeded.
netSalt => NULL() !< Net salt entering the ocean [kgSalt m-2 s-1]
netMassOut => NULL() !< Net water mass flux out of the ocean integrated over a forcing timestep,
!! with negative values for water leaving the ocean [H ~> m or kg m-2]

! heat associated with water crossing ocean surface
real, pointer, dimension(:,:) :: &
Expand Down Expand Up @@ -188,8 +189,8 @@ module MOM_forcing_type

! CFC-related arrays needed in the MOM_CFC_cap module
real, pointer, dimension(:,:) :: &
cfc11_flux => NULL(), & !< flux of cfc_11 into the ocean [CU Z T-1 kg m-3 = mol Z T-1 m-3 ~> mol m-2 s-1].
cfc12_flux => NULL(), & !< flux of cfc_12 into the ocean [CU Z T-1 kg m-3 = mol Z T-1 m-3 ~> mol m-2 s-1].
cfc11_flux => NULL(), & !< flux of cfc_11 into the ocean [CU R Z T-1 kg m-3 ~> mol m-2 s-1]
cfc12_flux => NULL(), & !< flux of cfc_12 into the ocean [CU R Z T-1 kg m-3 ~> mol m-2 s-1]
ice_fraction => NULL(), & !< fraction of sea ice coverage at h-cells, from 0 to 1 [nondim].
u10_sqr => NULL() !< wind magnitude at 10 m squared [L2 T-2 ~> m2 s-2]

Expand Down Expand Up @@ -733,12 +734,6 @@ subroutine extractFluxes1d(G, GV, US, fluxes, optics, nsw, j, dt, &
! Diagnostics follow...
if (calculate_diags) then

! Store Net_salt for unknown reason?
if (associated(fluxes%salt_flux)) then
! This seems like a bad idea to me. -RWH
if (calculate_diags) fluxes%netSalt(i,j) = US%kg_m2s_to_RZ_T*Net_salt(i)
endif

! Initialize heat_content_massin that is diagnosed in mixedlayer_convection or
! applyBoundaryFluxes such that the meaning is as the sum of all incoming components.
if (associated(fluxes%heat_content_massin)) then
Expand Down Expand Up @@ -1094,20 +1089,19 @@ subroutine MOM_forcing_chksum(mesg, fluxes, G, US, haloshift)
call hchksum(fluxes%seaice_melt_heat, mesg//" fluxes%seaice_melt_heat", G%HI, &
haloshift=hshift, scale=US%QRZ_T_to_W_m2)
if (associated(fluxes%p_surf)) &
call hchksum(fluxes%p_surf, mesg//" fluxes%p_surf", G%HI, haloshift=hshift , scale=US%RL2_T2_to_Pa)
call hchksum(fluxes%p_surf, mesg//" fluxes%p_surf", G%HI, haloshift=hshift, scale=US%RL2_T2_to_Pa)
if (associated(fluxes%u10_sqr)) &
call hchksum(fluxes%u10_sqr, mesg//" fluxes%u10_sqr", G%HI, haloshift=hshift , scale=US%L_to_m**2*US%s_to_T**2)
call hchksum(fluxes%u10_sqr, mesg//" fluxes%u10_sqr", G%HI, haloshift=hshift, scale=US%L_to_m**2*US%s_to_T**2)
if (associated(fluxes%ice_fraction)) &
call hchksum(fluxes%ice_fraction, mesg//" fluxes%ice_fraction", G%HI, haloshift=hshift)
if (associated(fluxes%cfc11_flux)) &
call hchksum(fluxes%cfc11_flux, mesg//" fluxes%cfc11_flux", G%HI, haloshift=hshift, scale=US%Z_to_m*US%s_to_T)
call hchksum(fluxes%cfc11_flux, mesg//" fluxes%cfc11_flux", G%HI, haloshift=hshift, scale=US%RZ_T_to_kg_m2s)
if (associated(fluxes%cfc12_flux)) &
call hchksum(fluxes%cfc12_flux, mesg//" fluxes%cfc12_flux", G%HI, haloshift=hshift, scale=US%Z_to_m*US%s_to_T)
call hchksum(fluxes%cfc12_flux, mesg//" fluxes%cfc12_flux", G%HI, haloshift=hshift, scale=US%RZ_T_to_kg_m2s)
if (associated(fluxes%salt_flux)) &
call hchksum(fluxes%salt_flux, mesg//" fluxes%salt_flux", G%HI, haloshift=hshift, scale=US%RZ_T_to_kg_m2s)
if (associated(fluxes%TKE_tidal)) &
call hchksum(fluxes%TKE_tidal, mesg//" fluxes%TKE_tidal", G%HI, haloshift=hshift, &
scale=US%RZ3_T3_to_W_m2)
call hchksum(fluxes%TKE_tidal, mesg//" fluxes%TKE_tidal", G%HI, haloshift=hshift, scale=US%RZ3_T3_to_W_m2)
if (associated(fluxes%ustar_tidal)) &
call hchksum(fluxes%ustar_tidal, mesg//" fluxes%ustar_tidal", G%HI, haloshift=hshift, scale=US%Z_to_m*US%s_to_T)
if (associated(fluxes%lrunoff)) &
Expand Down Expand Up @@ -1306,22 +1300,22 @@ subroutine register_forcing_type_diags(Time, diag, US, use_temperature, handles,
endif
endif

! units for cfc11_flux and cfc12_flux are mol m-2 s-1
! units for cfc11_flux and cfc12_flux are [Conc R Z T-1 ~> mol m-2 s-1]
! See:
! http://clipc-services.ceda.ac.uk/dreq/u/0940cbee6105037e4b7aa5579004f124.html
! http://clipc-services.ceda.ac.uk/dreq/u/e9e21426e4810d0bb2d3dddb24dbf4dc.html
if (present(use_cfcs)) then
if (use_cfcs) then
handles%id_cfc11 = register_diag_field('ocean_model', 'cfc11_flux', diag%axesT1, Time, &
'Gas exchange flux of CFC11 into the ocean ', 'mol m-2 s-1', &
conversion= US%Z_to_m*US%s_to_T,&
'Gas exchange flux of CFC11 into the ocean ', &
'mol m-2 s-1', conversion=US%RZ_T_to_kg_m2s, &
cmor_field_name='fgcfc11', &
cmor_long_name='Surface Downward CFC11 Flux', &
cmor_standard_name='surface_downward_cfc11_flux')

handles%id_cfc12 = register_diag_field('ocean_model', 'cfc12_flux', diag%axesT1, Time, &
'Gas exchange flux of CFC12 into the ocean ', 'mol m-2 s-1', &
conversion= US%Z_to_m*US%s_to_T,&
'Gas exchange flux of CFC12 into the ocean ', &
'mol m-2 s-1', conversion=US%RZ_T_to_kg_m2s, &
cmor_field_name='fgcfc12', &
cmor_long_name='Surface Downward CFC12 Flux', &
cmor_standard_name='surface_downward_cfc12_flux')
Expand Down Expand Up @@ -2977,7 +2971,6 @@ subroutine allocate_forcing_by_group(G, fluxes, water, heat, ustar, press, &
call myAlloc(fluxes%seaice_melt,isd,ied,jsd,jed, water)
call myAlloc(fluxes%netMassOut,isd,ied,jsd,jed, water)
call myAlloc(fluxes%netMassIn,isd,ied,jsd,jed, water)
call myAlloc(fluxes%netSalt,isd,ied,jsd,jed, water)
call myAlloc(fluxes%seaice_melt_heat,isd,ied,jsd,jed, heat)
call myAlloc(fluxes%sw,isd,ied,jsd,jed, heat)
call myAlloc(fluxes%lw,isd,ied,jsd,jed, heat)
Expand Down Expand Up @@ -3264,6 +3257,8 @@ subroutine deallocate_forcing_type(fluxes)
if (associated(fluxes%lrunoff)) deallocate(fluxes%lrunoff)
if (associated(fluxes%frunoff)) deallocate(fluxes%frunoff)
if (associated(fluxes%seaice_melt)) deallocate(fluxes%seaice_melt)
if (associated(fluxes%netMassOut)) deallocate(fluxes%netMassOut)
if (associated(fluxes%netMassIn)) deallocate(fluxes%netMassIn)
if (associated(fluxes%salt_flux)) deallocate(fluxes%salt_flux)
if (associated(fluxes%p_surf_full)) deallocate(fluxes%p_surf_full)
if (associated(fluxes%p_surf)) deallocate(fluxes%p_surf)
Expand Down Expand Up @@ -3332,7 +3327,6 @@ subroutine rotate_forcing(fluxes_in, fluxes, turns)
call rotate_array(fluxes_in%seaice_melt, turns, fluxes%seaice_melt)
call rotate_array(fluxes_in%netMassOut, turns, fluxes%netMassOut)
call rotate_array(fluxes_in%netMassIn, turns, fluxes%netMassIn)
call rotate_array(fluxes_in%netSalt, turns, fluxes%netSalt)
endif

if (do_heat) then
Expand Down
Loading

0 comments on commit 7d80abc

Please sign in to comment.