/* data output samle program * file: sample.c * make: cc -64 sample.c out.o -lmpi * run: mpirun -np 4 ./a.out * check: cat out.txt * function ffopen(I) 1. open a file 'out.txt' with append mode. 2. put the current wallclock time in the file, then flush. 3. if a file open error happens, return 1. * function ffput(int* A, int n) 1. put the whole contents of an array 'A' in the file, then flush. the size of A is n. 2. if the address of A is NULL, then return 1. * function ffclose() 1. put the current wallclock time in the file, then flush. 2. close the file. 3. if a file close error happens, return 1. * M.Yuko@SuperCon2003(7.25) */ #include #include #define N 5 int ffopen(); int ffput(int*, int); int ffclose(); main(int argc, char *argv[]) { int num_procs; int my_proc; int a[N]; int i, j; int root=0; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &num_procs); MPI_Comm_rank(MPI_COMM_WORLD, &my_proc); if(my_proc == root) ffopen(); /* called after MPI intialization */ for(i = 0; i < N; i++) a[i] = -11; if(my_proc == root) ffput(a, N); /* called anytime */ if (my_proc == root) { for(i=0;i