From 2645d979283d88f396cc6a8f30fd9f7aa9a05c57 Mon Sep 17 00:00:00 2001
From: "Mulas, Giacomo" <gmulas@oa-cagliari.inaf.it>
Date: Tue, 19 Mar 2024 12:20:46 +0100
Subject: [PATCH] make the splitting of outputs conditional on _OPENMP

---
 src/cluster/cluster.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp
index f0135268..257d5213 100644
--- a/src/cluster/cluster.cpp
+++ b/src/cluster/cluster.cpp
@@ -361,10 +361,13 @@ void cluster(string config_file, string data_file, string output_path) {
 #ifdef _OPENMP
 	myompthread = omp_get_thread_num();
 	if (myompthread == 0) ompnumthreads = omp_get_num_threads();
-#endif
 	FILE *output_2 = fopen((output_path + "/c_OCLU_" + to_string(myompthread)).c_str(), "w");
 	fstream tppoan_2;
 	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 **tqse_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 c6_2;
 	delete c9_2;
+#ifdef _OPENMP
 	fclose(output_2);
 	tppoan_2.close();
+#endif
 	delete[] gaps_2;
 	for (int ti = 0; ti <2 -1; ti++) {
 	  delete[] tqse_2[ti];
@@ -604,6 +609,7 @@ void cluster(string config_file, string data_file, string output_path) {
 	delete[] am_2;
 	
       } // jxi488 loop
+#ifdef _OPENMP
       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
 	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());
 	printf("done.\n");
       }
+#endif
       tppoan.close();
     } else { // In case TPPOAN could not be opened. Should never happen.
       printf("\nERROR: failed to open TPPOAN file.\n");
-- 
GitLab