49 PetscOptionsSetValue(PETSC_NULL,
"-options_left",
"0");
55 err = PetscInitialize(0, 0, 0, 0);
57 MPI_Init(&argc, &argv);
62 flags = ceps::getNew<Flags>(argc,argv);
66 std::cout << std::endl;
68 CepsString toWrite =
" CEPS : Cardiac ElectroPhysiology Simulator";
70 std::cout << toWrite << std::setw(length) << std::right <<
",d88b.d88b," << std::endl;
71 toWrite =
" (" +
CepsString(CEPS_GIT_HASH) +
")";
73 std::cout << toWrite << std::setw(length) << std::right <<
"88888888888" << std::endl;
76 std::cout << toWrite << std::setw(length) << std::right <<
"`Y8888888Y'" << std::endl;
79 std::cout << toWrite << std::setw(length) << std::right <<
"`Y888Y' " << std::endl;
81 gethostname(hn, 1024);
84 std::cout << toWrite << std::setw(length) << std::right <<
"`Y' " << std::endl;
85 #ifdef CEPS_DEBUG_ENABLED
86 std::cout << std::endl;
87 std::cout <<
" CEPS was compiled in Debug mode." << std::endl;
88 std::cout <<
" Debug information can be found in file: " <<
flags->
getDebugLogName() << std::endl;
92 std::cout << std::endl;
93 std::cout <<
" Profiling is ON." << std::endl;
111 std::cout <<
" Computation done, see you soon !" << std::endl;
115 #ifdef CEPS_USE_PETSC
127 std::exception_ptr eptr = std::current_exception();
131 std::rethrow_exception(eptr);
138 #ifdef CEPS_DEBUG_ENABLED
147 std::cerr <<
"<!> Wrong termination <!>" << std::endl;
158 #ifdef CEPS_USE_PETSC
159 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
161 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
170 #ifdef CEPS_USE_PETSC
171 MPI_Comm_size(PETSC_COMM_WORLD,&gridSize);
173 MPI_Comm_size(MPI_COMM_WORLD ,&gridSize);
200 #ifdef CEPS_USE_PETSC
201 PetscBarrier(PETSC_NULL);
203 MPI_Barrier(MPI_COMM_WORLD);
211 std::cout <<
"Begin Round Robin (sequential block)" << std::endl;
213 #ifdef CEPS_USE_PETSC
214 PetscSequentialPhaseBegin(PETSC_COMM_WORLD,1);
218 for (i=0; i<rank; i++)
226 #ifdef CEPS_USE_PETSC
227 PetscSequentialPhaseEnd(PETSC_COMM_WORLD,1);
230 for (i=
getRank(); i<nbProc; i++)
236 std::cout << std::endl <<
"End Round Robin" << std::endl << std::endl;
248 #ifdef CEPS_USE_PETSC
249 return &PETSC_COMM_WORLD;
251 return &MPI_COMM_WORLD;
264 const int bufsize=128;
265 std::array<char, bufsize> buffer;
266 auto pipe = popen(command.c_str(),
"r");
275 if ((count = fread(buffer.data(),1,bufsize,pipe))>0)
276 output.insert(output.end(),std::begin(buffer),std::next(std::begin(buffer),count));
278 notOkExec = pclose(pipe);
280 if (not pipe or notOkExec)
283 "Failed system call:\n " + command
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
#define CEPS_SEPARATOR_LENGTH
std::basic_string< CepsChar > CepsString
C++ format string.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
int32_t CepsInt
Need 32 bit integer.
Flags * flags
Global variable, used in every application.
CepsString errorMessage(CepsBool color=true) const
Nice display of error.
CepsBool testing() const
Tells if currently running in a test suite (switched in CepsGlobalFixture.hpp)
CepsString getDebugLogName() const
Name has the form debug_PID.log (PID of master node)
CepsString getProfilingLogName() const
Name has the form profiling_PID.log (PID of master node)
CepsString execute(CepsString command, CepsBool withErr=false, CepsBool abortOnErr=false)
Not really a parallel thing. Calls system() and deals with return code.
CepsUInt getRank()
Returns current processor rank.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
CepsBool isVerbose()
Check if the verbosity is enabled on the master proc (always false on slave procs).
MPI_Comm getCommunicator()
Get the communicator.
CepsBool isLast()
Is calling process last in computing grid ?
CepsBool isParallel()
Is there more than 1 process currently working ?
std::ofstream & debugLog()
Get the DebugLog used in Ceps.
const _Type & max(const CepsVector< _Type, _Alloc > &vec)
Returns the maximum of the vector, const version.
CepsUInt getGridSize()
Returns the number of process on the computing grid.
CepsUInt initialize(int argc, char *argv[])
Initializes parallel environment.
void finalize()
Finalizes parallel environment.
void barrier()
Explicit barrier: wait for all processors before continuing.
void beginSequential()
Begins a sequential block.
CepsBool isMaster()
Is calling process the master ?
MPI_Comm * getPtrCommunicator()
Get pointer to the communicator.
void endSequential()
End a sequential block.
CepsBool isProfiling()
Check if we are currently profiling on the master proc (always false on slave procs).
void destroyObject(_Type &)
Destroy[delete] any type.
void finalizeWithError()
Calls MPI_Abort, function used instead of std::terminate()