Skip to content

Commit

Permalink
Merge pull request #1 from nikizadehgfdl/obgc_obc_seg_data_update_period
Browse files Browse the repository at this point in the history
Obgc obc seg data update period
  • Loading branch information
andrew-c-ross authored Aug 5, 2021
2 parents 32038a2 + e4bd8eb commit 2616a34
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ module MOM
!! 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.
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 :: &
Expand Down Expand Up @@ -1054,6 +1058,17 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
CS%dtbt_reset_time = CS%dtbt_reset_time + CS%dtbt_reset_interval
endif
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 !### Change >= to > here.
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

call step_MOM_dyn_split_RK2(u, v, h, CS%tv, CS%visc, Time_local, dt, forces, &
p_surf_begin, p_surf_end, CS%uh, CS%vh, CS%uhtr, CS%vhtr, &
Expand Down Expand Up @@ -1924,6 +1939,13 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
"DTBT will be set every dynamics time step. The default "//&
"is set by DT_THERM. This is only used if SPLIT is true.", &
units="s", default=default_val, do_not_read=(dtbt > 0.0))

CS%dt_obc_seg_period = -1.0
call get_param(param_file, "MOM", "DT_OBC_SEG_UPDATE_OBGC", CS%dt_obc_seg_period, &
"The time between OBC segment data updates for OBGC tracers. "//&
"The default is set to DT. This is only used if SPLIT is true.", &
units="s", default=CS%dt)

endif

! This is here in case these values are used inappropriately.
Expand Down Expand Up @@ -2622,6 +2644,19 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
CS%dtbt_reset_time = CS%dtbt_reset_time - CS%dtbt_reset_interval
endif
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(CS%dt_obc_seg_period)
! Set dt_obc_seg_time to be the next even multiple of dt_obc_seg_interval.
CS%dt_obc_seg_time = Time_init + CS%dt_obc_seg_interval * &
((Time - Time_init) / CS%dt_obc_seg_interval)
if ((CS%dt_obc_seg_time > Time) .and. CS%OBC%update_OBC_seg_data) then
! Back up dtbt_reset_time one interval to force dtbt to be calculated,
! because the restart was not aligned with the interval to recalculate
! dtbt, and dtbt was not read from a restart file.
CS%dt_obc_seg_time = CS%dt_obc_seg_time - CS%dt_obc_seg_interval
endif
endif
elseif (CS%use_RK2) then
call initialize_dyn_unsplit_RK2(CS%u, CS%v, CS%h, Time, G, GV, US, &
param_file, diag, CS%dyn_unsplit_RK2_CSp, restart_CSp, &
Expand Down
6 changes: 6 additions & 0 deletions src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ module MOM_open_boundary
logical :: user_BCs_set_globally = .false. !< True if any OBC_USER_CONFIG is set
!! for input from user directory.
logical :: update_OBC = .false. !< Is OBC data time-dependent
logical :: update_OBC_seg_data = .false. !< Is it the time for OBC segment data update for fields that
!! require less frequent update
logical :: needs_IO_for_data = .false. !< Is any i/o needed for OBCs
logical :: zero_vorticity = .false. !< If True, sets relative vorticity to zero on open boundaries.
logical :: freeslip_vorticity = .false. !< If True, sets normal gradient of tangential velocity to zero
Expand Down Expand Up @@ -3897,6 +3899,10 @@ subroutine update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)
allocate(h_stack(GV%ke))
h_stack(:) = 0.0
do m = 1,segment%num_fields
!This field may not require a high frequency OBC segment update and might be allowed
!a less frequent update as set by the parameter update_OBC_period_max in MOM.F90.
!Cycle if it is not the time to update OBC segment data for this field.
if (trim(segment%field(m)%genre) == 'obgc' .and. (.not. OBC%update_OBC_seg_data)) cycle
if (segment%field(m)%fid > 0) then
siz(1)=size(segment%field(m)%buffer_src,1)
siz(2)=size(segment%field(m)%buffer_src,2)
Expand Down

0 comments on commit 2616a34

Please sign in to comment.