Hello, everyone<br><br> I am modifying my program to be used in user-specified real precision such as single/double/quad precision.<br> I use Fortran (Intel fortran)<br> But when I make the following test program, it failed and reported as this,.<br>
Fatal error in PMPI_Bcast: Invalid datatype, error stack:<br>PMPI_Bcast(1301): MPI_Bcast(buf=0012FEE8, count=1, dtype=USER<f90_real>, root=0<br> MPI_COMM_WORLD) failed<br>PMPI_Bcast(1252): Datatype has not been committed<br>
<br><br> I searched the web but can find little about this MPI_TYPE_CREATE_F90_REAL,<br>Anyone can help me out?<br><br>Thank you.<br><br><br>ccccccccccccccccccccccccccccccccccccccccc<br><br> PROGRAM TEST<br> IMPLICIT NONE<br>
INCLUDE "MPIF.h"<br><br>C Define real type in different precision<br> INTEGER,PARAMETER::SP=SELECTED_REAL_KIND(6,37)<br> INTEGER,PARAMETER::DP=SELECTED_REAL_KIND(15,307)<br> INTEGER,PARAMETER::QP=SELECTED_REAL_KIND(33,4931)<br>
<br> INTEGER MYID,NUM_PROCS,IERR<br><br>C MPI REAL DATA TYPE<br> INTEGER MPI_REAL_SP,MPI_REAL_DP,MPI_REAL_QP<br><br> REAL(KIND=SP)::s<br> REAL(KIND=DP)::d<br> REAL(KIND=QP)::q<br><br>C Initialize MPI enviroment<br>
CALL MPI_INIT(IERR)<br><br>C get my Rank ID<br> CALL MPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)<br><br>C get the number of procs<br> CALL MPI_COMM_SIZE(MPI_COMM_WORLD,NUM_PROCS,IERR)<br><br>C Output the precision and range for each real type<br>
WRITE(6,10)PRECISION(1.0_SP),RANGE(1.0_SP),<br> & PRECISION(1.0_DP),RANGE(1.0_DP),<br> & PRECISION(1.0_QP),RANGE(1.0_QP)<br><br>C Define MPI REAL Type<br> CALL MPI_TYPE_CREATE_F90_REAL(6,MPI_UNDEFINED,MPI_REAL_SP,IERR)<br>
CALL MPI_TYPE_CREATE_F90_REAL(15,MPI_UNDEFINED,MPI_REAL_DP,IERR)<br> CALL MPI_TYPE_CREATE_F90_REAL(33,MPI_UNDEFINED,MPI_REAL_QP,IERR)<br><br> <br>c test real type<br> IF(MYID.EQ.0) THEN<br> s=1.0_SP<br>
d=2.0_DP<br> q=3.0_QP<br> END IF<br><br>c broadcast the above 3 values from master node<br> CALL MPI_BCAST(s,1,MPI_REAL_SP,0,MPI_COMM_WORLD,IERR)<br> CALL MPI_BCAST(d,1,MPI_REAL_DP,0,MPI_COMM_WORLD,IERR)<br>
CALL MPI_BCAST(q,1,MPI_REAL_QP,0,MPI_COMM_WORLD,IERR)<br><br>C output the result<br> PRINT*,'MyID=',MYID,' s=',s,' d=',d,' q=',q <br><br>C finish the mpi enviroment<br> CALL MPI_FINALIZE(IERR)<br>
<br> STOP<br><br>10 FORMAT('REAL PRECISION: SP(',I2,',',I4,')',1X,<br> & 'DP(',I2,',',I4,')',1X,<br> & 'QP(',I2,',',I4,')')<br>
<br> END <br><br>cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc<br>