Skip to content

Commit 6283fc5

Browse files
committed
dynamic real
1 parent e49cc24 commit 6283fc5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

test/basic.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ program basic
33
use mpi
44
use, intrinsic :: iso_fortran_env, only: stderr=>error_unit, compiler_version
55

6-
implicit none (type, external)
6+
implicit none
77

88
integer :: ierr
99

test/thread_pass.f90

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ program mpi_pass
1010

1111
implicit none
1212

13+
integer :: mpipasstype
14+
1315
integer :: mcount, ierr
1416
real :: dat(0:99), val(200)
1517
integer :: dest, i, num_procs, id, tag
@@ -18,6 +20,16 @@ program mpi_pass
1820
! type(MPI_STATUS) :: status
1921
integer :: status(MPI_STATUS_SIZE)
2022

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+
2133
call system_clock(tic)
2234

2335
call MPI_Init(ierr)
@@ -44,12 +56,12 @@ program mpi_pass
4456
select case (id)
4557
case (0)
4658
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)
4860
if (ierr /= MPI_SUCCESS) error stop "MPI_Recv failed"
4961

5062
! print '(i0,a,i0,a,i0)', id, ' Got data from processor ', status%MPI_SOURCE, ' tag ',status%MPI_TAG
5163

52-
call MPI_Get_count(status, MPI_REAL, mcount, ierr)
64+
call MPI_Get_count(status, mpipasstype, mcount, ierr)
5365
if (ierr /= MPI_SUCCESS) error stop "MPI_Get_count failed"
5466

5567
print '(i0,a,i0,a)', id, ' Got ', mcount, ' elements.'
@@ -64,7 +76,7 @@ program mpi_pass
6476

6577
dest = 0
6678
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)
6880
if(ierr /= MPI_SUCCESS) error stop "MPI_Send failed"
6981

7082
case default

0 commit comments

Comments
 (0)