Skip to content
Open
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
34 changes: 28 additions & 6 deletions external/RSL_LITE/module_dm.F
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,28 @@ INTEGER function getrealmpitype()
RETURN
END FUNCTION getrealmpitype

! internal, used below: the MPI pair type (value, rank) matching a REAL,
! for the MAXLOC and MINLOC reductions, which need a pair type
INTEGER function getreal2mpitype()
#ifndef STUBMPI
IMPLICIT NONE
INTEGER rtypesize, dtypesize, ierr
CALL mpi_type_size ( MPI_REAL, rtypesize, ierr )
CALL mpi_type_size ( MPI_DOUBLE_PRECISION, dtypesize, ierr )
IF ( RWORDSIZE .EQ. rtypesize ) THEN
getreal2mpitype = MPI_2REAL
ELSE IF ( RWORDSIZE .EQ. dtypesize ) THEN
getreal2mpitype = MPI_2DOUBLE_PRECISION
ELSE
CALL wrf_error_fatal ( 'RWORDSIZE or DWORDSIZE does not match any MPI type' )
END IF
#else
! required dummy initialization for function that is never called
getreal2mpitype = 1
#endif
RETURN
END FUNCTION getreal2mpitype

INTEGER FUNCTION wrf_dm_max_int ( inval )
IMPLICIT NONE
#ifndef STUBMPI
Expand Down Expand Up @@ -1419,11 +1441,11 @@ SUBROUTINE wrf_dm_maxval_real ( val, idex, jdex )
inreduce=(/ val, real(mytask) /)
bcast=(/ idex,jdex /)
CALL wrf_get_dm_communicator(comm)
call MPI_Allreduce(inreduce,outreduce,1,MPI_2REAL,&
call MPI_Allreduce(inreduce,outreduce,1,getreal2mpitype(),&
MPI_MAXLOC,comm,i)
mrank=outreduce(2)
val=outreduce(1)
call MPI_Bcast(bcast,2,MPI_REAL,mrank,comm,i)
call MPI_Bcast(bcast,2,MPI_INTEGER,mrank,comm,i)
idex=bcast(1)
jdex=bcast(2)
# else
Expand All @@ -1444,11 +1466,11 @@ SUBROUTINE wrf_dm_minval_real ( val, idex, jdex )
inreduce=(/ val, real(mytask) /)
bcast=(/ idex,jdex /)
CALL wrf_get_dm_communicator(comm)
call MPI_Allreduce(inreduce,outreduce,1,MPI_2REAL,&
call MPI_Allreduce(inreduce,outreduce,1,getreal2mpitype(),&
MPI_MINLOC,comm,i)
mrank=outreduce(2)
val=outreduce(1)
call MPI_Bcast(bcast,2,MPI_REAL,mrank,comm,i)
call MPI_Bcast(bcast,2,MPI_INTEGER,mrank,comm,i)
idex=bcast(1)
jdex=bcast(2)
# else
Expand All @@ -1474,7 +1496,7 @@ SUBROUTINE wrf_dm_maxval_doubleprecision ( val, idex, jdex )
MPI_MAXLOC,comm,i)
mrank=outreduce(2)
val=outreduce(1)
call MPI_Bcast(bcast,2,MPI_DOUBLE_PRECISION,mrank,comm,i)
call MPI_Bcast(bcast,2,MPI_INTEGER,mrank,comm,i)
idex=bcast(1)
jdex=bcast(2)
# else
Expand All @@ -1499,7 +1521,7 @@ SUBROUTINE wrf_dm_minval_doubleprecision ( val, idex, jdex )
MPI_MINLOC,comm,i)
mrank=outreduce(2)
val=outreduce(1)
call MPI_Bcast(bcast,2,MPI_DOUBLE_PRECISION,mrank,comm,i)
call MPI_Bcast(bcast,2,MPI_INTEGER,mrank,comm,i)
idex=bcast(1)
jdex=bcast(2)
# else
Expand Down