-
Notifications
You must be signed in to change notification settings - Fork 365
GOTM in MPAS-Ocean #704
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
GOTM in MPAS-Ocean #704
Conversation
It has been tested in a single column test case following Section 5.1 of Kärnä, 2020, which is an updated version of the surface gradient forcing test case in #615. The test case is in compass test number 138. The simulated velocity and viscosity profiles are compared with the analytical solution of Equations (67) and (69), and a simulation using constant viscosity of 0.01 m^2/s in CVMix. The results depends on the bottom drag coefficient, here set to 0.0173, corresponding to the value inferred from the analytical solution with a layer thickness of 0.06 m. |
Currently the GOTM module reads in its own namelist file ('gotmturb.nml', included in the compass test) at the beginning of the simulation. The path of the GOTM namelist file can be set in the MPAS-Ocean namelist. This is coded in the GOTM library so we will need to customize GOTM or have a way to generate the GOTM namelist if we want to control the behavior of GOTM from the MPAS-Ocean namelist. GOTM requires input of bottom drag coefficient (to compute the bottom friction velocity) and the bottom roughness length, both set to constant in the namelist right now. But later may use the values from the bottom drag parameters in other part of the MPAS-Ocean code once they are ready. |
@sbrus89 Could you please take a look at this when you have time? Looks like I don't have the access to assign a reviewer... |
The implementation of GOTM in MPAS-Ocean has also been tested in a JRA55do forced G-case before rebasing to the Here are some MPAS-Analysis results: |
@qingli411 please post a |
@mark-petersen The |
771b309
to
a8d3217
Compare
@qingli411 I rebased on the head of This is the output from the nightly regression suite:
for both gnu and intel, the restart tests all fail. This means one of these:
either way, the 'state' of the system is not identical just after beginning a restart, as it would be if the model proceeded without restarting. Try to fix (1) first. The solution to (2) is to add variables to the restart file. But we only do that if they are absolutely needed. If they can be computed on init instead, that is better. You can copy my restart test here, for your convenience: you can tar up that whole directory, copy it to your own space, and run |
@mark-petersen OK. I think it's probably due to the second reason. GOTM solves prognostic equations for TKE and a length scale and requires the state of some variables from the previous time step. I added a list of variables that GOTM needs in the Related to this I have a question on the way to initialize these arrays in MPAS-O. Here I initialize the arrays only once using a saved variable |
src/core_ocean/Registry.xml
Outdated
<!-- FIELDS FOR GOTM --> | ||
<var name="gotmVertViscTopOfCell" type="real" dimensions="nVertLevelsP1 nCells Time" units="m^2 s^{-1}" | ||
description="GOTM: vertical viscosity defined at the cell center (horizontally) and top (vertically)" | ||
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.
Here you are adding 3D fields that are allocated whether gotm is in use or not. To fix that, add a new package in Registry.xml called gotmPKG
and put all of your new variables in that package (not forwardMode;analysisMode
). You will need to add code to turn on the package if the first gotm flag is true. Follow the example here:
src/core_ocean/driver/mpas_ocn_core_interface.F
238 !
239 ! test for variable bottom drag of momentum, variableBottomDragPKG
240 call mpas_pool_get_package(packagePool, 'variableBottomDragPKGActive', variableBottomDragPKGActive)
241 call mpas_pool_get_config(configPool, 'config_use_variable_drag', config_use_variable_drag)
242 if ( config_use_variable_drag ) then
243 variableBottomDragPKGActive = .true.
244 end if
For bfb restarts, add the prognostic variables that are needed for restart to the restart stream in the Registry.xml file here:
1550 <stream name="restart"
Also, think carefully about which variables go into the state var_struct. Those should really only be the variables we have a prognostic equation for (i.e. use a time-stepping method to advance). All the other variables that are secondary should go into the diagnostic var_struct.
The difference is important because the state variables have 2 time levels for the timestepping, and the diagnostics only have one timelevel. From Registry:
1883 <var_struct name="state" time_levs="2">
...
2220 <var_struct name="diagnostics" time_levs="1">
so think carefully about what what variables belong in state. Those get double the memory, and that is needed for the time-stepping routines. The diagnostics are computed from the state variables, but only need a single instance in memory, for one time slice.
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 done in 2f63289 and 6693f2b. I think all the GOTM variables here need to be state variables rather than diagnostics variables as values from the previous time step are required to step GOTM forward.
Correct, you do not want to use a You can use the flag |
! initialize GOTM arrays at the first step | ||
! MPAS-O (1:nlev+1) <-> GOTM (nlev:0) | ||
if (first) then | ||
!$omp do schedule(runtime) |
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.
@qingli411 all our omp calls have changed format in #513. Please search for all !$omp lines in your PR and change to this:
!$omp parallel
!$omp do schedule(runtime) &
!$omp private(k, ki)
do iCell = 1, nCells
...
for all cell, edge, and vertex loops. The private variables are any index or scalar value assigned within the loop.
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.
Note that the first index (here iCell) is not in the private line on purpose. That is because openMP knows to run thread-parallel on that first loop.
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.
Initialization of the GOTM state variables are now in the init subroutine (see 7b00c93).
I also changed the format for the OpenMP directives. But since my knowledge of OpenMP is very limited I'm not sure whether it work with OpenMP... Here GOTM has its own initialization step (called in the subroutine ocn_vmix_gotm_init
), which allocates memory for a list of 1D arrays (vertical profiles of TKE, length scales, viscosity etc). Then I loop over all the MPAS-O cells to call GOTM to update these variables for each cell (the GOTM state variables allocated in MPAS-O).
gotmEpsbTopOfCellNew(k, iCell) = gotm_epsb(ki) | ||
end do | ||
end do | ||
!$omp end do |
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.
At the end of a cell, edge, or vertex loop, change all omp lines to:
!$omp end do
!$omp end parallel
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
@mark-petersen I have made the requested changes and run Here is my nightly test suite directory Output from the nightly regression suite
|
@qingli411 please compile with openmp on, i.e.
and you will see some mismatching |
@mark-petersen That should be fixed now. |
@qingli411 try to run the nightly regression suite with openmp on and debug. I get a floating invalid error:
note the line number is for *.f90, after the C-pre processor (use All this is printing to the screen.
You should remove all printing to the screen (print statements). If you want to keep verbose debug printing, use
where you can remove the |
You may need to set
in your window before running to test the omp lines properly. |
@mark-petersen OK I will do that. The printing to the screen is in the GOTM library... We will need to modify the GOTM repository to write that information to the log file. |
@mark-petersen With the above fix (7c8fc6e) the nightly regression suite with openmp on and debug fails on the Thread and Decomp tests with
See the output of the nightly regression suite here.
I guess some variables were not correctly initialized in the Thread tests. I have set |
@qingli411 thanks for your work on this. We don't want excessive output written, even to log files. Lines like |
@mark-petersen I understand that. But I don't think we have an easy way to control how GOTM writes out these messages as it is an external library. Same is for the way it reads in its own namelist. We will need to have a customized version of GOTM in MPAS-O if we want to have better control. |
Yes, I understand now. It is best to not customize GOTM, just use it straight. Are there actual Fortran print statements in GOTM? They don't have an internal verbose flag to shut them off? If every processor uses print, and we are using 1k to 10k processors, then GOTM would be completely unusable in E3SM. If so, please try to get GOTM to put the print statements within a CPP verbose flag. Even if it takes several months to go through, it's worth making an issue to them now. Also, better to work with them than split off your own version of the code. It's a really reasonable request. |
@mark-petersen I'm still in contact with the GOTM developers on possible better solutions. But, with their help, here (a603b7e) is a workaround to suppress the GOTM messages which only involves changing one line of code in GOTM. So I added the change in the Makefile. What do you think? |
Replace the meshPool interface with the ocn_mesh module within the GOTM driver file in MPAS-O
With the fix to the spacing Fortran Intrinsic issue.
67fb5bf
to
ca37c46
Compare
rebased. Passes nightly regression suite with gnu and intel, both debug, gotm off. Also tested QU240 with gotm on with both. |
Update mpas-source: add GOTM vertical mixing library Brings in a new mpas-source submodule with changes only to the ocean core, as well as bld file updates corresponding to Registry changes. It adds the General Ocean Turbulence Model (GOTM) in MPAS-Ocean as an additional option for the vertical turbulence closure, especially for coastal simulations in which the present implementation of KPP in CVMix does not work well. GOTM is a turbulence closure library that includes a set of two equation models such as k-epsilon and the generic length scale model (GLS; Umlauf and Burchard, 2003). See MPAS-Dev/MPAS-Model#704 GOTM is default off, but is compiled by E3SM. [NML] [BFB]
Update mpas-source: add GOTM vertical mixing library Brings in a new mpas-source submodule with changes only to the ocean core, as well as bld file updates corresponding to Registry changes. It adds the General Ocean Turbulence Model (GOTM) in MPAS-Ocean as an additional option for the vertical turbulence closure, especially for coastal simulations in which the present implementation of KPP in CVMix does not work well. GOTM is a turbulence closure library that includes a set of two equation models such as k-epsilon and the generic length scale model (GLS; Umlauf and Burchard, 2003). See MPAS-Dev/MPAS-Model#704 GOTM is default off, but is compiled by E3SM. [NML] [BFB]
MPAS-Dev/MPAS-Model#704 is needed for the GOTM test.
MPAS-Dev/MPAS-Model#704 is needed for the GOTM test.
GOTM in MPAS-Ocean MPAS-Dev#704 This PR adds the General Ocean Turbulence Model (GOTM) in MPAS-Ocean as an additional option for the vertical turbulence closure, especially for coastal simulations in which the present implementation of KPP in CVMix does not work well. GOTM is a turbulence closure library that includes a set of two equation models such as k-epsilon and the generic length scale model (GLS; Umlauf and Burchard, 2003).
GOTM in MPAS-Ocean MPAS-Dev#704
GOTM in MPAS-Ocean MPAS-Dev#704 This PR adds the General Ocean Turbulence Model (GOTM) in MPAS-Ocean as an additional option for the vertical turbulence closure, especially for coastal simulations in which the present implementation of KPP in CVMix does not work well. GOTM is a turbulence closure library that includes a set of two equation models such as k-epsilon and the generic length scale model (GLS; Umlauf and Burchard, 2003).
This PR adds the General Ocean Turbulence Model (GOTM) in MPAS-Ocean as an additional option for the vertical turbulence closure, especially for coastal simulations in which the present implementation of KPP in CVMix does not work well. GOTM is a turbulence closure library that includes a set of two equation models such as k-epsilon and the generic length scale model (GLS; Umlauf and Burchard, 2003).