<commit_before>#include "orbit_mpi.hh"

#include <cstdlib>
#include <cstring>
#include <iostream>
#include <ctime>

/** A C wrapper around MPI_Init. */
int ORBIT_MPI_Init(int *len, char ***ch){
  int res = 0;
#if USE_MPI > 0
  res = MPI_Init(len,ch);
#else
  res  = 1;
#endif
  return res;
}

/** A C wrapper around MPI_Initialized. */
int ORBIT_MPI_Initialized(int *init){
 int res = 0;
#if USE_MPI > 0
  res = MPI_Initialized(init);
#else
  *init = 0;
#endif
  return res;
}

/** A C wrapper around MPI_Finalize. */
int ORBIT_MPI_Finalize(){
  return ORBIT_MPI_Finalize(NULL);
}

/** A C wrapper around MPI_Finalize(message). */
int ORBIT_MPI_Finalize(const char* message){
  int res = 0;
  int rank;
  ORBIT_MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  int init;
  ORBIT_MPI_Initialized(&init);
#if USE_MPI > 0
  if(init > 0){
    res = MPI_Finalize();
  }
#else
  res  = 1;
#endif
  if(rank == 0){
    if(Py_IsInitialized()){
      PyErr_SetString(PyExc_RuntimeError,"ORBIT_MPI_Finalize.");
      PyErr_Print();
      PyRun_SimpleString("import traceback; traceback.print_stack()");
    }
    if(message != NULL){
      std::cerr<<"Error PyORBIT Message:"<<std::endl;
      std::cerr<<message<<std::endl;
      std::cerr<<"Stop."<<std::endl;
    }
  }
  if(Py_IsInitialized()){
    Py_Exit(1);
  }
  else{
    exit(1);
  }
  return res;
}

/** A C wrapper around MPI_Get_processor_name. */
int ORBIT_MPI_Get_processor_name(char *name, int* len){
  int res = 0;
#if USE_MPI > 0<commit_msg>After call to ORBIT_MPI_Finalize() in the main.cc the exit was done with the exit code 1 (by call to exit(1)) even the termination was normal. We added the condition statement to exit(0) if there is no message in ORBIT_MPI_Finalize("message").<commit_after>#include "orbit_mpi.hh"

#include <cstdlib>
#include <cstring>
#include <iostream>
#include <ctime>

/** A C wrapper around MPI_Init. */
int ORBIT_MPI_Init(int *len, char ***ch){
  int res = 0;
#if USE_MPI > 0
  res = MPI_Init(len,ch);
#else
  res  = 1;
#endif
  return res;
}

/** A C wrapper around MPI_Initialized. */
int ORBIT_MPI_Initialized(int *init){
 int res = 0;
#if USE_MPI > 0
  res = MPI_Initialized(init);
#else
  *init = 0;
#endif
  return res;
}

/** A C wrapper around MPI_Finalize. */
int ORBIT_MPI_Finalize(){
  return ORBIT_MPI_Finalize(NULL);
}

/** A C wrapper around MPI_Finalize(message). */
int ORBIT_MPI_Finalize(const char* message){
  int res = 0;
  int rank;
  ORBIT_MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  int init;
  ORBIT_MPI_Initialized(&init);
#if USE_MPI > 0
  if(init > 0){
    res = MPI_Finalize();
  }
#else
  res  = 1;
#endif
  if(rank == 0){
    if(Py_IsInitialized()){
      PyErr_SetString(PyExc_RuntimeError,"ORBIT_MPI_Finalize.");
      PyErr_Print();
      PyRun_SimpleString("import traceback; traceback.print_stack()");
    }
    if(message != NULL){
      std::cerr<<"Error PyORBIT Message:"<<std::endl;
      std::cerr<<message<<std::endl;
      std::cerr<<"Stop."<<std::endl;
    }
  }
  if(Py_IsInitialized()){
    Py_Exit(1);
  }
  else{
  	if(message != NULL){
  		exit(1);
  	}
  	else{
  		exit(0);
  	}
  }
  return res;
}

/** A C wrapper around MPI_Get_processor_name. */
int ORBIT_MPI_Get_processor_name(char *name, int* len){
  int res = 0;
#if USE_MPI > 0
{'fraction_non_alphanumeric': 0.14785276073619633, 'fraction_numerical': 0.010429447852760737, 'mean_word_length': 3.788546255506608, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '194770', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1286, 'n_words': 305}