update new files
[unres.git] / source / maxlik / src-Fmatch / sendrecv.f
1       program main
2       include 'mpif.h'
3       integer rank, size, to, from, tag, count, i, ierr
4       integer src, dest
5       integer st_source, st_tag, st_count
6       integer status(MPI_STATUS_SIZE)
7       double precision data(100)
8
9       call MPI_INIT( ierr )
10       call MPI_COMM_RANK( MPI_COMM_WORLD, rank, ierr )
11       call MPI_COMM_SIZE( MPI_COMM_WORLD, size, ierr )
12       print *, 'Process ', rank, ' of ', size, ' is alive'
13       dest = size - 1
14       src = 0
15       if (rank .eq. src) then
16          to     = dest
17          count  = 10
18          tag    = 2001
19          do 10 i=1, 10
20  10         data(i) = i
21          call MPI_SEND( data, count, MPI_DOUBLE_PRECISION, to,
22      +                   tag, MPI_COMM_WORLD, ierr )
23       else if (rank .eq. dest) then
24          tag   = MPI_ANY_TAG
25          count = 10
26          from  = MPI_ANY_SOURCE
27          call MPI_RECV( data, count, MPI_DOUBLE_PRECISION, from,
28      +                  tag, MPI_COMM_WORLD, status, ierr )
29          print *, rank, ' received', (data(i),i=1,10)
30       endif
31
32       call MPI_FINALIZE( ierr )
33       end