Skip to content

Commit e4ab72a

Browse files
committed
Initialize MPI related variables: myid, num_procs and root_proc
1 parent 214bdb8 commit e4ab72a

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ void ESolver_KS_LCAO_TDDFT<Device>::update_pot(UnitCell& ucell, const int istep,
271271
{
272272
// Gather H and S matrices to root process
273273
#ifdef __MPI
274-
int myid, num_procs;
274+
int myid = 0;
275+
int num_procs = 1;
275276
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
276277
MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
277278

source/module_hamilt_lcao/module_tddft/evolve_elec.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ void Evolve_elec<Device>::solve_psi(const int& istep,
114114
// H_laststep and S_laststep are already gathered in esolver_ks_lcao_tddft.cpp
115115
#ifdef __MPI
116116
// Access the rank of the calling process in the communicator
117-
int myid, root_proc = 0;
117+
int myid = 0;
118+
int root_proc = 0;
118119
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
119120

120121
// Gather psi to the root process

source/module_hamilt_lcao/module_tddft/evolve_psi.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ void evolve_psi_tensor(const int nband,
160160
if (use_lapack)
161161
{
162162
// Need to gather H and S matrix to root process here
163-
int myid, num_procs;
163+
int myid = 0;
164+
int num_procs = 1;
164165
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
165166
MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
166167

@@ -186,7 +187,8 @@ void evolve_psi_tensor(const int nband,
186187
ct::Tensor U_operator(ct::DataType::DT_COMPLEX_DOUBLE, ct_device_type, ct::TensorShape({len_HS}));
187188
U_operator.zero();
188189

189-
int myid, root_proc = 0;
190+
int myid = 0;
191+
int root_proc = 0;
190192
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
191193

192194
// (1)->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

source/module_hamilt_lcao/module_tddft/propagator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ void Propagator::compute_propagator_tensor(const int nlocal,
7474
}
7575
else
7676
{
77-
int myid, root_proc = 0;
77+
int myid = 0;
78+
int root_proc = 0;
7879
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
7980
if (myid == root_proc)
8081
{

0 commit comments

Comments
 (0)