Commit 6172baec authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Merge branch 'test_parallel_execution' into 'master'

Test parallel execution

See merge request giacomo.mulas/np_tmcode!26
parents 43ccc2f4 99990106
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -8,9 +8,13 @@ ifndef BUILDDIR_NPTM
override BUILDDIR_NPTM=$(BUILDDIR)/libnptm
override BUILDDIR_NPTM=$(BUILDDIR)/libnptm
endif
endif
ifndef LIBNPTM
ifndef LIBNPTM
# choose one of the two following lines, depending on whether a static or dynamic libnptm is wanted
ifdef STATIC_NPTM
#override LIBNPTM=$(BUILDDIR_NPTM)/libnptm.a
override LIBNPTM=$(BUILDDIR_NPTM)/libnptm.a
override STATICFLAG="-lsz -lz -laec -static"
else
override LIBNPTM=$(BUILDDIR_NPTM)/libnptm.so
override LIBNPTM=$(BUILDDIR_NPTM)/libnptm.so
override STATICFLAG=""
endif
endif
endif
DOCSDIR=$(SRCDIR)/../doc
DOCSDIR=$(SRCDIR)/../doc


@@ -28,7 +32,7 @@ $(LIBNPTM):
	BUILDDIR=$(BUILDDIR) BUILDDIR_NPTM=$(BUILDDIR_NPTM) LIBNPTM=$(LIBNPTM) $(MAKE) -C libnptm $@
	BUILDDIR=$(BUILDDIR) BUILDDIR_NPTM=$(BUILDDIR_NPTM) LIBNPTM=$(LIBNPTM) $(MAKE) -C libnptm $@


$(SUBDIRS): $(BUILDDIR) $(LIBNPTM)
$(SUBDIRS): $(BUILDDIR) $(LIBNPTM)
	BUILDDIR=$(BUILDDIR) BUILDDIR_NPTM=$(BUILDDIR_NPTM) LIBNPTM=$(LIBNPTM) $(MAKE) -C $@
	BUILDDIR=$(BUILDDIR) BUILDDIR_NPTM=$(BUILDDIR_NPTM) LIBNPTM=$(LIBNPTM) STATICFLAG=$(STATICFLAG) $(MAKE) -C $@


clean: $(BUILDDIR)
clean: $(BUILDDIR)
	BUILDDIR=$(BUILDDIR) $(MAKE) -C cluster clean
	BUILDDIR=$(BUILDDIR) $(MAKE) -C cluster clean
+40 −33
Original line number Original line Diff line number Diff line
@@ -20,6 +20,10 @@
#include "../include/errors.h"
#include "../include/errors.h"
#endif
#endif


#ifndef INCLUDE_LOGGING_H_
#include "../include/logging.h"
#endif

#ifndef INCLUDE_CONFIGURATION_H_
#ifndef INCLUDE_CONFIGURATION_H_
#include "../include/Configuration.h"
#include "../include/Configuration.h"
#endif
#endif
@@ -48,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...
// 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);
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
/*! \brief C++ implementation of CLU
 *
 *
@@ -57,13 +61,15 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
 *  \param output_path: `string` Directory to write the output files in.
 *  \param output_path: `string` Directory to write the output files in.
 */
 */
void cluster(string config_file, string data_file, string output_path) {
void cluster(string config_file, string data_file, string output_path) {
  printf("INFO: making legacy configuration...");
  Logger *logger = new Logger(LOG_INFO);
  logger->log("INFO: making legacy configuration...", LOG_INFO);
  ScattererConfiguration *sconf = NULL;
  ScattererConfiguration *sconf = NULL;
  try {
  try {
    sconf = ScattererConfiguration::from_dedfb(config_file);
    sconf = ScattererConfiguration::from_dedfb(config_file);
  } catch(const OpenConfigurationFileException &ex) {
  } catch(const OpenConfigurationFileException &ex) {
    printf("\nERROR: failed to open scatterer configuration file.\n");
    logger->err("\nERROR: failed to open scatterer configuration file.\n");
    printf("FILE: %s\n", ex.what());
    string message = "FILE: " + string(ex.what()) + "\n";
    logger->err(message);
    exit(1);
    exit(1);
  }
  }
  sconf->write_formatted(output_path + "/c_OEDFB");
  sconf->write_formatted(output_path + "/c_OEDFB");
@@ -73,12 +79,13 @@ void cluster(string config_file, string data_file, string output_path) {
  try {
  try {
    gconf = GeometryConfiguration::from_legacy(data_file);
    gconf = GeometryConfiguration::from_legacy(data_file);
  } catch (const OpenConfigurationFileException &ex) {
  } catch (const OpenConfigurationFileException &ex) {
    printf("\nERROR: failed to open geometry configuration file.\n");
    logger->err("\nERROR: failed to open geometry configuration file.\n");
    printf("FILE: %s\n", ex.what());
    string message = "FILE: " + string(ex.what()) + "\n";
    logger->err(message);
    if (sconf) delete sconf;
    if (sconf) delete sconf;
    exit(1);
    exit(1);
  }
  }
  printf(" done.\n");
  logger->log(" done.\n", LOG_INFO);
  if (sconf->number_of_spheres == gconf->number_of_spheres) {
  if (sconf->number_of_spheres == gconf->number_of_spheres) {
    // Shortcuts to variables stored in configuration objects
    // Shortcuts to variables stored in configuration objects
    int nsph = gconf->number_of_spheres;
    int nsph = gconf->number_of_spheres;
@@ -278,9 +285,9 @@ void cluster(string config_file, string data_file, string output_path) {
    tppoan.open(tppoan_name.c_str(), ios::out | ios::binary);
    tppoan.open(tppoan_name.c_str(), ios::out | ios::binary);
    if (tppoan.is_open()) {
    if (tppoan.is_open()) {
#ifdef USE_LAPACK
#ifdef USE_LAPACK
      printf("INFO: using LAPACK calls.\n");
      logger->log("INFO: using LAPACK calls.\n", LOG_INFO);
#else
#else
      printf("INFO: using fall-back lucin() calls.\n");
      logger->log("INFO: using fall-back lucin() calls.\n", LOG_INFO);
#endif
#endif
      tppoan.write(reinterpret_cast<char *>(&iavm), sizeof(int));
      tppoan.write(reinterpret_cast<char *>(&iavm), sizeof(int));
      tppoan.write(reinterpret_cast<char *>(&isam), sizeof(int));
      tppoan.write(reinterpret_cast<char *>(&isam), sizeof(int));
@@ -299,7 +306,7 @@ void cluster(string config_file, string data_file, string output_path) {
      }
      }
      // do the first iteration on jxi488 separately, since it seems to be different from the others
      // do the first iteration on jxi488 separately, since it seems to be different from the others
      int jxi488 = 1;
      int jxi488 = 1;
      jer = cluster_jxi488_cycle(jxi488, sconf, gconf, c1, c1ao, c2, c3, c4, c6, c9, output, output_path, gaps, tqse, tqspe, tqss, tqsps, zpv, gapm, gappm, nth, nths, nph, nphs, nk, nks, nkks, argi, args, gap, gapp, tqce, tqcpe, tqcs, tqcps, duk, tppoan, cextlr, cext, cmullr, cmul, gapv, tqev, tqsv, nxi, nsph, mxndm, inpol, iavm, npnt, npntts, isam, lm, th, thstp, thlst, ths, thsstp, thslst, ph, phstp, phlst, phs, phsstp, phslst, th1, ph1, ths1, phs1, thsca, u, us, un, uns, up, ups, unmp, unsmp, upmp, upsmp, scan, cfmp, sfmp, cfsp, sfsp, sqsfi, exri, lcalc, arg, wn, vk, ndit, am, isq, ibf);
      jer = cluster_jxi488_cycle(jxi488, sconf, gconf, c1, c1ao, c2, c3, c4, c6, c9, output, output_path, gaps, tqse, tqspe, tqss, tqsps, zpv, gapm, gappm, nth, nths, nph, nphs, nk, nks, nkks, argi, args, gap, gapp, tqce, tqcpe, tqcs, tqcps, duk, tppoan, cextlr, cext, cmullr, cmul, gapv, tqev, tqsv, nxi, nsph, mxndm, inpol, iavm, npnt, npntts, isam, lm, th, thstp, thlst, ths, thsstp, thslst, ph, phstp, phlst, phs, phsstp, phslst, th1, ph1, ths1, phs1, thsca, u, us, un, uns, up, ups, unmp, unsmp, upmp, upsmp, scan, cfmp, sfmp, cfsp, sfsp, sqsfi, exri, lcalc, arg, wn, vk, ndit, am, isq, ibf, logger);


      // Create this variable and initialise it with a default here, so that it is defined anyway, with or without OpenMP support enabled
      // Create this variable and initialise it with a default here, so that it is defined anyway, with or without OpenMP support enabled
      int ompnumthreads = 1;
      int ompnumthreads = 1;
@@ -594,7 +601,7 @@ void cluster(string config_file, string data_file, string output_path) {
	// ok, now I can actually start the parallel calculations
	// ok, now I can actually start the parallel calculations
#pragma omp for
#pragma omp for
	for (jxi488 = 2; jxi488 <= nxi; jxi488++) {
	for (jxi488 = 2; jxi488 <= nxi; jxi488++) {
	  jer = cluster_jxi488_cycle(jxi488, sconf_2, gconf_2, c1_2, c1ao_2, c2_2, c3_2, c4_2, c6_2, c9_2, output_2, output_path, gaps_2, tqse_2, tqspe_2, tqss_2, tqsps_2, zpv_2, gapm_2, gappm_2, nth_2, nths_2, nph_2, nphs_2, nk_2, nks_2, nkks_2, argi_2, args_2, gap_2, gapp_2, tqce_2, tqcpe_2, tqcs_2, tqcps_2, duk_2, tppoan_2, cextlr_2, cext_2, cmullr_2, cmul_2, gapv_2, tqev_2, tqsv_2, nxi_2, nsph_2, mxndm_2, inpol_2, iavm_2, npnt_2, npntts_2, isam_2, lm_2, th_2, thstp_2, thlst_2, ths_2, thsstp_2, thslst_2, ph_2, phstp_2, phlst_2, phs_2, phsstp_2, phslst_2, th1_2, ph1_2, ths1_2, phs1_2, thsca_2, u_2, us_2, un_2, uns_2, up_2, ups_2, unmp_2, unsmp_2, upmp_2, upsmp_2, scan_2, cfmp_2, sfmp_2, cfsp_2, sfsp_2, sqsfi_2, exri_2, lcalc_2, arg_2, wn_2, vk_2, ndit_2, am_2, isq_2, ibf_2);
	  jer = cluster_jxi488_cycle(jxi488, sconf_2, gconf_2, c1_2, c1ao_2, c2_2, c3_2, c4_2, c6_2, c9_2, output_2, output_path, gaps_2, tqse_2, tqspe_2, tqss_2, tqsps_2, zpv_2, gapm_2, gappm_2, nth_2, nths_2, nph_2, nphs_2, nk_2, nks_2, nkks_2, argi_2, args_2, gap_2, gapp_2, tqce_2, tqcpe_2, tqcs_2, tqcps_2, duk_2, tppoan_2, cextlr_2, cext_2, cmullr_2, cmul_2, gapv_2, tqev_2, tqsv_2, nxi_2, nsph_2, mxndm_2, inpol_2, iavm_2, npnt_2, npntts_2, isam_2, lm_2, th_2, thstp_2, thlst_2, ths_2, thsstp_2, thslst_2, ph_2, phstp_2, phlst_2, phs_2, phsstp_2, phslst_2, th1_2, ph1_2, ths1_2, phs1_2, thsca_2, u_2, us_2, un_2, uns_2, up_2, ups_2, unmp_2, unsmp_2, upmp_2, upsmp_2, scan_2, cfmp_2, sfmp_2, cfsp_2, sfsp_2, sqsfi_2, exri_2, lcalc_2, arg_2, wn_2, vk_2, ndit_2, am_2, isq_2, ibf_2, logger);
	}
	}


#pragma omp barrier
#pragma omp barrier
@@ -613,7 +620,7 @@ void cluster(string config_file, string data_file, string output_path) {
	  tppoanp_2->close();
	  tppoanp_2->close();
	  delete tppoanp_2;
	  delete tppoanp_2;
	  delete[] gaps_2;
	  delete[] gaps_2;
	  for (int ti = 0; ti <2 -1; ti++) {
	  for (int ti = 0; ti < 2; ti++) {
	    delete[] tqse_2[ti];
	    delete[] tqse_2[ti];
	    delete[] tqce_2[ti];
	    delete[] tqce_2[ti];
	    delete[] tqcs_2[ti];
	    delete[] tqcs_2[ti];
@@ -682,7 +689,8 @@ void cluster(string config_file, string data_file, string output_path) {
	}
	}
#pragma omp barrier
#pragma omp barrier
	{
	{
	  printf("Closed thread-local output files of thread %d, syncing threads\n", myompthread);
	  string message = "Closing thread-local output files of thread " + to_string(myompthread) + " and syncing threads.\n";
	  logger->log(message);
	}
	}
      } // closes pragma omp parallel
      } // closes pragma omp parallel
#ifdef _OPENMP
#ifdef _OPENMP
@@ -692,7 +700,8 @@ void cluster(string config_file, string data_file, string output_path) {
	for (int ri = 1; ri < ompnumthreads; ri++) {
	for (int ri = 1; 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);
	  printf("Copying ASCII output of thread %d of %d... ", ri, ompnumthreads - 1);
	  string message = "Copying ASCII output of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
	  logger->log(message);
	  FILE *partial_output = fopen(partial_file_name.c_str(), "r");
	  FILE *partial_output = fopen(partial_file_name.c_str(), "r");
	  char c = fgetc(partial_output);
	  char c = fgetc(partial_output);
	  while (c != EOF) {
	  while (c != EOF) {
@@ -701,12 +710,10 @@ void cluster(string config_file, string data_file, string output_path) {
	  }
	  }
	  fclose(partial_output);
	  fclose(partial_output);
	  remove(partial_file_name.c_str());
	  remove(partial_file_name.c_str());
	  printf("done.\n");
	  logger->log("done.\n");
	  //	}
	  //for (int ri = 1; ri < ompnumthreads; ri++) {
	  //string partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
	  partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
	  partial_file_name = output_path + "/c_TPPOAN_" + to_string(ri);
	  printf("Copying binary output of thread %d of %d... ", ri, ompnumthreads - 1);
	  message = "Copying binary output of thread " + to_string(ri) + " of " + to_string(ompnumthreads - 1) + "... ";
	  logger->log(message);
	  fstream partial_tppoan;
	  fstream partial_tppoan;
	  partial_tppoan.open(partial_file_name.c_str(), ios::in | ios::binary);
	  partial_tppoan.open(partial_file_name.c_str(), ios::in | ios::binary);
	  partial_tppoan.seekg(0, ios::end);
	  partial_tppoan.seekg(0, ios::end);
@@ -718,14 +725,14 @@ void cluster(string config_file, string data_file, string output_path) {
	  partial_tppoan.close();
	  partial_tppoan.close();
	  delete[] binary_buffer;
	  delete[] binary_buffer;
	  remove(partial_file_name.c_str());
	  remove(partial_file_name.c_str());
	  printf("done.\n");
	  logger->log("done.\n");
	}
	}
      }
      }
#endif
#endif
      tppoanp->close();
      tppoanp->close();
      delete tppoanp;
      delete tppoanp;
    } 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");
      logger->err("\nERROR: failed to open TPPOAN file.\n");
    }
    }
    fclose(output);
    fclose(output);
    // Clean memory
    // Clean memory
@@ -740,13 +747,13 @@ void cluster(string config_file, string data_file, string output_path) {
    delete[] zpv;
    delete[] zpv;
    delete c1;
    delete c1;
    delete c1ao;
    delete c1ao;
    delete c2;
    delete c3;
    delete c3;
    delete c4;
    delete c4;
    delete c6;
    delete c6;
    delete c9;
    delete c9;
    delete[] am_vector;
    delete[] am_vector;
    delete[] am;
    delete[] am;
    //delete[] tam;
    delete[] gaps;
    delete[] gaps;
    for (int ti = 1; ti > -1; ti--) {
    for (int ti = 1; ti > -1; ti--) {
      delete[] tqse[ti];
      delete[] tqse[ti];
@@ -809,11 +816,12 @@ void cluster(string config_file, string data_file, string output_path) {
  }
  }
  delete sconf;
  delete sconf;
  delete gconf;
  delete gconf;
  printf("Finished: output written to %s.\n", (output_path + "/c_OCLU").c_str());
  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)
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;
  // int nxi = sconf->number_of_scales;
@@ -877,8 +885,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
  // int ibf;
  // int ibf;





  logger->log("INFO: running scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");
  printf("INFO: running scale iteration %d of %d...", jxi488, nxi);
  int jaw = 1;
  int jaw = 1;
  fprintf(output, "========== JXI =%3d ====================\n", jxi488);
  fprintf(output, "========== JXI =%3d ====================\n", jxi488);
  double xi = sconf->scale_vec[jxi488 - 1];
  double xi = sconf->scale_vec[jxi488 - 1];
@@ -1272,10 +1279,10 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
		      real(c1->sas[i226 - 1][0][1]), imag(c1->sas[i226 - 1][0][1]),
		      real(c1->sas[i226 - 1][0][1]), imag(c1->sas[i226 - 1][0][1]),
		      real(c1->sas[i226 - 1][1][1]), imag(c1->sas[i226 - 1][1][1])
		      real(c1->sas[i226 - 1][1][1]), imag(c1->sas[i226 - 1][1][1])
		      );
		      );
	      for (int j225 = 0; j225 < 16; j225++) { // QUESTION: check that 16 is a fixed dimension
	      for (int j225 = 0; j225 < 16; j225++) {
		c1ao->vint[j225] = c1ao->vints[i226 - 1][j225];
		c1->vint[j225] = c1->vints[i226 - 1][j225];
	      } // j225 loop
	      } // j225 loop
	      mmulc(c1ao->vint, cmullr, cmul);
	      mmulc(c1->vint, cmullr, cmul);
	      fprintf(output, "  MULS\n");
	      fprintf(output, "  MULS\n");
	      for (int i1 = 0; i1 < 4; i1++) {
	      for (int i1 = 0; i1 < 4; i1++) {
		fprintf(
		fprintf(
@@ -1305,7 +1312,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
	  fprintf(output, "     CLUSTER\n");
	  fprintf(output, "     CLUSTER\n");
	  pcros(vk, exri, c1, c1ao, c4);
	  pcros(vk, exri, c1, c1ao, c4);
	  mextc(vk, exri, c1ao->fsac, cextlr, cext);
	  mextc(vk, exri, c1ao->fsac, cextlr, cext);
	  mmulc(c1ao->vint, cmullr, cmul);
	  mmulc(c1->vint, cmullr, cmul);
	  if (jw != 0) {
	  if (jw != 0) {
	    jw = 0;
	    jw = 0;
	    // Some implicit loops writing to binary.
	    // Some implicit loops writing to binary.
@@ -1370,9 +1377,9 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
	  }
	  }
	  // label 254
	  // label 254
	  for (int i = 0; i < 16; i++) {
	  for (int i = 0; i < 16; i++) {
	    double value = real(c1ao->vint[i]);
	    double value = real(c1->vint[i]);
	    tppoan.write(reinterpret_cast<char *>(&value), sizeof(double));
	    tppoan.write(reinterpret_cast<char *>(&value), sizeof(double));
	    value = imag(c1ao->vint[i]);
	    value = imag(c1->vint[i]);
	    tppoan.write(reinterpret_cast<char *>(&value), sizeof(double));
	    tppoan.write(reinterpret_cast<char *>(&value), sizeof(double));
	  }
	  }
	  for (int i = 0; i < 4; i++) {
	  for (int i = 0; i < 4; i++) {
@@ -1553,7 +1560,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
  // delete[] am_vector;
  // delete[] am_vector;
  // delete[] am;
  // delete[] am;


  printf(" done.\n");
  logger->log("INFO: finished scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");


  return jer;
  return jer;


+24 −20
Original line number Original line Diff line number Diff line
@@ -40,9 +40,18 @@ protected:
  int nsph;
  int nsph;
  //! \brief Maximum order of field expansion.
  //! \brief Maximum order of field expansion.
  int lm;
  int lm;
  //! \brief NLMMT. QUESTION: definition?
  //! \brief Contiguous RMI vector.
  int nlmmt;
  dcomplex *vec_rmi;
  //! \brief Contiguous REI vector.
  dcomplex *vec_rei;
  //! \brief Contiguous W vector.
  dcomplex *vec_w;
  //! \brief Contiguous VINTS vector
  dcomplex *vec_vints;
  
public:
public:
  //! \brief NLMMT = 2 * LM * (LM + 2).
  int nlmmt;
  //! \brief Number of configurations
  //! \brief Number of configurations
  int configurations;
  int configurations;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
@@ -54,6 +63,8 @@ public:
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex *fsas;
  dcomplex *fsas;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex *vint;
  //! \brief QUESTION: definition?
  dcomplex **vints;
  dcomplex **vints;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  double *sscs;
  double *sscs;
@@ -94,11 +105,13 @@ public:
   * \param iog: `int *` Vector of spherical units ID numbers.
   * \param iog: `int *` Vector of spherical units ID numbers.
   */
   */
  C1(int ns, int l_max, int *nshl, int *iog);
  C1(int ns, int l_max, int *nshl, int *iog);

  /*! \brief C1 instance constructor copying all contents from a preexisting template
  /*! \brief C1 instance constructor copying all contents from a preexisting template
   *
   *
   * \param rhs: `C1` preexisting template.
   * \param rhs: `C1` preexisting template.
   */
   */
  C1(const C1& rhs);
  C1(const C1& rhs);

  //! \brief C1 instance destroyer.
  //! \brief C1 instance destroyer.
  ~C1();
  ~C1();
};
};
@@ -107,12 +120,14 @@ public:
 *
 *
 */
 */
class C2 {
class C2 {
protected:
  //! \brief Number of spheres.
  //! \brief Number of spheres.
  int nsph;
  int nsph;
  //! \brief Number of required orders.
  //! \brief Number of required orders.
  int nhspo;
  int nhspo;
  //! \brief QUESTION: what is nl?
  //! \brief QUESTION: what is nl?
  int nl;
  int nl;

public:
public:
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex *ris;
  dcomplex *ris;
@@ -133,6 +148,7 @@ public:
   * \param npntts: `int`
   * \param npntts: `int`
   */
   */
  C2(int ns, int nl, int npnt, int npntts);
  C2(int ns, int nl, int npnt, int npntts);

  /*! \brief C2 instance constructor copying its contents from preexisting instance.
  /*! \brief C2 instance constructor copying its contents from preexisting instance.
   *
   *
   * \param rhs: `C2` object to copy contents from
   * \param rhs: `C2` object to copy contents from
@@ -163,6 +179,7 @@ public:
  /*! \brief C3 instance constructor.
  /*! \brief C3 instance constructor.
   */
   */
  C3();
  C3();

  /*! \brief C3 instance constructor copying its contents from a preexisting object.
  /*! \brief C3 instance constructor copying its contents from a preexisting object.
   */
   */
  C3(const C3& rhs);
  C3(const C3& rhs);
@@ -237,19 +254,6 @@ protected:
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  int lm;
  int lm;


  /*! \brief Allocate the necessary common vectors depending on configuration.
   *
   * The size of the vectors and matrices defined in various common
   * blocks, and particularly in C1, depends on many settings of the
   * problem configuration, such as the number of spheres, the number
   * of layers the spheres are made of, the field expansion order and
   * others. This function collects the calculations needed to infer
   * the necessary amount of memory for these configurable elements,
   * thus making the class constructor more compact and easier to handle.
   *
   * \param c4: `C4 *` Pointer to a C4 structure.
   */
  //void allocate_vectors(C4 *c4);
public:
public:
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex *vh;
  dcomplex *vh;
@@ -264,12 +268,8 @@ public:
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex **am0m;
  dcomplex **am0m;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex *vint;
  //! \brief QUESTION: definition?
  dcomplex *vintm;
  dcomplex *vintm;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex **vints;
  //! \brief QUESTION: definition?
  dcomplex *vintt;
  dcomplex *vintt;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex **fsac;
  dcomplex **fsac;
@@ -305,6 +305,7 @@ public:
   * \param c4: `C4 *` Pointer to a C4 structure.
   * \param c4: `C4 *` Pointer to a C4 structure.
   */
   */
  C1_AddOns(C4 *c4);
  C1_AddOns(C4 *c4);

  /*! \brief C1_AddOns instance constructor copying contents from a preexisting object.
  /*! \brief C1_AddOns instance constructor copying contents from a preexisting object.
   *
   *
   * \param rhs: `C1_AddOns` preexisting object to copy from.
   * \param rhs: `C1_AddOns` preexisting object to copy from.
@@ -319,7 +320,7 @@ public:
 */
 */
class C6 {
class C6 {
public:
public:
  //! \brief QUESTION: definition?
  //! \brief LMTPO = 2 * LM + 1.
  int lmtpo;
  int lmtpo;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  double *rac3j;
  double *rac3j;
@@ -329,6 +330,7 @@ public:
   * \param lmtpo: `int` QUESTION: definition?
   * \param lmtpo: `int` QUESTION: definition?
   */
   */
  C6(int lmtpo);
  C6(int lmtpo);

  /*! \brief C6 instance constructor copying contents from preexisting object.
  /*! \brief C6 instance constructor copying contents from preexisting object.
   *
   *
   * \param lmtpo: `int` QUESTION: definition?
   * \param lmtpo: `int` QUESTION: definition?
@@ -352,6 +354,7 @@ protected:
  int nlem;
  int nlem;
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  int nlemt;
  int nlemt;

public:
public:
  //! \brief QUESTION: definition?
  //! \brief QUESTION: definition?
  dcomplex **gis;
  dcomplex **gis;
@@ -368,6 +371,7 @@ public:
   * \param nlemt: `int` QUESTION: definition?
   * \param nlemt: `int` QUESTION: definition?
   */
   */
  C9(int ndi, int nlem, int ndit, int nlemt);
  C9(int ndi, int nlem, int ndit, int nlemt);

  /*! \brief C9 instance constructor copying contents from preexisting object.
  /*! \brief C9 instance constructor copying contents from preexisting object.
   *
   *
   * \param rhs: `C9` preexisting object to copy from
   * \param rhs: `C9` preexisting object to copy from
+3 −2
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@


class ScattererConfiguration;
class ScattererConfiguration;
class GeometryConfiguration;
class GeometryConfiguration;
class Logger;
class C1;
class C1;
class C1_AddOns;
class C1_AddOns;
class C2;
class C2;
@@ -53,7 +54,7 @@ class C9;
class GeometryConfiguration {
class GeometryConfiguration {
  //! Temporary work-around to allow cluster() and sphere() peeking in.
  //! Temporary work-around to allow cluster() and sphere() peeking in.
  friend void cluster(std::string, std::string, std::string);
  friend void cluster(std::string, std::string, std::string);
  friend int cluster_jxi488_cycle(int, ScattererConfiguration *, GeometryConfiguration *, C1 *, C1_AddOns *, C2 *,  C3 *,  C4 *,  C6 *,  C9 *, std::FILE *, std::string, double *, double **, dcomplex **, double **, dcomplex **, double ****, double **, dcomplex **, int, int, int, int, int, int, int, double *, double *, double **, dcomplex **, double **, dcomplex **, double **, dcomplex **, double *, std::fstream &, double **, double **, double **, double **, double *, double *, double *, int, int, np_int, int, int, int, int, int, int, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double &, double &, double &, double &, double &, double, double, int, dcomplex, double, double, np_int, dcomplex **, int, int);
  friend int cluster_jxi488_cycle(int, ScattererConfiguration *, GeometryConfiguration *, C1 *, C1_AddOns *, C2 *,  C3 *,  C4 *,  C6 *,  C9 *, std::FILE *, std::string, double *, double **, dcomplex **, double **, dcomplex **, double ****, double **, dcomplex **, int, int, int, int, int, int, int, double *, double *, double **, dcomplex **, double **, dcomplex **, double **, dcomplex **, double *, std::fstream &, double **, double **, double **, double **, double *, double *, double *, int, int, np_int, int, int, int, int, int, int, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double &, double &, double &, double &, double &, double, double, int, dcomplex, double, double, np_int, dcomplex **, int, int, Logger *);
  friend void sphere(std::string, std::string, std::string);
  friend void sphere(std::string, std::string, std::string);
protected:
protected:
  //! \brief Number of spherical components.
  //! \brief Number of spherical components.
@@ -185,7 +186,7 @@ public:
class ScattererConfiguration {
class ScattererConfiguration {
  //! Temporary work-around to allow cluster() and sphere() peeking in.
  //! Temporary work-around to allow cluster() and sphere() peeking in.
  friend void cluster(std::string, std::string, std::string);
  friend void cluster(std::string, std::string, std::string);
  friend int cluster_jxi488_cycle(int, ScattererConfiguration *, GeometryConfiguration *, C1 *, C1_AddOns *, C2 *,  C3 *,  C4 *,  C6 *,  C9 *, std::FILE *, std::string, double *, double **, dcomplex **, double **, dcomplex **, double ****, double **, dcomplex **, int, int, int, int, int, int, int, double *, double *, double **, dcomplex **, double **, dcomplex **, double **, dcomplex **, double *, std::fstream &, double **, double **, double **, double **, double *, double *, double *, int, int, np_int, int, int, int, int, int, int, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double &, double &, double &, double &, double &, double, double, int, dcomplex, double, double, np_int, dcomplex **, int, int);
  friend int cluster_jxi488_cycle(int, ScattererConfiguration *, GeometryConfiguration *, C1 *, C1_AddOns *, C2 *,  C3 *,  C4 *,  C6 *,  C9 *, std::FILE *, std::string, double *, double **, dcomplex **, double **, dcomplex **, double ****, double **, dcomplex **, int, int, int, int, int, int, int, double *, double *, double **, dcomplex **, double **, dcomplex **, double **, dcomplex **, double *, std::fstream &, double **, double **, double **, double **, double *, double *, double *, int, int, np_int, int, int, int, int, int, int, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double &, double &, double &, double &, double &, double, double, int, dcomplex, double, double, np_int, dcomplex **, int, int, Logger *);
  friend void sphere(std::string, std::string, std::string);
  friend void sphere(std::string, std::string, std::string);
protected:
protected:
  //! \brief Matrix of dielectric parameters with size [NON_TRANS_LAYERS x N_SPHERES x N_SCALES].
  //! \brief Matrix of dielectric parameters with size [NON_TRANS_LAYERS x N_SPHERES x N_SCALES].
+1 −0
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ public:
      current = old->p_prev;
      current = old->p_prev;
      delete old;
      delete old;
    }
    }
    delete current;
  }
  }
  
  
  /*! \brief Append an element at the end of the List.
  /*! \brief Append an element at the end of the List.
Loading