Skip to content
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

Remove extra subroutine for all_reduce_min_max in mpi utilites #766

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions assimilation_code/modules/utilities/mpi_utilities_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
!> and allows programs to swap in the null version to compile the
!> same source files into a serial program.
!>
!> The names of these routines were intentionally picked to be
!> more descriptive to someone who doesn't the MPI interfaces.
!> e.g. MPI_AllReduce() may not immediately tell a user what
!> it does, but broadcast_minmax() is hopefully more helpful.
!>
!> If you add any routines or change any arguments in this file
!> you must make the same changes in the null version. These two
!> modules have the same module name and must have identical
Expand Down Expand Up @@ -138,9 +133,8 @@ module mpi_utilities_mod
task_sync, array_broadcast, send_to, receive_from, iam_task0, &
broadcast_send, broadcast_recv, shell_execute, sleep_seconds, &
sum_across_tasks, get_dart_mpi_comm, datasize, send_minmax_to, &
get_from_fwd, get_from_mean, broadcast_minmax, broadcast_flag, &
start_mpi_timer, read_mpi_timer, send_sum_to, get_global_max, &
all_reduce_min_max ! deprecated, replace by broadcast_minmax
get_from_fwd, get_from_mean, broadcast_flag, start_mpi_timer, &
read_mpi_timer, send_sum_to, get_global_max, all_reduce_min_max

character(len=*), parameter :: source = 'mpi_utilities_mod.f90'

Expand Down Expand Up @@ -1467,26 +1461,11 @@ end subroutine send_minmax_to

!-----------------------------------------------------------------------------

!> cover routine which is deprecated. when all user code replaces this
!> with broadcast_minmax(), remove this.

subroutine all_reduce_min_max(min_var, max_var, num_elements)

integer, intent(in) :: num_elements
real(r8), intent(inout) :: min_var(num_elements)
real(r8), intent(inout) :: max_var(num_elements)

call broadcast_minmax(min_var, max_var, num_elements)

end subroutine all_reduce_min_max

!-----------------------------------------------------------------------------

!> Find min and max of each element of an array, put the result on every task.
!> Overwrites arrays min_var, max_var with the minimum and maximum for each
!> element across all tasks.

subroutine broadcast_minmax(min_var, max_var, num_elements)
subroutine all_reduce_min_max(min_var, max_var, num_elements)

integer, intent(in) :: num_elements
real(r8), intent(inout) :: min_var(num_elements)
Expand All @@ -1502,7 +1481,7 @@ subroutine broadcast_minmax(min_var, max_var, num_elements)
call mpi_allreduce(MPI_IN_PLACE, min_var, num_elements, datasize, MPI_MIN, get_dart_mpi_comm(), errcode)
call mpi_allreduce(MPI_IN_PLACE, max_var, num_elements, datasize, MPI_MAX, get_dart_mpi_comm(), errcode)

end subroutine broadcast_minmax
end subroutine all_reduce_min_max

!-----------------------------------------------------------------------------
!> Broadcast logical
Expand Down
29 changes: 4 additions & 25 deletions assimilation_code/modules/utilities/mpif08_utilities_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
!> and allows programs to swap in the null version to compile the
!> same source files into a serial program.
!>
!> The names of these routines were intentionally picked to be
!> more descriptive to someone who doesn't the MPI interfaces.
!> e.g. MPI_AllReduce() may not immediately tell a user what
!> it does, but broadcast_minmax() is hopefully more helpful.
!>
!> If you add any routines or change any arguments in this file
!> you must make the same changes in the null version. These two
!> modules have the same module name and must have identical
Expand Down Expand Up @@ -138,9 +133,8 @@ module mpi_utilities_mod
task_sync, array_broadcast, send_to, receive_from, iam_task0, &
broadcast_send, broadcast_recv, shell_execute, sleep_seconds, &
sum_across_tasks, get_dart_mpi_comm, datasize, send_minmax_to, &
get_from_fwd, get_from_mean, broadcast_minmax, broadcast_flag, &
start_mpi_timer, read_mpi_timer, send_sum_to, get_global_max, &
all_reduce_min_max ! deprecated, replace by broadcast_minmax
get_from_fwd, get_from_mean, broadcast_flag, start_mpi_timer, &
read_mpi_timer, send_sum_to, get_global_max, all_reduce_min_max

character(len=*), parameter :: source = 'mpi_utilities_mod.f90'

Expand Down Expand Up @@ -1467,26 +1461,11 @@ end subroutine send_minmax_to

!-----------------------------------------------------------------------------

!> cover routine which is deprecated. when all user code replaces this
!> with broadcast_minmax(), remove this.

subroutine all_reduce_min_max(min_var, max_var, num_elements)

integer, intent(in) :: num_elements
real(r8), intent(inout) :: min_var(num_elements)
real(r8), intent(inout) :: max_var(num_elements)

call broadcast_minmax(min_var, max_var, num_elements)

end subroutine all_reduce_min_max

!-----------------------------------------------------------------------------

!> Find min and max of each element of an array, put the result on every task.
!> Overwrites arrays min_var, max_var with the minimum and maximum for each
!> element across all tasks.

subroutine broadcast_minmax(min_var, max_var, num_elements)
subroutine all_reduce_min_max(min_var, max_var, num_elements)

integer, intent(in) :: num_elements
real(r8), intent(inout) :: min_var(num_elements)
Expand All @@ -1502,7 +1481,7 @@ subroutine broadcast_minmax(min_var, max_var, num_elements)
call mpi_allreduce(MPI_IN_PLACE, min_var, num_elements, datasize, MPI_MIN, get_dart_mpi_comm(), errcode)
call mpi_allreduce(MPI_IN_PLACE, max_var, num_elements, datasize, MPI_MAX, get_dart_mpi_comm(), errcode)

end subroutine broadcast_minmax
end subroutine all_reduce_min_max

!-----------------------------------------------------------------------------
!> Broadcast logical
Expand Down
24 changes: 4 additions & 20 deletions assimilation_code/modules/utilities/null_mpi_utilities_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ module mpi_utilities_mod
task_sync, array_broadcast, send_to, receive_from, iam_task0, &
broadcast_send, broadcast_recv, shell_execute, sleep_seconds, &
sum_across_tasks, get_dart_mpi_comm, datasize, send_minmax_to, &
get_from_fwd, get_from_mean, broadcast_minmax, broadcast_flag, &
start_mpi_timer, read_mpi_timer, send_sum_to, get_global_max, &
all_reduce_min_max ! deprecated, replace by broadcast_minmax
get_from_fwd, get_from_mean, broadcast_flag, start_mpi_timer, &
read_mpi_timer, send_sum_to, get_global_max, all_reduce_min_max

character(len=*), parameter :: source = 'null_mpi_utilities_mod.f90'

Expand Down Expand Up @@ -432,32 +431,17 @@ end subroutine send_minmax_to

!-----------------------------------------------------------------------------

!> cover routine which is deprecated. when all user code replaces this
!> with broadcast_minmax(), remove this.

subroutine all_reduce_min_max(min_var, max_var, num_elements)

integer, intent(in) :: num_elements
real(r8), intent(inout) :: min_var(num_elements)
real(r8), intent(inout) :: max_var(num_elements)

call broadcast_minmax(min_var, max_var, num_elements)

end subroutine all_reduce_min_max

!-----------------------------------------------------------------------------

!> Find min and max of each element of an array across tasks, put the result on every task.
!> For this null_mpi_version min_var and max_var are unchanged because there is
!> only 1 task.

subroutine broadcast_minmax(min_var, max_var, num_elements)
subroutine all_reduce_min_max(min_var, max_var, num_elements)

integer, intent(in) :: num_elements
real(r8), intent(inout) :: min_var(num_elements)
real(r8), intent(inout) :: max_var(num_elements)

end subroutine broadcast_minmax
end subroutine all_reduce_min_max

!-----------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions models/FESOM/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module model_mod

use obs_kind_mod, only : get_index_for_quantity

use mpi_utilities_mod, only: my_task_id, broadcast_minmax, task_count
use mpi_utilities_mod, only: my_task_id, all_reduce_min_max, task_count

use fesom_modules, only: read_node, read_aux3, read_depth, read_namelist, &
nCells => myDim_nod2D, & ! number of surface locations
Expand Down Expand Up @@ -828,7 +828,7 @@ subroutine pert_model_copies(ens_handle, ens_size, pert_amp, interf_provided)
enddo

! get global min/max for each variable
call broadcast_minmax(min_var, max_var, num_variables)
call all_reduce_min_max(min_var, max_var, num_variables)
deallocate(within_range)

call init_random_seq(random_seq, my_task_id()+1)
Expand Down
4 changes: 2 additions & 2 deletions models/mpas_atm/model_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module model_mod
QTY_SURFACE_TYPE, & ! for rttov
QTY_CLOUD_FRACTION ! for rttov

use mpi_utilities_mod, only: my_task_id, broadcast_minmax
use mpi_utilities_mod, only: my_task_id, all_reduce_min_max

use random_seq_mod, only: random_seq_type, init_random_seq, random_gaussian

Expand Down Expand Up @@ -1812,7 +1812,7 @@ subroutine pert_model_copies(ens_handle, ens_size, pert_amp, interf_provided)
enddo

! get global min/max for each variable
call broadcast_minmax(min_var, max_var, num_variables)
call all_reduce_min_max(min_var, max_var, num_variables)
deallocate(within_range)

call init_random_seq(random_seq, my_task_id()+1)
Expand Down
Loading