@@ -820,9 +820,11 @@ subroutine horizontally_average_field(G, GV, isdf, jsdf, h, staggered_in_x, stag
820
820
logical , dimension (:), intent (out ) :: averaged_mask ! < Mask for horizontally averaged field [nondim]
821
821
822
822
! Local variables
823
- real :: volume(G% isc:G% iec, G% jsc:G% jec, size (field,3 )) ! The area [m2], volume [m3] or mass [kg] of each cell.
823
+ real :: volume(G% isc:G% iec, G% jsc:G% jec, size (field,3 )) ! The area [L2 ~> m2], volume [L2 m ~> m3]
824
+ ! or mass [L2 kg m-2 ~> kg] of each cell.
824
825
real :: stuff(G% isc:G% iec, G% jsc:G% jec, size (field,3 )) ! The area, volume or mass-weighted integral of the
825
- ! field being averaged in each cell, in [m2 A], [m3 A] or [kg A],
826
+ ! field being averaged in each cell, in [L2 a ~> m2 A],
827
+ ! [L2 m a ~> m3 A] or [L2 kg m-2 A ~> kg A],
826
828
! depending on the weighting for the averages and whether the
827
829
! model makes the Boussinesq approximation.
828
830
real , dimension (size (field, 3 )) :: vol_sum ! The global sum of the areas [m2], volumes [m3] or mass [kg]
@@ -847,22 +849,21 @@ subroutine horizontally_average_field(G, GV, isdf, jsdf, h, staggered_in_x, stag
847
849
stuff_sum(k) = 0 .
848
850
if (is_extensive) then
849
851
do j= G% jsc, G% jec ; do I= G% isc, G% iec
850
- volume(I,j,k) = (G % US % L_to_m ** 2 * G % areaCu(I,j) ) * G% mask2dCu(I,j)
852
+ volume(I,j,k) = G % areaCu(I,j) * G% mask2dCu(I,j)
851
853
stuff(I,j,k) = volume(I,j,k) * field(I,j,k)
852
854
enddo ; enddo
853
855
else ! Intensive
854
856
do j= G% jsc, G% jec ; do I= G% isc, G% iec
855
857
height = 0.5 * (h(i,j,k) + h(i+1 ,j,k))
856
- volume(I,j,k) = (G% US% L_to_m** 2 * G% areaCu(I,j)) &
857
- * (GV% H_to_MKS * height) * G% mask2dCu(I,j)
858
+ volume(I,j,k) = G% areaCu(I,j) * (GV% H_to_MKS * height) * G% mask2dCu(I,j)
858
859
stuff(I,j,k) = volume(I,j,k) * field(I,j,k)
859
860
enddo ; enddo
860
861
endif
861
862
enddo
862
863
else ! Interface
863
864
do k= 1 ,nz
864
865
do j= G% jsc, G% jec ; do I= G% isc, G% iec
865
- volume(I,j,k) = (G % US % L_to_m ** 2 * G % areaCu(I,j) ) * G% mask2dCu(I,j)
866
+ volume(I,j,k) = G % areaCu(I,j) * G% mask2dCu(I,j)
866
867
stuff(I,j,k) = volume(I,j,k) * field(I,j,k)
867
868
enddo ; enddo
868
869
enddo
@@ -873,22 +874,21 @@ subroutine horizontally_average_field(G, GV, isdf, jsdf, h, staggered_in_x, stag
873
874
do k= 1 ,nz
874
875
if (is_extensive) then
875
876
do J= G% jsc, G% jec ; do i= G% isc, G% iec
876
- volume(i,J,k) = (G % US % L_to_m ** 2 * G % areaCv(i,J) ) * G% mask2dCv(i,J)
877
+ volume(i,J,k) = G % areaCv(i,J) * G% mask2dCv(i,J)
877
878
stuff(i,J,k) = volume(i,J,k) * field(i,J,k)
878
879
enddo ; enddo
879
880
else ! Intensive
880
881
do J= G% jsc, G% jec ; do i= G% isc, G% iec
881
882
height = 0.5 * (h(i,j,k) + h(i,j+1 ,k))
882
- volume(i,J,k) = (G% US% L_to_m** 2 * G% areaCv(i,J)) &
883
- * (GV% H_to_MKS * height) * G% mask2dCv(i,J)
883
+ volume(i,J,k) = G% areaCv(i,J) * (GV% H_to_MKS * height) * G% mask2dCv(i,J)
884
884
stuff(i,J,k) = volume(i,J,k) * field(i,J,k)
885
885
enddo ; enddo
886
886
endif
887
887
enddo
888
888
else ! Interface
889
889
do k= 1 ,nz
890
890
do J= G% jsc, G% jec ; do i= G% isc, G% iec
891
- volume(i,J,k) = (G % US % L_to_m ** 2 * G % areaCv(i,J) ) * G% mask2dCv(i,J)
891
+ volume(i,J,k) = G % areaCv(i,J) * G% mask2dCv(i,J)
892
892
stuff(i,J,k) = volume(i,J,k) * field(i,J,k)
893
893
enddo ; enddo
894
894
enddo
@@ -900,7 +900,7 @@ subroutine horizontally_average_field(G, GV, isdf, jsdf, h, staggered_in_x, stag
900
900
if (is_extensive) then
901
901
do j= G% jsc, G% jec ; do i= G% isc, G% iec
902
902
if (h(i,j,k) > 0 .) then
903
- volume(i,j,k) = (G % US % L_to_m ** 2 * G % areaT(i,j) ) * G% mask2dT(i,j)
903
+ volume(i,j,k) = G % areaT(i,j) * G% mask2dT(i,j)
904
904
stuff(i,j,k) = volume(i,j,k) * field(i,j,k)
905
905
else
906
906
volume(i,j,k) = 0 .
@@ -909,16 +909,15 @@ subroutine horizontally_average_field(G, GV, isdf, jsdf, h, staggered_in_x, stag
909
909
enddo ; enddo
910
910
else ! Intensive
911
911
do j= G% jsc, G% jec ; do i= G% isc, G% iec
912
- volume(i,j,k) = (G% US% L_to_m** 2 * G% areaT(i,j)) &
913
- * (GV% H_to_MKS * h(i,j,k)) * G% mask2dT(i,j)
912
+ volume(i,j,k) = G% areaT(i,j) * (GV% H_to_MKS * h(i,j,k)) * G% mask2dT(i,j)
914
913
stuff(i,j,k) = volume(i,j,k) * field(i,j,k)
915
914
enddo ; enddo
916
915
endif
917
916
enddo
918
917
else ! Interface
919
918
do k= 1 ,nz
920
919
do j= G% jsc, G% jec ; do i= G% isc, G% iec
921
- volume(i,j,k) = (G % US % L_to_m ** 2 * G % areaT(i,j) ) * G% mask2dT(i,j)
920
+ volume(i,j,k) = G % areaT(i,j) * G% mask2dT(i,j)
922
921
stuff(i,j,k) = volume(i,j,k) * field(i,j,k)
923
922
enddo ; enddo
924
923
enddo
@@ -930,8 +929,8 @@ subroutine horizontally_average_field(G, GV, isdf, jsdf, h, staggered_in_x, stag
930
929
! Packing the sums into a single array with a single call to sum across PEs saves reduces
931
930
! the costs of communication.
932
931
do k= 1 ,nz
933
- sums_EFP(2 * k-1 ) = reproducing_sum_EFP(volume(:,:,k), only_on_PE= .true. )
934
- sums_EFP(2 * k) = reproducing_sum_EFP(stuff(:,:,k), only_on_PE= .true. )
932
+ sums_EFP(2 * k-1 ) = reproducing_sum_EFP(volume(:,:,k), only_on_PE= .true. , unscale = G % US % L_to_m ** 2 )
933
+ sums_EFP(2 * k) = reproducing_sum_EFP(stuff(:,:,k), only_on_PE= .true. , unscale = G % US % L_to_m ** 2 )
935
934
enddo
936
935
call EFP_sum_across_PEs(sums_EFP, 2 * nz)
937
936
do k= 1 ,nz
0 commit comments