source: CIVL/examples/mpi/collective/factorial.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 556 bytes
RevLine 
[2b1f29a]1// online source: http://d3s.mff.cuni.cz/~ceres/sch/mwy/text/ch07s08s05.html
2#include <stdio.h>
3#include <string.h>
4#include <stdlib.h>
5
6#include <mpi.h>
7
8int main (int iArgC, char *apArgV [])
9{
10 int iOutput;
11 int iInput;
12 int iRank;
13
14 MPI_Init (&iArgC, &apArgV);
15 MPI_Comm_rank (MPI_COMM_WORLD, &iRank);
16 if (iRank == 0) iInput = 1;
17 else iInput = iRank;
18 MPI_Scan (&iInput, &iOutput, 1, MPI_INT, MPI_PROD, MPI_COMM_WORLD);
19 printf ("Process %d: Factorial %d\n", iRank, iOutput);
20 MPI_Finalize ();
21
22 return (0);
23}
Note: See TracBrowser for help on using the repository browser.