int main(int argc,char *argv[]) { typedef PsimagLite::Concurrency ConcurrencyType; ConcurrencyType concurrency(&argc,&argv,1); InputCheck inputCheck; PsimagLite::String filename=""; int opt = 0; PsimagLite::String strUsage(argv[0]); strUsage += " -f filename"; PsimagLite::String insitu(""); while ((opt = getopt(argc, argv,"f:o:")) != -1) { switch (opt) { case 'f': filename = optarg; break; case 'o': if (insitu=="") { insitu = optarg; } else { insitu += ","; insitu += optarg; } break; default: inputCheck.usageMain(strUsage); return 1; } } // sanity checks here if (filename=="") { inputCheck.usageMain(strUsage); return 1; } // print license if (ConcurrencyType::root()) { std::cerr<<ProgramGlobals::license; Provenance provenance; std::cout<<provenance; } InputNgType::Writeable ioWriteable(filename,inputCheck); InputNgType::Readable io(ioWriteable); ParametersDmrgSolverType dmrgSolverParams(io); if (insitu!="") dmrgSolverParams.insitu = insitu; #ifndef USE_PTHREADS inputCheck.checkForThreads(dmrgSolverParams.nthreads); #endif ConcurrencyType::npthreads = dmrgSolverParams.nthreads; #ifdef USE_COMPLEX std::cerr<<argv[0]<<" EXPERIMENTAL option complex is in use\n"; mainLoop0<MySparseMatrixC>(io,dmrgSolverParams,inputCheck); #else mainLoop0<MySparseMatrixReal>(io,dmrgSolverParams,inputCheck); #endif }
int main(int argc,char *argv[]) { typedef PsimagLite::Concurrency ConcurrencyType; ConcurrencyType concurrency(&argc,&argv,1); InputCheck inputCheck; PsimagLite::String filename=""; int opt = 0; OperatorOptions options; PsimagLite::String strUsage(argv[0]); if (utils::basename(strUsage) == "operator") options.enabled = true; strUsage += " -f filename [-k] [-p precision] [-V] [whatToMeasure]"; int precision = 6; bool keepFiles = false; bool versionOnly = false; /* PSIDOC DmrgDriver \begin{itemize} \item[-f] {[}Mandatory, String{]} Input to use. \item[-p] [Optional, Integer] Digits of precision for printing. \item[whatToMeasure] {[}Optional, String{]} What to measure in-situ \item[-l] {[}Optional, String{]} Without this option std::cout is redirected to a file. This option with the string ``?'' prints name of such log file. This option with the string ``-'' writes std::cout to terminal. In other cases, string is the name of the file to redirect std::cout to. \item[-k] [Optional] Keep untar files \end{itemize} */ /* PSIDOC OperatorDriver The arguments to the \verb!operator! executable are as follows. \begin{itemize} \item[-f] [Mandatory, String] Input to use. The Model= line is very important in input.inp. \item[-s] [Optional, Integer] Site for operator. Meaningful only for Models where the Hilbert space depends on the site (different kinds of atoms). Defaults to 0. \item[-l] [Mandatory, String] The label or name for this operator. This is model dependent. For example to obtain $c_{\uparrow}$ for the Hubbard model, say \begin{verbatim} ./operator -l c -f input.inp\end{verbatim} See the function naturalOperator for each Model. \item[-d] [Optional, Integer] Degree of freedom (spin, orbital or combination of both) to use. This is model dependent. For example to obtain $c_\downarrow$ for the Hubbard model, say \begin{verbatim}./operator -l c -d 1 -f input.inp\end{verbatim} See the function naturalOperator for each Model. Defaults to 0. \item[-t] [Optional, Void] Transpose the operator. For example to obtain $c^\dagger_\uparrow$ for a Hubbard model, say \begin{verbatim}./operator -l c -t -f input.inp\end{verbatim} \end{itemize} */ while ((opt = getopt(argc, argv,"f:s:l:d:F:o:p:tkV")) != -1) { switch (opt) { case 'f': filename = optarg; break; case 'o': std::cerr<<argv[0]<<": Omit the \"-o\". It's not needed anymore.\n"; std::cerr<<"\t Write the insitu measurements at the end of the command line\n"; return 1; case 's': options.site = atoi(optarg); break; case 'l': options.label = optarg; break; case 'd': options.dof = atoi(optarg); break; case 't': options.transpose = true; break; case 'k': keepFiles = true; break; case 'F': std::cerr<<argv[0]<<": Omit the \"-F\". It's not needed anymore.\n"; std::cerr<<"\t It is implied by the label: n=bosonic, c=fermionic, etc\n"; return 2; case 'p': precision = atoi(optarg); std::cout.precision(precision); std::cerr.precision(precision); break; case 'V': versionOnly = true; options.label = "-"; break; default: inputCheck.usageMain(strUsage); return 1; } } // sanity checks here if (filename=="" && !versionOnly) { inputCheck.usageMain(strUsage); return 1; } PsimagLite::String insitu = (optind < argc) ? argv[optind] : ""; if (!options.enabled && options.label != "-") { bool queryOnly = (options.label == "?"); if (options.label == "" || options.label == "?") { options.label = ArchiveFilesType::coutName(filename); if (queryOnly) { std::cout<<options.label<<"\n"; return 0; } } GlobalCoutStream.open(options.label.c_str()); if (!GlobalCoutStream || GlobalCoutStream.bad() || !GlobalCoutStream.good()) { PsimagLite::String str(argv[0]); str += ": Could not redirect std::cout to " + options.label + "\n"; throw PsimagLite::RuntimeError(str); } std::cerr<<argv[0]<<" ATTENTION: All standard output now sent to "; std::cerr<<options.label<<"\n"; std::cerr.flush(); GlobalCoutBuffer = std::cout.rdbuf(); //save old buf std::cout.rdbuf(GlobalCoutStream.rdbuf()); //redirect std::cout to file atexit(restoreCoutBuffer); } // print license if (ConcurrencyType::root() && !options.enabled) { std::cout<<ProgramGlobals::license; Provenance provenance; std::cout<<provenance; } if (versionOnly) return 0; InputNgType::Writeable ioWriteable(filename,inputCheck); InputNgType::Readable io(ioWriteable); ParametersDmrgSolverType dmrgSolverParams(io, false); ArchiveFilesType af(dmrgSolverParams,filename,options.enabled,options.label); if (insitu!="") dmrgSolverParams.insitu = insitu; if (dmrgSolverParams.options.find("minimizeDisk") != PsimagLite::String::npos) dmrgSolverParams.options += ",noSaveWft,noSaveStacks,noSaveData"; #ifndef USE_PTHREADS inputCheck.checkForThreads(dmrgSolverParams.nthreads); #endif ConcurrencyType::npthreads = dmrgSolverParams.nthreads; registerSignals(); PsimagLite::String targeting = inputCheck.getTargeting(dmrgSolverParams.options); bool isComplex = (dmrgSolverParams.options.find("useComplex") != PsimagLite::String::npos); if (targeting=="TimeStepTargetting") isComplex = true; if (isComplex) { mainLoop0<MySparseMatrixComplex, CvectorSizeType>(io,dmrgSolverParams,targeting,options); } else { mainLoop0<MySparseMatrixReal, CvectorSizeType>(io,dmrgSolverParams,targeting,options); } if (options.enabled) return 0; af.deletePackedFiles(); if (!keepFiles) ArchiveFilesType::staticDelete(); }
int main(int argc,char *argv[]) { typedef PsimagLite::Concurrency ConcurrencyType; ConcurrencyType concurrency(&argc,&argv,1); InputCheck inputCheck; PsimagLite::String filename=""; int opt = 0; OperatorOptions options; PsimagLite::String strUsage(argv[0]); if (utils::basename(strUsage) == "operator") options.enabled = true; strUsage += " -f filename"; PsimagLite::String insitu(""); int precision = 6; /* PSIDOC OperatorDriver The arguments to the \verb!operator! executable are as follows. \begin{itemize} \item[-f] [Mandatory, String] Input to use. The Model= line is very important in input.inp. \item[-s] [Optional, Integer] Site for operator. Meaningful only for Models where the Hilbert space depends on the site (different kinds of atoms). Defaults to 0. \item[-l] [Mandatory, String] The label or name for this operator. This is model dependent. For example to obtain $c_{\uparrow}$ for the Hubbard model, say \begin{verbatim} ./operator -l c -f input.inp -F -1\end{verbatim} See the function naturalOperator for each Model. \item[-d] [Optional, Integer] Degree of freedom (spin, orbital or combination of both) to use. This is model dependent. For example to obtain $c_\downarrow$ for the Hubbard model, say \begin{verbatim}./operator -l c -d 1 -f input.inp -F -1\end{verbatim} See the function naturalOperator for each Model. Defaults to 0. \item[-F] [Mandatory, 1 or -1] If this operator commutes on \emph{different} sites say 1 here. If it anticommutes on \emph{different} sites say -1. \item[-t] [Optional, Void] Transpose the operator. For example to obtain $c^\dagger_\uparrow$ for a Hubbard model, say \begin{verbatim}./operator -l c -t -f input.inp -F -1\end{verbatim} \end{itemize} */ while ((opt = getopt(argc, argv,"f:o:s:l:d:F:p:t")) != -1) { switch (opt) { case 'f': filename = optarg; break; case 'o': if (insitu=="") { insitu = optarg; } else { insitu += ","; insitu += optarg; } break; case 's': options.site = atoi(optarg); break; case 'l': options.label = optarg; break; case 'd': options.dof = atoi(optarg); break; case 't': options.transpose = true; break; case 'F': options.fermionicSign = atoi(optarg); break; case 'p': precision = atoi(optarg); std::cout.precision(precision); std::cerr.precision(precision); break; default: inputCheck.usageMain(strUsage); return 1; } } // sanity checks here if (filename=="") { inputCheck.usageMain(strUsage); return 1; } // print license if (ConcurrencyType::root()) { std::cerr<<ProgramGlobals::license; Provenance provenance; std::cerr<<provenance; } InputNgType::Writeable ioWriteable(filename,inputCheck); InputNgType::Readable io(ioWriteable); ParametersDmrgSolverType dmrgSolverParams(io); if (insitu!="") dmrgSolverParams.insitu = insitu; #ifndef USE_PTHREADS inputCheck.checkForThreads(dmrgSolverParams.nthreads); #endif ConcurrencyType::npthreads = dmrgSolverParams.nthreads; registerSignals(); #ifdef USE_COMPLEX std::cerr<<argv[0]<<" EXPERIMENTAL option complex is in use\n"; mainLoop0<MySparseMatrixC>(io,dmrgSolverParams,inputCheck,options); #else mainLoop0<MySparseMatrixReal>(io,dmrgSolverParams,inputCheck,options); #endif }