ALPS MPS Codes
Reference documentation.
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
libpscan
options.cpp
Go to the documentation of this file.
1
/*****************************************************************************
2
*
3
* ALPS MPS DMRG Project
4
*
5
* Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6
* 2011-2011 by Michele Dolfi <dolfim@phys.ethz.ch>
7
*
8
* This software is part of the ALPS Applications, published under the ALPS
9
* Application License; you can use, redistribute it and/or modify it under
10
* the terms of the license, either version 1 or (at your option) any later
11
* version.
12
*
13
* You should have received a copy of the ALPS Application License along with
14
* the ALPS Applications; see the file LICENSE.txt. If not, the license is also
15
* available from http://alps.comp-phys.org/.
16
*
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
* DEALINGS IN THE SOFTWARE.
24
*
25
*****************************************************************************/
26
27
#include "
libpscan/options.hpp
"
28
#include <alps/utility/copyright.hpp>
29
#include <boost/limits.hpp>
30
#include <boost/throw_exception.hpp>
31
#include <boost/program_options.hpp>
32
#include <stdexcept>
33
34
35
Options::Options
()
36
:
37
time_limit(0.),
38
use_mpi(false),
39
valid(false),
// shall we really run?
40
write_xml(false)
41
{ }
42
43
Options::Options
(
int
argc,
char
** argv)
44
{
45
namespace
po = boost::program_options;
46
47
programname
= std::string(argv[0]);
48
valid
=
true
;
49
if
(argc) {
50
std::string filename;
51
int
dummy;
52
po::options_description desc(
"Allowed options"
);
53
desc.add_options()
54
(
"help"
,
"produce help message"
)
55
(
"license,l"
,
"print license conditions"
)
56
(
"mpi"
,
"run in parallel using MPI"
)
57
(
"Nmax"
, po::value<int>(&dummy),
"not used, only for backward compatibility with `dmrg`"
)
58
(
"time-limit,T"
, po::value<double>(&
time_limit
)->default_value(0),
"time limit for the simulation"
)
59
(
"write-xml"
,
"write results to XML files"
)
60
(
"input-file"
, po::value<std::string>(&filename),
"input file"
);
61
po::positional_options_description p;
62
p.add(
"input-file"
, 1);
63
64
po::variables_map vm;
65
po::store(po::command_line_parser(argc, argv).options(desc).positional(p).
run
(), vm);
66
po::notify(vm);
67
68
69
if
(vm.count(
"help"
)) {
70
std::cout << desc <<
"\n"
;
71
valid
=
false
;
72
}
73
if
(vm.count(
"license"
)) {
74
alps::print_license(std::cout);
75
valid
=
false
;
76
}
77
if
(!
valid
)
78
return
;
79
80
if
(vm.count(
"mpi"
)) {
81
use_mpi
=
true
;
82
}
83
84
if
(vm.count(
"write-xml"
))
85
write_xml
=
true
;
86
87
if
(!filename.empty())
88
jobfilename
=boost::filesystem::path(filename);
89
else
90
boost::throw_exception(std::runtime_error(
"No job file specified"
));
91
}
92
}
run
void run(std::string const &chkp1, std::string const &chkp2)
Definition:
main.cpp:52
Options::jobfilename
boost::filesystem::path jobfilename
Definition:
options.hpp:48
Options::Options
Options()
Definition:
options.cpp:35
Options::time_limit
double time_limit
Definition:
options.hpp:44
Options::valid
bool valid
Definition:
options.hpp:46
Options::use_mpi
bool use_mpi
Definition:
options.hpp:45
Options::write_xml
bool write_xml
Definition:
options.hpp:47
options.hpp
program options parser for parameter scans scheduler
Options::programname
std::string programname
Definition:
options.hpp:43
Generated on Thu Aug 21 2014 11:18:55 for ALPS MPS Codes by
1.8.7