Skip to content

Commit 3a623f0

Browse files
committed
Fix ALE_sponge tendency diagnostic units
Corrected the units and conversion factor in init_ALE_sponge_diags for the various sp_tendency_... diagnostics. Previously they had only been correct for the tendencies of nondimensional quantities. The code also now stores the scaling factor that is set in set_up_ALE_sponge_field_fixed for later use in registering the sponge tendency diagnostics. Several instances of unusual spacing around semicolons in MOM_ALE_sponge were also standardized. The documented units and conversion factors for some diagnostics were corrected, but all solutions are bitwise identical.
1 parent 7ca5ed9 commit 3a623f0

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

src/parameterizations/vertical/MOM_ALE_sponge.F90

+30-22
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ subroutine initialize_ALE_sponge_fixed(Iresttime, G, GV, param_file, CS, data_h,
306306
call pass_var(data_dz, G%Domain, To_All+Omit_Corners, halo=1)
307307

308308
! u points
309-
CS%num_col_u = 0 ;
309+
CS%num_col_u = 0
310310
if (present(Iresttime_u_in)) then
311311
Iresttime_u(:,:) = Iresttime_u_in(:,:)
312312
else
@@ -350,15 +350,15 @@ subroutine initialize_ALE_sponge_fixed(Iresttime, G, GV, param_file, CS, data_h,
350350
"The total number of columns where sponges are applied at u points.", like_default=.true.)
351351

352352
! v points
353-
CS%num_col_v = 0 ;
353+
CS%num_col_v = 0
354354
if (present(Iresttime_v_in)) then
355355
Iresttime_v(:,:) = Iresttime_v_in(:,:)
356356
else
357-
do J=G%jscB,G%jecB; do i=G%isc,G%iec
357+
do J=G%jscB,G%jecB ; do i=G%isc,G%iec
358358
Iresttime_v(i,J) = 0.5 * (Iresttime(i,j) + Iresttime(i,j+1))
359359
enddo ; enddo
360360
endif
361-
do J=G%jscB,G%jecB; do i=G%isc,G%iec
361+
do J=G%jscB,G%jecB ; do i=G%isc,G%iec
362362
if ((Iresttime_v(i,J) > 0.0) .and. (G%mask2dCv(i,J) > 0.0)) &
363363
CS%num_col_v = CS%num_col_v + 1
364364
enddo ; enddo
@@ -594,8 +594,8 @@ subroutine initialize_ALE_sponge_varying(Iresttime, G, GV, US, param_file, CS, I
594594
Iresttime_u(I,j) = 0.5 * (Iresttime(i,j) + Iresttime(i+1,j))
595595
enddo ; enddo
596596
endif
597-
CS%num_col_u = 0 ;
598-
do j=G%jsc,G%jec; do I=G%iscB,G%iecB
597+
CS%num_col_u = 0
598+
do j=G%jsc,G%jec ; do I=G%iscB,G%iecB
599599
if ((Iresttime_u(I,j) > 0.0) .and. (G%mask2dCu(I,j) > 0.0)) &
600600
CS%num_col_u = CS%num_col_u + 1
601601
enddo ; enddo
@@ -622,12 +622,12 @@ subroutine initialize_ALE_sponge_varying(Iresttime, G, GV, US, param_file, CS, I
622622
if (present(Iresttime_v_in)) then
623623
Iresttime_v(:,:) = Iresttime_v_in(:,:)
624624
else
625-
do J=G%jscB,G%jecB; do i=G%isc,G%iec
625+
do J=G%jscB,G%jecB ; do i=G%isc,G%iec
626626
Iresttime_v(i,J) = 0.5 * (Iresttime(i,j) + Iresttime(i,j+1))
627627
enddo ; enddo
628628
endif
629-
CS%num_col_v = 0 ;
630-
do J=G%jscB,G%jecB; do i=G%isc,G%iec
629+
CS%num_col_v = 0
630+
do J=G%jscB,G%jecB ; do i=G%isc,G%iec
631631
if ((Iresttime_v(i,J) > 0.0) .and. (G%mask2dCv(i,J) > 0.0)) &
632632
CS%num_col_v = CS%num_col_v + 1
633633
enddo ; enddo
@@ -663,16 +663,23 @@ subroutine init_ALE_sponge_diags(Time, G, diag, CS, US)
663663
type(ALE_sponge_CS), intent(inout) :: CS !< ALE sponge control structure
664664
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
665665
! Local Variables
666+
character(len=:), allocatable :: tend_unit ! The units for a sponge tendency diagnostic.
667+
real :: tend_conv ! The conversion factor use for the sponge tendency [A T-1 ~> a s-1]
666668
integer :: m
667669

668670
CS%diag => diag
669671

670672
do m=1,CS%fldno
671673
CS%id_sp_tendency(m) = -1
672-
CS%id_sp_tendency(m) = register_diag_field('ocean_model', &
673-
'sp_tendency_' // CS%Ref_val(m)%name, diag%axesTL, Time, &
674-
'Time tendency due to restoring ' // CS%Ref_val(m)%long_name, &
675-
CS%Ref_val(m)%unit, conversion=US%s_to_T)
674+
if ((trim(CS%Ref_val(m)%unit) == 'none') .or. (len_trim(CS%Ref_val(m)%unit) == 0)) then
675+
tend_unit = "s-1"
676+
else
677+
tend_unit = trim(CS%Ref_val(m)%unit)//" s-1"
678+
endif
679+
tend_conv = US%s_to_T ; if (CS%Ref_val(m)%scale /= 0.0) tend_conv = US%s_to_T / CS%Ref_val(m)%scale
680+
CS%id_sp_tendency(m) = register_diag_field('ocean_model', 'sp_tendency_'//CS%Ref_val(m)%name, &
681+
diag%axesTL, Time, long_name='Time tendency due to restoring '//CS%Ref_val(m)%long_name, &
682+
units=tend_unit, conversion=tend_conv)
676683
enddo
677684

678685
CS%id_sp_u_tendency = -1
@@ -716,8 +723,8 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, &
716723
if (.not.associated(CS)) return
717724

718725
scale_fac = 1.0 ; if (present(scale)) scale_fac = scale
719-
long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name
720-
unit = 'none'; if (present(sp_unit)) unit = sp_unit
726+
long_name = sp_name ; if (present(sp_long_name)) long_name = sp_long_name
727+
unit = 'none' ; if (present(sp_unit)) unit = sp_unit
721728

722729
CS%fldno = CS%fldno + 1
723730
if (CS%fldno > MAX_FIELDS_) then
@@ -732,6 +739,7 @@ subroutine set_up_ALE_sponge_field_fixed(sp_val, G, GV, f_ptr, CS, &
732739
CS%Ref_val(CS%fldno)%name = sp_name
733740
CS%Ref_val(CS%fldno)%long_name = long_name
734741
CS%Ref_val(CS%fldno)%unit = unit
742+
CS%Ref_val(CS%fldno)%scale = scale_fac
735743
allocate(CS%Ref_val(CS%fldno)%p(CS%nz_data,CS%num_col), source=0.0)
736744
do col=1,CS%num_col
737745
do k=1,CS%nz_data
@@ -775,15 +783,15 @@ subroutine set_up_ALE_sponge_field_varying(filename, fieldname, Time, G, GV, US,
775783
character(len=256) :: mesg ! String for error messages
776784
character(len=256) :: long_name ! The long name of the tracer field
777785
character(len=256) :: unit ! The unit of the tracer field
778-
long_name = sp_name; if (present(sp_long_name)) long_name = sp_long_name
779-
unit = 'none'; if (present(sp_unit)) unit = sp_unit
786+
long_name = sp_name ; if (present(sp_long_name)) long_name = sp_long_name
787+
unit = 'none' ; if (present(sp_unit)) unit = sp_unit
780788

781789
! Local variables for ALE remapping
782790

783791
if (.not.associated(CS)) return
784792
! initialize time interpolator module
785793
call time_interp_external_init()
786-
isd = G%isd; ied = G%ied; jsd = G%jsd; jed = G%jed
794+
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
787795
CS%fldno = CS%fldno + 1
788796
if (CS%fldno > MAX_FIELDS_) then
789797
write(mesg, '("Increase MAX_FIELDS_ to at least ",I3," in MOM_memory.h or decrease "//&
@@ -888,8 +896,8 @@ subroutine set_up_ALE_sponge_vel_field_varying(filename_u, fieldname_u, filename
888896

889897
override =.true.
890898

891-
isd = G%isd; ied = G%ied; jsd = G%jsd; jed = G%jed
892-
isdB = G%isdB; iedB = G%iedB; jsdB = G%jsdB; jedB = G%jedB
899+
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
900+
isdB = G%isdB ; iedB = G%iedB ; jsdB = G%jsdB ; jedB = G%jedB
893901
! get a unique id for this field which will allow us to return an array
894902
! containing time-interpolated values from an external file corresponding
895903
! to the current model date.
@@ -1081,7 +1089,7 @@ subroutine apply_ALE_sponge(h, tv, dt, G, GV, US, CS, Time)
10811089
call pass_var(mask_z, G%Domain, To_All+Omit_Corners, halo=1)
10821090

10831091
allocate(mask_u(G%isdB:G%iedB,G%jsd:G%jed,1:nz_data))
1084-
do j=G%jsc,G%jec; do I=G%iscB,G%iecB
1092+
do j=G%jsc,G%jec ; do I=G%iscB,G%iecB
10851093
mask_u(I,j,1:nz_data) = min(mask_z(i,j,1:nz_data),mask_z(i+1,j,1:nz_data))
10861094
enddo ; enddo
10871095

@@ -1128,7 +1136,7 @@ subroutine apply_ALE_sponge(h, tv, dt, G, GV, US, CS, Time)
11281136
call pass_var(mask_z, G%Domain, To_All+Omit_Corners, halo=1)
11291137

11301138
allocate(mask_v(G%isd:G%ied,G%jsdB:G%jedB,1:nz_data))
1131-
do J=G%jscB,G%jecB; do i=G%isc,G%iec
1139+
do J=G%jscB,G%jecB ; do i=G%isc,G%iec
11321140
mask_v(i,J,1:nz_data) = min(mask_z(i,j,1:nz_data),mask_z(i,j+1,1:nz_data))
11331141
enddo ; enddo
11341142

0 commit comments

Comments
 (0)