cc_staff
153
edits
m (Fortran 2008 updates) |
m (Fortran 2008 updates) |
||
Line 280: | Line 280: | ||
TYPE(MPI_Comm), INTENT(IN) :: comm | TYPE(MPI_Comm), INTENT(IN) :: comm | ||
INTEGER, INTENT(OUT) :: rank | INTEGER, INTENT(OUT) :: rank | ||
INTEGER, OPTIONAL, INTENT(OUT) :: | INTEGER, OPTIONAL, INTENT(OUT) :: ierr | ||
</source> | </source> | ||
</tab> | </tab> | ||
Line 368: | Line 368: | ||
use mpi_f08 | use mpi_f08 | ||
implicit none | |||
integer :: rank, size | integer :: rank, size | ||
Line 440: | Line 441: | ||
<type> MESSAGE(*) | <type> MESSAGE(*) | ||
INTEGER :: COUNT, DATATYPE, DEST, TAG, COMM, IERR | INTEGER :: COUNT, DATATYPE, DEST, TAG, COMM, IERR | ||
</source> | |||
</tab> | |||
<tab name="Fortran 2008"> | |||
<source lang="fortran"> | |||
MPI_Send(message, count, datatype, dest, tag, comm, ierr) | |||
TYPE(*), DIMENSION(..), INTENT(IN) :: message | |||
INTEGER, INTENT(IN) :: count, dest, tag | |||
TYPE(MPI_Datatype), INTENT(IN) :: datatype | |||
TYPE(MPI_Comm), INTENT(IN) :: comm | |||
INTEGER, OPTIONAL, INTENT(OUT) :: ierr | |||
</source> | </source> | ||
</tab> | </tab> | ||
Line 479: | Line 490: | ||
<type> :: MESSAGE(*) | <type> :: MESSAGE(*) | ||
INTEGER :: COUNT, DATATYPE, SOURCE, TAG, COMM, STATUS(MPI_STATUS_SIZE), IERR | INTEGER :: COUNT, DATATYPE, SOURCE, TAG, COMM, STATUS(MPI_STATUS_SIZE), IERR | ||
</source> | |||
</tab> | |||
<tab name="Fortran 2008"> | |||
<source lang="fortran"> | |||
MPI_Recv(message, count, datatype, source, tag, comm, status, ierr) | |||
TYPE(*), DIMENSION(..) :: message | |||
INTEGER, INTENT(IN) :: count, source, tag | |||
TYPE(MPI_Datatype), INTENT(IN) :: datatype | |||
TYPE(MPI_Comm), INTENT(IN) :: comm | |||
TYPE(MPI_Status) :: status | |||
INTEGER, OPTIONAL, INTENT(OUT) :: ierr | |||
</source> | </source> | ||
</tab> | </tab> | ||
Line 568: | Line 590: | ||
implicit none | implicit none | ||
use | use mpi | ||
integer, parameter :: BUFMAX=81 | integer, parameter :: BUFMAX=81 | ||
character(len=BUFMAX) :: outbuf, inbuf, tmp | character(len=BUFMAX) :: outbuf, inbuf, tmp | ||
Line 594: | Line 616: | ||
call MPI_FINALIZE(ierr) | call MPI_FINALIZE(ierr) | ||
end program phello2 | |||
}} | |||
</tab> | |||
<tab name="Fortran 2008"> | |||
{{File | |||
|name=phello2.f90 | |||
|lang="fortran" | |||
|contents= | |||
program phello2 | |||
implicit none | |||
use mpi_f08 | |||
integer, parameter :: BUFMAX=81 | |||
character(len=BUFMAX) :: outbuf, inbuf, tmp | |||
integer :: rank, num_procs | |||
integer :: sendto, recvfrom | |||
type(MPI_Status) :: status | |||
call MPI_Init() | |||
call MPI_Comm_rank(MPI_COMM_WORLD, rank) | |||
call MPI_Comm_size(MPI_COMM_WORLD, num_procs) | |||
outbuf = 'Hello, world! from process ' | |||
write(tmp,'(i2)') rank | |||
outbuf = outbuf(1:len_trim(outbuf)) // tmp(1:len_trim(tmp)) | |||
write(tmp,'(i2)') num_procs | |||
outbuf = outbuf(1:len_trim(outbuf)) // ' of ' // tmp(1:len_trim(tmp)) | |||
sendto = mod((rank + 1), num_procs) | |||
recvfrom = mod((rank + num_procs - 1), num_procs) | |||
call MPI_Send(outbuf, BUFMAX, MPI_CHARACTER, sendto, 0, MPI_COMM_WORLD) | |||
call MPI_Recv(inbuf, BUFMAX, MPI_CHARACTER, recvfrom, 0, MPI_COMM_WORLD, status) | |||
print *, 'Process', rank, ': Process', recvfrom, ' said:', inbuf | |||
call MPI_Finalize() | |||
end program phello2 | end program phello2 |