Refactor OBC segment init/update (Part 1)#1053
Open
herrwang0 wants to merge 3 commits intoNOAA-GFDL:dev/gfdlfrom
Open
Refactor OBC segment init/update (Part 1)#1053herrwang0 wants to merge 3 commits intoNOAA-GFDL:dev/gfdlfrom
herrwang0 wants to merge 3 commits intoNOAA-GFDL:dev/gfdlfrom
Conversation
This commit changes the indexing variables in open boundary routine update_OBC_segment_data, so that they are consistent with the rest of the model. The changes improve readability and prepares moving part of the subroutine to initialize_segment_data. The changes includes, * Use [ij][se]d and [IJ][se]dB aliases for indexings in segment%HI * Replace [ij][se]_obc with [IJ][se]dB * For interior cells, retire [ij]shift and use [ij]sd that are already saved in segment%HI Other minor changes: * Add a comment that segment%Cg is never used by the model * Change normal_trans_bt in update_OBC_segment_data from an allocatable array to a scalar
This commit moves allocating buffer_dst array of segment%field type to routine initialize_segment_data from update_OBC_segment_data. This array is always allocated and exits in the duration of the run. It makes more sense to have the allocation occur in the init subroutine, than a routine called every time step. Other changes * Simplify remapping_core_h call in update_OBC_segment_data. * make dz_stack a fix-sized array than an allocatable
765ba50 to
59a219a
Compare
This commit moves out all allocations from initialize_segment_data to a
new subroutine allocate_segment_field_data, which includes buffer_src
and buffer_dst. allocate_segment_field_data always assigns other
attributes of segment%field, including "on_face", "scale", "use_IO"
Minor updates
* Remove OBC%thickness_segment_data_exists, which is never used.
* Change string "genre" in segment%field to logical "bgc_tracer"
* Remove GV input (unused) from subroutine scale_factor_from_name
* Rename local variables in initialize_segment_data for clarity
* fields -> field_names
* fieldname -> varname
59a219a to
5e369f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This PR is the first one of a series of PRs on OBC refactor, targeting how segment data is initialized and updated, specifically subroutines
initialize_segment_dataandupdate_OBC_segment_data. The work is broken down to three parts to hopefully make review easier.The refactor is driven by a bug in the OBC where segment data fails to update correctly when using the
VALUEoption. This specific issue will be addressed in the last part of this series.Changes in this PR
This PR contains three incremental, compartmentalized commits. While the commit messages provide granular details, here is a summary of their objectives:
d8d4bf3 Renames indexing variables in
update_OBC_segment_datato match the rest of the module. This improves consistency and simplifies the migration of logic into the subroutine toinitialize_segment_data.b55e0a6 Moves the allocation of
buffer_dstarrays fromupdate_OBC_segment_datatoinitialize_segment_data. Since these arrays are always allocated, they are more appropriately handled during the initialization phase.fa220e4 Extracts the allocations of both
buffer_dstandbuffer_srcarrays out of the main body ofinitialize_segment_data. This improves readability and prepares for separating physical and BGC fields in the next PR.Each commit is tested to be compilable and introduces no answer change.