-
Notifications
You must be signed in to change notification settings - Fork 8
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
Clean up diagnostic variables in WW3 for Langmuir turbulence parameterization #4
Conversation
1. Remove redundant temporary variables (ETUSSX, ETUSSY, ETUSSXH, ETUSSYH) and lines for calculating the surface Stokes drift and surface layer averaged Stokes drift. 2. Calculation of surface layer averaged Stokes drift and the tail contribution to both surface and surface layer averaged Stokes drift are activated when W3_CESMCOUPLED is defined.
Replace the mixed layer depth by a surface layer depth for the depth averaged Stokes drift and define it to be 1/5 of the mixed layer depth when importing the field.
1. Remove unnecessary diagnostic variables for Langmuir turbulence parameterization in CESM. 2. Move the calculations of Langmuir enhancement factor (lamult) and surface layer averaged Langmuir number (lasl) to the cap-code. 3. Add a new variable (lasl) to be exported for Langmuir turbulence parameterization in CESM.
@qingli411 it looks like you are removing LANGMT as a variable output from WW3. Do you want to be able to retain this variable in WW3 output? I've been working on getting a cesm-like case set up for UFS and we discovered that the LANGMT variable is not getting written to the ww3 history file right now. I've fixed a couple of issues and I am now getting LANGMT in the netcdf file, but it is all undefined. |
@DeniseWorthen
|
@alperaltuntas Do you have any suggestions on which branch of CESM I should use or start from to test the changes here? |
@qingli411 , For testing, I suggest you use the newly created cesm2_3_alpha09b tag, but make sure to switch to main_0.0.4 and dev/unified_0.0.4 tags for WW3_interface and WW3, respectively. |
OK. I will try that. Thanks! @alperaltuntas |
model/src/w3adatmd.F90
Outdated
ALLOCATE ( WADATS(IMOD)%XLANGMT(NXXX), STAT=ISTAT ) | ||
ALLOCATE ( WADATS(IMOD)%XUSSHX(NXXX), STAT=ISTAT ) | ||
CHECK_ALLOC_STATUS ( ISTAT ) | ||
ALLOCATE ( WADATS(IMOD)%XUSSY(NXXX), STAT=ISTAT ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe, you mean to allocate XUSSHY
here, and not ``XUSSY`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
model/src/w3adatmd.F90
Outdated
ALLOCATE ( WADATS(IMOD)%XLANGMT(1), STAT=ISTAT ) | ||
ALLOCATE ( WADATS(IMOD)%XUSSHX(1), STAT=ISTAT ) | ||
CHECK_ALLOC_STATUS ( ISTAT ) | ||
ALLOCATE ( WADATS(IMOD)%XUSSY(1), STAT=ISTAT ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I believe you mean to allocate XUSSHY here, and not ``XUSSY`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
model/src/w3iogoncdmd.F90
Outdated
#ifdef W3_CESMCOUPLED | ||
USE W3ADATMD, ONLY: LANGMT | ||
#endif | ||
#ifdef W3_CESMCOUPLED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the whitespaces before ifdefs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
model/src/wav_grdout.F90
Outdated
@@ -225,7 +225,8 @@ subroutine initialize_gridout | |||
varatts( "USP ", "USSPY ", "Partitioned surface Stokes drift y ", "m s-1 ", "p ", .false.) , & | |||
varatts( "TWC ", "TAUOCX ", "Total wave to ocean stress x ", "Pa ", " ", .false.) , & | |||
varatts( "TWC ", "TAUOCY ", "Total wave to ocean stress y ", "Pa ", " ", .false.) , & | |||
varatts( "LAN ", "LANGMT ", "Turbulent Langmuir number (La_t) ", "nd ", " ", .false.) & | |||
varatts( "USSH ", "USSHX ", "Surface layer averaged Stokes drift x ", "m s-1 ", " ", .false.) , & | |||
varatts( "USSH ", "USSHY ", "Surface layer averaged Stokes drift y ", "m s-1 ", " ", .false.) , & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to remove the comma at the end here (before ampersand).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
alphal = atan( sin(sww) / ( & | ||
2.5 * UST(isea)*ASF(isea)*sqrt(dair/dwat) & | ||
/ max(1.e-14, sqrt(USSX(jsea)**2+USSY(jsea)**2)) & | ||
* log(max(1.0, abs(1.25*HSL(ix,iy)/HS(jsea)))) & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we get a floating point error when HS is zero. It is unclear to me why HS becomes exactly zero at a sea point, but regardless, it looks like this expression should be refactored to ensure numerical stability for cells where denominators are very small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to set sw_lamult
to 1 when HS=0
. So I add this condition in the if statement on Line 673.
Thanks, @alperaltuntas, for reviewing this PR! And sorry for my delay. In addition to fixing these, I also added a switch |
I am closing this PR in favor of the updated version #8 |
Pull Request Summary
This PR cleans up the calculation of Stokes drift and other diagnostics variables in WW3 for Langmuir turbulence parameterization in CESM.
Description
USSX
andUSSY
) and surface layer averaged Stokes drift (USSHX
andUSSHY
). The calculation of surface layer averaged Stokes drift and the tail contributions to both versions of Stokes drift are activated whenW3_CESMCOUPLED
is defined.HML
to a more general surface layer depthHSL
. This depth is used to calculate the surface layer averaged Stokes drift. When used in CESM, the surface layer depth is defined as 1/5 of the mixed layer depth. Now this 1/5 factor is applied to the mixed layer depth when importing the fields in the cap.USSHX
andUSSHY
). The Langmuir enhancement factor (LAMULT
) and the surface layer averaged Langmuir number (LASL
) are now calculated when they are exported in the cap.LASL
is needed for the Langmuir induced entrainment parameterization in CVMix but was not there in the cap code. So it is now added following the wayLAMULT
is defined.LAMULT
,LASL
) as well. But given that the calculation of these variables are moved to the cap, and the way division by zero and physically invalid values (both should be rare) are handled, small changes to these variables are expected.Issue(s) addressed
This PR partially addresses the following issues.
Commit Message
Clean up the calculation of Stokes drift and other diagnostic variables for Langmuir turbulence parameterization.
Check list
Testing
This PR has not been tested yet.
Todo
I think there are still a few things to do in this PR. But I'm not sure what's the best way to proceed so I listed them here for discussion. Any suggestions? @alperaltuntas @DeniseWorthen @mvertens
ifdef
s to control whether or not to include the high frequency tail contributions to the Stokes drift or whether or not we should output the surface layer averaged Stokes drift. We may need some newifdef
s for better control of such features for non-CESM users as described in Add optional high frequency tail to USSX, USSY NOAA-EMC/WW3#669.USSHX
,USSHY
) needs additional lines inw3iogomd.F90
that depend on the indices of the flag arrayFLOGRD
. I’m not sure what’s the best way to combine the flags inFLOGRD
andifdef
s so I didn’t add them. Right nowUSSHX
andUSSHY
should be calculated and used in the cap whenW3_CESMCOUPLED
is defined but they are not in the WW3 output.USSHX
andUSSHY
inw3initmd.F90
andw3iorsmd.F90
for initialization and restart? Again they depend on the indices in the arrays of the flags.LAMULT
andLASL
(now inwav_import_export.F90
), we may need better ways to check division by zero. I also put some arbitrary limits to avoid unphysical behavior (e.g.,LASL
should default to a large number which corresponds toLAMULT=1
andUSSX=USSY=0
, andLASL
should be greater than zero). I think we should make sure these are consistent with other part of the code.