minimal_mpi_variablenp_test.cc File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "mpi.h"

Functions

int main (int argc, char **argv)
 Minimal mpi self test for varying number of processors. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Minimal mpi self test for varying number of processors.

39 {
40 
41  int myid, numprocs;
42 
43  MPI_Init(&argc,&argv);
44  MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
45  MPI_Comm_rank(MPI_COMM_WORLD,&myid);
46 
47  std::stringstream filename_stringstream;
48  filename_stringstream
49  << "mpi_seltest_np" <<numprocs << "rank" << myid;
50 
51  std::ofstream myfile;
52  myfile.open(filename_stringstream.str().c_str());
53 
54  myfile << "This worked" << std::endl;
55  myfile.close();
56 
57  MPI_Finalize();
58 
59  return 0;
60 } //end of main