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

Use allocate with source to initialize arrays #1499

Merged
merged 2 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/ALE/MOM_regridding.F90
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ subroutine initialize_regridding(CS, GV, US, max_depth, param_file, mdl, coord_m
CS%nk=ke

! Target resolution (for fixed coordinates)
allocate( CS%coordinateResolution(CS%nk) ); CS%coordinateResolution(:) = -1.E30
allocate( CS%coordinateResolution(CS%nk), source=-1.E30 )
if (state_dependent(CS%regridding_scheme)) then
! Target values
allocate( CS%target_density(CS%nk+1) ); CS%target_density(:) = -1.E30*US%kg_m3_to_R
allocate( CS%target_density(CS%nk+1), source=-1.E30*US%kg_m3_to_R )
endif

if (allocated(dz)) then
Expand Down
50 changes: 17 additions & 33 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2233,16 +2233,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
endif
endif

if (use_frazil) then
allocate(CS%tv%frazil(isd:ied,jsd:jed)) ; CS%tv%frazil(:,:) = 0.0
endif
if (bound_salinity) then
allocate(CS%tv%salt_deficit(isd:ied,jsd:jed)) ; CS%tv%salt_deficit(:,:) = 0.0
endif
if (use_frazil) allocate(CS%tv%frazil(isd:ied,jsd:jed), source=0.0)
if (bound_salinity) allocate(CS%tv%salt_deficit(isd:ied,jsd:jed), source=0.0)

if (bulkmixedlayer .or. use_temperature) then
allocate(CS%Hml(isd:ied,jsd:jed)) ; CS%Hml(:,:) = 0.0
endif
if (bulkmixedlayer .or. use_temperature) allocate(CS%Hml(isd:ied,jsd:jed), source=0.0)

if (bulkmixedlayer) then
GV%nkml = nkml ; GV%nk_rho_varies = nkml + nkbl
Expand All @@ -2258,8 +2252,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
CS%t_dyn_rel_adv = 0.0 ; CS%t_dyn_rel_thermo = 0.0 ; CS%t_dyn_rel_diag = 0.0

if (debug_truncations) then
allocate(CS%u_prev(IsdB:IedB,jsd:jed,nz)) ; CS%u_prev(:,:,:) = 0.0
allocate(CS%v_prev(isd:ied,JsdB:JedB,nz)) ; CS%v_prev(:,:,:) = 0.0
allocate(CS%u_prev(IsdB:IedB,jsd:jed,nz), source=0.0)
allocate(CS%v_prev(isd:ied,JsdB:JedB,nz), source=0.0)
MOM_internal_state%u_prev => CS%u_prev
MOM_internal_state%v_prev => CS%v_prev
call safe_alloc_ptr(CS%ADp%du_dt_visc,IsdB,IedB,jsd,jed,nz)
Expand All @@ -2279,9 +2273,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &

CS%CDp%uh => CS%uh ; CS%CDp%vh => CS%vh

if (CS%interp_p_surf) then
allocate(CS%p_surf_prev(isd:ied,jsd:jed)) ; CS%p_surf_prev(:,:) = 0.0
endif
if (CS%interp_p_surf) allocate(CS%p_surf_prev(isd:ied,jsd:jed), source=0.0)

ALLOC_(CS%ssh_rint(isd:ied,jsd:jed)) ; CS%ssh_rint(:,:) = 0.0
ALLOC_(CS%ave_ssh_ibc(isd:ied,jsd:jed)) ; CS%ave_ssh_ibc(:,:) = 0.0
Expand All @@ -2293,9 +2285,9 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
! initialization routine for tv.
if (use_EOS) call EOS_init(param_file, CS%tv%eqn_of_state, US)
if (use_temperature) then
allocate(CS%tv%TempxPmE(isd:ied,jsd:jed)) ; CS%tv%TempxPmE(:,:) = 0.0
allocate(CS%tv%TempxPmE(isd:ied,jsd:jed), source=0.0)
if (use_geothermal) then
allocate(CS%tv%internal_heat(isd:ied,jsd:jed)) ; CS%tv%internal_heat(:,:) = 0.0
allocate(CS%tv%internal_heat(isd:ied,jsd:jed), source=0.0)
endif
endif
call callTree_waypoint("state variables allocated (initialize_MOM)")
Expand Down Expand Up @@ -2406,18 +2398,13 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
if (CS%rotate_index) then
G_in%ke = GV%ke

allocate(u_in(G_in%IsdB:G_in%IedB, G_in%jsd:G_in%jed, nz))
allocate(v_in(G_in%isd:G_in%ied, G_in%JsdB:G_in%JedB, nz))
allocate(h_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed, nz))
u_in(:,:,:) = 0.0
v_in(:,:,:) = 0.0
h_in(:,:,:) = GV%Angstrom_H
allocate(u_in(G_in%IsdB:G_in%IedB, G_in%jsd:G_in%jed, nz), source=0.0)
allocate(v_in(G_in%isd:G_in%ied, G_in%JsdB:G_in%JedB, nz), source=0.0)
allocate(h_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed, nz), source=GV%Angstrom_H)

if (use_temperature) then
allocate(T_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed, nz))
allocate(S_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed, nz))
T_in(:,:,:) = 0.0
S_in(:,:,:) = 0.0
allocate(T_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed, nz), source=0.0)
allocate(S_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed, nz), source=0.0)

CS%tv%T => T_in
CS%tv%S => S_in
Expand All @@ -2428,10 +2415,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
! when using an ice shelf. Passing the ice shelf diagnostics CS from MOM
! for legacy reasons. The actual ice shelf diag CS is internal to the ice shelf
call initialize_ice_shelf(param_file, G_in, Time, ice_shelf_CSp, diag_ptr)
allocate(frac_shelf_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed))
frac_shelf_in(:,:) = 0.0
allocate(CS%frac_shelf_h(isd:ied, jsd:jed))
CS%frac_shelf_h(:,:) = 0.0
allocate(frac_shelf_in(G_in%isd:G_in%ied, G_in%jsd:G_in%jed), source=0.0)
allocate(CS%frac_shelf_h(isd:ied, jsd:jed), source=0.0)
call ice_shelf_query(ice_shelf_CSp,G,CS%frac_shelf_h)
! MOM_initialize_state is using the unrotated metric
call rotate_array(CS%frac_shelf_h, -turns, frac_shelf_in)
Expand Down Expand Up @@ -2479,8 +2464,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
else
if (use_ice_shelf) then
call initialize_ice_shelf(param_file, G, Time, ice_shelf_CSp, diag_ptr)
allocate(CS%frac_shelf_h(isd:ied, jsd:jed))
CS%frac_shelf_h(:,:) = 0.0
allocate(CS%frac_shelf_h(isd:ied, jsd:jed), source=0.0)
call ice_shelf_query(ice_shelf_CSp,G,CS%frac_shelf_h)
call MOM_initialize_state(CS%u, CS%v, CS%h, CS%tv, Time, G, GV, US, &
param_file, dirs, restart_CSp, CS%ALE_CSp, CS%tracer_Reg, &
Expand Down Expand Up @@ -2617,7 +2601,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
call thickness_diffuse_init(Time, G, GV, US, param_file, diag, CS%CDp, CS%thickness_diffuse_CSp)

if (CS%split) then
allocate(eta(SZI_(G),SZJ_(G))) ; eta(:,:) = 0.0
allocate(eta(SZI_(G),SZJ_(G)), source=0.0)
call initialize_dyn_split_RK2(CS%u, CS%v, CS%h, CS%uh, CS%vh, eta, Time, &
G, GV, US, param_file, diag, CS%dyn_split_RK2_CSp, restart_CSp, &
CS%dt, CS%ADp, CS%CDp, MOM_internal_state, CS%VarMix, CS%MEKE, &
Expand Down
24 changes: 12 additions & 12 deletions src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3092,17 +3092,17 @@ subroutine set_up_BT_OBC(OBC, eta, BT_OBC, BT_Domain, G, GV, US, MS, halo, use_B
endif

if (.not. BT_OBC%is_alloced) then
allocate(BT_OBC%Cg_u(isdw-1:iedw,jsdw:jedw)) ; BT_OBC%Cg_u(:,:) = 0.0
allocate(BT_OBC%H_u(isdw-1:iedw,jsdw:jedw)) ; BT_OBC%H_u(:,:) = 0.0
allocate(BT_OBC%uhbt(isdw-1:iedw,jsdw:jedw)) ; BT_OBC%uhbt(:,:) = 0.0
allocate(BT_OBC%ubt_outer(isdw-1:iedw,jsdw:jedw)) ; BT_OBC%ubt_outer(:,:) = 0.0
allocate(BT_OBC%eta_outer_u(isdw-1:iedw,jsdw:jedw)) ; BT_OBC%eta_outer_u(:,:) = 0.0

allocate(BT_OBC%Cg_v(isdw:iedw,jsdw-1:jedw)) ; BT_OBC%Cg_v(:,:) = 0.0
allocate(BT_OBC%H_v(isdw:iedw,jsdw-1:jedw)) ; BT_OBC%H_v(:,:) = 0.0
allocate(BT_OBC%vhbt(isdw:iedw,jsdw-1:jedw)) ; BT_OBC%vhbt(:,:) = 0.0
allocate(BT_OBC%vbt_outer(isdw:iedw,jsdw-1:jedw)) ; BT_OBC%vbt_outer(:,:) = 0.0
allocate(BT_OBC%eta_outer_v(isdw:iedw,jsdw-1:jedw)) ; BT_OBC%eta_outer_v(:,:)=0.0
allocate(BT_OBC%Cg_u(isdw-1:iedw,jsdw:jedw), source=0.0)
allocate(BT_OBC%H_u(isdw-1:iedw,jsdw:jedw), source=0.0)
allocate(BT_OBC%uhbt(isdw-1:iedw,jsdw:jedw), source=0.0)
allocate(BT_OBC%ubt_outer(isdw-1:iedw,jsdw:jedw), source=0.0)
allocate(BT_OBC%eta_outer_u(isdw-1:iedw,jsdw:jedw), source=0.0)

allocate(BT_OBC%Cg_v(isdw:iedw,jsdw-1:jedw), source=0.0)
allocate(BT_OBC%H_v(isdw:iedw,jsdw-1:jedw), source=0.0)
allocate(BT_OBC%vhbt(isdw:iedw,jsdw-1:jedw), source=0.0)
allocate(BT_OBC%vbt_outer(isdw:iedw,jsdw-1:jedw), source=0.0)
allocate(BT_OBC%eta_outer_v(isdw:iedw,jsdw-1:jedw), source=0.0)
BT_OBC%is_alloced = .true.
call create_group_pass(BT_OBC%pass_uv, BT_OBC%ubt_outer, BT_OBC%vbt_outer, BT_Domain)
call create_group_pass(BT_OBC%pass_uhvh, BT_OBC%uhbt, BT_OBC%vhbt, BT_Domain)
Expand Down Expand Up @@ -4743,7 +4743,7 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
wave_drag_file = trim(slasher(inputdir))//trim(wave_drag_file)
call log_param(param_file, mdl, "INPUTDIR/BT_WAVE_DRAG_FILE", wave_drag_file)

allocate(lin_drag_h(isd:ied,jsd:jed)) ; lin_drag_h(:,:) = 0.0
allocate(lin_drag_h(isd:ied,jsd:jed), source=0.0)

call MOM_read_data(wave_drag_file, wave_drag_var, lin_drag_h, G%Domain, scale=US%m_to_Z*US%T_to_s)
call pass_var(lin_drag_h, G%Domain)
Expand Down
58 changes: 20 additions & 38 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -946,17 +946,15 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_hf_PFu_2d > 0) then
allocate(hf_PFu_2d(G%IsdB:G%IedB,G%jsd:G%jed))
hf_PFu_2d(:,:) = 0.0
allocate(hf_PFu_2d(G%IsdB:G%IedB,G%jsd:G%jed), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
hf_PFu_2d(I,j) = hf_PFu_2d(I,j) + CS%PFu(I,j,k) * CS%ADp%diag_hfrac_u(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_hf_PFu_2d, hf_PFu_2d, CS%diag)
deallocate(hf_PFu_2d)
endif
if (CS%id_hf_PFv_2d > 0) then
allocate(hf_PFv_2d(G%isd:G%ied,G%JsdB:G%JedB))
hf_PFv_2d(:,:) = 0.0
allocate(hf_PFv_2d(G%isd:G%ied,G%JsdB:G%JedB), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
hf_PFv_2d(i,J) = hf_PFv_2d(i,J) + CS%PFv(i,J,k) * CS%ADp%diag_hfrac_v(i,J,k)
enddo ; enddo ; enddo
Expand All @@ -965,17 +963,15 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_h_PFu > 0) then
allocate(h_PFu(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke))
h_PFu(:,:,:) = 0.0
allocate(h_PFu(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
h_PFu(I,j,k) = CS%PFu(I,j,k) * CS%ADp%diag_hu(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_h_PFu, h_PFu, CS%diag)
deallocate(h_PFu)
endif
if (CS%id_h_PFv > 0) then
allocate(h_PFv(G%isd:G%ied,G%JsdB:G%JedB,GV%ke))
h_PFv(:,:,:) = 0.0
allocate(h_PFv(G%isd:G%ied,G%JsdB:G%JedB,GV%ke), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
h_PFv(i,J,k) = CS%PFv(i,J,k) * CS%ADp%diag_hv(i,J,k)
enddo ; enddo ; enddo
Expand Down Expand Up @@ -1013,17 +1009,15 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_hf_CAu_2d > 0) then
allocate(hf_CAu_2d(G%IsdB:G%IedB,G%jsd:G%jed))
hf_CAu_2d(:,:) = 0.0
allocate(hf_CAu_2d(G%IsdB:G%IedB,G%jsd:G%jed), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
hf_CAu_2d(I,j) = hf_CAu_2d(I,j) + CS%CAu(I,j,k) * CS%ADp%diag_hfrac_u(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_hf_CAu_2d, hf_CAu_2d, CS%diag)
deallocate(hf_CAu_2d)
endif
if (CS%id_hf_CAv_2d > 0) then
allocate(hf_CAv_2d(G%isd:G%ied,G%JsdB:G%JedB))
hf_CAv_2d(:,:) = 0.0
allocate(hf_CAv_2d(G%isd:G%ied,G%JsdB:G%JedB), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
hf_CAv_2d(i,J) = hf_CAv_2d(i,J) + CS%CAv(i,J,k) * CS%ADp%diag_hfrac_v(i,J,k)
enddo ; enddo ; enddo
Expand All @@ -1032,17 +1026,15 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_h_CAu > 0) then
allocate(h_CAu(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke))
h_CAu(:,:,:) = 0.0
allocate(h_CAu(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
h_CAu(I,j,k) = CS%CAu(I,j,k) * CS%ADp%diag_hu(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_h_CAu, h_CAu, CS%diag)
deallocate(h_CAu)
endif
if (CS%id_h_CAv > 0) then
allocate(h_CAv(G%isd:G%ied,G%JsdB:G%JedB,GV%ke))
h_CAv(:,:,:) = 0.0
allocate(h_CAv(G%isd:G%ied,G%JsdB:G%JedB,GV%ke), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
h_CAv(i,J,k) = CS%CAv(i,J,k) * CS%ADp%diag_hv(i,J,k)
enddo ; enddo ; enddo
Expand Down Expand Up @@ -1080,17 +1072,15 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_hf_u_BT_accel_2d > 0) then
allocate(hf_u_BT_accel_2d(G%IsdB:G%IedB,G%jsd:G%jed))
hf_u_BT_accel_2d(:,:) = 0.0
allocate(hf_u_BT_accel_2d(G%IsdB:G%IedB,G%jsd:G%jed), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
hf_u_BT_accel_2d(I,j) = hf_u_BT_accel_2d(I,j) + CS%u_accel_bt(I,j,k) * CS%ADp%diag_hfrac_u(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_hf_u_BT_accel_2d, hf_u_BT_accel_2d, CS%diag)
deallocate(hf_u_BT_accel_2d)
endif
if (CS%id_hf_v_BT_accel_2d > 0) then
allocate(hf_v_BT_accel_2d(G%isd:G%ied,G%JsdB:G%JedB))
hf_v_BT_accel_2d(:,:) = 0.0
allocate(hf_v_BT_accel_2d(G%isd:G%ied,G%JsdB:G%JedB), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
hf_v_BT_accel_2d(i,J) = hf_v_BT_accel_2d(i,J) + CS%v_accel_bt(i,J,k) * CS%ADp%diag_hfrac_v(i,J,k)
enddo ; enddo ; enddo
Expand All @@ -1099,17 +1089,15 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_h_u_BT_accel > 0) then
allocate(h_u_BT_accel(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke))
h_u_BT_accel(:,:,:) = 0.0
allocate(h_u_BT_accel(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
h_u_BT_accel(I,j,k) = CS%u_accel_bt(I,j,k) * CS%ADp%diag_hu(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_h_u_BT_accel, h_u_BT_accel, CS%diag)
deallocate(h_u_BT_accel)
endif
if (CS%id_h_v_BT_accel > 0) then
allocate(h_v_BT_accel(G%isd:G%ied,G%JsdB:G%JedB,GV%ke))
h_v_BT_accel(:,:,:) = 0.0
allocate(h_v_BT_accel(G%isd:G%ied,G%JsdB:G%JedB,GV%ke), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
h_v_BT_accel(i,J,k) = CS%v_accel_bt(i,J,k) * CS%ADp%diag_hv(i,J,k)
enddo ; enddo ; enddo
Expand All @@ -1118,53 +1106,47 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, Time_local, dt, forces, p_s
endif

if (CS%id_PFu_visc_rem > 0) then
allocate(PFu_visc_rem(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke))
PFu_visc_rem(:,:,:) = 0.0
allocate(PFu_visc_rem(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
PFu_visc_rem(I,j,k) = CS%PFu(I,j,k) * CS%ADp%visc_rem_u(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_PFu_visc_rem, PFu_visc_rem, CS%diag)
deallocate(PFu_visc_rem)
endif
if (CS%id_PFv_visc_rem > 0) then
allocate(PFv_visc_rem(G%isd:G%ied,G%JsdB:G%JedB,GV%ke))
PFv_visc_rem(:,:,:) = 0.0
allocate(PFv_visc_rem(G%isd:G%ied,G%JsdB:G%JedB,GV%ke), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
PFv_visc_rem(i,J,k) = CS%PFv(i,J,k) * CS%ADp%visc_rem_v(i,J,k)
enddo ; enddo ; enddo
call post_data(CS%id_PFv_visc_rem, PFv_visc_rem, CS%diag)
deallocate(PFv_visc_rem)
endif
if (CS%id_CAu_visc_rem > 0) then
allocate(CAu_visc_rem(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke))
CAu_visc_rem(:,:,:) = 0.0
allocate(CAu_visc_rem(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
CAu_visc_rem(I,j,k) = CS%CAu(I,j,k) * CS%ADp%visc_rem_u(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_CAu_visc_rem, CAu_visc_rem, CS%diag)
deallocate(CAu_visc_rem)
endif
if (CS%id_CAv_visc_rem > 0) then
allocate(CAv_visc_rem(G%isd:G%ied,G%JsdB:G%JedB,GV%ke))
CAv_visc_rem(:,:,:) = 0.0
allocate(CAv_visc_rem(G%isd:G%ied,G%JsdB:G%JedB,GV%ke), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
CAv_visc_rem(i,J,k) = CS%CAv(i,J,k) * CS%ADp%visc_rem_v(i,J,k)
enddo ; enddo ; enddo
call post_data(CS%id_CAv_visc_rem, CAv_visc_rem, CS%diag)
deallocate(CAv_visc_rem)
endif
if (CS%id_u_BT_accel_visc_rem > 0) then
allocate(u_BT_accel_visc_rem(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke))
u_BT_accel_visc_rem(:,:,:) = 0.0
allocate(u_BT_accel_visc_rem(G%IsdB:G%IedB,G%jsd:G%jed,GV%ke), source=0.0)
do k=1,nz ; do j=js,je ; do I=Isq,Ieq
u_BT_accel_visc_rem(I,j,k) = CS%u_accel_bt(I,j,k) * CS%ADp%visc_rem_u(I,j,k)
enddo ; enddo ; enddo
call post_data(CS%id_u_BT_accel_visc_rem, u_BT_accel_visc_rem, CS%diag)
deallocate(u_BT_accel_visc_rem)
endif
if (CS%id_v_BT_accel_visc_rem > 0) then
allocate(v_BT_accel_visc_rem(G%isd:G%ied,G%JsdB:G%JedB,GV%ke))
v_BT_accel_visc_rem(:,:,:) = 0.0
allocate(v_BT_accel_visc_rem(G%isd:G%ied,G%JsdB:G%JedB,GV%ke), source=0.0)
do k=1,nz ; do J=Jsq,Jeq ; do i=is,ie
v_BT_accel_visc_rem(i,J,k) = CS%v_accel_bt(i,J,k) * CS%ADp%visc_rem_v(i,J,k)
enddo ; enddo ; enddo
Expand Down Expand Up @@ -1375,8 +1357,8 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, US, param
call get_param(param_file, mdl, "DEBUG_TRUNCATIONS", debug_truncations, &
default=.false.)

allocate(CS%taux_bot(IsdB:IedB,jsd:jed)) ; CS%taux_bot(:,:) = 0.0
allocate(CS%tauy_bot(isd:ied,JsdB:JedB)) ; CS%tauy_bot(:,:) = 0.0
allocate(CS%taux_bot(IsdB:IedB,jsd:jed), source=0.0)
allocate(CS%tauy_bot(isd:ied,JsdB:JedB), source=0.0)

ALLOC_(CS%uhbt(IsdB:IedB,jsd:jed)) ; CS%uhbt(:,:) = 0.0
ALLOC_(CS%vhbt(isd:ied,JsdB:JedB)) ; CS%vhbt(:,:) = 0.0
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_unsplit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ subroutine initialize_dyn_unsplit(u, v, h, Time, G, GV, US, param_file, diag, CS
call get_param(param_file, mdl, "TIDES", use_tides, &
"If true, apply tidal momentum forcing.", default=.false.)

allocate(CS%taux_bot(IsdB:IedB,jsd:jed)) ; CS%taux_bot(:,:) = 0.0
allocate(CS%tauy_bot(isd:ied,JsdB:JedB)) ; CS%tauy_bot(:,:) = 0.0
allocate(CS%taux_bot(IsdB:IedB,jsd:jed), source=0.0)
allocate(CS%tauy_bot(isd:ied,JsdB:JedB), source=0.0)

MIS%diffu => CS%diffu ; MIS%diffv => CS%diffv
MIS%PFu => CS%PFu ; MIS%PFv => CS%PFv
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_unsplit_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ subroutine initialize_dyn_unsplit_RK2(u, v, h, Time, G, GV, US, param_file, diag
call get_param(param_file, mdl, "TIDES", use_tides, &
"If true, apply tidal momentum forcing.", default=.false.)

allocate(CS%taux_bot(IsdB:IedB,jsd:jed)) ; CS%taux_bot(:,:) = 0.0
allocate(CS%tauy_bot(isd:ied,JsdB:JedB)) ; CS%tauy_bot(:,:) = 0.0
allocate(CS%taux_bot(IsdB:IedB,jsd:jed), source=0.0)
allocate(CS%tauy_bot(isd:ied,JsdB:JedB), source=0.0)

MIS%diffu => CS%diffu ; MIS%diffv => CS%diffv
MIS%PFu => CS%PFu ; MIS%PFv => CS%PFv
Expand Down
8 changes: 4 additions & 4 deletions src/core/MOM_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,10 @@ subroutine allocate_metrics(G)
ALLOC_(G%sin_rot(isd:ied,jsd:jed)) ; G%sin_rot(:,:) = 0.0
ALLOC_(G%cos_rot(isd:ied,jsd:jed)) ; G%cos_rot(:,:) = 1.0

allocate(G%gridLonT(isg:ieg)) ; G%gridLonT(:) = 0.0
allocate(G%gridLonB(G%IsgB:G%IegB)) ; G%gridLonB(:) = 0.0
allocate(G%gridLatT(jsg:jeg)) ; G%gridLatT(:) = 0.0
allocate(G%gridLatB(G%JsgB:G%JegB)) ; G%gridLatB(:) = 0.0
allocate(G%gridLonT(isg:ieg), source=0.0)
allocate(G%gridLonB(G%IsgB:G%IegB), source=0.0)
allocate(G%gridLatT(jsg:jeg), source=0.0)
allocate(G%gridLatB(G%JsgB:G%JegB), source=0.0)

end subroutine allocate_metrics

Expand Down
Loading