Skip to content

Commit 0c103bb

Browse files
committed
Merge branch 'user/ksh/open_bc' into user/ksh/open_bc_uv
2 parents 5f222f0 + 3fa6245 commit 0c103bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+702
-487
lines changed

src/core/MOM.F90

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,29 +1424,6 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in)
14241424

14251425
call find_obsolete_params(param_file)
14261426

1427-
#ifdef SYMMETRIC_MEMORY_
1428-
symmetric = .true.
1429-
#else
1430-
symmetric = .false.
1431-
#endif
1432-
#ifdef STATIC_MEMORY_
1433-
call MOM_domains_init(G%domain, param_file, symmetric=symmetric, &
1434-
static_memory=.true., NIHALO=NIHALO_, NJHALO=NJHALO_, &
1435-
NIGLOBAL=NIGLOBAL_, NJGLOBAL=NJGLOBAL_, NIPROC=NIPROC_, &
1436-
NJPROC=NJPROC_)
1437-
#else
1438-
call MOM_domains_init(G%domain, param_file, symmetric=symmetric)
1439-
#endif
1440-
call callTree_waypoint("domains initialized (initialize_MOM)")
1441-
1442-
call MOM_checksums_init(param_file)
1443-
1444-
call diag_mediator_infrastructure_init()
1445-
call MOM_io_init(param_file)
1446-
call MOM_grid_init(G, param_file)
1447-
call verticalGridInit( param_file, CS%GV )
1448-
GV => CS%GV
1449-
14501427
! Read relevant parameters and write them to the model log.
14511428
call log_version(param_file, "MOM", version, "")
14521429
call get_param(param_file, "MOM", "VERBOSITY", verbosity, &
@@ -1656,21 +1633,53 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in)
16561633
if (CS%adiabatic .and. CS%bulkmixedlayer) call MOM_error(FATAL, &
16571634
"MOM: ADIABATIC and BULKMIXEDLAYER can not both be defined.")
16581635

1636+
! Set up the model domain and grids.
1637+
#ifdef SYMMETRIC_MEMORY_
1638+
symmetric = .true.
1639+
#else
1640+
symmetric = .false.
1641+
#endif
1642+
#ifdef STATIC_MEMORY_
1643+
call MOM_domains_init(G%domain, param_file, symmetric=symmetric, &
1644+
static_memory=.true., NIHALO=NIHALO_, NJHALO=NJHALO_, &
1645+
NIGLOBAL=NIGLOBAL_, NJGLOBAL=NJGLOBAL_, NIPROC=NIPROC_, &
1646+
NJPROC=NJPROC_)
1647+
#else
1648+
call MOM_domains_init(G%domain, param_file, symmetric=symmetric)
1649+
#endif
1650+
call callTree_waypoint("domains initialized (initialize_MOM)")
1651+
1652+
call MOM_checksums_init(param_file)
1653+
1654+
call diag_mediator_infrastructure_init()
1655+
call MOM_io_init(param_file)
1656+
call MOM_grid_init(G, param_file)
1657+
1658+
call create_dyn_horgrid(dG, G%HI)
1659+
dG%first_direction = G%first_direction
1660+
dG%bathymetry_at_vel = G%bathymetry_at_vel
1661+
call clone_MOM_domain(G%Domain, dG%Domain)
1662+
1663+
call verticalGridInit( param_file, CS%GV )
1664+
GV => CS%GV
1665+
dG%g_Earth = GV%g_Earth
1666+
1667+
16591668
! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.
1660-
if (CS%debug .or. G%symmetric) &
1661-
call clone_MOM_domain(G%Domain, G%Domain_aux, symmetric=.false.)
1669+
if (CS%debug .or. dG%symmetric) &
1670+
call clone_MOM_domain(dG%Domain, dG%Domain_aux, symmetric=.false.)
16621671

16631672
call MOM_timing_init(CS)
16641673

16651674
call tracer_registry_init(param_file, CS%tracer_Reg)
16661675

16671676
! Copy a common variable from the vertical grid to the horizontal grid.
16681677
! Consider removing this later?
1669-
G%ke = GV%ke
1678+
! G%ke = GV%ke
16701679

1671-
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke
1672-
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
1673-
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
1680+
is = dG%isc ; ie = dG%iec ; js = dG%jsc ; je = dG%jec ; nz = GV%ke
1681+
isd = dG%isd ; ied = dG%ied ; jsd = dG%jsd ; jed = dG%jed
1682+
IsdB = dG%IsdB ; IedB = dG%IedB ; JsdB = dG%JsdB ; JedB = dG%JedB
16741683

16751684
! Allocate and initialize space for primary MOM variables.
16761685
ALLOC_(CS%u(IsdB:IedB,jsd:jed,nz)) ; CS%u(:,:,:) = 0.0
@@ -1785,17 +1794,28 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in)
17851794
call callTree_waypoint("restart registration complete (initialize_MOM)")
17861795

17871796
call cpu_clock_begin(id_clock_MOM_init)
1788-
call MOM_initialize_fixed(G, CS%OBC, param_file, write_geom_files, dirs%output_directory)
1797+
call MOM_initialize_fixed(dG, CS%OBC, param_file, write_geom_files, dirs%output_directory)
17891798
call callTree_waypoint("returned from MOM_initialize_fixed() (initialize_MOM)")
17901799
call MOM_initialize_coord(GV, param_file, write_geom_files, &
1791-
dirs%output_directory, CS%tv, G%max_depth)
1800+
dirs%output_directory, CS%tv, dG%max_depth)
17921801
call callTree_waypoint("returned from MOM_initialize_coord() (initialize_MOM)")
17931802

17941803
if (CS%use_ALE_algorithm) then
1795-
call ALE_init(param_file, GV, G%max_depth, CS%ALE_CSp)
1804+
call ALE_init(param_file, GV, dG%max_depth, CS%ALE_CSp)
17961805
call callTree_waypoint("returned from ALE_init() (initialize_MOM)")
17971806
endif
17981807

1808+
! Shift from using the temporary dynamic grid type to using the final (potentially
1809+
! static) ocean grid type.
1810+
! call clone_MOM_domain(dG%Domain, CS%G%Domain)
1811+
! call MOM_grid_init(CS%G, param_file)
1812+
1813+
call copy_dyngrid_to_MOM_grid(dg, G)
1814+
! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.
1815+
if (CS%debug .or. G%symmetric) &
1816+
call clone_MOM_domain(G%Domain, G%Domain_aux, symmetric=.false.)
1817+
G%ke = GV%ke
1818+
17991819
call MOM_initialize_state(CS%u, CS%v, CS%h, CS%tv, Time, G, GV, param_file, &
18001820
dirs, CS%restart_CSp, CS%ALE_CSp, CS%tracer_Reg, &
18011821
CS%sponge_CSp, CS%ALE_sponge_CSp, CS%OBC, Time_in)
@@ -1805,20 +1825,6 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in)
18051825
! From this point, there may be pointers being set, so the final grid type
18061826
! that will persist through the run has to be used.
18071827

1808-
! Shift from using the temporary dynamic grid type to using the final (potentially
1809-
! static) ocean grid type.
1810-
! call clone_MOM_domain(dG%Domain, CS%G%Domain)
1811-
! call MOM_grid_init(CS%G, param_file)
1812-
! call copy_dyngrid_to_MOM_grid(dg, CS%G)
1813-
! Allocate the auxiliary non-symmetric domain for debugging or I/O purposes.
1814-
! if (CS%debug .or. CS%G%symmetric) &
1815-
! call clone_MOM_domain(CS%G%Domain, CS%G%Domain_aux, symmetric=.false.)
1816-
1817-
! ! Copy a common variable from the vertical grid to the horizontal grid.
1818-
! ! Consider removing this later?
1819-
! CS%G%ke = GV%ke
1820-
! G => CS%G
1821-
18221828
if (test_grid_copy) then
18231829
! Copy the data from the temporary grid to the dyn_hor_grid to CS%G.
18241830
call create_dyn_horgrid(dG, G%HI)
@@ -1885,12 +1891,12 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in)
18851891

18861892
diag => CS%diag
18871893
! Initialize the diag mediator.
1888-
call diag_mediator_init(G, param_file, diag, doc_file_dir=dirs%output_directory)
1894+
call diag_mediator_init(G, GV%ke, param_file, diag, doc_file_dir=dirs%output_directory)
18891895

18901896
! Initialize the diagnostics mask arrays.
18911897
! This step has to be done after call to MOM_initialize_state
18921898
! and before MOM_diagnostics_init
1893-
call diag_masks_set(G, CS%missing, diag)
1899+
call diag_masks_set(G, GV%ke, CS%missing, diag)
18941900

18951901
! Set up a pointers h within diag mediator control structure,
18961902
! this needs to occur _after_ CS%h has been allocated.

src/core/MOM_CoriolisAdv.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ subroutine CoriolisAdv_init(Time, G, param_file, diag, AD, CS)
875875
CS%diag => diag ; CS%Time => Time
876876

877877
! Read all relevant parameters and write them to the model log.
878-
call log_version(param_file, mod, version)
878+
call log_version(param_file, mod, version, "")
879879
call get_param(param_file, mod, "NOSLIP", CS%no_slip, &
880880
"If true, no slip boundary conditions are used; otherwise \n"//&
881881
"free slip boundary conditions are assumed. The \n"//&

src/core/MOM_PressureForce.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ subroutine PressureForce_init(Time, G, GV, param_file, diag, CS, tides_CSp)
144144
else ; allocate(CS) ; endif
145145

146146
! Read all relevant parameters and write them to the model log.
147-
call log_version(param_file, mod, version)
147+
call log_version(param_file, mod, version, "")
148148
call get_param(param_file, mod, "ANALYTIC_FV_PGF", CS%Analytic_FV_PGF, &
149149
"If true the pressure gradient forces are calculated \n"//&
150150
"with a finite volume form that analytically integrates \n"//&

src/core/MOM_PressureForce_Montgomery.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ subroutine PressureForce_Mont_init(Time, G, GV, param_file, diag, CS, tides_CSp)
967967
endif
968968

969969
mod = "MOM_PressureForce_Mont"
970-
call log_version(param_file, mod, version)
970+
call log_version(param_file, mod, version, "")
971971
call get_param(param_file, mod, "RHO_0", CS%Rho0, &
972972
"The mean ocean density used with BOUSSINESQ true to \n"//&
973973
"calculate accelerations and the mass for conservation \n"//&

src/core/MOM_PressureForce_analytic_FV.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ subroutine PressureForce_AFV_init(Time, G, GV, param_file, diag, CS, tides_CSp)
871871
endif
872872

873873
mod = "MOM_PressureForce_AFV"
874-
call log_version(param_file, mod, version)
874+
call log_version(param_file, mod, version, "")
875875
call get_param(param_file, mod, "RHO_0", CS%Rho0, &
876876
"The mean ocean density used with BOUSSINESQ true to \n"//&
877877
"calculate accelerations and the mass for conservation \n"//&

src/core/MOM_continuity.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ subroutine continuity_init(Time, G, GV, param_file, diag, CS)
190190
allocate(CS)
191191

192192
! Read all relevant parameters and write them to the model log.
193-
call log_version(param_file, mod, version)
193+
call log_version(param_file, mod, version, "")
194194
call get_param(param_file, mod, "CONTINUITY_SCHEME", tmpstr, &
195195
"CONTINUITY_SCHEME selects the discretization for the \n"//&
196196
"continuity solver. The only valid value currently is: \n"//&

src/core/MOM_continuity_PPM.F90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, GV, CS, uhbt, vhbt, OBC,
192192

193193
apply_OBC_u_flather_east = .false. ; apply_OBC_u_flather_west = .false.
194194
apply_OBC_v_flather_north = .false. ; apply_OBC_v_flather_south = .false.
195-
if (present(OBC)) then ; if (associated(OBC)) then
195+
if (present(OBC)) then ; if (associated(OBC)) then ; if (OBC%this_pe) then
196196
apply_OBC_u_flather_east = OBC%apply_OBC_u_flather_east
197197
apply_OBC_u_flather_west = OBC%apply_OBC_u_flather_west
198198
apply_OBC_v_flather_north = OBC%apply_OBC_v_flather_north
@@ -202,7 +202,7 @@ subroutine continuity_PPM(u, v, hin, h, uh, vh, dt, G, GV, CS, uhbt, vhbt, OBC,
202202
if (apply_OBC_u_flather_east .or. apply_OBC_u_flather_west .or. &
203203
apply_OBC_v_flather_north .or. apply_OBC_v_flather_south) &
204204
h_input(:,:,:) = hin(:,:,:)
205-
endif ; endif
205+
endif ; endif ; endif
206206

207207
if (present(visc_rem_u) .neqv. present(visc_rem_v)) call MOM_error(FATAL, &
208208
"MOM_continuity_PPM: Either both visc_rem_u and visc_rem_v or neither"// &
@@ -424,9 +424,9 @@ subroutine zonal_mass_flux(u, h_in, uh, dt, G, GV, CS, LB, uhbt, OBC, &
424424
use_visc_rem = present(visc_rem_u)
425425
apply_OBC_u = .false. ; set_BT_cont = .false.
426426
if (present(BT_cont)) set_BT_cont = (associated(BT_cont))
427-
if (present(OBC)) then ; if (associated(OBC)) then
427+
if (present(OBC)) then ; if (associated(OBC)) then ; if (OBC%this_pe) then
428428
apply_OBC_u = OBC%apply_OBC_u
429-
endif ; endif
429+
endif ; endif ; endif
430430
ish = LB%ish ; ieh = LB%ieh ; jsh = LB%jsh ; jeh = LB%jeh ; nz = G%ke
431431

432432
CFL_dt = CS%CFL_limit_adjust / dt
@@ -1181,9 +1181,9 @@ subroutine meridional_mass_flux(v, h_in, vh, dt, G, GV, CS, LB, vhbt, OBC, &
11811181
use_visc_rem = present(visc_rem_v)
11821182
apply_OBC_v = .false. ; set_BT_cont = .false.
11831183
if (present(BT_cont)) set_BT_cont = (associated(BT_cont))
1184-
if (present(OBC)) then ; if (associated(OBC)) then
1184+
if (present(OBC)) then ; if (associated(OBC)) then ; if (OBC%this_pe) then
11851185
apply_OBC_v = OBC%apply_OBC_v
1186-
endif ; endif
1186+
endif ; endif ; endif
11871187
ish = LB%ish ; ieh = LB%ieh ; jsh = LB%jsh ; jeh = LB%jeh ; nz = G%ke
11881188

11891189
CFL_dt = CS%CFL_limit_adjust / dt
@@ -2163,7 +2163,7 @@ subroutine continuity_PPM_init(Time, G, GV, param_file, diag, CS)
21632163
allocate(CS)
21642164

21652165
! Read all relevant parameters and write them to the model log.
2166-
call log_version(param_file, mod, version)
2166+
call log_version(param_file, mod, version, "")
21672167
call get_param(param_file, mod, "MONOTONIC_CONTINUITY", CS%monotonic, &
21682168
"If true, CONTINUITY_PPM uses the Colella and Woodward \n"//&
21692169
"monotonic limiter. The default (false) is to use a \n"//&

src/core/MOM_open_boundary.F90

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! This file is part of MOM6. See LICENSE.md for the license.
2-
!> Controls where open boundary conditions are applied
2+
!> Controls where open boundary conditions are applied
33
module MOM_open_boundary
44

55
! This file is part of MOM6. See LICENSE.md for the license.
@@ -11,6 +11,7 @@ module MOM_open_boundary
1111
use MOM_error_handler, only : MOM_mesg, MOM_error, FATAL, WARNING
1212
use MOM_file_parser, only : get_param, log_version, param_file_type, log_param
1313
use MOM_grid, only : ocean_grid_type
14+
use MOM_dyn_horgrid, only : dyn_horgrid_type
1415
use MOM_io, only : EAST_FACE, NORTH_FACE
1516
use MOM_io, only : slasher, read_data
1617
use MOM_tracer_registry, only : add_tracer_OBC_values, tracer_registry_type
@@ -100,6 +101,7 @@ module MOM_open_boundary
100101
real :: rx_max !< The maximum magnitude of the baroclinic radiation
101102
!! velocity (or speed of characteristics), in m s-1. The
102103
!! default value is 10 m s-1.
104+
logical :: this_pe !< Is there an open boundary on this tile?
103105
end type ocean_OBC_type
104106

105107
integer :: id_clock_pass
@@ -112,11 +114,9 @@ module MOM_open_boundary
112114

113115
!> Enables OBC module and reads configuration parameters
114116
subroutine open_boundary_config(G, param_file, OBC)
115-
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
117+
type(dyn_horgrid_type), intent(in) :: G !< Ocean grid structure
116118
type(param_file_type), intent(in) :: param_file !< Parameter file handle
117119
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
118-
! Local variables
119-
logical :: flather_east, flather_west, flather_north, flather_south
120120

121121
allocate(OBC)
122122

@@ -164,9 +164,9 @@ end subroutine open_boundary_config
164164

165165
!> Initialize open boundary control structure
166166
subroutine open_boundary_init(G, param_file, OBC)
167-
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
168-
type(param_file_type), intent(in) :: param_file !< Parameter file handle
169-
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
167+
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
168+
type(param_file_type), intent(in) :: param_file !< Parameter file handle
169+
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
170170
! Local variables
171171

172172
if (.not.associated(OBC)) return
@@ -244,7 +244,7 @@ end subroutine open_boundary_end
244244
!> Sets the slope of bathymetry normal to an open bounndary to zero.
245245
subroutine open_boundary_impose_normal_slope(OBC, G, depth)
246246
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
247-
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
247+
type(dyn_horgrid_type), intent(in) :: G !< Ocean grid structure
248248
real, dimension(SZI_(G),SZJ_(G)), intent(inout) :: depth !< Bathymetry at h-points
249249
! Local variables
250250
integer :: i, j
@@ -270,7 +270,7 @@ end subroutine open_boundary_impose_normal_slope
270270
!> Reconcile masks and open boundaries, deallocate OBC on PEs where it is not needed
271271
subroutine open_boundary_impose_land_mask(OBC, G)
272272
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
273-
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
273+
type(dyn_horgrid_type), intent(in) :: G !< Ocean grid structure
274274
! Local variables
275275
integer :: i, j
276276
logical :: any_U, any_V
@@ -306,22 +306,24 @@ subroutine open_boundary_impose_land_mask(OBC, G)
306306
! bathymetry inside the boundary was do shallow and flagged as land.
307307
if (OBC%OBC_mask_u(I,j)) any_U = .true.
308308
enddo ; enddo
309-
if (.not. any_U) then
310-
deallocate(OBC%OBC_mask_u)
311-
endif
309+
! if (.not. any_U) then
310+
! deallocate(OBC%OBC_mask_u)
311+
! endif
312312
endif
313313

314314
any_V = .false.
315315
if (associated(OBC%OBC_mask_v)) then
316316
do J=G%JsdB,G%JedB ; do i=G%isd,G%ied
317317
if (OBC%OBC_mask_v(i,J)) any_V = .true.
318318
enddo ; enddo
319-
if (.not. any_V) then
320-
deallocate(OBC%OBC_mask_v)
321-
endif
319+
! if (.not. any_V) then
320+
! deallocate(OBC%OBC_mask_v)
321+
! endif
322322
endif
323323

324-
if (.not.(any_U .or. any_V)) call open_boundary_dealloc(OBC)
324+
! if (.not.(any_U .or. any_V)) call open_boundary_dealloc(OBC)
325+
OBC%this_pe = .true.
326+
if (.not.(any_U .or. any_V)) OBC%this_pe = .false.
325327

326328
end subroutine open_boundary_impose_land_mask
327329

@@ -442,7 +444,7 @@ end subroutine Radiation_Open_Bdry_Conds
442444
!> Sets the domain boundaries as Flather open boundaries using the original
443445
!! Flather run-time logicals
444446
subroutine set_Flather_positions(G, OBC)
445-
type(ocean_grid_type), intent(inout) :: G
447+
type(dyn_horgrid_type), intent(inout) :: G
446448
type(ocean_OBC_type), pointer :: OBC
447449
! Local variables
448450
integer :: east_boundary, west_boundary, north_boundary, south_boundary
@@ -566,8 +568,6 @@ subroutine set_Flather_positions(G, OBC)
566568
enddo ; enddo
567569
endif
568570

569-
! If there are no OBC points on this PE, there is no reason to keep the OBC
570-
! type, and it could be deallocated.
571571
end subroutine set_Flather_positions
572572

573573
!> Sets the initial definitions of the characteristic open boundary conditions.
@@ -595,8 +595,8 @@ subroutine set_Flather_data(OBC, tv, h, G, PF, tracer_Reg)
595595
real, pointer, dimension(:,:,:) :: &
596596
OBC_T_u => NULL(), & ! These arrays should be allocated and set to
597597
OBC_T_v => NULL(), & ! specify the values of T and S that should come
598-
OBC_S_u => NULL(), &
599-
OBC_S_v => NULL()
598+
OBC_S_u => NULL(), &
599+
OBC_S_v => NULL()
600600

601601
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke
602602
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
@@ -639,7 +639,7 @@ subroutine set_Flather_data(OBC, tv, h, G, PF, tracer_Reg)
639639
if (.not.associated(OBC%eta_outer_v)) then
640640
allocate(OBC%eta_outer_v(isd:ied,JsdB:JedB)) ; OBC%eta_outer_v(:,:) = 0.0
641641
endif
642-
642+
643643
if (read_OBC_uv) then
644644
call read_data(filename, 'ubt', OBC%ubt_outer, &
645645
domain=G%Domain%mpp_domain, position=EAST_FACE)

0 commit comments

Comments
 (0)