@@ -679,7 +679,7 @@ end subroutine set_pen_shortwave
679
679
! > Diagnose a mixed layer depth (MLD) determined by a given density difference with the surface.
680
680
! > This routine is appropriate in MOM_diabatic_aux due to its position within the time stepping.
681
681
subroutine diagnoseMLDbyDensityDifference (id_MLD , h , tv , densityDiff , G , GV , US , diagPtr , &
682
- id_N2subML , id_MLDsq , dz_subML , ref_p_mld , id_ref_z )
682
+ id_N2subML , id_MLDsq , dz_subML , ref_h_mld , id_ref_z , id_ref_rho )
683
683
type (ocean_grid_type), intent (in ) :: G ! < Grid type
684
684
type (verticalGrid_type), intent (in ) :: GV ! < ocean vertical grid structure
685
685
type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
@@ -694,9 +694,10 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
694
694
integer , optional , intent (in ) :: id_MLDsq ! < Optional handle (ID) of squared MLD
695
695
real , optional , intent (in ) :: dz_subML ! < The distance over which to calculate N2subML
696
696
! ! or 50 m if missing [Z ~> m]
697
- real , optional , intent (in ) :: ref_p_mld ! < Optional reference pressure used to calculate the
698
- ! ! densisty, defults to 0.0 is not present [R L2 T-2 ~> Pa ].
697
+ real , optional , intent (in ) :: ref_h_mld ! < Optional reference depth used to calculate the
698
+ ! ! densisty, defults to 0.0 is not present [Z ~> m ].
699
699
integer , optional , intent (in ) :: id_ref_z ! < Handle (ID) of reference depth diagnostic
700
+ integer , optional , intent (in ) :: id_ref_rho ! < Handle (ID) of reference depth diagnostic
700
701
701
702
! Local variables
702
703
real , dimension (SZI_(G)) :: deltaRhoAtKm1, deltaRhoAtK ! Density differences [R ~> kg m-3].
@@ -710,7 +711,6 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
710
711
real , dimension (SZI_(G),SZK_(GV)) :: dZ_2d ! Layer thicknesses in depth units [Z ~> m]
711
712
real , dimension (SZI_(G)) :: dZ, dZm1 ! Layer thicknesses associated with interfaces [Z ~> m]
712
713
real , dimension (SZI_(G)) :: rhoSurf ! Density used in finding the mixed layer depth [R ~> kg m-3].
713
- real :: rhoSurf_ref ! Density used in finding the mixed layer depth [R ~> kg m-3].
714
714
real , dimension (SZI_(G), SZJ_(G)) :: z_ref_diag ! the actual depth of the k interface [Z ~> m].
715
715
real , dimension (SZI_(G), SZJ_(G)) :: MLD ! Diagnosed mixed layer depth [Z ~> m].
716
716
real , dimension (SZI_(G), SZJ_(G)) :: subMLN2 ! Diagnosed stratification below ML [T-2 ~> s-2].
@@ -719,11 +719,14 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
719
719
! have been stored already.
720
720
real :: gE_Rho0 ! The gravitational acceleration, sometimes divided by the Boussinesq
721
721
! reference density [H T-2 R-1 ~> m4 s-2 kg-1 or m s-2].
722
+ real :: H_to_RL2_T2 ! A conversion factor from thicknesses in H to pressure [R L2 T-2 H-1 ~> Pa m-1 or Pa m2 kg-1]
722
723
real :: dZ_sub_ML ! Depth below ML over which to diagnose stratification [Z ~> m]
723
724
real :: aFac ! A nondimensional factor [nondim]
724
725
real :: ddRho ! A density difference [R ~> kg m-3]
725
- real , dimension (SZI_(G)) :: ks
726
- real :: errZ, errZm1
726
+ real :: dddpth ! , thresh
727
+ real :: rhoSurf_k, rhoSurf_km1
728
+ real , dimension (SZI_(G), SZJ_(G)) :: rhoSurf_2d
729
+ ! real, dimension(SZI_(G)) :: ks
727
730
integer , dimension (2 ) :: EOSdom ! The i-computational domain for the equation of state
728
731
integer :: i, j, is, ie, js, je, k, nz, id_N2, id_SQ
729
732
@@ -746,41 +749,51 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
746
749
is = G% isc ; ie = G% iec ; js = G% jsc ; je = G% jec ; nz = GV% ke
747
750
748
751
pRef_MLD(:) = 0.0 ; hRef_MLD(:) = 0.0
749
- if (present (ref_p_mld)) pRef_MLD(is:ie) = ref_p_mld
750
- if (present (ref_p_mld)) hRef_MLD(is:ie) = ref_p_mld ! horrible pressure to depth calc
752
+ if (present (ref_h_mld)) hRef_MLD(:) = ref_h_mld
753
+ if (present (ref_h_mld)) then
754
+ H_to_RL2_T2 = GV% H_to_RZ * GV% g_Earth
755
+ pRef_MLD(:) = (0.5 * H_to_RL2_T2)* ref_h_mld
756
+ endif
751
757
z_ref_diag(:,:) = 0 .
758
+ ! thresh = 0.0011
752
759
753
760
EOSdom(:) = EOS_domain(G% HI)
754
761
do j= js,je
755
762
! Find the vertical distances across layers.
756
763
call thickness_to_dz(h, tv, dZ_2d, j, G, GV)
757
764
758
765
if (pRef_MLD(is) .ne. 0.0 ) then
759
- ks(is:ie) = 0
766
+ ! ks(is:ie) = 0
767
+ rhoSurf(:) = 0.0
760
768
do i= is,ie
761
769
dZ(i) = 0.5 * dZ_2d(i,1 ) ! Depth of center of surface layer
762
- if (dZ(i) >= hRef_MLD(i)) ks(i) = k
770
+ if (dZ(i) >= hRef_MLD(i)) then
771
+ call calculate_density(tv% T(i,j,1 ), tv% S(i,j,1 ), pRef_MLD(i), rhoSurf_k, tv% eqn_of_state)
772
+ rhoSurf(i) = rhoSurf_k
773
+ endif
763
774
enddo
764
775
do k= 2 ,nz
765
776
do i= is,ie
766
- if (ks(i)==0 .and. k< nz) then ! still havent found 10 m depth
767
- if (dZ(i) >= hRef_MLD(i)) then ! check whether the previous layer was closer
768
- errZ = dZ(i) - hRef_MLD(i)
769
- errZm1 = hRef_MLD(i) - dZm1(i)
770
- if (errZ <= errZm1) then ; ks(i) = k; z_ref_diag(i,j)= dZ(i); ! set the k reference
771
- elseif (errZm1 < errZ) then ; ks(i) = k-1 ; z_ref_diag(i,j)= dZm1(i); endif
772
- elseif (dZ(i) < hRef_MLD(i)) then ! go to the next layer
773
- dZm1(i) = dZ(i) ! Depth of center of layer K-1
774
- dZ(i) = dZ(i) + 0.5 * ( dZ_2d(i,k) + dZ_2d(i,k-1 ) ) ! Depth of center of layer K
775
- endif
776
- elseif (ks(i)==0 .and. k== nz) then
777
- ks(i)= 1
777
+ dZm1(i) = dZ(i) ! Depth of center of layer K-1
778
+ dZ(i) = dZ(i) + 0.5 * ( dZ_2d(i,k) + dZ_2d(i,k-1 ) ) ! Depth of center of layer K
779
+ dddpth = dZ(i) - dZm1(i)
780
+ ! if ((rhoSurf(i) == 0.) .and. (dddpth > thresh) .and. &
781
+ if ((rhoSurf(i) == 0 .) .and. &
782
+ (dZm1(i) < hRef_MLD(i)) .and. (dZ(i) >= hRef_MLD(i))) then
783
+ aFac = ( hRef_MLD(i) - dZm1(i) ) / dddpth
784
+ z_ref_diag(i,j) = (dZ(i) * aFac + dZm1(i) * (1 . - aFac))
785
+ call calculate_density(tv% T(i,j,k) , tv% S(i,j,k) , pRef_MLD, rhoSurf_k, tv% eqn_of_state)
786
+ call calculate_density(tv% T(i,j,k-1 ), tv% S(i,j,k-1 ), pRef_MLD, rhoSurf_km1, tv% eqn_of_state)
787
+ rhoSurf(i) = (rhoSurf_k * aFac + rhoSurf_km1 * (1 . - aFac))
788
+ ! elseif (dddpth<=thresh) then
789
+ elseif ((rhoSurf(i) == 0 .) .and. (k>= nz)) then
790
+ call calculate_density(tv% T(i,j,1 ), tv% S(i,j,1 ), pRef_MLD(i), rhoSurf_k, tv% eqn_of_state)
791
+ rhoSurf(i) = rhoSurf_k
778
792
endif
779
793
enddo
780
794
enddo
781
795
do i= is,ie
782
- call calculate_density(tv% T(i,j,ks(i)), tv% S(i,j,ks(i)), pRef_MLD(i), rhoSurf_ref, tv% eqn_of_state)
783
- rhoSurf(i) = rhoSurf_ref
796
+ rhoSurf_2d(i,j)= rhoSurf(i)
784
797
deltaRhoAtK(i) = 0 .
785
798
MLD(i,j) = 0 .
786
799
if (id_N2> 0 ) then
@@ -790,6 +803,42 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
790
803
N2_region_set(i) = (G% mask2dT(i,j)<0.5 ) ! Only need to work on ocean points.
791
804
endif
792
805
enddo
806
+ do i= is,ie ; dZ(i) = 0.5 * dZ_2d(i,1 ) ; enddo ! Reset the depth of center to the surface layer
807
+ ! !!!!!!!!!!!!!
808
+ ! ks(is:ie) = 0
809
+ ! do i=is,ie
810
+ ! dZ(i) = 0.5 * dZ_2d(i,1) ! Depth of center of surface layer
811
+ ! if (dZ(i) >= hRef_MLD(i)) ks(i) = k
812
+ ! enddo
813
+ ! do k=2,nz
814
+ ! do i=is,ie
815
+ ! if (ks(i)==0 .and. k<nz) then ! still havent found 10 m depth
816
+ ! if (dZ(i) >= hRef_MLD(i)) then ! check whether the previous layer was closer
817
+ ! errZ = dZ(i) - hRef_MLD(i)
818
+ ! errZm1 = hRef_MLD(i) - dZm1(i)
819
+ ! if (errZ <= errZm1) then; ks(i) = k; z_ref_diag(i,j)=dZ(i); ! set the k reference
820
+ ! elseif (errZm1 < errZ) then; ks(i) = k-1; z_ref_diag(i,j)=dZm1(i); endif
821
+ ! elseif (dZ(i) < hRef_MLD(i)) then ! go to the next layer
822
+ ! dZm1(i) = dZ(i) ! Depth of center of layer K-1
823
+ ! dZ(i) = dZ(i) + 0.5 * ( dZ_2d(i,k) + dZ_2d(i,k-1) ) ! Depth of center of layer K
824
+ ! endif
825
+ ! elseif (ks(i)==0 .and. k==nz) then
826
+ ! ks(i)=1
827
+ ! endif
828
+ ! enddo
829
+ ! enddo
830
+ ! do i=is,ie
831
+ ! call calculate_density(tv%T(i,j,ks(i)), tv%S(i,j,ks(i)), pRef_MLD(i), rhoSurf_ref, tv%eqn_of_state)
832
+ ! rhoSurf(i) = rhoSurf_ref
833
+ ! deltaRhoAtK(i) = 0.
834
+ ! MLD(i,j) = 0.
835
+ ! if (id_N2>0) then
836
+ ! subMLN2(i,j) = 0.0
837
+ ! H_subML(i) = h(i,j,1) ; dH_N2(i) = 0.0 ; dZ_N2(i) = 0.0 ! may need to cahnge the 1 on this line?
838
+ ! T_subML(i) = 0.0 ; S_subML(i) = 0.0 ; T_deeper(i) = 0.0 ; S_deeper(i) = 0.0
839
+ ! N2_region_set(i) = (G%mask2dT(i,j)<0.5) ! Only need to work on ocean points.
840
+ ! endif
841
+ ! enddo
793
842
! !!!!!!!!!!!
794
843
! do i=is,ie
795
844
! ks(i) = 0
@@ -825,9 +874,11 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
825
874
! endif
826
875
! enddo
827
876
elseif (pRef_MLD(is) == 0.0 ) then
877
+ rhoSurf(:) = 0.0
828
878
do i= is,ie ; dZ(i) = 0.5 * dZ_2d(i,1 ) ; enddo ! Depth of center of surface layer
829
879
call calculate_density(tv% T(:,j,1 ), tv% S(:,j,1 ), pRef_MLD, rhoSurf, tv% eqn_of_state, EOSdom)
830
880
do i= is,ie
881
+ rhoSurf_2d(i,j)= rhoSurf(i)
831
882
deltaRhoAtK(i) = 0 .
832
883
MLD(i,j) = 0 .
833
884
if (id_N2> 0 ) then
@@ -909,6 +960,7 @@ subroutine diagnoseMLDbyDensityDifference(id_MLD, h, tv, densityDiff, G, GV, US,
909
960
if (id_SQ > 0 ) call post_data(id_SQ, MLD2, diagPtr)
910
961
911
962
if ((id_ref_z > 0 ) .and. (pRef_MLD(is).ne. 0 .)) call post_data(id_ref_z, z_ref_diag , diagPtr)
963
+ if (id_ref_rho > 0 ) call post_data(id_ref_rho, rhoSurf_2d , diagPtr)
912
964
913
965
end subroutine diagnoseMLDbyDensityDifference
914
966
@@ -2051,5 +2103,4 @@ end subroutine diabatic_aux_end
2051
2103
! ! salinities due to the application of the surface forcing. It may also calculate the implied
2052
2104
! ! turbulent kinetic energy requirements for this forcing to be mixed over the model's finite
2053
2105
! ! vertical resolution in the surface layers.
2054
-
2055
2106
end module MOM_diabatic_aux
0 commit comments