Skip to content

Commit

Permalink
add CFC_BC_year_offset, converts model time to time in CFC_BC_file
Browse files Browse the repository at this point in the history
add desc argument to log_param calls in MOM_CFC_cap
  • Loading branch information
klindsay28 committed Mar 1, 2023
1 parent c142e4c commit db06a54
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
19 changes: 14 additions & 5 deletions config_src/drivers/nuopc_cap/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ module MOM_surface_forcing_nuopc
character(len=30) :: cfc11_var_name !< name of cfc11 in CFC_BC_file
character(len=30) :: cfc12_var_name !< name of cfc11 in CFC_BC_file
real, pointer, dimension(:,:) :: trestore_mask => NULL() !< mask for SST restoring
integer :: id_srestore = -1 !< id number for time_interp_external.
integer :: id_trestore = -1 !< id number for time_interp_external.
integer :: id_cfc11_atm = -1 !< id number for time_interp_external.
integer :: id_cfc12_atm = -1 !< id number for time_interp_external.
integer :: id_srestore = -1 !< id number for time_interp_external.
integer :: id_trestore = -1 !< id number for time_interp_external.
integer :: CFC_BC_year_offset = 0 !< offset to add to model time to get time value used in CFC_BC_file
integer :: id_cfc11_atm = -1 !< id number for time_interp_external.
integer :: id_cfc12_atm = -1 !< id number for time_interp_external.

! Diagnostics handles
type(forcing_diags), public :: handles
Expand Down Expand Up @@ -596,7 +597,8 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! CFCs
if (CS%use_CFC) then
call CFC_cap_fluxes(fluxes, sfc_state, G, US, CS%Rho0, Time, CS%id_cfc11_atm, CS%id_cfc11_atm)
call CFC_cap_fluxes(fluxes, sfc_state, G, US, CS%Rho0, Time, CS%CFC_BC_year_offset, &
CS%id_cfc11_atm, CS%id_cfc11_atm)
endif

if (associated(IOB%salt_flux)) then
Expand Down Expand Up @@ -1118,6 +1120,8 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,
character(len=48) :: flnam
character(len=240) :: basin_file
integer :: i, j, isd, ied, jsd, jed
integer :: CFC_BC_data_year ! specific year in CFC BC data calendar
integer :: CFC_BC_model_year ! model year corresponding to CFC_BC_data_year

isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed

Expand Down Expand Up @@ -1424,6 +1428,11 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,
CS%CFC_BC_file = trim(CS%inputdir) // trim(CS%CFC_BC_file)
endif
if (len_trim(CS%CFC_BC_file) > 0) then
call get_param(param_file, mdl, "CFC_BC_DATA_YEAR", CFC_BC_data_year, &
"Specific year in CFC_BC_FILE data calendar", default=2000, do_not_log=.true.)
call get_param(param_file, mdl, "CFC_BC_MODEL_YEAR", CFC_BC_model_year, &
"Model year corresponding to CFC_BC_MODEL_YEAR", default=2000, do_not_log=.true.)
CS%CFC_BC_year_offset = CFC_BC_data_year - CFC_BC_model_year
call get_param(param_file, mdl, "CFC11_VARIABLE", CS%cfc11_var_name, &
"The name of the variable representing CFC-11 in "//&
"CFC_BC_FILE.", default="CFC_11", do_not_log=.true.)
Expand Down
25 changes: 19 additions & 6 deletions src/tracer/MOM_CFC_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module MOM_CFC_cap
use MOM_open_boundary, only : ocean_OBC_type
use MOM_restart, only : query_initialized, set_initialized, MOM_restart_CS
use MOM_spatial_means, only : global_mass_int_EFP
use MOM_time_manager, only : time_type
use MOM_time_manager, only : time_type, increment_date
use time_interp_external_mod, only : init_external_field, time_interp_external
use MOM_tracer_registry, only : register_tracer
use MOM_tracer_types, only : tracer_registry_type
Expand Down Expand Up @@ -86,6 +86,7 @@ function register_CFC_cap(HI, GV, param_file, CS, tr_Reg, restart_CS)
# include "version_variable.h"
real, dimension(:,:,:), pointer :: tr_ptr => NULL()
character(len=200) :: dummy ! Dummy variable to store params that need to be logged here.
integer :: dummy_int ! Dummy variable to store params that need to be logged here.
character :: m2char
logical :: register_CFC_cap
integer :: isd, ied, jsd, jed, nz, m
Expand All @@ -108,7 +109,8 @@ function register_CFC_cap(HI, GV, param_file, CS, tr_Reg, restart_CS)
! Add the directory if CS%IC_file is not already a complete path.
call get_param(param_file, mdl, "INPUTDIR", inputdir, default=".")
CS%IC_file = trim(slasher(inputdir))//trim(CS%IC_file)
call log_param(param_file, mdl, "INPUTDIR/CFC_IC_FILE", CS%IC_file)
call log_param(param_file, mdl, "INPUTDIR/CFC_IC_FILE", CS%IC_file, &
"full path of CFC_IC_FILE")
endif
call get_param(param_file, mdl, "CFC_IC_FILE_IS_Z", CS%Z_IC_file, &
"If true, CFC_IC_FILE is in depth space, not layer space", &
Expand All @@ -135,9 +137,14 @@ function register_CFC_cap(HI, GV, param_file, CS, tr_Reg, restart_CS)
! Add the directory if dummy is not already a complete path.
call get_param(param_file, mdl, "INPUTDIR", inputdir, default=".")
dummy = trim(slasher(inputdir))//trim(dummy)
call log_param(param_file, mdl, "INPUTDIR/CFC_IC_FILE", dummy)
call log_param(param_file, mdl, "INPUTDIR/CFC_BC_FILE", dummy, &
"full path of CFC_BC_FILE")
endif
if (len_trim(dummy) > 0) then
call get_param(param_file, mdl, "CFC_BC_DATA_YEAR", dummy_int, &
"Specific year in CFC_BC_FILE data calendar", default=2000)
call get_param(param_file, mdl, "CFC_BC_MODEL_YEAR", dummy_int, &
"Model year corresponding to CFC_BC_MODEL_YEAR", default=2000)
call get_param(param_file, mdl, "CFC11_VARIABLE", dummy, &
"The name of the variable representing CFC-11 in "//&
"CFC_BC_FILE.", default="CFC_11")
Expand Down Expand Up @@ -428,7 +435,8 @@ end subroutine CFC_cap_surface_state

!> Orchestrates the calculation of the CFC fluxes [mol m-2 s-1], including getting the ATM
!! concentration, and calculating the solubility, Schmidt number, and gas exchange.
subroutine CFC_cap_fluxes(fluxes, sfc_state, G, US, Rho0, Time, id_cfc11_atm, id_cfc12_atm)
subroutine CFC_cap_fluxes(fluxes, sfc_state, G, US, Rho0, Time, CFC_BC_year_offset, &
id_cfc11_atm, id_cfc12_atm)
type(ocean_grid_type), intent(in ) :: G !< The ocean's grid structure.
type(unit_scale_type), intent(in ) :: US !< A dimensional unit scaling type
type(surface), intent(in ) :: sfc_state !< A structure containing fields
Expand All @@ -439,10 +447,13 @@ subroutine CFC_cap_fluxes(fluxes, sfc_state, G, US, Rho0, Time, id_cfc11_atm, id
real, intent(in ) :: Rho0 !< The mean ocean density [R ~> kg m-3]
type(time_type), intent(in ) :: Time !< The time of the fluxes, used for interpolating the
!! CFC's concentration in the atmosphere.
integer, intent(in ) :: CFC_BC_year_offset !< offset to add to model time to get
!! time value used in CFC_BC_file
integer, optional, intent(inout):: id_cfc11_atm !< id number for time_interp_external.
integer, optional, intent(inout):: id_cfc12_atm !< id number for time_interp_external.

! Local variables
type(time_type) :: Time_external ! time value used in CFC_BC_file
real, dimension(SZI_(G),SZJ_(G)) :: &
kw_wo_sc_no_term, & ! gas transfer velocity, without the Schmidt number term [Z T-1 ~> m s-1].
kw, & ! gas transfer velocity [Z T-1 ~> m s-1].
Expand All @@ -462,9 +473,11 @@ subroutine CFC_cap_fluxes(fluxes, sfc_state, G, US, Rho0, Time, id_cfc11_atm, id

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

Time_external = increment_date(Time, years=CFC_BC_year_offset)

! CFC11 ATM concentration
if (present(id_cfc11_atm) .and. (id_cfc11_atm /= -1)) then
call time_interp_external(id_cfc11_atm, Time, cfc11_atm)
call time_interp_external(id_cfc11_atm, Time_external, cfc11_atm)
! convert from ppt (pico mol/mol) to mol/mol
cfc11_atm = cfc11_atm * 1.0e-12
else
Expand All @@ -475,7 +488,7 @@ subroutine CFC_cap_fluxes(fluxes, sfc_state, G, US, Rho0, Time, id_cfc11_atm, id

! CFC12 ATM concentration
if (present(id_cfc12_atm) .and. (id_cfc12_atm /= -1)) then
call time_interp_external(id_cfc12_atm, Time, cfc12_atm)
call time_interp_external(id_cfc12_atm, Time_external, cfc12_atm)
! convert from ppt (pico mol/mol) to mol/mol
cfc12_atm = cfc12_atm * 1.0e-12
else
Expand Down

0 comments on commit db06a54

Please sign in to comment.