Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User/wfc/spear 20200207 #7

Merged
merged 10 commits into from
Feb 7, 2020
26 changes: 19 additions & 7 deletions config_src/coupled_driver/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ module MOM_surface_forcing_gfdl
logical :: restore_temp !< If true, the coupled MOM driver adds a term to restore sea
!! surface temperature to a specified value.
real :: Flux_const !< Piston velocity for surface restoring [m s-1]
real :: Flux_const_salt !< Piston velocity for surface salt restoring [m s-1]
real :: Flux_const_temp !< Piston velocity for surface temp restoring [m s-1]
logical :: salt_restore_as_sflux !< If true, SSS restore as salt flux instead of water flux
logical :: adjust_net_srestore_to_zero !< Adjust srestore to zero (for both salt_flux or vprec)
logical :: adjust_net_srestore_by_scaling !< Adjust srestore w/o moving zero contour
Expand Down Expand Up @@ -352,7 +354,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, G, US, CS, sfc
do j=js,je ; do i=is,ie
delta_sss = data_restore(i,j)- sfc_state%SSS(i,j)
delta_sss = sign(1.0,delta_sss)*min(abs(delta_sss),CS%max_delta_srestore)
fluxes%salt_flux(i,j) = 1.e-3*G%mask2dT(i,j) * (CS%Rho0*CS%Flux_const)* &
fluxes%salt_flux(i,j) = 1.e-3*G%mask2dT(i,j) * (CS%Rho0*CS%Flux_const_salt)* &
(CS%basin_mask(i,j)*open_ocn_mask(i,j)*CS%srestore_mask(i,j)) *delta_sss ! kg Salt m-2 s-1
enddo ; enddo
if (CS%adjust_net_srestore_to_zero) then
Expand All @@ -372,7 +374,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, G, US, CS, sfc
delta_sss = sfc_state%SSS(i,j) - data_restore(i,j)
delta_sss = sign(1.0,delta_sss)*min(abs(delta_sss),CS%max_delta_srestore)
fluxes%vprec(i,j) = (CS%basin_mask(i,j)*open_ocn_mask(i,j)*CS%srestore_mask(i,j))* &
(CS%Rho0*CS%Flux_const) * &
(CS%Rho0*CS%Flux_const_salt) * &
delta_sss / (0.5*(sfc_state%SSS(i,j) + data_restore(i,j)))
endif
enddo ; enddo
Expand All @@ -398,7 +400,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, G, US, CS, sfc
delta_sst = data_restore(i,j)- sfc_state%SST(i,j)
delta_sst = sign(1.0,delta_sst)*min(abs(delta_sst),CS%max_delta_trestore)
fluxes%heat_added(i,j) = G%mask2dT(i,j) * CS%trestore_mask(i,j) * &
(CS%Rho0*fluxes%C_p) * delta_sst * CS%Flux_const ! W m-2
(CS%Rho0*fluxes%C_p) * delta_sst * CS%Flux_const_temp ! W m-2
enddo ; enddo
endif

Expand Down Expand Up @@ -1331,10 +1333,15 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS)

if (CS%restore_salt) then
call get_param(param_file, mdl, "FLUXCONST", CS%Flux_const, &
"The constant that relates the restoring surface fluxes "//&
"The constant that relates the restoring surface salt fluxes "//&
"to the relative surface anomalies (akin to a piston "//&
"velocity). Note the non-MKS units.", units="m day-1", &
fail_if_missing=.true.)
call get_param(param_file, mdl, "FLUXCONST_SALT", CS%Flux_const_salt, &
"The constant that relates the restoring surface fluxes "//&
"to the relative surface anomalies (akin to a piston "//&
"velocity). Note the non-MKS units.", units="m day-1", &
fail_if_missing=.false., default=CS%Flux_const)
call get_param(param_file, mdl, "SALT_RESTORE_FILE", CS%salt_restore_file, &
"A file in which to find the surface salinity to use for restoring.", &
default="salt_restore.nc")
Expand All @@ -1343,7 +1350,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS)
"SALT_RESTORE_FILE for restoring salinity.", &
default="salt")
! Convert CS%Flux_const from m day-1 to m s-1.
CS%Flux_const = CS%Flux_const / 86400.0
CS%Flux_const_salt = CS%Flux_const_salt / 86400.0

call get_param(param_file, mdl, "SRESTORE_AS_SFLUX", CS%salt_restore_as_sflux, &
"If true, the restoring of salinity is applied as a salt "//&
Expand Down Expand Up @@ -1379,10 +1386,15 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS)

if (CS%restore_temp) then
call get_param(param_file, mdl, "FLUXCONST", CS%Flux_const, &
"The constant that relates the restoring surface fluxes "//&
"The constant that relates the restoring surface temperature fluxes "//&
"to the relative surface anomalies (akin to a piston "//&
"velocity). Note the non-MKS units.", units="m day-1", &
fail_if_missing=.true.)
call get_param(param_file, mdl, "FLUXCONST_TEMP", CS%Flux_const_temp, &
"The constant that relates the restoring surface temperature fluxes "//&
"to the relative surface anomalies (akin to a piston "//&
"velocity). Note the non-MKS units.", units="m day-1", &
fail_if_missing=.false., default=CS%Flux_const)
call get_param(param_file, mdl, "SST_RESTORE_FILE", CS%temp_restore_file, &
"A file in which to find the surface temperature to use for restoring.", &
default="temp_restore.nc")
Expand All @@ -1391,7 +1403,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS)
"SST_RESTORE_FILE for restoring sst.", &
default="temp")
! Convert CS%Flux_const from m day-1 to m s-1.
CS%Flux_const = CS%Flux_const / 86400.0
CS%Flux_const_temp = CS%Flux_const_temp / 86400.0

call get_param(param_file, mdl, "MAX_DELTA_TRESTORE", CS%max_delta_trestore, &
"The maximum sst difference used in restoring terms.", &
Expand Down
33 changes: 10 additions & 23 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module MOM
use MOM_restart, only : register_restart_field, query_initialized, save_restart
use MOM_restart, only : restart_init, is_new_run, MOM_restart_CS
use MOM_spatial_means, only : global_mass_integral
use MOM_time_manager, only : time_type, real_to_time, time_type_to_real, operator(+)
use MOM_time_manager, only : time_type, real_to_time, set_time, time_type_to_real, operator(+)
use MOM_time_manager, only : operator(-), operator(>), operator(*), operator(/)
use MOM_time_manager, only : operator(>=), increment_date
use MOM_unit_tests, only : unit_tests
Expand Down Expand Up @@ -608,12 +608,13 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &

rel_time = 0.0
do n=1,n_max
rel_time = rel_time + dt ! The relative time at the end of the step.
! Set the universally visible time to the middle of the time step.
CS%Time = Time_start + real_to_time(rel_time - 0.5*dt)
! Set the local time to the end of the time step.
Time_local = Time_start + real_to_time(rel_time)

! Set the universally visible time to the middle of the time step
CS%Time = Time_start + set_time(int(floor(rel_time+0.5*dt+0.5)))
rel_time = rel_time + dt

! Set the local time to the end of the time step.
Time_local = Time_start + set_time(int(floor(rel_time+0.5)))
if (showCallTree) call callTree_enter("DT cycles (step_MOM) n=",n)

!===========================================================================
Expand All @@ -635,15 +636,9 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &
dtdia = dt*min(ntstep,n_max-(n-1))
endif

end_time_thermo = Time_local
if (dtdia > dt) then
! If necessary, temporarily reset CS%Time to the center of the period covered
! by the call to step_MOM_thermo, noting that they begin at the same time.
CS%Time = CS%Time + real_to_time(0.5*(dtdia-dt))
! The end-time of the diagnostic interval needs to be set ahead if there
! are multiple dynamic time steps worth of thermodynamics applied here.
end_time_thermo = Time_local + real_to_time(dtdia-dt)
endif
! The end-time of the diagnostic interval needs to be set ahead if there
! are multiple dynamic time steps worth of thermodynamics applied here.
end_time_thermo = Time_local + set_time(int(floor(dtdia-dt+0.5)))

! Apply diabatic forcing, do mixing, and regrid.
call step_MOM_thermo(CS, G, GV, US, u, v, h, CS%tv, fluxes, dtdia, &
Expand All @@ -654,8 +649,6 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &
CS%t_dyn_rel_thermo = -dtdia
if (showCallTree) call callTree_waypoint("finished diabatic_first (step_MOM)")

if (dtdia > dt) & ! Reset CS%Time to its previous value.
CS%Time = Time_start + real_to_time(rel_time - 0.5*dt)
endif ! end of block "(CS%diabatic_first .and. (CS%t_dyn_rel_adv==0.0))"

if (do_dyn) then
Expand Down Expand Up @@ -740,10 +733,6 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &
"before call to diabatic.")
endif

! If necessary, temporarily reset CS%Time to the center of the period covered
! by the call to step_MOM_thermo, noting that they end at the same time.
if (dtdia > dt) CS%Time = CS%Time - real_to_time(0.5*(dtdia-dt))

! Apply diabatic forcing, do mixing, and regrid.
call step_MOM_thermo(CS, G, GV, US, u, v, h, CS%tv, fluxes, dtdia, &
Time_local, .false., Waves=Waves)
Expand All @@ -756,8 +745,6 @@ subroutine step_MOM(forces, fluxes, sfc_state, Time_start, time_interval, CS, &
CS%t_dyn_rel_thermo = 0.0
endif

if (dtdia > dt) & ! Reset CS%Time to its previous value.
CS%Time = Time_start + real_to_time(rel_time - 0.5*dt)
endif

if (do_dyn) then
Expand Down
6 changes: 6 additions & 0 deletions src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ subroutine extractFluxes1d(G, GV, fluxes, optics, nsw, j, dt,
if (do_NSR) Net_salt_rate(i) = (scale * 1. * (1000.0 * fluxes%salt_flux(i,j))) * GV%kg_m2_to_H
endif

if (associated(fluxes%salt_flux_added)) then
Net_salt(i) = Net_salt(i) + (scale * dt * (1000.0 * fluxes%salt_flux_added(i,j))) * GV%kg_m2_to_H
!Repeat above code for 'rate' term
if (do_NSR) Net_salt_rate(i) = Net_salt_rate(i) + (scale * 1. * (1000.0 * fluxes%salt_flux_added(i,j))) * GV%kg_m2_to_H
endif

! Diagnostics follow...
if (calculate_diags) then

Expand Down
Loading