forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
101 lines (93 loc) · 2.88 KB
/
main.cpp
File metadata and controls
101 lines (93 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//==========================================================
// AUTHOR : mohan
// DATE : 2008-11-10
//==========================================================
#include "source_main/driver.h"
#include "fftw3.h"
#include "source_base/parallel_global.h"
#include "source_io/parse_args.h"
#include "source_io/module_parameter/parameter.h"
#include "source_main/version.h"
#ifdef _OPENMP
#include <omp.h>
#endif
#include <ctime>
#include <iostream>
namespace
{
void print_welcome_banner()
{
#ifdef VERSION
const char* version = VERSION;
#else
const char* version = "unknown";
#endif
#ifdef COMMIT_INFO
#include "commit.h"
const char* commit = COMMIT;
#else
const char* commit = "unknown";
#endif
std::cout << " "
<< std::endl
<< " ABACUS " << version << std::endl
<< std::endl
<< " Atomic-orbital Based Ab-initio Computation at UStc "
<< std::endl
<< std::endl
<< " Website: http://abacus.ustc.edu.cn/ "
<< std::endl
<< " Documentation: https://abacus.deepmodeling.com/ "
<< std::endl
<< " Repository: https://github.com/abacusmodeling/abacus-develop "
<< std::endl
<< " https://github.com/deepmodeling/abacus-develop "
<< std::endl
<< " Commit: " << commit << std::endl
<< std::endl;
time_t time_now = time(nullptr);
std::cout << " " << ctime(&time_now);
}
} // namespace
int main(int argc, char** argv)
{
/*
read the arguement in the command-line,
with "abacus -v", the program exit and returns version info,
with no arguments, the program continues.
*/
ModuleIO::parse_args(argc, argv);
/*
read the mpi parameters in the command-line,
initialize the mpi environment.
*/
int nproc = 1;
int my_rank = 0;
int nthread_per_proc = 1;
Parallel_Global::read_pal_param(argc, argv, nproc, nthread_per_proc, my_rank);
if (my_rank == 0)
{
print_welcome_banner();
}
#ifdef _OPENMP
// ref: https://www.fftw.org/fftw3_doc/Usage-of-Multi_002dthreaded-FFTW.html
fftw_init_threads();
fftw_plan_with_nthreads(omp_get_max_threads());
#endif
PARAM.set_pal_param(my_rank, nproc, nthread_per_proc);
/*
main program for doing electronic structure calculations.
*/
Driver DD;
DD.init();
/*
After running mpi version of abacus, release the mpi resources.
*/
#ifdef __MPI
Parallel_Global::finalize_mpi();
#endif
#ifdef _OPENMP
fftw_cleanup_threads();
#endif
return 0;
}