Move some parts of btstep() into subroutines #845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modularize btstep
This PR moves some parts of
btstep()
into subroutines:btstep_ubt_from_layer
btstep_find_Cor
btloop_setup
btloop_setup_eta
btloop_setup_OBCs
btloop_update_v
btloop_update_u
btstep_layer_accel
This eliminates the duplication of the u and v update code in the bt loop, but preserves the
BT_USE_OLD_CORIOLIS_BRACKET_BUG
in the update when v is done second.The creation of these subroutines should not change answers. I have tested it in the Baltic OM4 0.25 case with
BT_USE_OLD_CORIOLIS_BRACKET_BUG
bothTrue
andFalse
.Each routine has many arguments and I have tried to correctly label them
intent(in)
orintent(inout)
as appropriate. Some variables did not have clear comments describing them in this module (ex.use_BT_cont
orjsvf
), so I have not put doxygen comments describing them in this commit. These can be added when I address the review.The short description of each routine is:
btstep_ubt_from_layer
: Calculate the zonal and meridional velocity from the 3-D velocity.btstep_find_Cor
: Find the Coriolis force terms _zon and _mer.btloop_setup
: Set ubt, vbt, eta, find face areas, and set valid array size at the beginning of each barotropic loop.btloop_setup_eta
: A routine to set eta_pred and the running time integral of uhbt and vhbt.btloop_setup_OBCs
: Setup old or previous ubt, vbt, vbt, and vhbt for different OBC options before the next step in the btstep loop.btloop_update_v
: Update meridional velocity.btloop_update_u
: Update zonal velocity.btstep_layer_accel
: Calculate the zonal and meridional acceleration of each layer due to the barotropic calculation.