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

Update MOM_mixed_layer_restrat.F90 #568

Merged
merged 3 commits into from
Feb 25, 2024

Conversation

marshallward
Copy link
Member

Adding and calculating diagnostic front length scale (lf_bodner) to mixed layer restratification code

@marshallward
Copy link
Member Author

I think this addresses the issues raised in #532 and #542. Authorship of @amoebaliz was preserved, with @kshedstrom and myself added as co-authors.

@marshallward marshallward force-pushed the test_mle_diag_v3 branch 2 times, most recently from c945458 to cd69215 Compare February 8, 2024 17:44
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: Patch coverage is 63.15789% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 37.20%. Comparing base (3f7465a) to head (7032df3).

Files Patch % Lines
...ameterizations/lateral/MOM_mixed_layer_restrat.F90 63.15% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           dev/gfdl     #568   +/-   ##
=========================================
  Coverage     37.20%   37.20%           
=========================================
  Files           271      271           
  Lines         80457    80473   +16     
  Branches      15002    15005    +3     
=========================================
+ Hits          29932    29943   +11     
- Misses        44958    44960    +2     
- Partials       5567     5570    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This revised PR addresses all of the concerns that I had with its predecessors (PR #532 and #542).

@marshallward
Copy link
Member Author

I seem to have changed something which let u_star3 become NaN, this needs to be fixed.

@marshallward
Copy link
Member Author

marshallward commented Feb 9, 2024

The splitting of the loop to accommodate the new ANSWER_DATE caused u_star3 and w_star3 to be unassigned and to lose their Z3/T3 dimensional corrections. These have now been fixed. (They will probably be squashed, assuming everything looks correct.)

I removed most of the explicit dimension scalings in the diag formula, which should no longer be needed since the new cuberoot() preserves dimensions and we don't need to accomodate it anymore. But I may have bungled up some Z's and H's here and it may need some further review.

@amoebaliz
Copy link

amoebaliz commented Feb 9, 2024 via email

@marshallward
Copy link
Member Author

marshallward commented Feb 9, 2024

I am kind of baffled about the dimension error here. There's a Z^3 missing somewhere, but everything else is passing, and I don't know how that is possible.

I'm also unable to replicate these dimensional errors when I run locally.

@marshallward
Copy link
Member Author

Dimensions of Z2/H seemed to have fixed it.

I am still confused about the units of ustar, but in the context of this module I can see that it's consistent.

@marshallward
Copy link
Member Author

This need a new review from @Hallberg-NOAA when he gets back from leave.


lf_bodner_diag(i,j) = &
0.25 * cuberoot(CS%mstar * u_star3 + CS%nstar * w_star3)**2 &
/ (f2_h * max(little_h(i,j), GV%Angstrom_H))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to convert this to units of [L ~> m], the denominator should be multiplied by (US%L_to_Z * GV%H_to_RZ* tv%SpV_avg(i,j,1)) when in fully non-Boussinesq mode or in Boussinesq mode the denominator should be multiplied by (GV%H_to_Z*US%L_to_Z). (Compare this with the expressions that set wpup at lines 943 and 968.) Were we to make this change here, the conversion factor at line 1814 would need to be changed to US%L_to_m, while the units of lf_bodner_diag on line 811 would stay as they are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented this suggestion.

Copy link
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR should be changed in one of two ways - either to document the units of lf_bodner_diag consistently with how the code is written, or to revise lf_bodner_diag so that it is in the more natural units of [L ~> m]. I would prefer the latter, as it gives a diagnostic that is much more natural in non-Boussinesq mode (i.e., it avoids using the Boussinesq reference density). There are two separate comments attached to specific lines describing each of the two (mutually exclusive) options.

@marshallward
Copy link
Member Author

I agree with @Hallberg-NOAA's second suggestion: if the Bodner lengthscale is L then it should be saved as L.

I've made some changes based on your suggestion to move the LH Z-2 scaling back into the equation for lf_bodner. Since wpup did the same scaling, I moved the Boussinesq/non-Boussinesq forms of this scaling factor into a new variable. (It's possible some consolidation could be done here, but I left things as they are.)

I also moved the id_lfbod if-block outside of the do-loop, to help with performance.

@@ -928,14 +937,20 @@ subroutine mixedlayer_restrat_Bodner(CS, G, GV, US, h, uhtr, vhtr, tv, forces, d
CS%MLD_filtered_slow(i,j) = big_H(i,j)
enddo ; enddo

if (allocated(tv%SpV_avg) .and. .not.(GV%Boussinesq .or. GV%semi_Boussinesq)) then
uflux_rescale = US%Z_to_L * GV%RZ_to_H / tv%SpV_avg(i,j,1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In non-Boussinesq mode, uflux_rescale is a function of i and j, and it therefore either needs to be turned into a 2-d array or calculated inside of the relevant i- and j- loops.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

CS%nstar * max(0., -bflux(i,j)) * BLD(i,j) ))**2, CS%min_wstar2) * &
( US%Z_to_L * GV%RZ_to_H / tv%SpV_avg(i,j,1))
CS%nstar * max(0., -bflux(i,j)) * BLD(i,j) ))**2, CS%min_wstar2) &
* uflux_rescale
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 953 is not equivalent to the previous line 938 because the former was a function of i- and j-.

amoebaliz and others added 3 commits February 25, 2024 11:40
Adding and calculating diagnostic front length scale (lf_bodner) to
mixed layer restratification code

Co-authored-by: Kate Hedstrom <kshedstrom@alaska.edu>
Co-authored-by: Marshall Ward <marshall.ward@noaa.gov>
Fix two issues which emerged from the Bodner length scale diagnostic
after the cuberoot ANSWER_DATE was introduced.

The split of the loop due to the cuberoot caused ustar to be assigned in
a separate loop, leaving it uninitialized for the length scale
diagnostics loop.  It also had its dimensions removed.

However, the whole point of the new cuberoot() function was to preserve
its dimensions, so there was no need for the intermediate dimensional
manipulation, and all dimensionality should be shifted to the
registration.

This patch removes the intermediate dimensions and also explicitly
defines it as Z2/H rather than L.
The scaling of the Bodner lengthscale diagnostic is correctly restored
to L in this patch.  The Z2 H-1 constant is factored into the
calculation of the lengthscale; I believe this represents a conversion
from a [Z2 T-2]-like momentum flux to a [LH T-2]-like momentum flux.

A generic `uflux_rescale` term was introduced to be used in both
ld_bodner and wpup, to avoid a double division by SpV.

The if-block for computation of ld_bodner was also moved outside of the
loop, in order to facilitate vectorization.
@marshallward marshallward force-pushed the test_mle_diag_v3 branch 2 times, most recently from 42b0f4b to 7032df3 Compare February 25, 2024 16:41
Copy link
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request now looks correct to me.


! Rescale from [Z2 H-1 to L]
lf_bodner_diag(i,j) = lf_bodner_diag(i,j) * uflux_rescale
enddo ; enddo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has a horizontal indexing error in non-Boussinesq mode because in that case the appropriate rescaling factor is a function of (i,j).

This was referenced Feb 25, 2024
@Hallberg-NOAA
Copy link
Member

This PR has passed pipeline testing at https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/22420.

@Hallberg-NOAA Hallberg-NOAA merged commit f92e4ac into NOAA-GFDL:dev/gfdl Feb 25, 2024
12 checks passed
@marshallward marshallward deleted the test_mle_diag_v3 branch May 8, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants