Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into rescale_forcing_time_args
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Dec 8, 2021
2 parents 8f00ef3 + 5f21667 commit f551431
Show file tree
Hide file tree
Showing 15 changed files with 611 additions and 935 deletions.
14 changes: 10 additions & 4 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ endif
# These are set to true by our Travis configuration if testing a pull request
DO_REGRESSION_TESTS ?=
REPORT_COVERAGE ?=
CODECOV_UPLOADER_URL ?= https://uploader.codecov.io/latest/linux/codecov

ifeq ($(DO_REGRESSION_TESTS), true)
BUILDS += target
Expand All @@ -165,6 +166,7 @@ else
endif



# List of source files to link this Makefile's dependencies to model Makefiles
# Assumes a depth of two, and the following extensions: F90 inc c h
# (1): Root directory
Expand Down Expand Up @@ -542,6 +544,7 @@ $(foreach c,$(CONFIGS),$(eval $(call CONFIG_DIM_RULE,$(c))))
# $(4): MOM_override configuration
# $(5): Environment variables
# $(6): Number of MPI ranks

define STAT_RULE
work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6 $(VENV_PATH)
@echo "Running test $$*.$(1)..."
Expand Down Expand Up @@ -570,10 +573,13 @@ work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6 $(VENV_PATH)
@echo -e "$(DONE): $$*.$(1); no runtime errors."
if [ $(3) ]; then \
mkdir -p results/$$* ; \
cd build/symmetric \
&& bash <(curl -s https://codecov.io/bash) -Z -n $$@ \
> codecov.$$*.$(1).out \
2> codecov.$$*.$(1).err \
cd build/symmetric ; \
gcov *.gcda > gcov.$$*.$(1).out ; \
curl -s $(CODECOV_UPLOADER_URL) -o codecov ; \
chmod +x codecov ; \
./codecov -Z -f "*.gcov" -n $$@ \
> codecov.$$*.$(1).out \
2> codecov.$$*.$(1).err \
&& echo -e "${MAGENTA}Report uploaded to codecov.${RESET}"; \
fi
endef
Expand Down
20 changes: 12 additions & 8 deletions config_src/drivers/FMS_cap/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
real :: delta_sss ! temporary storage for sss diff from restoring value [ppt]
real :: delta_sst ! temporary storage for sst diff from restoring value [degC]

real :: kg_m2_s_conversion ! A combination of unit conversion factors for rescaling
! mass fluxes [R Z s m2 kg-1 T-1 ~> 1].
real :: kg_m2_s_conversion ! A combination of unit conversion factors for rescaling
! mass fluxes [R Z s m2 kg-1 T-1 ~> 1]
real :: rhoXcp ! Reference density times heat capacity times unit scaling
! factors [Q R degC-1 ~> J m-3 degC-1]
real :: sign_for_net_FW_bug ! Should be +1. but an old bug can be recovered by using -1.
Expand Down Expand Up @@ -658,14 +658,16 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS, dt_
! Local variables
real, dimension(SZI_(G),SZJ_(G)) :: &
rigidity_at_h, & ! Ice rigidity at tracer points [L4 Z-1 T-1 ~> m3 s-1]
net_mass_src, & ! A temporary of net mass sources [kg m-2 s-1].
net_mass_src, & ! A temporary of net mass sources [R Z T-1 ~> kg m-2 s-1].
ustar_tmp ! A temporary array of ustar values [Z T-1 ~> m s-1].

real :: I_GEarth ! The inverse of the gravitational acceleration [T2 Z L-2 ~> s2 m-1]
real :: Kv_rho_ice ! (CS%Kv_sea_ice / CS%density_sea_ice) [L4 Z-2 T-1 R-1 ~> m5 s-1 kg-1]
real :: mass_ice ! mass of sea ice at a face [R Z ~> kg m-2]
real :: mass_eff ! effective mass of sea ice for rigidity [R Z ~> kg m-2]
real :: wt1, wt2 ! Relative weights of previous and current values of ustar [nondim].
real :: kg_m2_s_conversion ! A combination of unit conversion factors for rescaling
! mass fluxes [R Z s m2 kg-1 T-1 ~> 1]

integer :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq, i0, j0
integer :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, isr, ier, jsr, jer
Expand All @@ -682,6 +684,8 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS, dt_
isr = is-isd+1 ; ier = ie-isd+1 ; jsr = js-jsd+1 ; jer = je-jsd+1
i0 = is - isc_bnd ; j0 = js - jsc_bnd

kg_m2_s_conversion = US%kg_m2s_to_RZ_T

! allocation and initialization if this is the first time that this
! mechanical forcing type has been used.
if (.not.forces%initialized) then
Expand Down Expand Up @@ -774,15 +778,15 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS, dt_
i0 = is - isc_bnd ; j0 = js - jsc_bnd
do j=js,je ; do i=is,ie ; if (G%mask2dT(i,j) > 0.0) then
if (associated(IOB%lprec)) &
net_mass_src(i,j) = net_mass_src(i,j) + IOB%lprec(i-i0,j-j0)
net_mass_src(i,j) = net_mass_src(i,j) + kg_m2_s_conversion * IOB%lprec(i-i0,j-j0)
if (associated(IOB%fprec)) &
net_mass_src(i,j) = net_mass_src(i,j) + IOB%fprec(i-i0,j-j0)
net_mass_src(i,j) = net_mass_src(i,j) + kg_m2_s_conversion * IOB%fprec(i-i0,j-j0)
if (associated(IOB%runoff)) &
net_mass_src(i,j) = net_mass_src(i,j) + IOB%runoff(i-i0,j-j0)
net_mass_src(i,j) = net_mass_src(i,j) + kg_m2_s_conversion * IOB%runoff(i-i0,j-j0)
if (associated(IOB%calving)) &
net_mass_src(i,j) = net_mass_src(i,j) + IOB%calving(i-i0,j-j0)
net_mass_src(i,j) = net_mass_src(i,j) + kg_m2_s_conversion * IOB%calving(i-i0,j-j0)
if (associated(IOB%q_flux)) &
net_mass_src(i,j) = net_mass_src(i,j) - IOB%q_flux(i-i0,j-j0)
net_mass_src(i,j) = net_mass_src(i,j) - kg_m2_s_conversion * IOB%q_flux(i-i0,j-j0)
endif ; enddo ; enddo
if (wt1 <= 0.0) then
do j=js,je ; do i=is,ie
Expand Down
37 changes: 19 additions & 18 deletions config_src/drivers/FMS_cap/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ module ocean_model_mod

logical :: icebergs_alter_ocean !< If true, the icebergs can change ocean the
!! ocean dynamics and forcing fluxes.
real :: press_to_z !< A conversion factor between pressure and ocean
!! depth in m, usually 1/(rho_0*g) [m Pa-1].
real :: press_to_z !< A conversion factor between pressure and ocean depth,
!! usually 1/(rho_0*g) [Z T2 R-1 L-2 ~> m Pa-1].
real :: C_p !< The heat capacity of seawater [J degC-1 kg-1].
logical :: offline_tracer_mode = .false. !< If false, use the model in prognostic mode
!! with the barotropic and baroclinic dynamics, thermodynamics,
Expand Down Expand Up @@ -242,16 +242,16 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
!! tracer fluxes, and can be used to spawn related
!! internal variables in the ice model.
! Local variables
real :: Rho0 ! The Boussinesq ocean density [kg m-3].
real :: G_Earth ! The gravitational acceleration [m s-2].
real :: HFrz !< If HFrz > 0 (m), melt potential will be computed.
real :: Rho0 ! The Boussinesq ocean density [R ~> kg m-3]
real :: G_Earth ! The gravitational acceleration [L2 Z-1 T-2 ~> m s-2]
real :: HFrz !< If HFrz > 0 [Z ~> m], melt potential will be computed.
!! The actual depth over which melt potential is computed will
!! min(HFrz, OBLD), where OBLD is the boundary layer depth.
!! If HFrz <= 0 (default), melt potential will not be computed.
logical :: use_melt_pot!< If true, allocate melt_potential array
logical :: use_melt_pot !< If true, allocate melt_potential array

! This include declares and sets the variable "version".
#include "version_variable.h"
! This include declares and sets the variable "version".
# include "version_variable.h"
character(len=40) :: mdl = "ocean_model_init" ! This module's name.
character(len=48) :: stagger ! A string indicating the staggering locations for the
! surface velocities returned to the coupler.
Expand Down Expand Up @@ -331,28 +331,29 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
"calculate accelerations and the mass for conservation "//&
"properties, or with BOUSSINSEQ false to convert some "//&
"parameters from vertical units of m to kg m-2.", &
units="kg m-3", default=1035.0)
units="kg m-3", default=1035.0, scale=OS%US%kg_m3_to_R)
call get_param(param_file, mdl, "G_EARTH", G_Earth, &
"The gravitational acceleration of the Earth.", &
units="m s-2", default = 9.80)
units="m s-2", default=9.80, scale=OS%US%m_s_to_L_T**2*OS%US%Z_to_m)

call get_param(param_file, mdl, "ICE_SHELF", OS%use_ice_shelf, &
"If true, enables the ice shelf model.", default=.false.)

call get_param(param_file, mdl, "ICEBERGS_APPLY_RIGID_BOUNDARY", OS%icebergs_alter_ocean, &
"If true, allows icebergs to change boundary condition felt by ocean", default=.false.)

OS%press_to_z = 1.0/(Rho0*G_Earth)
OS%press_to_z = 1.0 / (Rho0*G_Earth)

! Consider using a run-time flag to determine whether to do the diagnostic
! vertical integrals, since the related 3-d sums are not negligible in cost.
call get_param(param_file, mdl, "HFREEZE", HFrz, &
"If HFREEZE > 0, melt potential will be computed. The actual depth "//&
"over which melt potential is computed will be min(HFREEZE, OBLD), "//&
"where OBLD is the boundary layer depth. If HFREEZE <= 0 (default), "//&
"melt potential will not be computed.", units="m", default=-1.0, do_not_log=.true.)
"melt potential will not be computed.", &
units="m", default=-1.0, scale=OS%US%m_to_Z, do_not_log=.true.)

if (HFrz .gt. 0.0) then
if (HFrz > 0.0) then
use_melt_pot=.true.
else
use_melt_pot=.false.
Expand Down Expand Up @@ -655,7 +656,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, time_start_upda

! Translate state into Ocean.
! call convert_state_to_ocean_type(OS%sfc_state, Ocean_sfc, OS%grid, OS%US, &
! Ice_ocean_boundary%p, OS%press_to_z)
! OS%fluxes%p_surf_full, OS%press_to_z)
call convert_state_to_ocean_type(OS%sfc_state, Ocean_sfc, OS%grid, OS%US)
Time1 = OS%Time ; if (do_dyn) Time1 = OS%Time_dyn
call coupler_type_send_data(Ocean_sfc%fields, Time1)
Expand Down Expand Up @@ -816,9 +817,9 @@ subroutine convert_state_to_ocean_type(sfc_state, Ocean_sfc, G, US, patm, press_
!! have their data set here.
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
real, optional, intent(in) :: patm(:,:) !< The pressure at the ocean surface [Pa].
real, optional, intent(in) :: press_to_z !< A conversion factor between pressure and
!! ocean depth in m, usually 1/(rho_0*g) [m Pa-1].
real, optional, intent(in) :: patm(:,:) !< The pressure at the ocean surface [R L2 T-2 ~> Pa]
real, optional, intent(in) :: press_to_z !< A conversion factor between pressure and ocean
!! depth, usually 1/(rho_0*g) [Z T2 R-1 L-2 ~> m Pa-1]
! Local variables
real :: IgR0
character(len=48) :: val_str
Expand Down Expand Up @@ -860,7 +861,7 @@ subroutine convert_state_to_ocean_type(sfc_state, Ocean_sfc, G, US, patm, press_

if (present(patm)) then
do j=jsc_bnd,jec_bnd ; do i=isc_bnd,iec_bnd
Ocean_sfc%sea_lev(i,j) = US%Z_to_m * sfc_state%sea_lev(i+i0,j+j0) + patm(i,j) * press_to_z
Ocean_sfc%sea_lev(i,j) = US%Z_to_m * (sfc_state%sea_lev(i+i0,j+j0) + patm(i,j) * press_to_z)
Ocean_sfc%area(i,j) = US%L_to_m**2 * G%areaT(i+i0,j+j0)
enddo ; enddo
else
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
Loading

0 comments on commit f551431

Please sign in to comment.