Skip to content
Snippets Groups Projects
Commit faf34cfe authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Define logger as pointer

parent 9684920c
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ using namespace std;
// I would like to put it all in a struct, but then I'd have to write a constructor for it, due to members defined as references, creating a worse nightmare than the one I'd like to simplify...
int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConfiguration *gconf, C1 *c1, C1_AddOns *c1ao, C2 *c2, C3 *c3, C4 *c4, C6 *c6, C9 *c9, FILE *output, string output_path, double *gaps, double **tqse, dcomplex **tqspe, double **tqss, dcomplex **tqsps, double ****zpv, double **gapm, dcomplex **gappm, int nth, int nths, int nph, int nphs, int nk, int nks, int nkks, double *argi, double *args, double **gap, dcomplex **gapp, double **tqce, dcomplex **tqcpe, double **tqcs, dcomplex **tqcps, double *duk, fstream &tppoan, double **cextlr, double **cext, double **cmullr, double **cmul, double *gapv, double *tqev, double *tqsv, int nxi, int nsph, np_int mxndm, int inpol, int iavm, int npnt, int npntts, int isam, int lm, double th, double thstp, double thlst, double ths, double thsstp, double thslst, double ph, double phstp, double phlst, double phs, double phsstp, double phslst, double th1, double ph1, double ths1, double phs1, double thsca, double *u, double *us, double *un, double *uns, double *up, double *ups, double *unmp, double *unsmp, double *upmp, double *upsmp, double &scan, double &cfmp, double &sfmp, double &cfsp, double &sfsp, double sqsfi, double exri, int lcalc, dcomplex arg, double wn, double vk, np_int ndit, dcomplex **am, int isq, int ibf, Logger &logger);
int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConfiguration *gconf, C1 *c1, C1_AddOns *c1ao, C2 *c2, C3 *c3, C4 *c4, C6 *c6, C9 *c9, FILE *output, string output_path, double *gaps, double **tqse, dcomplex **tqspe, double **tqss, dcomplex **tqsps, double ****zpv, double **gapm, dcomplex **gappm, int nth, int nths, int nph, int nphs, int nk, int nks, int nkks, double *argi, double *args, double **gap, dcomplex **gapp, double **tqce, dcomplex **tqcpe, double **tqcs, dcomplex **tqcps, double *duk, fstream &tppoan, double **cextlr, double **cext, double **cmullr, double **cmul, double *gapv, double *tqev, double *tqsv, int nxi, int nsph, np_int mxndm, int inpol, int iavm, int npnt, int npntts, int isam, int lm, double th, double thstp, double thlst, double ths, double thsstp, double thslst, double ph, double phstp, double phlst, double phs, double phsstp, double phslst, double th1, double ph1, double ths1, double phs1, double thsca, double *u, double *us, double *un, double *uns, double *up, double *ups, double *unmp, double *unsmp, double *upmp, double *upsmp, double &scan, double &cfmp, double &sfmp, double &cfsp, double &sfsp, double sqsfi, double exri, int lcalc, dcomplex arg, double wn, double vk, np_int ndit, dcomplex **am, int isq, int ibf, Logger *logger);
/*! \brief C++ implementation of CLU
*
......@@ -61,15 +61,15 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
* \param output_path: `string` Directory to write the output files in.
*/
void cluster(string config_file, string data_file, string output_path) {
Logger logger(LOG_INFO);
logger.log("INFO: making legacy configuration...", LOG_INFO);
Logger *logger = new Logger(LOG_INFO);
logger->log("INFO: making legacy configuration...", LOG_INFO);
ScattererConfiguration *sconf = NULL;
try {
sconf = ScattererConfiguration::from_dedfb(config_file);
} catch(const OpenConfigurationFileException &ex) {
logger.err("\nERROR: failed to open scatterer configuration file.\n");
logger->err("\nERROR: failed to open scatterer configuration file.\n");
string message = "FILE: " + string(ex.what()) + "\n";
logger.err(message);
logger->err(message);
exit(1);
}
sconf->write_formatted(output_path + "/c_OEDFB");
......@@ -79,13 +79,13 @@ void cluster(string config_file, string data_file, string output_path) {
try {
gconf = GeometryConfiguration::from_legacy(data_file);
} catch (const OpenConfigurationFileException &ex) {
logger.err("\nERROR: failed to open geometry configuration file.\n");
logger->err("\nERROR: failed to open geometry configuration file.\n");
string message = "FILE: " + string(ex.what()) + "\n";
logger.err(message);
logger->err(message);
if (sconf) delete sconf;
exit(1);
}
logger.log(" done.\n", LOG_INFO);
logger->log(" done.\n", LOG_INFO);
if (sconf->number_of_spheres == gconf->number_of_spheres) {
// Shortcuts to variables stored in configuration objects
int nsph = gconf->number_of_spheres;
......@@ -285,9 +285,9 @@ void cluster(string config_file, string data_file, string output_path) {
tppoan.open(tppoan_name.c_str(), ios::out | ios::binary);
if (tppoan.is_open()) {
#ifdef USE_LAPACK
logger.log("INFO: using LAPACK calls.\n", LOG_INFO);
logger->log("INFO: using LAPACK calls.\n", LOG_INFO);
#else
logger.log("INFO: using fall-back lucin() calls.\n", LOG_INFO);
logger->log("INFO: using fall-back lucin() calls.\n", LOG_INFO);
#endif
tppoan.write(reinterpret_cast<char *>(&iavm), sizeof(int));
tppoan.write(reinterpret_cast<char *>(&isam), sizeof(int));
......@@ -690,7 +690,7 @@ void cluster(string config_file, string data_file, string output_path) {
#pragma omp barrier
{
string message = "Closing thread-local output files of thread " + to_string(myompthread) + " and syncing threads.\n";
logger.log(message);
logger->log(message);
}
} // closes pragma omp parallel
#ifdef _OPENMP
......@@ -701,7 +701,7 @@ void cluster(string config_file, string data_file, string output_path) {
// 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 message = "Copying ASCII output of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
logger.log(message);
logger->log(message);
FILE *partial_output = fopen(partial_file_name.c_str(), "r");
char c = fgetc(partial_output);
while (c != EOF) {
......@@ -710,10 +710,10 @@ void cluster(string config_file, string data_file, string output_path) {
}
fclose(partial_output);
remove(partial_file_name.c_str());
logger.log("done.\n");
logger->log("done.\n");
partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
message = "Copying binary output of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
logger.log(message);
logger->log(message);
fstream partial_tppoan;
partial_tppoan.open(partial_file_name.c_str(), ios::in | ios::binary);
partial_tppoan.seekg(0, ios::end);
......@@ -725,14 +725,14 @@ void cluster(string config_file, string data_file, string output_path) {
partial_tppoan.close();
delete[] binary_buffer;
remove(partial_file_name.c_str());
logger.log("done.\n");
logger->log("done.\n");
}
}
#endif
tppoanp->close();
delete tppoanp;
} else { // In case TPPOAN could not be opened. Should never happen.
logger.err("\nERROR: failed to open TPPOAN file.\n");
logger->err("\nERROR: failed to open TPPOAN file.\n");
}
fclose(output);
// Clean memory
......@@ -816,11 +816,12 @@ void cluster(string config_file, string data_file, string output_path) {
}
delete sconf;
delete gconf;
logger.log("Finished: output written to " + output_path + "/c_OCLU\n");
logger->log("Finished: output written to " + output_path + "/c_OCLU\n");
delete logger;
}
int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConfiguration *gconf, C1 *c1, C1_AddOns *c1ao, C2 *c2, C3 *c3, C4 *c4, C6 *c6, C9 *c9, FILE *output, string output_path, double *gaps, double **tqse, dcomplex **tqspe, double **tqss, dcomplex **tqsps, double ****zpv, double **gapm, dcomplex **gappm, int nth, int nths, int nph, int nphs, int nk, int nks, int nkks, double *argi, double *args, double **gap, dcomplex **gapp, double **tqce, dcomplex **tqcpe, double **tqcs, dcomplex **tqcps, double *duk, fstream &tppoan, double **cextlr, double **cext, double **cmullr, double **cmul, double *gapv, double *tqev, double *tqsv, int nxi, int nsph, np_int mxndm, int inpol, int iavm, int npnt, int npntts, int isam, int lm, double th, double thstp, double thlst, double ths, double thsstp, double thslst, double ph, double phstp, double phlst, double phs, double phsstp, double phslst, double th1, double ph1, double ths1, double phs1, double thsca, double *u, double *us, double *un, double *uns, double *up, double *ups, double *unmp, double *unsmp, double *upmp, double *upsmp, double &scan, double &cfmp, double &sfmp, double &cfsp, double &sfsp, double sqsfi, double exri, int lcalc, dcomplex arg, double wn, double vk, np_int ndit, dcomplex **am, int isq, int ibf, Logger &logger)
int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConfiguration *gconf, C1 *c1, C1_AddOns *c1ao, C2 *c2, C3 *c3, C4 *c4, C6 *c6, C9 *c9, FILE *output, string output_path, double *gaps, double **tqse, dcomplex **tqspe, double **tqss, dcomplex **tqsps, double ****zpv, double **gapm, dcomplex **gappm, int nth, int nths, int nph, int nphs, int nk, int nks, int nkks, double *argi, double *args, double **gap, dcomplex **gapp, double **tqce, dcomplex **tqcpe, double **tqcs, dcomplex **tqcps, double *duk, fstream &tppoan, double **cextlr, double **cext, double **cmullr, double **cmul, double *gapv, double *tqev, double *tqsv, int nxi, int nsph, np_int mxndm, int inpol, int iavm, int npnt, int npntts, int isam, int lm, double th, double thstp, double thlst, double ths, double thsstp, double thslst, double ph, double phstp, double phlst, double phs, double phsstp, double phslst, double th1, double ph1, double ths1, double phs1, double thsca, double *u, double *us, double *un, double *uns, double *up, double *ups, double *unmp, double *unsmp, double *upmp, double *upsmp, double &scan, double &cfmp, double &sfmp, double &cfsp, double &sfsp, double sqsfi, double exri, int lcalc, dcomplex arg, double wn, double vk, np_int ndit, dcomplex **am, int isq, int ibf, Logger *logger)
{
// int nxi = sconf->number_of_scales;
......@@ -884,7 +885,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
// int ibf;
logger.log("INFO: running scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");
logger->log("INFO: running scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");
int jaw = 1;
fprintf(output, "========== JXI =%3d ====================\n", jxi488);
double xi = sconf->scale_vec[jxi488 - 1];
......@@ -1559,7 +1560,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
// delete[] am_vector;
// delete[] am;
logger.log("INFO: finished scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");
logger->log("INFO: finished scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");
return jer;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment