@@ -469,28 +469,28 @@ containing the largest value.
469469 ...
470470 ! each process has an array of 30 double: ain(30)
471471
472- DOUBLE PRECISION ain(30), aout(30)
473- INTEGER ind(30);
474- DOUBLE PRECISION in(2,30), out(2,30)
475- INTEGER i, myrank, root, ierr;
476-
477- MPI_COMM_RANK(MPI_COMM_WORLD, myrank);
478- DO I=1, 30
479- in(1,i) = ain(i)
480- in(2,i) = myrank ! myrank is coerced to a double
481- END DO
472+ DOUBLE PRECISION :: ain(30), aout(30)
473+ INTEGER :: ind(30)
474+ DOUBLE PRECISION :: in(2,30), out(2,30)
475+ INTEGER :: i, myrank, root, ierr
476+
477+ call MPI_COMM_RANK(MPI_COMM_WORLD, myrank)
478+ DO I=1, 30
479+ in(1,i) = ain(i)
480+ in(2,i) = myrank ! myrank is coerced to a double
481+ END DO
482482
483- MPI_REDUCE( in, out, 30, MPI_2DOUBLE_PRECISION, MPI_MAXLOC, root,
484- comm, ierr );
483+ call MPI_REDUCE( in, out, 30, MPI_2DOUBLE_PRECISION, MPI_MAXLOC, root, &
484+ comm, ierr )
485485 ! At this point, the answer resides on process root
486486
487- IF (myrank .EQ. root) THEN
488- ! read ranks out
489- DO I= 1, 30
490- aout(i) = out(1,i)
491- ind(i) = out(2,i) ! rank is coerced back to an integer
492- END DO
493- END IF
487+ IF (myrank == root) THEN
488+ ! read ranks out
489+ DO I= 1, 30
490+ aout(i) = out(1,i)
491+ ind(i) = out(2,i) ! rank is coerced back to an integer
492+ END DO
493+ END IF
494494
495495 **Example 5: ** Each process has a nonempty array of values. Find the
496496minimum global value, the rank of the process that holds it, and its
0 commit comments