@@ -10,6 +10,8 @@ program mpi_pass
10
10
11
11
implicit none
12
12
13
+ integer :: mpipasstype
14
+
13
15
integer :: mcount, ierr
14
16
real :: dat(0 :99 ), val(200 )
15
17
integer :: dest, i, num_procs, id, tag
@@ -18,6 +20,16 @@ program mpi_pass
18
20
! type(MPI_STATUS) :: status
19
21
integer :: status (MPI_STATUS_SIZE)
20
22
23
+
24
+ if (storage_size(dat) == 32 ) then
25
+ mpipasstype = MPI_REAL
26
+ else if (storage_size(dat) == 64 ) then
27
+ mpipasstype = MPI_DOUBLE_PRECISION
28
+ else
29
+ error stop " Unsupported data type size"
30
+ endif
31
+
32
+
21
33
call system_clock (tic)
22
34
23
35
call MPI_Init(ierr)
@@ -44,12 +56,12 @@ program mpi_pass
44
56
select case (id)
45
57
case (0 )
46
58
print * , id, " waiting for MPI_send() from image 1"
47
- call MPI_Recv (val, size (val), MPI_REAL , MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, status, ierr)
59
+ call MPI_Recv (val, size (val), mpipasstype , MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, status, ierr)
48
60
if (ierr /= MPI_SUCCESS) error stop " MPI_Recv failed"
49
61
50
62
! print '(i0,a,i0,a,i0)', id, ' Got data from processor ', status%MPI_SOURCE, ' tag ',status%MPI_TAG
51
63
52
- call MPI_Get_count(status, MPI_REAL , mcount, ierr)
64
+ call MPI_Get_count(status, mpipasstype , mcount, ierr)
53
65
if (ierr /= MPI_SUCCESS) error stop " MPI_Get_count failed"
54
66
55
67
print ' (i0,a,i0,a)' , id, ' Got ' , mcount, ' elements.'
@@ -64,7 +76,7 @@ program mpi_pass
64
76
65
77
dest = 0
66
78
tag = 55
67
- call MPI_Send(dat, size (dat), MPI_REAL , dest, tag, MPI_COMM_WORLD, ierr)
79
+ call MPI_Send(dat, size (dat), mpipasstype , dest, tag, MPI_COMM_WORLD, ierr)
68
80
if (ierr /= MPI_SUCCESS) error stop " MPI_Send failed"
69
81
70
82
case default
0 commit comments