Loading src/cluster/cluster.cpp +203 −132 Original line number Diff line number Diff line Loading @@ -43,7 +43,56 @@ using namespace std; 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); // 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... // // struct clu_jxi488_cycle_args { // 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 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); /*! \brief C++ implementation of CLU * Loading Loading @@ -115,19 +164,20 @@ void cluster(string config_file, string data_file, string output_path) { C6 *c6 = new C6(c4->lmtpo); FILE *output = fopen((output_path + "/c_OCLU").c_str(), "w"); int jer = 0; // int lcalc = 0; int lcalc = 0; dcomplex arg = 0.0 + 0.0 * I; dcomplex ccsam = 0.0 + 0.0 * I; int configurations = 0; for (int ci = 1; ci <= nsph; ci++) { if (sconf->iog_vec[ci -1] >= ci) configurations++; } C2 *c2 = new C2(nsph, configurations, npnt, npntts); // np_int ndit = 2 * nsph * c4->nlim; // dcomplex *am_vector = new dcomplex[ndit * ndit](); // dcomplex **am = new dcomplex*[ndit]; // for (int ai = 0; ai < ndit; ai++) { // am[ai] = (am_vector + ai * ndit); // } np_int ndit = 2 * nsph * c4->nlim; dcomplex *am_vector = new dcomplex[ndit * ndit](); dcomplex **am = new dcomplex*[ndit]; for (int ai = 0; ai < ndit; ai++) { am[ai] = (am_vector + ai * ndit); } const int ndi = c4->nsph * c4->nlim; C9 *c9 = new C9(ndi, c4->nlem, 2 * ndi, 2 * c4->nlem); double *gaps = new double[nsph](); Loading Loading @@ -166,6 +216,16 @@ void cluster(string config_file, string data_file, string output_path) { gap[gi] = new double[2](); gapm[gi] = new double[2](); } double *u = new double[3](); double *us = new double[3](); double *un = new double[3](); double *uns = new double[3](); double *up = new double[3](); double *ups = new double[3](); double *unmp = new double[3](); double *unsmp = new double[3](); double *upmp = new double[3](); double *upsmp = new double[3](); double *argi = new double[1](); double *args = new double[1](); double *duk = new double[3](); Loading @@ -181,8 +241,8 @@ void cluster(string config_file, string data_file, string output_path) { cmullr[ci] = new double[4](); cmul[ci] = new double[4](); } //int isq, ibf; //double scan, cfmp, sfmp, cfsp, sfsp; int isq, ibf; double scan, cfmp, sfmp, cfsp, sfsp; // End of global variables for CLU fprintf(output, " READ(IR,*)NSPH,LI,LE,MXNDM,INPOL,NPNT,NPNTTS,IAVM,ISAM\n"); fprintf(output, " %5d%5d%5d%5ld%5d%5d%5d%5d%5d\n", Loading Loading @@ -271,6 +331,7 @@ void cluster(string config_file, string data_file, string output_path) { tppoan.write(reinterpret_cast<char *>(&nths), sizeof(int)); tppoan.write(reinterpret_cast<char *>(&nphs), sizeof(int)); double wn = wp / 3.0e8; double sqsfi = 1.0; if (sconf->idfc < 0) { vk = sconf->xip * wn; fprintf(output, " VK=%15.7lE, XI IS SCALE FACTOR FOR LENGTHS\n", vk); Loading @@ -278,7 +339,7 @@ void cluster(string config_file, string data_file, string output_path) { } for (int jxi488 = 1; jxi488 <= nxi; jxi488++) { // To test parallelism, I will now start feeding this function with "clean" copies of the parameters, so that they will not be changed by previous iterations, and each one will behave as the first one 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); 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); } // jxi488 loop tppoan.close(); } else { // In case TPPOAN could not be opened. Should never happen. Loading @@ -301,8 +362,8 @@ void cluster(string config_file, string data_file, string output_path) { delete[] zpv[zi]; } delete[] zpv; //delete[] am_vector; //delete[] am; delete[] am_vector; delete[] am; //delete[] tam; delete[] gaps; for (int ti = 1; ti > -1; ti--) { Loading Loading @@ -336,6 +397,16 @@ void cluster(string config_file, string data_file, string output_path) { delete[] gap; delete[] gapm; delete[] gapv; delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] argi; delete[] args; delete[] duk; Loading @@ -360,68 +431,68 @@ void cluster(string config_file, string data_file, string output_path) { } 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 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 nxi = sconf->number_of_scales; int nsph = gconf->number_of_spheres; np_int mxndm = (np_int)gconf->mxndm; int inpol = gconf->in_pol; int iavm = gconf->iavm; int npnt = gconf->npnt; int npntts = gconf->npntts; int isam = gconf->meridional_type; int lm = gconf->l_max; double th = gconf->in_theta_start; double thstp = gconf->in_theta_step; double thlst = gconf->in_theta_end; double ths = gconf->sc_theta_start; double thsstp = gconf->sc_theta_step; double thslst = gconf->sc_theta_end; double ph = gconf->in_phi_start; double phstp = gconf->in_phi_step; double phlst = gconf->in_phi_end; double phs = gconf->sc_phi_start; double phsstp = gconf->sc_phi_step; double phslst = gconf->sc_phi_end; double th1 = th; double ph1 = ph; double ths1 = ths; double phs1 = phs; double thsca = 0.0; if (isam > 1) thsca = ths - th; double *u = new double[3](); double *us = new double[3](); double *un = new double[3](); double *uns = new double[3](); double *up = new double[3](); double *ups = new double[3](); double *unmp = new double[3](); double *unsmp = new double[3](); double *upmp = new double[3](); double *upsmp = new double[3](); double scan; double cfmp; double sfmp; double cfsp; double sfsp; double sqsfi = 1.0; double exri = sqrt(sconf->exdc); // int nxi = sconf->number_of_scales; // int nsph = gconf->number_of_spheres; // np_int mxndm = (np_int)gconf->mxndm; // int inpol = gconf->in_pol; // int iavm = gconf->iavm; // int npnt = gconf->npnt; // int npntts = gconf->npntts; // int isam = gconf->meridional_type; // int lm = gconf->l_max; // double th = gconf->in_theta_start; // double thstp = gconf->in_theta_step; // double thlst = gconf->in_theta_end; // double ths = gconf->sc_theta_start; // double thsstp = gconf->sc_theta_step; // double thslst = gconf->sc_theta_end; // double ph = gconf->in_phi_start; // double phstp = gconf->in_phi_step; // double phlst = gconf->in_phi_end; // double phs = gconf->sc_phi_start; // double phsstp = gconf->sc_phi_step; // double phslst = gconf->sc_phi_end; // double th1 = th; // double ph1 = ph; // double ths1 = ths; // double phs1 = phs; // double thsca = 0.0; // if (isam > 1) thsca = ths - th; // double *u = new double[3](); // double *us = new double[3](); // double *un = new double[3](); // double *uns = new double[3](); // double *up = new double[3](); // double *ups = new double[3](); // double *unmp = new double[3](); // double *unsmp = new double[3](); // double *upmp = new double[3](); // double *upsmp = new double[3](); // double scan; // double cfmp; // double sfmp; // double cfsp; // double sfsp; // double sqsfi = 1.0; // double exri = sqrt(sconf->exdc); int jer = 0; int lcalc = 0; dcomplex arg = 0.0 + 0.0 * I; double wp = sconf->wp; double wn = wp / 3.0e8; double vk = 0.0; if (sconf->idfc < 0) vk = sconf->xip * wn; np_int ndit = 2 * nsph * c4->nlim; dcomplex *am_vector = new dcomplex[ndit * ndit](); dcomplex **am = new dcomplex*[ndit]; for (int ai = 0; ai < ndit; ai++) { am[ai] = (am_vector + ai * ndit); } int isq; int ibf; // int lcalc = 0; // dcomplex arg = 0.0 + 0.0 * I; // double wp = sconf->wp; // double wn = wp / 3.0e8; // double vk = 0.0; // if (sconf->idfc < 0) vk = sconf->xip * wn; // np_int ndit = 2 * nsph * c4->nlim; // dcomplex *am_vector = new dcomplex[ndit * ndit](); // dcomplex **am = new dcomplex*[ndit]; // for (int ai = 0; ai < ndit; ai++) { // am[ai] = (am_vector + ai * ndit); // } // int isq; // int ibf; Loading @@ -442,18 +513,18 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf hjv(exri, vkarg, jer, lcalc, arg, c1, c1ao, c4); if (jer != 0) { fprintf(output, " STOP IN HJV\n"); delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; // break; // rewrite this to go to the end of the function, to free locally allocated variables and return jer } Loading Loading @@ -483,35 +554,35 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf ); if (jer != 0) { fprintf(output, " STOP IN DME\n"); delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; //break; } } if (jer != 0) { delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; //break; } Loading @@ -519,18 +590,18 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf cms(am, c1, c1ao, c4, c6); invert_matrix(am, ndit, jer, mxndm); if (jer != 0) { delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; // break; // jxi488 loop: goes to memory clean } Loading Loading @@ -1087,18 +1158,18 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf th += thstp; } // jth486 loop delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; printf(" done.\n"); Loading src/include/Configuration.h +2 −2 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class C9; class GeometryConfiguration { //! Temporary work-around to allow cluster() and sphere() peeking in. 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 *); 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 void sphere(std::string, std::string, std::string); protected: //! \brief Number of spherical components. Loading Loading @@ -180,7 +180,7 @@ public: class ScattererConfiguration { //! Temporary work-around to allow cluster() and sphere() peeking in. 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 *); 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 void sphere(std::string, std::string, std::string); protected: //! \brief Matrix of dielectric parameters with size [NON_TRANS_LAYERS x N_SPHERES x N_SCALES]. Loading Loading
src/cluster/cluster.cpp +203 −132 Original line number Diff line number Diff line Loading @@ -43,7 +43,56 @@ using namespace std; 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); // 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... // // struct clu_jxi488_cycle_args { // 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 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); /*! \brief C++ implementation of CLU * Loading Loading @@ -115,19 +164,20 @@ void cluster(string config_file, string data_file, string output_path) { C6 *c6 = new C6(c4->lmtpo); FILE *output = fopen((output_path + "/c_OCLU").c_str(), "w"); int jer = 0; // int lcalc = 0; int lcalc = 0; dcomplex arg = 0.0 + 0.0 * I; dcomplex ccsam = 0.0 + 0.0 * I; int configurations = 0; for (int ci = 1; ci <= nsph; ci++) { if (sconf->iog_vec[ci -1] >= ci) configurations++; } C2 *c2 = new C2(nsph, configurations, npnt, npntts); // np_int ndit = 2 * nsph * c4->nlim; // dcomplex *am_vector = new dcomplex[ndit * ndit](); // dcomplex **am = new dcomplex*[ndit]; // for (int ai = 0; ai < ndit; ai++) { // am[ai] = (am_vector + ai * ndit); // } np_int ndit = 2 * nsph * c4->nlim; dcomplex *am_vector = new dcomplex[ndit * ndit](); dcomplex **am = new dcomplex*[ndit]; for (int ai = 0; ai < ndit; ai++) { am[ai] = (am_vector + ai * ndit); } const int ndi = c4->nsph * c4->nlim; C9 *c9 = new C9(ndi, c4->nlem, 2 * ndi, 2 * c4->nlem); double *gaps = new double[nsph](); Loading Loading @@ -166,6 +216,16 @@ void cluster(string config_file, string data_file, string output_path) { gap[gi] = new double[2](); gapm[gi] = new double[2](); } double *u = new double[3](); double *us = new double[3](); double *un = new double[3](); double *uns = new double[3](); double *up = new double[3](); double *ups = new double[3](); double *unmp = new double[3](); double *unsmp = new double[3](); double *upmp = new double[3](); double *upsmp = new double[3](); double *argi = new double[1](); double *args = new double[1](); double *duk = new double[3](); Loading @@ -181,8 +241,8 @@ void cluster(string config_file, string data_file, string output_path) { cmullr[ci] = new double[4](); cmul[ci] = new double[4](); } //int isq, ibf; //double scan, cfmp, sfmp, cfsp, sfsp; int isq, ibf; double scan, cfmp, sfmp, cfsp, sfsp; // End of global variables for CLU fprintf(output, " READ(IR,*)NSPH,LI,LE,MXNDM,INPOL,NPNT,NPNTTS,IAVM,ISAM\n"); fprintf(output, " %5d%5d%5d%5ld%5d%5d%5d%5d%5d\n", Loading Loading @@ -271,6 +331,7 @@ void cluster(string config_file, string data_file, string output_path) { tppoan.write(reinterpret_cast<char *>(&nths), sizeof(int)); tppoan.write(reinterpret_cast<char *>(&nphs), sizeof(int)); double wn = wp / 3.0e8; double sqsfi = 1.0; if (sconf->idfc < 0) { vk = sconf->xip * wn; fprintf(output, " VK=%15.7lE, XI IS SCALE FACTOR FOR LENGTHS\n", vk); Loading @@ -278,7 +339,7 @@ void cluster(string config_file, string data_file, string output_path) { } for (int jxi488 = 1; jxi488 <= nxi; jxi488++) { // To test parallelism, I will now start feeding this function with "clean" copies of the parameters, so that they will not be changed by previous iterations, and each one will behave as the first one 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); 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); } // jxi488 loop tppoan.close(); } else { // In case TPPOAN could not be opened. Should never happen. Loading @@ -301,8 +362,8 @@ void cluster(string config_file, string data_file, string output_path) { delete[] zpv[zi]; } delete[] zpv; //delete[] am_vector; //delete[] am; delete[] am_vector; delete[] am; //delete[] tam; delete[] gaps; for (int ti = 1; ti > -1; ti--) { Loading Loading @@ -336,6 +397,16 @@ void cluster(string config_file, string data_file, string output_path) { delete[] gap; delete[] gapm; delete[] gapv; delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] argi; delete[] args; delete[] duk; Loading @@ -360,68 +431,68 @@ void cluster(string config_file, string data_file, string output_path) { } 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 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 nxi = sconf->number_of_scales; int nsph = gconf->number_of_spheres; np_int mxndm = (np_int)gconf->mxndm; int inpol = gconf->in_pol; int iavm = gconf->iavm; int npnt = gconf->npnt; int npntts = gconf->npntts; int isam = gconf->meridional_type; int lm = gconf->l_max; double th = gconf->in_theta_start; double thstp = gconf->in_theta_step; double thlst = gconf->in_theta_end; double ths = gconf->sc_theta_start; double thsstp = gconf->sc_theta_step; double thslst = gconf->sc_theta_end; double ph = gconf->in_phi_start; double phstp = gconf->in_phi_step; double phlst = gconf->in_phi_end; double phs = gconf->sc_phi_start; double phsstp = gconf->sc_phi_step; double phslst = gconf->sc_phi_end; double th1 = th; double ph1 = ph; double ths1 = ths; double phs1 = phs; double thsca = 0.0; if (isam > 1) thsca = ths - th; double *u = new double[3](); double *us = new double[3](); double *un = new double[3](); double *uns = new double[3](); double *up = new double[3](); double *ups = new double[3](); double *unmp = new double[3](); double *unsmp = new double[3](); double *upmp = new double[3](); double *upsmp = new double[3](); double scan; double cfmp; double sfmp; double cfsp; double sfsp; double sqsfi = 1.0; double exri = sqrt(sconf->exdc); // int nxi = sconf->number_of_scales; // int nsph = gconf->number_of_spheres; // np_int mxndm = (np_int)gconf->mxndm; // int inpol = gconf->in_pol; // int iavm = gconf->iavm; // int npnt = gconf->npnt; // int npntts = gconf->npntts; // int isam = gconf->meridional_type; // int lm = gconf->l_max; // double th = gconf->in_theta_start; // double thstp = gconf->in_theta_step; // double thlst = gconf->in_theta_end; // double ths = gconf->sc_theta_start; // double thsstp = gconf->sc_theta_step; // double thslst = gconf->sc_theta_end; // double ph = gconf->in_phi_start; // double phstp = gconf->in_phi_step; // double phlst = gconf->in_phi_end; // double phs = gconf->sc_phi_start; // double phsstp = gconf->sc_phi_step; // double phslst = gconf->sc_phi_end; // double th1 = th; // double ph1 = ph; // double ths1 = ths; // double phs1 = phs; // double thsca = 0.0; // if (isam > 1) thsca = ths - th; // double *u = new double[3](); // double *us = new double[3](); // double *un = new double[3](); // double *uns = new double[3](); // double *up = new double[3](); // double *ups = new double[3](); // double *unmp = new double[3](); // double *unsmp = new double[3](); // double *upmp = new double[3](); // double *upsmp = new double[3](); // double scan; // double cfmp; // double sfmp; // double cfsp; // double sfsp; // double sqsfi = 1.0; // double exri = sqrt(sconf->exdc); int jer = 0; int lcalc = 0; dcomplex arg = 0.0 + 0.0 * I; double wp = sconf->wp; double wn = wp / 3.0e8; double vk = 0.0; if (sconf->idfc < 0) vk = sconf->xip * wn; np_int ndit = 2 * nsph * c4->nlim; dcomplex *am_vector = new dcomplex[ndit * ndit](); dcomplex **am = new dcomplex*[ndit]; for (int ai = 0; ai < ndit; ai++) { am[ai] = (am_vector + ai * ndit); } int isq; int ibf; // int lcalc = 0; // dcomplex arg = 0.0 + 0.0 * I; // double wp = sconf->wp; // double wn = wp / 3.0e8; // double vk = 0.0; // if (sconf->idfc < 0) vk = sconf->xip * wn; // np_int ndit = 2 * nsph * c4->nlim; // dcomplex *am_vector = new dcomplex[ndit * ndit](); // dcomplex **am = new dcomplex*[ndit]; // for (int ai = 0; ai < ndit; ai++) { // am[ai] = (am_vector + ai * ndit); // } // int isq; // int ibf; Loading @@ -442,18 +513,18 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf hjv(exri, vkarg, jer, lcalc, arg, c1, c1ao, c4); if (jer != 0) { fprintf(output, " STOP IN HJV\n"); delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; // break; // rewrite this to go to the end of the function, to free locally allocated variables and return jer } Loading Loading @@ -483,35 +554,35 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf ); if (jer != 0) { fprintf(output, " STOP IN DME\n"); delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; //break; } } if (jer != 0) { delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; //break; } Loading @@ -519,18 +590,18 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf cms(am, c1, c1ao, c4, c6); invert_matrix(am, ndit, jer, mxndm); if (jer != 0) { delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; return jer; // break; // jxi488 loop: goes to memory clean } Loading Loading @@ -1087,18 +1158,18 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf th += thstp; } // jth486 loop delete[] u; delete[] us; delete[] un; delete[] uns; delete[] up; delete[] ups; delete[] unmp; delete[] unsmp; delete[] upmp; delete[] upsmp; delete[] am_vector; delete[] am; // delete[] u; // delete[] us; // delete[] un; // delete[] uns; // delete[] up; // delete[] ups; // delete[] unmp; // delete[] unsmp; // delete[] upmp; // delete[] upsmp; // delete[] am_vector; // delete[] am; printf(" done.\n"); Loading
src/include/Configuration.h +2 −2 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ class C9; class GeometryConfiguration { //! Temporary work-around to allow cluster() and sphere() peeking in. 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 *); 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 void sphere(std::string, std::string, std::string); protected: //! \brief Number of spherical components. Loading Loading @@ -180,7 +180,7 @@ public: class ScattererConfiguration { //! Temporary work-around to allow cluster() and sphere() peeking in. 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 *); 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 void sphere(std::string, std::string, std::string); protected: //! \brief Matrix of dielectric parameters with size [NON_TRANS_LAYERS x N_SPHERES x N_SCALES]. Loading