Skip to content

Commit 7672fdd

Browse files
authored
Merge pull request #173 from PDoakORNL/clang-format-proposed
Clang format proposed
2 parents 0d57c07 + 0ccf312 commit 7672fdd

File tree

109 files changed

+4174
-3831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+4174
-3831
lines changed

src/.clang-format

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: true
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: Left
8+
AlignOperands: false
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: false
11+
AllowShortBlocksOnASingleLine: true
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: All
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: true
20+
BinPackArguments: false
21+
BinPackParameters: false
22+
BreakBeforeBraces: Custom
23+
BraceWrapping:
24+
AfterClass: true
25+
AfterControlStatement: true
26+
AfterEnum: true
27+
AfterFunction: true
28+
AfterNamespace: true
29+
AfterObjCDeclaration: true
30+
AfterStruct: true
31+
AfterUnion: true
32+
AfterExternBlock: true
33+
BeforeCatch: true
34+
BeforeElse: true
35+
IndentBraces: false
36+
SplitEmptyFunction: false
37+
SplitEmptyRecord: false
38+
SplitEmptyNamespace: false
39+
BreakBeforeBinaryOperators: None
40+
BreakBeforeInheritanceComma: false
41+
BreakBeforeTernaryOperators: true
42+
BreakConstructorInitializersBeforeComma: false
43+
BreakConstructorInitializers: BeforeColon
44+
BreakAfterJavaFieldAnnotations: false
45+
BreakStringLiterals: true
46+
ColumnLimit: 100
47+
CommentPragmas: '^ IWYU pragma:'
48+
CompactNamespaces: false
49+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
50+
ConstructorInitializerIndentWidth: 4
51+
ContinuationIndentWidth: 4
52+
Cpp11BracedListStyle: true
53+
DerivePointerAlignment: false
54+
DisableFormat: false
55+
ExperimentalAutoDetectBinPacking: false
56+
FixNamespaceComments: true
57+
ForEachMacros:
58+
- foreach
59+
- Q_FOREACH
60+
- BOOST_FOREACH
61+
IncludeBlocks: Preserve
62+
IncludeCategories:
63+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
64+
Priority: 2
65+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
66+
Priority: 3
67+
- Regex: '.*'
68+
Priority: 1
69+
IncludeIsMainRegex: '(Test)?$'
70+
IndentCaseLabels: false
71+
# @future IndentPPDirectives: BeforeHash
72+
IndentWidth: 2
73+
IndentWrappedFunctionNames: true
74+
JavaScriptQuotes: Leave
75+
JavaScriptWrapImports: true
76+
KeepEmptyLinesAtTheStartOfBlocks: false
77+
MacroBlockBegin: ''
78+
MacroBlockEnd: ''
79+
MaxEmptyLinesToKeep: 2
80+
NamespaceIndentation: None
81+
ObjCBlockIndentWidth: 2
82+
ObjCSpaceAfterProperty: false
83+
ObjCSpaceBeforeProtocolList: true
84+
PenaltyBreakAssignment: 10
85+
PenaltyBreakBeforeFirstCallParameter: 100000
86+
PenaltyBreakComment: 20
87+
PenaltyBreakFirstLessLess: 120
88+
PenaltyBreakString: 1000
89+
PenaltyExcessCharacter: 9
90+
PenaltyReturnTypeOnItsOwnLine: 8
91+
PointerAlignment: Left
92+
ReflowComments: false
93+
SortIncludes: false
94+
SortUsingDeclarations: false
95+
SpaceAfterCStyleCast: false
96+
SpaceAfterTemplateKeyword: false
97+
SpaceBeforeAssignmentOperators: true
98+
SpaceBeforeParens: ControlStatements
99+
SpaceInEmptyParentheses: false
100+
SpacesBeforeTrailingComments: 1
101+
SpacesInAngles: false
102+
SpacesInContainerLiterals: true
103+
SpaceBeforeCtorInitializerColon: true
104+
SpaceBeforeInheritanceColon: true
105+
SpaceBeforeRangeBasedForLoopColon: true
106+
SpaceInEmptyParentheses: false
107+
SpacesInCStyleCastParentheses: false
108+
SpacesInParentheses: false
109+
SpacesInSquareBrackets: false
110+
Standard: Cpp11
111+
TabWidth: 8
112+
UseTab: Never
113+
...
114+

src/Drivers/Mover.hpp

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333

3434
namespace qmcplusplus
3535
{
36-
37-
/**
36+
/**
3837
* @brief Container class includes all the classes required to operate walker moves
3938
*
4039
* Movers are distinct from walkers. Walkers are lightweight in memory, while
@@ -44,67 +43,70 @@ namespace qmcplusplus
4443
*
4544
* This class is used only by QMC drivers.
4645
*/
47-
struct Mover
48-
{
49-
using RealType = QMCTraits::RealType;
50-
51-
/// random number generator
52-
RandomGenerator<RealType> rng;
53-
/// electrons
54-
ParticleSet els;
55-
/// single particle orbitals
56-
SPOSet *spo;
57-
/// wavefunction container
58-
WaveFunction wavefunction;
59-
/// non-local pseudo-potentials
60-
NonLocalPP<RealType> nlpp;
61-
62-
/// constructor
63-
Mover(const uint32_t myPrime,
64-
const ParticleSet &ions)
65-
: spo(nullptr), rng(myPrime), nlpp(rng)
66-
{
67-
build_els(els, ions, rng);
68-
}
69-
70-
/// destructor
71-
~Mover() { if (spo!=nullptr) delete spo; }
46+
struct Mover
47+
{
48+
using RealType = QMCTraits::RealType;
7249

73-
};
50+
/// random number generator
51+
RandomGenerator<RealType> rng;
52+
/// electrons
53+
ParticleSet els;
54+
/// single particle orbitals
55+
SPOSet* spo;
56+
/// wavefunction container
57+
WaveFunction wavefunction;
58+
/// non-local pseudo-potentials
59+
NonLocalPP<RealType> nlpp;
7460

75-
template <class T, typename TBOOL>
76-
const std::vector<T *> filtered_list(const std::vector<T *> &input_list, const std::vector<TBOOL> &chosen)
61+
/// constructor
62+
Mover(const uint32_t myPrime, const ParticleSet& ions) : spo(nullptr), rng(myPrime), nlpp(rng)
7763
{
78-
std::vector<T *> final_list;
79-
for(int iw=0; iw<input_list.size(); iw++)
80-
if(chosen[iw]) final_list.push_back(input_list[iw]);
81-
return final_list;
64+
build_els(els, ions, rng);
8265
}
8366

84-
const std::vector<ParticleSet *> extract_els_list(const std::vector<Mover *> &mover_list)
67+
/// destructor
68+
~Mover()
8569
{
86-
std::vector<ParticleSet *> els_list;
87-
for(auto it=mover_list.begin(); it!=mover_list.end(); it++)
88-
els_list.push_back(&(*it)->els);
89-
return els_list;
70+
if (spo != nullptr)
71+
delete spo;
9072
}
73+
};
9174

92-
const std::vector<SPOSet *> extract_spo_list(const std::vector<Mover *> &mover_list)
93-
{
94-
std::vector<SPOSet *> spo_list;
95-
for(auto it=mover_list.begin(); it!=mover_list.end(); it++)
96-
spo_list.push_back((*it)->spo);
97-
return spo_list;
98-
}
75+
template<class T, typename TBOOL>
76+
const std::vector<T*>
77+
filtered_list(const std::vector<T*>& input_list, const std::vector<TBOOL>& chosen)
78+
{
79+
std::vector<T*> final_list;
80+
for (int iw = 0; iw < input_list.size(); iw++)
81+
if (chosen[iw])
82+
final_list.push_back(input_list[iw]);
83+
return final_list;
84+
}
9985

100-
const std::vector<WaveFunction *> extract_wf_list(const std::vector<Mover *> &mover_list)
101-
{
102-
std::vector<WaveFunction *> wf_list;
103-
for(auto it=mover_list.begin(); it!=mover_list.end(); it++)
104-
wf_list.push_back(&(*it)->wavefunction);
105-
return wf_list;
106-
}
86+
const std::vector<ParticleSet*> extract_els_list(const std::vector<Mover*>& mover_list)
87+
{
88+
std::vector<ParticleSet*> els_list;
89+
for (auto it = mover_list.begin(); it != mover_list.end(); it++)
90+
els_list.push_back(&(*it)->els);
91+
return els_list;
92+
}
10793

94+
const std::vector<SPOSet*> extract_spo_list(const std::vector<Mover*>& mover_list)
95+
{
96+
std::vector<SPOSet*> spo_list;
97+
for (auto it = mover_list.begin(); it != mover_list.end(); it++)
98+
spo_list.push_back((*it)->spo);
99+
return spo_list;
108100
}
109101

102+
const std::vector<WaveFunction*> extract_wf_list(const std::vector<Mover*>& mover_list)
103+
{
104+
std::vector<WaveFunction*> wf_list;
105+
for (auto it = mover_list.begin(); it != mover_list.end(); it++)
106+
wf_list.push_back(&(*it)->wavefunction);
107+
return wf_list;
108+
}
109+
110+
} // namespace qmcplusplus
111+
110112
#endif

src/Drivers/check_determinant.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ using namespace qmcplusplus;
3636

3737
void print_help()
3838
{
39-
//clang-format off
39+
// clang-format off
4040
cout << "usage:" << '\n';
4141
cout << " check_determinant [-hvV] [-g \"n0 n1 n2\"] [-n steps]" << '\n';
4242
cout << " [-N substeps] [-s seed]" << '\n';
@@ -48,14 +48,12 @@ void print_help()
4848
cout << " -s set the random seed. default: 11" << '\n';
4949
cout << " -v verbose output" << '\n';
5050
cout << " -V print version information and exit" << '\n';
51-
//clang-format on
51+
// clang-format on
5252

5353
exit(1); // print help and exit
5454
}
55-
int main(int argc, char **argv)
55+
int main(int argc, char** argv)
5656
{
57-
58-
5957
// clang-format off
6058
typedef QMCTraits::RealType RealType;
6159
typedef ParticleSet::ParticlePos_t ParticlePos_t;
@@ -75,7 +73,7 @@ int main(int argc, char **argv)
7573
bool verbose = false;
7674

7775
int opt;
78-
while(optind < argc)
76+
while (optind < argc)
7977
{
8078
if ((opt = getopt(argc, argv, "hvVg:n:N:r:s:")) != -1)
8179
{
@@ -84,7 +82,9 @@ int main(int argc, char **argv)
8482
case 'g': // tiling1 tiling2 tiling3
8583
sscanf(optarg, "%d %d %d", &na, &nb, &nc);
8684
break;
87-
case 'h': print_help(); break;
85+
case 'h':
86+
print_help();
87+
break;
8888
case 'n':
8989
nsteps = atoi(optarg);
9090
break;
@@ -94,7 +94,9 @@ int main(int argc, char **argv)
9494
case 's':
9595
iseed = atoi(optarg);
9696
break;
97-
case 'v': verbose = true; break;
97+
case 'v':
98+
verbose = true;
99+
break;
98100
case 'V':
99101
print_version(true);
100102
return 1;
@@ -126,7 +128,7 @@ int main(int argc, char **argv)
126128

127129
double accumulated_error = 0.0;
128130

129-
#pragma omp parallel reduction(+:accumulated_error)
131+
#pragma omp parallel reduction(+ : accumulated_error)
130132
{
131133
int ip = omp_get_thread_num();
132134

@@ -178,7 +180,8 @@ int main(int argc, char **argv)
178180
PosType dr = sqrttau * delta[iel];
179181
bool isValid = els.makeMoveAndCheck(iel, dr);
180182

181-
if (!isValid) continue;
183+
if (!isValid)
184+
continue;
182185

183186
// Compute gradient at the trial position
184187

@@ -213,13 +216,12 @@ int main(int argc, char **argv)
213216

214217
constexpr double small_err = std::numeric_limits<double>::epsilon() * 6e8;
215218

216-
cout << "total accumulated error of " << accumulated_error << " for " << np
217-
<< " procs" << '\n';
219+
cout << "total accumulated error of " << accumulated_error << " for " << np << " procs" << '\n';
218220

219221
if (accumulated_error / np > small_err)
220222
{
221-
cout << "Checking failed with accumulated error: " << accumulated_error / np
222-
<< " > " << small_err << '\n';
223+
cout << "Checking failed with accumulated error: " << accumulated_error / np << " > "
224+
<< small_err << '\n';
223225
return 1;
224226
}
225227
else

0 commit comments

Comments
 (0)