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

cleanup of mpp::get_peset function #1275

Merged
merged 2 commits into from
Aug 17, 2023
Merged
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
17 changes: 6 additions & 11 deletions mpp/include/mpp_util_mpi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ function get_peset(pelist)
integer, intent(in), optional :: pelist(:)
integer :: errunit
integer :: i, n
integer, allocatable :: sorted(:)

if( .NOT.PRESENT(pelist) )then !set it to current_peset_num
get_peset = current_peset_num; return
Expand All @@ -106,17 +105,14 @@ function get_peset(pelist)
enddo
endif

allocate( sorted(size(pelist(:))) )
sorted = pelist
errunit = stderr()
if( debug )write( errunit,* )'pelist=', pelist

!find if this array matches any existing peset
do i = 1,peset_num
if( debug )write( errunit,'(a,3i6)' )'pe, i, peset_num=', pe, i, peset_num
if( size(sorted(:)).EQ.size(peset(i)%list(:)) )then
if( ALL(sorted.EQ.peset(i)%list) )then
deallocate(sorted)
if( size(pelist(:)).EQ.size(peset(i)%list(:)) )then
if( ALL(pelist.EQ.peset(i)%list) )then
get_peset = i; return
end if
end if
Expand All @@ -126,14 +122,13 @@ function get_peset(pelist)
if( peset_num > current_peset_max ) call expand_peset()
i = peset_num !shorthand
!create list
allocate( peset(i)%list(size(sorted(:))) )
peset(i)%list(:) = sorted(:)
peset(i)%count = size(sorted(:))
allocate( peset(i)%list(size(pelist(:))) )
peset(i)%list(:) = pelist(:)
peset(i)%count = size(pelist(:))

call MPI_GROUP_INCL( peset(current_peset_num)%group, size(sorted(:)), sorted-mpp_root_pe(), peset(i)%group, error )
call MPI_GROUP_INCL( peset(current_peset_num)%group, size(pelist(:)), pelist-mpp_root_pe(), peset(i)%group, error )
call MPI_COMM_CREATE_GROUP(peset(current_peset_num)%id, peset(i)%group, &
DEFAULT_TAG, peset(i)%id, error )
deallocate(sorted)
get_peset = i

return
Expand Down