-
Notifications
You must be signed in to change notification settings - Fork 0
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
added nonhydrostatic capabilities to MPAS-O #21
base: master
Are you sure you want to change the base?
Conversation
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.
@scalandr, thank you for this amazing work! This will be such an great new capability for us to have.
I have noticed several things that need a little work. I still have a lot of code to go through but this is all I have time for for a little while so wanted to give you a chance to address it first.
The major one is that most if not all of the variables you added should be in the nonhydrostaticPKG
package (I suggest this name change). In the code, it will be important to only access these fields if the package is active. Typically, you can check if the field pointers are associated. See many examples of this throughout the code. If you don't make use of packages, your changes here will add substantially to the memory usage of the model even in hydrostatic mode.
The other, which is preventing the code from compiling and therefore preventing me from verifying that the results in hydrostatic mode are bit-for-bit is the incorrect indentation in src/shared/Makefile
. It needs to be with tabs, not spaces.
Please verify that the code compiles for you and then ping me to try testing again.
components/mpas-framework/Makefile
Outdated
($(FC) pio2.f90 $(FCINCLUDES) $(FFLAGS) $(LDFLAGS) $(LIBS) -o pio2.out &> /dev/null && echo "=> PIO 2 detected") || \ | ||
($(FC) pio2.f90 $(FCINCLUDES) $(FFLAGS) $(LDFLAGS) $(LIBS) -o pio2.out && echo "=> PIO 2 detected") || \ |
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.
@scalandr, this line needs to go back to what it used to be. I presume this was just to help you debug.
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.
@xylar, done.
components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_rk4.F
Outdated
Show resolved
Hide resolved
components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_rk4.F
Outdated
Show resolved
Hide resolved
components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_rk4.F
Outdated
Show resolved
Hide resolved
<var name="dynamicViscosity" type="real" dimensions="nVertLevelsP1 nCells Time" units="Ns/m^2" | ||
description="dynamic viscosity of water as a function of temperature and salinity" | ||
packages="forwardMode;analysisMode" | ||
/> | ||
<var name="uStar" type="real" dimensions="nVertLevels nCells Time" units="m s^{-1}" | ||
description="stress velocity for wall bounded flows" | ||
packages="forwardMode;analysisMode" | ||
/> | ||
<var name="yPlus" type="real" dimensions="nVertLevels nCells Time" units="m" | ||
description="boundary normal coordinate" | ||
packages="forwardMode;analysisMode" | ||
/> |
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.
Add to nonhydrostaticPKG
<var name="ugrad" type="real" dimensions="R3 nVertLevels nCells Time" units="s^{-1}" | ||
description="three-dimensional gradient of zonal velocity" | ||
/> | ||
<var name="vgrad" type="real" dimensions="R3 nVertLevels nCells Time" units="s^{-1}" | ||
description="three-dimensional gradient of meridional velocity" | ||
/> | ||
<var name="wgrad" type="real" dimensions="R3 nVertLevels nCells Time" units="s^{-1}" | ||
description="three-dimensional gradient of vertical velocity" | ||
/> | ||
<var name="tgrad" type="real" dimensions="R3 nVertLevels nCells Time" units="s^{-1}" | ||
description="three-dimensional gradient of temperature" | ||
/> | ||
<var name="sgrad" type="real" dimensions="R3 nVertLevels nCells Time" units="s^{-1}" | ||
description="three-dimensional gradient of salinity" | ||
/> | ||
<var name="Sh" type="real" dimensions="nVertLevels nCells Time" units="unitless" | ||
description="Structure function for heat and salt -- may want to consider separating at some point" | ||
/> | ||
<var name="Sm" type="real" dimensions="nVertLevels nCells Time" units="unitless" | ||
description="Structure function for momentum" | ||
/> |
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.
Add to nonhydrostaticPKG
<var name="Sh" type="real" dimensions="nVertLevels nCells Time" units="unitless" | ||
description="Structure function for heat and salt -- may want to consider separating at some point" | ||
/> | ||
<var name="Sm" type="real" dimensions="nVertLevels nCells Time" units="unitless" | ||
description="Structure function for momentum" | ||
/> |
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'm worried that the names Sh
and Sm
are not sufficiently descriptive or unique.
mpas_ocn_vvel_vert_advection.o \ | ||
mpas_ocn_vvel_horiz_advection.o \ | ||
mpas_ocn_vvel_coriolis.o \ | ||
mpas_ocn_vvel_hmix_del2.o \ | ||
mpas_ocn_vvel_advection.o \ | ||
mpas_ocn_vvel_pgf.o \ | ||
mpas_ocn_nonhydrostatic_pressure_solve.o \ |
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.
The indentation here seems to be incorrect.
mpas_ocn_two_equation_model_driver.o \ | ||
mpas_ocn_two_equation_structure_functions.o \ | ||
mpas_ocn_two_equation_model_driver.o \ | ||
mpas_ocn_tke_glsPsi_transport.o \ | ||
mpas_ocn_tke_advection_mono.o \ | ||
mpas_ocn_glsPsi_advection_mono.o \ | ||
mpas_ocn_shear_production.o \ | ||
mpas_ocn_buoyancy_production.o |
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.
Indentation here needs to be with tabs, not spaces. As a result, I am not able to build the code on Anvil.
Hi @xylar, I am ready to ask for a re-review of the PR. Before I click on the "re-request review" button I wanted to ask you about the two conflicting files. If I click on "Resolve conflicts" and fix them there, then my local branch will not see the changes, correct? What is your recommendation on how to proceed? Thanks! |
@scalandr, my recommendation for resolving conflicts like this is always to rebase onto If you use "Resolve conflicts" here, it will do a merge of I will update |
Okay, I just updated |
@xylar, when we did the rebase together last time we did
Shall i just do |
@scalandr, yes, that's right. You don't need to add |
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 see a few basically cosmetic things that I'd like to see fixed. After that, I'm ready for this to move to E3SM.
I'd like to have @dengwirda and @mark-petersen both approve here first, though.
<nml_option name="config_use_vertMom_del2" type="logical" default_value=".false." units="unitless" | ||
description="If true, Laplacian horizontal mixing is used on the vertical momentum equation." |
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.
The registry needs to be indented with tabs, not spaces everywhere.
<nml_record name="nonhydrostatic_pressure"> | ||
<nml_option name="config_enable_nonhydrostatic_mode" type="logical" default_value=".false." units="unitless" | ||
description="Flag to enable the nonhydrostatic pressure calculation" | ||
possible_values=".true. or .false." | ||
/> | ||
<nml_option name="config_nonhydrostatic_solve_surface_boundary_condition" type="character" default_value="noGradient" units="unitless" | ||
description="setting for surface boundary condition for the pressure correction solve" | ||
possible_values="noGradient or no pressure" | ||
/> | ||
<nml_option name="config_enable_vertMomentum_disable_nonHydro" type="logical" default_value=".false." units="unitless" | ||
description="flag to enable hydrostatic pressure with vertical momentum tendencies" | ||
possible_values=".true. or .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.
In the process of replacing spaces with tabs for indentation, please make the indentation consistent
<var name="vertVelocityNonhydro" type="real" dimensions="nVertLevelsP1 nCells Time" units="m s^{-1}" | ||
description="prognostic vertical velocity, only used when config_enable_nonhydrostatic_mode = .true." | ||
/> | ||
<var name="nonhydrostaticPressure" type="real" dimensions="nVertLevels nCells Time" units="N m^{-2}" | ||
description="nonhydrostatic pressure, set to zero if config_enable_nonhydrostatic_mode = .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.
Can these variables be put in the nonhydrostaticPKG
package? If they aren't used at all when the nonhydrostaticPKG
is disabled, this should be possible. If not, this will add to the memory used in hydrostatic mode.
<var name="tendVertVelocityNonhydro" type="real" dimensions="nVertLevelsP1 nCells Time" units="m s^{-2}" name_in_code="vertVelocityNonhydroTend" | ||
description="time tendency of the vertical velocity (Only active for non hydrostatic mode)" | ||
/> |
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.
Same here, can this be in the nonhydrostaticPKG
package?
<var name="velocityHmixTend" dimensions="nVertLevels nEdges Time" units="m/s^2" type="real" | ||
description="tendency of normal velocitydue to horizontal mixing" | ||
/> | ||
<var name="velocityVmixTend" dimensions="nVertLevels nEdges Time" units="m/s^2" type="real" | ||
description="tendency of normal velocity due to vertical mixing" | ||
/> | ||
<var name="velocityCoriolisTend" dimensions="nVertLevels nEdges Time" units="m/s^2" type="real" | ||
description="tendency of normal velocity due to Coriolis" | ||
/> | ||
<var name="velocityPGFtend" dimensions="nVertLevels nEdges Time" units="m/s^2" type="real" | ||
description="tendency of normal velocity due to PGF" | ||
/> | ||
<var name="velocityVadvTend" dimensions="nVertLevels nEdges Time" units="m/s^2" type="real" | ||
description="tendency of normal velocity due to vertical advection" | ||
/> | ||
<var name="velocityForcingTend" dimensions="nVertLevels nEdges Time" units="m/s^2" type="real" | ||
description="tendency of normal velocity due to top and bottom forcing" | ||
/> |
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 this still needs to happen.
print*, dt | ||
|
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 take this out. I assume it's for debugging.
|
||
call ocn_time_integrator_rk4_compute_thick_tends( block, dt, rk_substep_weights(rk_step), err ) | ||
block => block % next | ||
end do | ||
|
||
call mpas_timer_stop("RK4 vel/thick tendency computations") |
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.
Maybe put back these blank lines?
call mpas_timer_stop("RK4 vel/thick tendency computations") | ||
|
||
! Update halos for prognostic variables. |
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.
Maybe put back this comment (below the if)
call ocn_nonhydrostatic_pressure_update_velocity(normalVelocityNew, vertVelocityNonhydroNew, & | ||
layerThicknessNew, layerThickEdgeMean, nonhydrostaticPressure, nonhydrostaticPressureOld, & | ||
nhPressureCorrection, dt) |
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.
This is indented 3 spaces too many
@@ -658,7 +658,7 @@ subroutine ocn_meshCreate(domain) !{{{ | |||
!$acc edgeNormalVectors, & | |||
!$acc localVerticalUnitVectors, & | |||
!$acc cellTangentPlane, & | |||
!$acc coeffs_reconstruct) | |||
!$acc coeffs_reconstruct) |
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.
trailing space should be removed.
It looks like one more conflicting commit came in in the last few days. @scalandr, you'll need to rebase one more time. I ran the nightly test suite from compass with and without PETSc (and NetLib LAPACK). The first one was fine. The second was fine except for tests with different thread decompositions, as we have already discussed. I didn't try rerunning @scalandr's new nonhydro test case yet but will do that as part of an E3SM review. |
Hi @vanroekel, I took care of all your comments, so
|
@xylar, If I do the rebase I see So should I erase the first 7 lines, i.e. commits 88fb to 7355? |
@scalandr, no, sorry for the confusion. Here's what we're seeing on GitHub: |
Indeed, that seems to have taken care of it: |
@scalandr the new version is looking great! I think there is just one more question about the tridiagonal solve in my mind. It looks like you inlined that code. If that is true, can you remove the code for the solver itself? it shouldn't be needed anymore |
Hi @vanroekel, I finished inlining the tridiagonal solve in |
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.
This is looking great! I'm ready for this to move on to e3sm.
This commit resolves reveiew comments for PR #21 ('Add a regional sea-level projection capability to MALI') - Set up MPI variables outside of routine 'interpolation_init'. - Move reformatting command of 1D SL array to 2D array inside of routine 'interpolation' - Include #ifdef USE_SEALEVELMODEL inside of the check for config_uplift_method - other small fixes
@scalandr, I noticed when building this today that the make targets are out of date compared to master. Could you do a rebase to bring those changes in when you have time? Not super urgent but it would be a good idea. |
…Dev/develop Previously, when the regional sea-level prediction capability was added to MALI (#21), the restart config option for the sea-level model was not added. This led the sea-level model to get initialized to Timestep zero when coupled MALI-SLM simulations are being restarted, forgetting about the ice loading changes and associated viscoelastic solid earth deformation that happened in the timesteps prior to current model time. This PR fixes the problem by allowing the sea-level model to resume where it was left off. Note in parallel to this PR, the version of the SLM needs to incorporate the changes made in the following accompanying PR (MALI-Dev/1DSeaLevelModel_FWTW#9) * hollyhan/add_restart_functionality_slm: Don't call SLM on init of a restart Add addl info on restart about the calculated time since last SLM call Allow restarts at any interval when using SLM Add missing error flag so model actually dies when error occurs Add missing arguments to log write statement Update restart check to also use time interval division Adjust check if adaptive dt is on or not Update checks using interval division Improve error handling, correct other usage of config_uplift_method Improve synchronization of timesteps between MALI and SLM Add restart option when the SLM is coupled to MALI
This is a nonhydrostatic version of MPAS-O. This nonhydrostatic model enables new physics, allowing the correct representation of, for example, high-resolution internal waves dynamics, which are not well represented by the hydrostatic approximation. New vertical momentum and pressure terms are added in the formulation, and a coupled elliptic system is formed for the solution of the nonhydrostatic pressure correction. At every time step, this system is solved with the PETSc library using preconditioned iterative Krylov solvers. The flag
config_enable_nonhydrostatic_mode
can be used to turn on and off the nonhydrostatic capabilities.