Skip to content

Commit 52605fb

Browse files
committed
More tinkering with OBC_in vs CS%OBC
1 parent ba1d178 commit 52605fb

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

src/core/MOM.F90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,26 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, &
28832883
! reservoirs are used.
28842884
call open_boundary_register_restarts(HI, GV, US, CS%OBC, CS%tracer_Reg, &
28852885
param_file, restart_CSp, use_temperature)
2886+
if (turns /= 0) then
2887+
if (CS%OBC%radiation_BCs_exist_globally) then
2888+
OBC_in%rx_normal => CS%OBC%rx_normal
2889+
OBC_in%ry_normal => CS%OBC%ry_normal
2890+
endif
2891+
if (CS%OBC%oblique_BCs_exist_globally) then
2892+
OBC_in%rx_oblique_u => CS%OBC%rx_oblique_u
2893+
OBC_in%ry_oblique_u => CS%OBC%ry_oblique_u
2894+
OBC_in%rx_oblique_v => CS%OBC%rx_oblique_v
2895+
OBC_in%ry_oblique_v => CS%OBC%ry_oblique_v
2896+
OBC_in%cff_normal_u => CS%OBC%cff_normal_u
2897+
OBC_in%cff_normal_v => CS%OBC%cff_normal_v
2898+
endif
2899+
if (any(CS%OBC%tracer_x_reservoirs_used)) then
2900+
OBC_in%tres_x => CS%OBC%tres_x
2901+
endif
2902+
if (any(CS%OBC%tracer_y_reservoirs_used)) then
2903+
OBC_in%tres_y => CS%OBC%tres_y
2904+
endif
2905+
endif
28862906
endif
28872907

28882908
if (present(waves_CSp)) then

src/core/MOM_open_boundary.F90

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -352,24 +352,24 @@ module MOM_open_boundary
352352
type(remapping_CS), pointer :: remap_h_CS=> NULL() !< ALE remapping control structure for
353353
!! thickness-based fields on segments
354354
type(OBC_registry_type), pointer :: OBC_Reg => NULL() !< Registry type for boundaries
355-
real, allocatable :: rx_normal(:,:,:) !< Array storage for normal phase speed for EW radiation OBCs in units of
355+
real, pointer :: rx_normal(:,:,:) !< Array storage for normal phase speed for EW radiation OBCs in units of
356356
!! grid points per timestep [nondim]
357-
real, allocatable :: ry_normal(:,:,:) !< Array storage for normal phase speed for NS radiation OBCs in units of
357+
real, pointer :: ry_normal(:,:,:) !< Array storage for normal phase speed for NS radiation OBCs in units of
358358
!! grid points per timestep [nondim]
359-
real, allocatable :: rx_oblique_u(:,:,:) !< X-direction oblique boundary condition radiation speeds squared
359+
real, pointer :: rx_oblique_u(:,:,:) !< X-direction oblique boundary condition radiation speeds squared
360360
!! at u points for restarts [L2 T-2 ~> m2 s-2]
361-
real, allocatable :: ry_oblique_u(:,:,:) !< Y-direction oblique boundary condition radiation speeds squared
361+
real, pointer :: ry_oblique_u(:,:,:) !< Y-direction oblique boundary condition radiation speeds squared
362362
!! at u points for restarts [L2 T-2 ~> m2 s-2]
363-
real, allocatable :: rx_oblique_v(:,:,:) !< X-direction oblique boundary condition radiation speeds squared
363+
real, pointer :: rx_oblique_v(:,:,:) !< X-direction oblique boundary condition radiation speeds squared
364364
!! at v points for restarts [L2 T-2 ~> m2 s-2]
365-
real, allocatable :: ry_oblique_v(:,:,:) !< Y-direction oblique boundary condition radiation speeds squared
365+
real, pointer :: ry_oblique_v(:,:,:) !< Y-direction oblique boundary condition radiation speeds squared
366366
!! at v points for restarts [L2 T-2 ~> m2 s-2]
367-
real, allocatable :: cff_normal_u(:,:,:) !< Denominator for normalizing EW oblique boundary condition radiation
367+
real, pointer :: cff_normal_u(:,:,:) !< Denominator for normalizing EW oblique boundary condition radiation
368368
!! rates at u points for restarts [L2 T-2 ~> m2 s-2]
369-
real, allocatable :: cff_normal_v(:,:,:) !< Denominator for normalizing NS oblique boundary condition radiation
369+
real, pointer :: cff_normal_v(:,:,:) !< Denominator for normalizing NS oblique boundary condition radiation
370370
!! rates at v points for restarts [L2 T-2 ~> m2 s-2]
371-
real, allocatable :: tres_x(:,:,:,:) !< Array storage of tracer reservoirs for restarts, in unscaled units [conc]
372-
real, allocatable :: tres_y(:,:,:,:) !< Array storage of tracer reservoirs for restarts, in unscaled units [conc]
371+
real, pointer :: tres_x(:,:,:,:) !< Array storage of tracer reservoirs for restarts, in unscaled units [conc]
372+
real, pointer :: tres_y(:,:,:,:) !< Array storage of tracer reservoirs for restarts, in unscaled units [conc]
373373
logical :: debug !< If true, write verbose checksums for debugging purposes.
374374
real :: silly_h !< A silly value of thickness outside of the domain that can be used to test
375375
!! the independence of the OBCs to this external data [Z ~> m].
@@ -1948,15 +1948,15 @@ subroutine open_boundary_init(G, GV, US, param_file, OBC, restart_CS)
19481948
call create_group_pass(OBC%pass_oblique, OBC%cff_normal_u, OBC%cff_normal_v, G%Domain, To_All+Scalar_Pair)
19491949
call do_group_pass(OBC%pass_oblique, G%Domain)
19501950
endif
1951-
if (allocated(OBC%tres_x) .and. allocated(OBC%tres_y)) then
1951+
if (associated(OBC%tres_x) .and. associated(OBC%tres_y)) then
19521952
do m=1,OBC%ntr
19531953
call pass_vector(OBC%tres_x(:,:,:,m), OBC%tres_y(:,:,:,m), G%Domain, To_All+Scalar_Pair)
19541954
enddo
1955-
elseif (allocated(OBC%tres_x)) then
1955+
elseif (associated(OBC%tres_x)) then
19561956
do m=1,OBC%ntr
19571957
call pass_var(OBC%tres_x(:,:,:,m), G%Domain, position=EAST_FACE)
19581958
enddo
1959-
elseif (allocated(OBC%tres_y)) then
1959+
elseif (associated(OBC%tres_y)) then
19601960
do m=1,OBC%ntr
19611961
call pass_var(OBC%tres_y(:,:,:,m), G%Domain, position=NORTH_FACE)
19621962
enddo
@@ -2001,16 +2001,16 @@ subroutine open_boundary_dealloc(OBC)
20012001
if (allocated(OBC%segment)) deallocate(OBC%segment)
20022002
if (allocated(OBC%segnum_u)) deallocate(OBC%segnum_u)
20032003
if (allocated(OBC%segnum_v)) deallocate(OBC%segnum_v)
2004-
if (allocated(OBC%rx_normal)) deallocate(OBC%rx_normal)
2005-
if (allocated(OBC%ry_normal)) deallocate(OBC%ry_normal)
2006-
if (allocated(OBC%rx_oblique_u)) deallocate(OBC%rx_oblique_u)
2007-
if (allocated(OBC%ry_oblique_u)) deallocate(OBC%ry_oblique_u)
2008-
if (allocated(OBC%rx_oblique_v)) deallocate(OBC%rx_oblique_v)
2009-
if (allocated(OBC%ry_oblique_v)) deallocate(OBC%ry_oblique_v)
2010-
if (allocated(OBC%cff_normal_u)) deallocate(OBC%cff_normal_u)
2011-
if (allocated(OBC%cff_normal_v)) deallocate(OBC%cff_normal_v)
2012-
if (allocated(OBC%tres_x)) deallocate(OBC%tres_x)
2013-
if (allocated(OBC%tres_y)) deallocate(OBC%tres_y)
2004+
if (associated(OBC%rx_normal)) nullify(OBC%rx_normal)
2005+
if (associated(OBC%ry_normal)) nullify(OBC%ry_normal)
2006+
if (associated(OBC%rx_oblique_u)) nullify(OBC%rx_oblique_u)
2007+
if (associated(OBC%ry_oblique_u)) nullify(OBC%ry_oblique_u)
2008+
if (associated(OBC%rx_oblique_v)) nullify(OBC%rx_oblique_v)
2009+
if (associated(OBC%ry_oblique_v)) nullify(OBC%ry_oblique_v)
2010+
if (associated(OBC%cff_normal_u)) nullify(OBC%cff_normal_u)
2011+
if (associated(OBC%cff_normal_v)) nullify(OBC%cff_normal_v)
2012+
if (associated(OBC%tres_x)) nullify(OBC%tres_x)
2013+
if (associated(OBC%tres_y)) nullify(OBC%tres_y)
20142014
if (associated(OBC%remap_z_CS)) deallocate(OBC%remap_z_CS)
20152015
if (associated(OBC%remap_h_CS)) deallocate(OBC%remap_h_CS)
20162016
deallocate(OBC)
@@ -3369,7 +3369,7 @@ subroutine radiation_open_bdry_conds(OBC, u_new, u_old, v_new, v_old, G, GV, US,
33693369
haloshift=0, symmetric=sym, unscale=1.0/US%L_T_to_m_s**2)
33703370
endif
33713371
if (OBC%ntr == 0) return
3372-
if (.not. allocated (OBC%tres_x) .or. .not. allocated (OBC%tres_y)) return
3372+
if (.not. associated (OBC%tres_x) .or. .not. associated (OBC%tres_y)) return
33733373
do m=1,OBC%ntr
33743374
write(var_num,'(I3.3)') m
33753375
call uvchksum("radiation_OBCs: OBC%tres_[xy]_"//var_num, OBC%tres_x(:,:,:,m), OBC%tres_y(:,:,:,m), G%HI, &
@@ -5489,7 +5489,7 @@ subroutine update_segment_tracer_reservoirs(G, GV, uhr, vhr, h, OBC, dt, Reg)
54895489
((1.0-a_out+a_in)*segment%tr_Reg%Tr(m)%tres(I,j,k)+ &
54905490
((u_L_out+a_out)*Reg%Tr(ntr_id)%t(I+ishift,j,k) - &
54915491
(u_L_in+a_in)*segment%tr_Reg%Tr(m)%t(I,j,k)))
5492-
if (allocated(OBC%tres_x)) OBC%tres_x(I,j,k,m) = I_scale * segment%tr_Reg%Tr(m)%tres(I,j,k)
5492+
if (associated(OBC%tres_x)) OBC%tres_x(I,j,k,m) = I_scale * segment%tr_Reg%Tr(m)%tres(I,j,k)
54935493
enddo ; endif
54945494
enddo
54955495
enddo
@@ -5529,7 +5529,7 @@ subroutine update_segment_tracer_reservoirs(G, GV, uhr, vhr, h, OBC, dt, Reg)
55295529
((1.0-a_out+a_in)*segment%tr_Reg%Tr(m)%tres(i,J,k) + &
55305530
((v_L_out+a_out)*Reg%Tr(ntr_id)%t(i,J+jshift,k) - &
55315531
(v_L_in+a_in)*segment%tr_Reg%Tr(m)%t(i,J,k)))
5532-
if (allocated(OBC%tres_y)) OBC%tres_y(i,J,k,m) = I_scale * segment%tr_Reg%Tr(m)%tres(i,J,k)
5532+
if (associated(OBC%tres_y)) OBC%tres_y(i,J,k,m) = I_scale * segment%tr_Reg%Tr(m)%tres(i,J,k)
55335533
enddo ; endif
55345534
enddo
55355535
enddo
@@ -5605,7 +5605,7 @@ subroutine remap_OBC_fields(G, GV, h_old, h_new, OBC, PCM_cell)
56055605

56065606
! Update tracer concentrations
56075607
segment%tr_Reg%Tr(m)%tres(I,j,:) = tr_column(:)
5608-
if (allocated(OBC%tres_x)) then ; do k=1,nz
5608+
if (associated(OBC%tres_x)) then ; do k=1,nz
56095609
OBC%tres_x(I,j,k,m) = I_scale * segment%tr_Reg%Tr(m)%tres(I,j,k)
56105610
enddo ; endif
56115611

@@ -5672,7 +5672,7 @@ subroutine remap_OBC_fields(G, GV, h_old, h_new, OBC, PCM_cell)
56725672

56735673
! Update tracer concentrations
56745674
segment%tr_Reg%Tr(m)%tres(i,J,:) = tr_column(:)
5675-
if (allocated(OBC%tres_y)) then ; do k=1,nz
5675+
if (associated(OBC%tres_y)) then ; do k=1,nz
56765676
OBC%tres_y(i,J,k,m) = I_scale * segment%tr_Reg%Tr(m)%tres(i,J,k)
56775677
enddo ; endif
56785678

0 commit comments

Comments
 (0)