ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
fmpi_sane.f
Go to the documentation of this file.
1  program fmpi_sane
2 *
3 * This program checks to make sure that you can run a basic program
4 * on your machine using the Fortran77 interface to MPI.
5 * Can increase parameter wastesz, if you think size of executable
6 * is causing launching problem.
7 *
8  include 'mpif.h'
9  integer nproc, wastesz
10  parameter(nproc = 4)
11  parameter(wastesz = 100)
12  integer i, iam, np, ierr
13  integer mcom, wgrp, mgrp
14  integer irank(nproc), stat(mpi_status_size)
15  double precision wastespc(wastesz)
16 
17  call mpi_init(ierr)
18  call mpi_comm_size(mpi_comm_world, np, ierr)
19  if (np .lt. nproc) then
20  print*,'Not enough processes to run sanity check'
21  call mpi_abort(mpi_comm_world, -1, ierr)
22  end if
23 *
24 * Access all of WasteSpc
25 *
26  do 10 i = 1, wastesz
27  wastespc(i) = 0.0d0
28 10 continue
29 *
30 * Form context with NPROC members
31 *
32  do 20 i = 1, nproc
33  irank(i) = i - 1
34 20 continue
35  call mpi_comm_group(mpi_comm_world, wgrp, ierr)
36  call mpi_group_incl(wgrp, nproc, irank, mgrp, ierr)
37  call mpi_comm_create(mpi_comm_world, mgrp, mcom, ierr)
38  call mpi_group_free(mgrp, ierr)
39 *
40 * Everyone in new communicator sends a message to his neighbor
41 *
42  if (mcom .ne. mpi_comm_null) then
43  call mpi_comm_rank(mcom, iam, ierr)
44 *
45 * Odd nodes receive first, so we don't hang if MPI_Send is
46 * globally blocking
47 *
48  if (mod(iam, 2) .ne. 0) then
49  call mpi_recv(i, 1, mpi_integer, mod(nproc+iam-1, nproc),
50  & 0, mcom, stat, ierr)
51  call mpi_send(iam, 1, mpi_integer, mod(iam+1, nproc),
52  & 0, mcom, ierr)
53  else
54  call mpi_send(iam, 1, mpi_integer, mod(iam+1, nproc),
55  & 0, mcom, ierr)
56  call mpi_recv(i, 1, mpi_integer, mod(nproc+iam-1, nproc),
57  & 0, mcom, stat, ierr)
58  end if
59 *
60 * Make sure we've received the right information
61 *
62  if (i .ne. mod(nproc+iam-1, nproc)) then
63  print*,'Communication does not seem to work properly!!'
64  call mpi_abort(mpi_comm_world, -1, ierr)
65  end if
66  end if
67 
68  print*,iam,' F77 MPI sanity test passed.'
69  call mpi_finalize(ierr)
70 
71  stop
72  end
fmpi_sane
program fmpi_sane
Definition: fmpi_sane.f:1