Commit 2645d979 authored by Mulas, Giacomo's avatar Mulas, Giacomo
Browse files

make the splitting of outputs conditional on _OPENMP

parent d5c10ae3
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -361,10 +361,13 @@ void cluster(string config_file, string data_file, string output_path) {
#ifdef _OPENMP
#ifdef _OPENMP
	myompthread = omp_get_thread_num();
	myompthread = omp_get_thread_num();
	if (myompthread == 0) ompnumthreads = omp_get_num_threads();
	if (myompthread == 0) ompnumthreads = omp_get_num_threads();
#endif
	FILE *output_2 = fopen((output_path + "/c_OCLU_" + to_string(myompthread)).c_str(), "w");
	FILE *output_2 = fopen((output_path + "/c_OCLU_" + to_string(myompthread)).c_str(), "w");
	fstream tppoan_2;
	fstream tppoan_2;
	tppoan_2.open((output_path + "/c_TPPOAN_" + to_string(myompthread)).c_str(), ios::out | ios::binary);
	tppoan_2.open((output_path + "/c_TPPOAN_" + to_string(myompthread)).c_str(), ios::out | ios::binary);
#else
	FILE *output_2 = output;
	fstream &tppoan_2 = tppoan;  
#endif
	double *gaps_2 = new double[nsph]();
	double *gaps_2 = new double[nsph]();
	double **tqse_2 = new double*[2];
	double **tqse_2 = new double*[2];
	double **tqce_2 = new double*[2];
	double **tqce_2 = new double*[2];
@@ -533,8 +536,10 @@ void cluster(string config_file, string data_file, string output_path) {
	delete c4_2;
	delete c4_2;
	delete c6_2;
	delete c6_2;
	delete c9_2;
	delete c9_2;
#ifdef _OPENMP
	fclose(output_2);
	fclose(output_2);
	tppoan_2.close();
	tppoan_2.close();
#endif
	delete[] gaps_2;
	delete[] gaps_2;
	for (int ti = 0; ti <2 -1; ti++) {
	for (int ti = 0; ti <2 -1; ti++) {
	  delete[] tqse_2[ti];
	  delete[] tqse_2[ti];
@@ -604,6 +609,7 @@ void cluster(string config_file, string data_file, string output_path) {
	delete[] am_2;
	delete[] am_2;
	
	
      } // jxi488 loop
      } // jxi488 loop
#ifdef _OPENMP
      for (int ri = 0; ri < ompnumthreads; ri++) {
      for (int ri = 0; ri < ompnumthreads; ri++) {
      // Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them
      // Giovanni, please add here in this loop code to reopen the temporary files, reread them and append them respectively to the global output and tppoan, before closing them
	string partial_file_name = output_path + "/c_OCLU_" + to_string(ri);
	string partial_file_name = output_path + "/c_OCLU_" + to_string(ri);
@@ -630,6 +636,7 @@ void cluster(string config_file, string data_file, string output_path) {
	remove(partial_file_name.c_str());
	remove(partial_file_name.c_str());
	printf("done.\n");
	printf("done.\n");
      }
      }
#endif
      tppoan.close();
      tppoan.close();
    } else { // In case TPPOAN could not be opened. Should never happen.
    } else { // In case TPPOAN could not be opened. Should never happen.
      printf("\nERROR: failed to open TPPOAN file.\n");
      printf("\nERROR: failed to open TPPOAN file.\n");