Skip to content

Commit

Permalink
Merge pull request #81 from gustavo-marques/fix_salt_flux
Browse files Browse the repository at this point in the history
Adds missing parameter and fixes a bug
  • Loading branch information
alperaltuntas authored Oct 8, 2018
2 parents 48582eb + a2e9c1e commit a3dbe02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions config_src/mct_driver/MOM_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, Time, G, CS, &
real :: delta_sst ! temporary storage for sst diff from restoring value

real :: C_p ! heat capacity of seawater ( J/(K kg) )
real :: sign_for_net_FW_bug ! Should be +1. but an old bug can be recovered by using -1.

call cpu_clock_begin(id_clock_forcing)

Expand Down Expand Up @@ -461,15 +462,17 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, Time, G, CS, &
! salt flux
! more salt restoring logic
if (associated(fluxes%salt_flux)) &
fluxes%salt_flux(i,j) = G%mask2dT(i,j)*(IOB%salt_flux(i-i0,j-j0) + fluxes%salt_flux(i,j))
fluxes%salt_flux(i,j) = G%mask2dT(i,j)*(fluxes%salt_flux(i,j) - IOB%salt_flux(i-i0,j-j0))

if (associated(fluxes%salt_flux_in)) &
fluxes%salt_flux_in(i,j) = G%mask2dT(i,j)*IOB%salt_flux(i-i0,j-j0)
fluxes%salt_flux_in(i,j) = G%mask2dT(i,j)*(-IOB%salt_flux(i-i0,j-j0))

enddo; enddo

! adjust the NET fresh-water flux to zero, if flagged
if (CS%adjust_net_fresh_water_to_zero) then
sign_for_net_FW_bug = 1.
if (CS%use_net_FW_adjustment_sign_bug) sign_for_net_FW_bug = -1.
do j=js,je ; do i=is,ie
net_FW(i,j) = (((fluxes%lprec(i,j) + fluxes%fprec(i,j)) + &
(fluxes%lrunoff(i,j) + fluxes%frunoff(i,j))) + &
Expand All @@ -480,9 +483,9 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, Time, G, CS, &
! Bob thinks this is trying ensure the net fresh-water of the ocean + sea-ice system
! is constant.
! To do this correctly we will need a sea-ice melt field added to IOB. -AJA
if (associated(fluxes%salt_flux) .and. (CS%ice_salt_concentration>0.0)) &
net_FW(i,j) = net_FW(i,j) + G%areaT(i,j) * &
(fluxes%salt_flux(i,j) / CS%ice_salt_concentration)
if (associated(IOB%salt_flux) .and. (CS%ice_salt_concentration>0.0)) &
net_FW(i,j) = net_FW(i,j) + sign_for_net_FW_bug * G%areaT(i,j) * &
(IOB%salt_flux(i-i0,j-j0) / CS%ice_salt_concentration)
net_FW2(i,j) = net_FW(i,j)/G%areaT(i,j)
enddo; enddo

Expand Down Expand Up @@ -1044,6 +1047,11 @@ subroutine surface_forcing_init(Time, G, param_file, diag, CS, restore_salt, res
CS%adjust_net_fresh_water_to_zero, &
"If true, adjusts the net fresh-water forcing seen \n"//&
"by the ocean (including restoring) to zero.", default=.false.)
if (CS%adjust_net_fresh_water_to_zero) &
call get_param(param_file, mdl, "USE_NET_FW_ADJUSTMENT_SIGN_BUG", &
CS%use_net_FW_adjustment_sign_bug, &
"If true, use the wrong sign for the adjustment to\n"//&
"the net fresh-water.", default=.false.)
call get_param(param_file, mdl, "ADJUST_NET_FRESH_WATER_BY_SCALING", &
CS%adjust_net_fresh_water_by_scaling, &
"If true, adjustments to net fresh water to achieve zero net are\n"//&
Expand Down
4 changes: 2 additions & 2 deletions config_src/mct_driver/ocn_cap_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ subroutine ocn_import(x2o, ind, grid, ice_ocean_boundary, ocean_public, logunit,
! surface pressure
ice_ocean_boundary%p(i,j) = x2o(ind%x2o_Sa_pslv,k) * GRID%mask2dT(ig,jg)

! salt flux
ice_ocean_boundary%salt_flux(i,j) = x2o(ind%x2o_Fioi_salt,k) * GRID%mask2dT(ig,jg)
! salt flux (minus sign needed here -GMM)
ice_ocean_boundary%salt_flux(i,j) = -x2o(ind%x2o_Fioi_salt,k) * GRID%mask2dT(ig,jg)

! 1) visible, direct shortwave (W/m2)
! 2) visible, diffuse shortwave (W/m2)
Expand Down

0 comments on commit a3dbe02

Please sign in to comment.