Skip to content

Commit

Permalink
Adopted suggestions from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
atrayano committed Jan 7, 2025
1 parent 02f3794 commit 4916c93
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions base/MAPL_MaxMinMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ subroutine pmaxmin2d_r4 ( qname, a, pmin_, pmax_, fac_ )
!NOTE: the current version does not trap error conditions returned in status
integer :: status
integer :: comm
logical :: has_nans, hn
logical :: has_nans
logical :: has_nans_local
character(len=:), allocatable :: buf

if ( present(fac_) ) then
fac = fac_
Expand All @@ -87,7 +89,7 @@ subroutine pmaxmin2d_r4 ( qname, a, pmin_, pmax_, fac_ )

call ESMF_VmGetCurrent(vm=vm, rc=status)

has_nans = any(a /= a)
has_nans_local = any(a /= a)

pmin = minval(a, mask=(a==a))
pmax = maxval(a, mask=(a==a))
Expand All @@ -102,20 +104,19 @@ subroutine pmaxmin2d_r4 ( qname, a, pmin_, pmax_, fac_ )
if ( present(pmin_) ) pmin_ = pmin

call ESMF_VmGet(VM, mpicommunicator=comm, rc=status)
call MPI_Reduce(has_nans, hn, 1, MPI_LOGICAL, MPI_LOR, 0, comm, status)
! call MPI_Reduce(sendbuf=has_nans, recvbuf=hn, count=1, &
call MPI_Reduce(has_nans_local, has_nans, 1, MPI_LOGICAL, MPI_LOR, 0, comm, status)
! call MPI_Reduce(sendbuf=MPI_IN_PLACE, recvbuf=has_nans, count=1, &
! datatype=MPI_LOGICAL, op=MPI_LOR, root=0, comm=comm, ierror=status)

if ( fac /= 0.0 ) then ! trick to prevent printing
if ( MAPL_am_I_root(vm) ) then
name = ' '
name(1:len(qname)) = qname
if (hn) then
write(*,*) name, ' max = ', pmax*fac, ' min = ', pmin*fac, &
' has NaN'
else
write(*,*) name, ' max = ', pmax*fac, ' min = ', pmin*fac
buf = ""
if (has_nans) then
buf = " has NaN"
end if
write(*,*) name, ' max = ', pmax*fac, ' min = ', pmin*fac, buf
return
end if
end if
Expand Down

0 comments on commit 4916c93

Please sign in to comment.