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

Obc setup plus segment update period #198

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c396956
Setup OBC segments for COBALT/OBGC tracers
nikizadehgfdl Aug 17, 2022
b97954f
Setup OBC segments for COBALT/OBGC tracers
nikizadehgfdl Aug 17, 2022
a544c7e
Setup OBC segments for COBALT/OBGC tracers
nikizadehgfdl Aug 17, 2022
02a3d4e
Setup OBC segments for COBALT/OBGC tracers
nikizadehgfdl Aug 18, 2022
6199f7c
Setup OBC segments for COBALT/OBGC tracers
nikizadehgfdl Aug 18, 2022
8c112d7
Setup OBC segments for COBALT/OBGC tracers
nikizadehgfdl Aug 18, 2022
6d239c0
Add capability to change obc segment update period
nikizadehgfdl Aug 18, 2022
e14cbf9
Add capability to change obc segment update period
nikizadehgfdl Aug 22, 2022
aaf3ab8
Add capability to change obc segment update period
nikizadehgfdl Aug 22, 2022
203fd4e
Insert missing US%T_to_sec
nikizadehgfdl Sep 20, 2022
dd1624e
Merge branch 'dev/gfdl' into OBC_setup_plus_segment_update_period
nikizadehgfdl Sep 20, 2022
12ba409
Updates from Andrew Ross
nikizadehgfdl Sep 20, 2022
6a08a45
Per Andrew Ross review
nikizadehgfdl Oct 31, 2022
e79d9b1
corrected indentation per review
nikizadehgfdl Oct 31, 2022
dba7cf8
Avoid using module vars per review request
nikizadehgfdl Nov 1, 2022
96c46f0
Merge branch 'dev/gfdl' into OBC_setup_plus_segment_update_period
nikizadehgfdl Nov 1, 2022
7302599
Coding style corrections per review
nikizadehgfdl Nov 4, 2022
6c486a4
Modification per review: do_not_log if .not.associated(CS%OBC)
nikizadehgfdl Nov 7, 2022
be9be83
Merge branch 'dev/gfdl' into OBC_setup_plus_segment_update_period
Hallberg-NOAA Nov 7, 2022
a7e608c
Merge branch 'dev/gfdl' into OBC_setup_plus_segment_update_period
Hallberg-NOAA Nov 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module g_tracer_utils
character(len=fm_string_len) :: src_var_name !< Tracer source variable name
character(len=fm_string_len) :: src_var_unit !< Tracer source variable units
character(len=fm_string_len) :: src_var_gridspec !< Tracer source grid file name
character(len=fm_string_len) :: obc_src_file_name !< Boundary condition tracer source filename
character(len=fm_string_len) :: obc_src_field_name !< Boundary condition tracer source fieldname
integer :: src_var_record !< Unknown
logical :: requires_src_info = .false. !< Unknown
real :: src_var_unit_conversion = 1.0 !< This factor depends on the tracer. Ask Jasmin
Expand Down Expand Up @@ -61,6 +63,7 @@ module g_tracer_utils
public :: g_tracer_get_next
public :: g_tracer_is_prog
public :: g_diag_type
public :: g_tracer_get_obc_segment_props

!> Set the values of various (array) members of the tracer node g_tracer_type
!!
Expand Down Expand Up @@ -284,6 +287,17 @@ subroutine g_tracer_get_next(g_tracer,g_tracer_next)
type(g_tracer_type), pointer :: g_tracer_next !< Pointer to the next tracer node in the list
end subroutine g_tracer_get_next

!> get obc segment properties for each tracer
subroutine g_tracer_get_obc_segment_props(g_tracer_list, name, obc_has, src_file, src_var_name,lfac_in,lfac_out)
type(g_tracer_type), pointer :: g_tracer_list !< pointer to the head of the generic tracer list
character(len=*), intent(in) :: name !< tracer name
logical, intent(out):: obc_has !< .true. if This tracer has OBC
real, optional,intent(out):: lfac_in !< OBC reservoir inverse lengthscale factor
real, optional,intent(out):: lfac_out !< OBC reservoir inverse lengthscale factor
character(len=*),optional,intent(out):: src_file !< OBC source file
character(len=*),optional,intent(out):: src_var_name !< OBC source variable in file
end subroutine g_tracer_get_obc_segment_props

!>Vertical Diffusion of a tracer node
!!
!! This subroutine solves a tridiagonal equation to find and set values of vertically diffused field
Expand Down
34 changes: 32 additions & 2 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module MOM
use MOM_tracer_registry, only : lock_tracer_registry, tracer_registry_end
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_CS
use MOM_tracer_flow_control, only : tracer_flow_control_init, call_tracer_surface_state
use MOM_tracer_flow_control, only : tracer_flow_control_end
use MOM_tracer_flow_control, only : tracer_flow_control_end, call_tracer_register_obc_segments
use MOM_transcribe_grid, only : copy_dyngrid_to_MOM_grid, copy_MOM_grid_to_dyngrid
use MOM_unit_scaling, only : unit_scale_type, unit_scaling_init
use MOM_unit_scaling, only : unit_scaling_end, fix_restart_unit_scaling
Expand Down Expand Up @@ -294,7 +294,11 @@ module MOM
!! barotropic time step [s]. If this is negative dtbt is never
!! calculated, and if it is 0, dtbt is calculated every step.
type(time_type) :: dtbt_reset_interval !< A time_time representation of dtbt_reset_period.
type(time_type) :: dtbt_reset_time !< The next time DTBT should be calculated.
type(time_type) :: dtbt_reset_time !< The next time DTBT should be calculated.
real :: dt_obc_seg_period !< The time interval between OBC segment updates for OBGC tracers
type(time_type) :: dt_obc_seg_interval !< A time_time representation of dt_obc_seg_period.
type(time_type) :: dt_obc_seg_time !< The next time OBC segment update is applied to OBGC tracers.

real, dimension(:,:), pointer :: frac_shelf_h => NULL() !< fraction of total area occupied
!! by ice shelf [nondim]
real, dimension(:,:), pointer :: mass_shelf => NULL() !< Mass of ice shelf [R Z ~> kg m-2]
Expand Down Expand Up @@ -1132,6 +1136,17 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
call disable_averaging(CS%diag)
endif

!OBC segment data update for some fields can be less frequent than others
if(associated(CS%OBC)) then
CS%OBC%update_OBC_seg_data = .false.
if (CS%dt_obc_seg_period == 0.0) CS%OBC%update_OBC_seg_data = .true.
if (CS%dt_obc_seg_period > 0.0) then
if (Time_local >= CS%dt_obc_seg_time) then
CS%OBC%update_OBC_seg_data = .true.
CS%dt_obc_seg_time = CS%dt_obc_seg_time + CS%dt_obc_seg_interval
endif
endif
endif

if (CS%do_dynamics .and. CS%split) then !--------------------------- start SPLIT
! This section uses a split time stepping scheme for the dynamic equations,
Expand Down Expand Up @@ -2152,6 +2167,13 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
units="s", default=default_val, do_not_read=(dtbt > 0.0))
endif

CS%dt_obc_seg_period = -1.0
call get_param(param_file, "MOM", "DT_OBC_SEG_UPDATE_OBGC", CS%dt_obc_seg_period, &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written, this new parameter is being logged in every MOM_parameter_doc.all file, including in many where it is meaningless. Please add the argument do_not_log=.not.associated(CS%OBC) to this call or wrap it in on logical test for whether open boundary conditions are actually being used.

"The time between OBC segment data updates for OBGC tracers. "//&
"This must be an integer multiple of DT and DT_THERM. "//&
"The default is set to DT.", &
units="s", default=US%T_to_s*CS%dt)

! This is here in case these values are used inappropriately.
use_frazil = .false. ; bound_salinity = .false.
CS%tv%P_Ref = 2.0e7*US%kg_m3_to_R*US%m_s_to_L_T**2
Expand Down Expand Up @@ -2627,6 +2649,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
! could occur with the call to update_OBC_data or after the main initialization.
if (use_temperature) &
call register_temp_salt_segments(GV, US, CS%OBC, CS%tracer_Reg, param_file)
!This is the equivalent call to register_temp_salt_segments for external tracers with OBC
call call_tracer_register_obc_segments(GV, param_file, CS%tracer_flow_CSp, CS%tracer_Reg, CS%OBC)

! This needs the number of tracers and to have called any code that sets whether
! reservoirs are used.
Expand Down Expand Up @@ -2962,6 +2986,12 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
CS%ntrunc, cont_stencil=CS%cont_stencil)
endif

!Set OBC segment data update period
if (associated(CS%OBC) .and. CS%dt_obc_seg_period > 0.0) then
CS%dt_obc_seg_interval = real_to_time(US%T_to_s*CS%dt_obc_seg_period)
CS%dt_obc_seg_time = Time + CS%dt_obc_seg_interval

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test this, but I think setting this to Time + CS%dt_obc_seg_interval results in the tracer reservoirs not being initialized at the first time step and only getting initialized at the first obc segment update period. In both NWA and NEP regional domains, water inflowing from the boundary is very low in alkalinity, oxygen, and other tracers when the model first starts running, as if the reservoirs were initialized at 0.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the reservoirs should also be initialized by fill_obgc_segments. Need to look into this more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a way to fix this issue with two comments that I've left below.

endif

call callTree_waypoint("dynamics initialized (initialize_MOM)")

CS%mixedlayer_restrat = mixedlayer_restrat_init(Time, G, GV, US, param_file, diag, &
Expand Down
Loading