-
Notifications
You must be signed in to change notification settings - Fork 138
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
The send_data math (field buffer update) functions. #1131
Conversation
also corrected new #define typo from last pull.
the lagacy diag_manager. Adds a refactored version of send_data_3d, modified the buffer bounds checking functions, and necessary changes in diag_data and diag_util.
…cs.F90). Fixed CMakeLists.txt; cleaned up fms_diag_outfield_mod.
bointer remapping; plus moving back to original interface some diag_manager.F90 routines. Also removing send_dada_3d_refac() routine from diag_manager.F90.
…rue. Fixes bug of incorrect pointer bounds remapping (switching order of last two coordinates).
sned_data_3d and missing some documentation.
…into send_math_legacy_plus
unit test has the appropriate set access to private fields.
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 still think you should remove modern
from the names of the "modern" functions. If you want to use legacy
for the old ones, I supposed that can be acceptable. There are some other comments/changes that need to be done still.
diag_manager/diag_manager.F90
Outdated
TYPE(fmsDiagOutfield_type), ALLOCATABLE:: ofield_cfg !<Instance used in calling math funcsions. | ||
LOGICAL :: mf_result !<Logical result returned from some math (buffer udate) functions. | ||
LOGICAL, DIMENSION(1,1,1), target :: mask_dummy | ||
REAL :: rmask_threshold |
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.
what is this? Should it be a parameter?
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 the current diag_manager send_data_3d, there are several uses of magic numbers 0.5_r4_kind and 0.5_r8_kind. The same value, whatever it is, needs to be passed to one of the math functions. I used READ rmask_threshold to hold and pass the value being used. I will update comments.
diag_manager/diag_util.F90
Outdated
module procedure fms_update_bounds_legacy | ||
module procedure fms_update_bounds_modern |
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.
Did we discuss this in an email? The modern and legacy still irk me.
diag_manager/diag_util.F90
Outdated
!! of the "array" argument and store it the bounding box argument "bounds" | ||
SUBROUTINE fms_bounds_from_array_4D(bounds, array) | ||
REAL, INTENT( in), DIMENSION(:,:,:,:) :: array !< The 4D input array. | ||
TYPE (fms_diag_ibounds_type), INTENT(inout) :: bounds !< The instance of the bounding box. |
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.
Why can't this be the constructor function? If you move this to diag_data, then the variables could be private.
diag_manager/diag_util.F90
Outdated
!> @brief Update the the first three (normally x, y, and z) min and | ||
!! max boundaries (array indices) of the input bounding box "bounds" with | ||
!! the six specified bounds values. | ||
SUBROUTINE fms_update_bounds_modern(bounds, lower_i, upper_i, lower_j, upper_j, lower_k, upper_k) |
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 still don't like this name. We are going to have to go through and change this in the future. And by that time, everyone will forget.
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:) :: field_ptr => null()!< Pointer to the field | ||
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:,:) :: ofb_ptr => null()!< Pointer to the outfield buffer. | ||
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:,:) :: ofc_ptr => null()!< Pointer to the outfield counter. | ||
LOGICAL , pointer, DIMENSION(:,:,:,:) :: mask_ptr => null()!< Pointer to the mask. |
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.
We need to talk about these. It turns out there is an implied save here.
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 =>null()
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:) :: field_ptr => null() !< Pointer to the field | ||
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:,:) :: ofb_ptr => null() !< Pointer to the outfield buffer. | ||
LOGICAL , pointer, DIMENSION(:,:,:,:) :: mask_ptr => null() !< !< Pointer to the mask. |
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.
We need to discuss these also...
!> @brief This code will be used by the preprecessor to generate an implementation | ||
!! to the module procudure for the fieldbuff_copy_fieldvals interface. | ||
!! The function may set or add to the output field buffer (argument ofb) with the input | ||
!! field data array (argument field) |
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.
Yes but will that show up as the result when the doxygen documentation is created?
diag_manager/diag_util.F90
Outdated
bounds%kmax = UBOUND(array,3) | ||
END SUBROUTINE fms_bounds_from_array_4D | ||
|
||
!> @brief Determine the bounds of the first three dimentions |
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.
typo in dimentions
diag_manager/diag_util.F90
Outdated
|
||
CHARACTER(len=128) :: error_string1, error_string2 | ||
LOGICAL :: lims_not_exact = .true. |
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.
Does it imply save on lims_not_exact ?
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.
Yes, this should be:
LOGICAL :: lims_not_exact
lims_not_exact = .true.
OR you don't need it at all because 2 lines down, you are setting lims_not_exact
anyway. Are you trying to save this variable for next time?
fms_diag_fieldbuff_update.fh; and added TODO: with explanation. Added to diag manager namelist. Fixed some comments as per PR review.
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.
If you are going to insist on leaving the variables in fmsDiagIbounds_type public, then it needs to be documented in the code why they are public.
(fms_diag_fieldbuff_update.fh, diang_manager.F90)Please remove => null()
on any new pointers that are initialized when they are declared:
type(something), pointer :: var => null()
Instead do something like this:
type(something), pointer :: var
var => null()
This is a question about the variable lims_not_exact
that should be addressed
Please add a TODO for the integer pow_value
so we can discuss it with the rewrite
There still some doxygen that needs to be addressed in fms_diag_fieldbuff_update.fh
diag_manager/diag_data.F90
Outdated
INTEGER :: imin !< Lower i bound. | ||
INTEGER :: imax !< Upper i bound. | ||
INTEGER :: jmin !< Lower j bound. | ||
INTEGER :: jmax !< Upper j bound. | ||
INTEGER :: kmin !< Lower k bound. | ||
INTEGER :: kmax !< Upper k bound. |
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 add documentation about why these variables are public because it goes against the FMS coding standards.
LOGICAL, DIMENSION(:,:,:), INTENT(in), OPTIONAL :: mask | ||
CLASS(*), DIMENSION(:,:,:), INTENT(in), OPTIONAL :: rmask | ||
LOGICAL, DIMENSION(:,:,:), INTENT(in), OPTIONAL, contiguous, target :: mask | ||
CLASS(*), DIMENSION(:,:,:), INTENT(in), OPTIONAL, target :: rmask | ||
CHARACTER(len=*), INTENT(out), OPTIONAL :: err_msg | ||
|
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.
@ganganoaa We don't require updating old code/variables. It's too onerous on developers because, like you said, it's not obvious what some of the variables are.
diag_manager/diag_manager.F90
Outdated
REAL(kind=r4_kind), POINTER, DIMENSION(:,:,:) :: rmask_ptr_r4 => null() !< A pointer to r4 type of rmask | ||
REAL(kind=r8_kind), POINTER, DIMENSION(:,:,:) :: rmask_ptr_r8 => null() !<A pointer to r8 type of rmask |
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.
Remove the => null()
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 still needs to be fixed
diag_manager/diag_util.F90
Outdated
|
||
CHARACTER(len=128) :: error_string1, error_string2 | ||
LOGICAL :: lims_not_exact = .true. |
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.
Yes, this should be:
LOGICAL :: lims_not_exact
lims_not_exact = .true.
OR you don't need it at all because 2 lines down, you are setting lims_not_exact
anyway. Are you trying to save this variable for next time?
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:) :: field_ptr => null()!< Pointer to the field | ||
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:,:) :: ofb_ptr => null()!< Pointer to the outfield buffer. | ||
FMS_DIAG_FBU_DATA_TYPE_ , pointer, DIMENSION(:,:,:,:,:) :: ofc_ptr => null()!< Pointer to the outfield counter. | ||
LOGICAL , pointer, DIMENSION(:,:,:,:) :: mask_ptr => null()!< Pointer to the mask. |
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 =>null()
@@ -0,0 +1,31 @@ | |||
#undef FMS_DIAG_FBU_DATA_TYPE_ |
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.
@mlee03 can you look at this and make sure it's following your standards.
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.
We've been using "kind" macros instead of "type", e.g, FMS_DIAG_FBU_DATA_KIND_ r4_kind
. Also we put the macro definitions in the _r4.fh and _r8.fh files (separate files for r4 and r8_kind); the code went into the *.inc files.
@@ -0,0 +1,31 @@ | |||
#undef FMS_DIAG_FBU_DATA_TYPE_ |
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.
We've been using "kind" macros instead of "type", e.g, FMS_DIAG_FBU_DATA_KIND_ r4_kind
. Also we put the macro definitions in the _r4.fh and _r8.fh files (separate files for r4 and r8_kind); the code went into the *.inc files.
@@ -0,0 +1,31 @@ | |||
#undef FMS_DIAG_FBU_DATA_TYPE_ |
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.
We also put in the GNU Lesser General Public License stuff in the *inc and *fh files
data members of fmsDiagIbounds_type.
These items from @thomas-robinson were addressed in the push of 1PM today; but for exception of the doxygen that needs to be addressed in fms_diag_fieldbuff_update.fh, which is coming shortly. |
fms_diag_fieldbuff_update.fh
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.
These are the specific places that needs to be addressed. There may be more => null()
too.
diag_manager.F90 L1494 1495 need to remove the => null()
diag_util.F90 L1048 the lims_not_exact
variable should not be initialized. See the comment in the review.
fms_diag_fieldbuff_update.fh L882 Needs a doxygen documentation
diag_manager/diag_manager.F90
Outdated
REAL(kind=r4_kind), POINTER, DIMENSION(:,:,:) :: rmask_ptr_r4 => null() !< A pointer to r4 type of rmask | ||
REAL(kind=r8_kind), POINTER, DIMENSION(:,:,:) :: rmask_ptr_r8 => null() !<A pointer to r8 type of rmask |
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 still needs to be fixed
declaration line, and some missing comments.
Description
This PR is largely for the field buffer updating math routines to be when selected in
a namelist option in the legacy diag manager. Key parts of the presented code is
intend to supports the modern diag manager out of the box.
Functionality that was originally in send_data_3d was refactored and moved
to their own functions. The added capability of for direct 3D and 4D fields (with
corresponding 4D and 5D) buffers used in the legacy and modern diag manager, respectively.
The functions support R4, R8, I4 and I8 fields and buffers (matching in type) ,
Integer versions of the functions are not allowed in the legacy diag manager and
are commented out for this review .
Most of the code refactored from send_data_3d is in these files:
1. fms_diag_fieldbuff_update.F90
2. include/fms_diag_fieldbuff_update.inc
3. include/fms_diag_fieldbuff_update.fh
To allow the math functions to work with both the legacy and the modern diag_manager,
some refactoring of bounds checking functions was also necessary. This was used also
as an opportunity to remove repetitive code, and some utilities related to array index bounding boxes were introduced. These functions are largely in diag_util.F90
Some conventions:
Some of the code has comments that begin with !TODO: .Those that on the same line also have
text (MDM) , I expect that they be resolved in the modern diag manager.
Some missed opportunities :
remove the copy of the field array used in send_data_3d that was introduced in the EMC mixed mode merge.
There were issues implementing this (see this would have removed the innermost if/then/else construct in the buffer update loops. See fms_diag_outfield_type in file fms_daig_outfield.F90.
Fixes # (issue)
How Has This Been Tested?
All former unit tests pass. More unit tests were added. Regression tests are to be done.
Checklist:
make distcheck
passes