Skip to content

Commit

Permalink
feat: modern_diag_manager add fms_diag_do_reduction (NOAA-GFDL#1321)
Browse files Browse the repository at this point in the history
  • Loading branch information
uramirez8707 authored and rem1776 committed May 1, 2024
1 parent 46a7907 commit dc30bb7
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 92 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ list(APPEND fms_fortran_src_files
diag_manager/fms_diag_elem_weight_procs.F90
diag_manager/fms_diag_fieldbuff_update.F90
diag_manager/fms_diag_bbox.F90
diag_manager/fms_diag_reduction_methods.F90
drifters/cloud_interpolator.F90
drifters/drifters.F90
drifters/drifters_comm.F90
Expand Down
7 changes: 6 additions & 1 deletion diag_manager/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ libdiag_manager_la_SOURCES = \
fms_diag_elem_weight_procs.F90 \
fms_diag_fieldbuff_update.F90 \
fms_diag_bbox.F90 \
fms_diag_reduction_methods.F90 \
include/fms_diag_fieldbuff_update.inc \
include/fms_diag_fieldbuff_update.fh

Expand All @@ -73,7 +74,8 @@ diag_table_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEX
fms_diag_yaml_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
fms_diag_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_file_object_mod.$(FC_MODEXT) fms_diag_field_object_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
fms_diag_time_utils_mod.$(FC_MODEXT) \
fms_diag_output_buffer_mod.$(FC_MODEXT)
fms_diag_output_buffer_mod.$(FC_MODEXT) \
fms_diag_reduction_methods_mod.$(FC_MODEXT)
fms_diag_field_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) \
fms_diag_axis_object_mod.$(FC_MODEXT)
fms_diag_file_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) fms_diag_field_object_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) \
Expand All @@ -89,6 +91,8 @@ diag_manager_mod.$(FC_MODEXT): diag_axis_mod.$(FC_MODEXT) diag_data_mod.$(FC_MOD
fms_diag_time_reduction_mod.$(FC_MODEXT) fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT)
fms_diag_output_buffer_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT)
fms_diag_reduction_methods_mod.$(FC_MODEXT): fms_diag_bbox_mod.$(FC_MODEXT) fms_diag_output_buffer_mod.$(FC_MODEXT) \
diag_data_mod.$(FC_MODEXT)

# Mod files are built and then installed as headers.
MODFILES = \
Expand Down Expand Up @@ -121,6 +125,7 @@ MODFILES = \
fms_diag_bbox_mod.$(FC_MODEXT) \
fms_diag_elem_weight_procs_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT) \
fms_diag_reduction_methods_mod.$(FC_MODEXT) \
include/fms_diag_fieldbuff_update.inc \
include/fms_diag_fieldbuff_update.fh

Expand Down
21 changes: 15 additions & 6 deletions diag_manager/diag_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ LOGICAL FUNCTION send_data_3d(diag_field_id, field, time, is_in, js_in, ks_in, &
endif
END FUNCTION send_data_3d
!> @return true if send is successful
!TODO documentation, seperate the old and new
LOGICAL FUNCTION diag_send_data(diag_field_id, field, time, is_in, js_in, ks_in, &
& mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
INTEGER, INTENT(in) :: diag_field_id
Expand All @@ -1629,7 +1630,7 @@ LOGICAL FUNCTION diag_send_data(diag_field_id, field, time, is_in, js_in, ks_in,
TYPE (time_type), INTENT(in), OPTIONAL :: time
INTEGER, INTENT(in), OPTIONAL :: is_in, js_in, ks_in,ie_in,je_in, ke_in
LOGICAL, DIMENSION(:,:,:), INTENT(in), OPTIONAL, contiguous, target :: mask
CLASS(*), DIMENSION(:,:,:), INTENT(in), OPTIONAL, target :: rmask
CLASS(*), DIMENSION(:,:,:), INTENT(in), OPTIONAL, contiguous, target :: rmask
CHARACTER(len=*), INTENT(out), OPTIONAL :: err_msg

REAL :: weight1
Expand Down Expand Up @@ -1664,6 +1665,9 @@ LOGICAL FUNCTION diag_send_data(diag_field_id, field, time, is_in, js_in, ks_in,
CHARACTER(len=128) :: error_string, error_string1

REAL, ALLOCATABLE, DIMENSION(:,:,:) :: field_out !< Local copy of field
class(*), pointer, dimension(:,:,:,:) :: field_remap !< 4d remapped pointer
logical, pointer, dimension(:,:,:,:) :: mask_remap !< 4d remapped pointer
class(*), pointer, dimension(:,:,:,:) :: rmask_remap !< 4d remapped pointer
REAL(kind=r4_kind), POINTER, DIMENSION(:,:,:) :: rmask_ptr_r4 !< A pointer to r4 type of rmask
REAL(kind=r8_kind), POINTER, DIMENSION(:,:,:) :: rmask_ptr_r8 !<A pointer to r8 type of rmask

Expand Down Expand Up @@ -1704,11 +1708,15 @@ LOGICAL FUNCTION diag_send_data(diag_field_id, field, time, is_in, js_in, ks_in,
IF ( fms_error_handler('diag_manager_mod::send_data_3d', err_msg_local, err_msg) ) RETURN
END IF
if (use_modern_diag) then !> Set up array lengths for remapping
field_modern => null()
field_remap => null()
mask_remap => null()
rmask_remap => null()
ie = SIZE(field,1)
je = SIZE(field,2)
ke = SIZE(field,3)
field_modern(1:ie,1:je,1:ke,1:1) => field
field_remap(1:ie,1:je,1:ke,1:1) => field
if (present(mask)) mask_remap(1:ie,1:je,1:ke,1:1) => mask
if (present(rmask)) rmask_remap(1:ie,1:je,1:ke,1:1) => rmask
endif
SELECT TYPE (field)
TYPE IS (real(kind=r4_kind))
Expand All @@ -1722,9 +1730,10 @@ LOGICAL FUNCTION diag_send_data(diag_field_id, field, time, is_in, js_in, ks_in,
END SELECT
! Split old and modern2023 here
modern_if: iF (use_modern_diag) then
send_data_3d = fms_diag_object%fms_diag_accept_data(diag_field_id, field_modern, time, is_in, js_in, ks_in, &
& mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
nullify (field_modern)
diag_send_data = fms_diag_object%fms_diag_accept_data(diag_field_id, field_remap, mask_remap, rmask_remap, &
time, is_in, js_in, ks_in, ie_in, je_in, ke_in, weight, &
err_msg)
nullify (field_remap)
elSE ! modern_if
! oor_mask is only used for checking out of range values.
ALLOCATE(oor_mask(SIZE(field,1),SIZE(field,2),SIZE(field,3)), STAT=status)
Expand Down
18 changes: 18 additions & 0 deletions diag_manager/fms_diag_axis_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ module fms_diag_axis_object_mod
contains
procedure :: fill_subaxis
procedure :: axis_length
procedure :: get_starting_index
procedure :: get_ending_index
END TYPE fmsDiagSubAxis_type

!> @brief Type to hold the diurnal axis
Expand Down Expand Up @@ -766,6 +768,22 @@ function axis_length(this) &
res = this%ending_index - this%starting_index + 1
end function

!> @brief Accesses its member starting_index
!! @return a copy of the starting_index
function get_starting_index(this) result(indx)
class(fmsDiagSubAxis_type), intent(in) :: this !< diag_sub_axis object
integer :: indx !< Result to return
indx = this%starting_index
end function get_starting_index

!> @brief Accesses its member ending_index
!! @return a copy of the ending_index
function get_ending_index(this) result(indx)
class(fmsDiagSubAxis_type), intent(in) :: this !< diag_sub_axis object
integer :: indx !< Result to return
indx = this%ending_index
end function get_ending_index

!> @brief Get the ntiles in a domain
!> @return the number of tiles in a domain
function get_ntiles(this) &
Expand Down
3 changes: 2 additions & 1 deletion diag_manager/fms_diag_field_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ pure function get_mask_variant (this) &
result(rslt)
class (fmsDiagField_type), intent(in) :: this !< diag object
logical :: rslt
rslt = this%mask_variant
rslt = .false.
if (allocated(this%mask_variant)) rslt = this%mask_variant
end function get_mask_variant

!> @brief Gets local
Expand Down
Loading

0 comments on commit dc30bb7

Please sign in to comment.