@@ -127,7 +127,7 @@ void ModuleIO::write_cube(
127127 }
128128
129129#ifdef __MPI
130- ModuleIO::write_cube_core (ofs_cube, bz, nbz, nplane, startz_current, data, nx*ny, nz, 6 );
130+ ModuleIO::write_cube_core (ofs_cube, bz, nbz, nplane, startz_current, data, nx*ny, nz, 1 , 6 );
131131#else
132132 ModuleIO::write_cube_core (ofs_cube, data, nx*ny, nz, 6 );
133133#endif
@@ -140,28 +140,25 @@ void ModuleIO::write_cube(
140140 // / for cube file
141141 ofs_cube.close ();
142142 }
143-
144- return ;
145143}
146144
147145
146+ #ifdef __MPI
147+
148148void ModuleIO::write_cube_core (
149149 std::ofstream &ofs_cube,
150- #ifdef __MPI
151150 const int bz,
152151 const int nbz,
153152 const int nplane,
154153 const int startz_current,
155- #endif
156154 const double *const data,
157155 const int nxy,
158156 const int nz,
157+ const int nld,
159158 const int n_data_newline)
160159{
161160 ModuleBase::TITLE (" ModuleIO" , " write_cube_core" );
162161
163- #ifdef __MPI
164-
165162 const int my_rank = GlobalV::MY_RANK;
166163 const int my_pool = GlobalV::MY_POOL;
167164 const int rank_in_pool = GlobalV::RANK_IN_POOL;
@@ -176,7 +173,6 @@ void ModuleIO::write_cube_core(
176173
177174 // num_z: how many planes on processor 'ip'
178175 std::vector<int > num_z (nproc_in_pool, 0 );
179-
180176 for (int iz = 0 ; iz < nbz; iz++)
181177 {
182178 const int ip = iz % nproc_in_pool;
@@ -230,7 +226,7 @@ void ModuleIO::write_cube_core(
230226 // mohan change to rho_save on 2012-02-10
231227 // because this can make our next restart calculation lead
232228 // to the same scf_thr as the one saved.
233- zpiece[ixy] = data[ixy * nplane + iz - startz_current];
229+ zpiece[ixy] = data[ixy * nplane + ( iz - startz_current) * nld ];
234230 }
235231 }
236232 // case 2: > first part rho: send the rho to
@@ -239,7 +235,7 @@ void ModuleIO::write_cube_core(
239235 {
240236 for (int ixy = 0 ; ixy < nxy; ixy++)
241237 {
242- zpiece[ixy] = data[ixy * nplane + iz - startz_current];
238+ zpiece[ixy] = data[ixy * nplane + ( iz - startz_current) * nld ];
243239 }
244240 MPI_Send (zpiece.data (), nxy, MPI_DOUBLE, 0 , tag, POOL_WORLD);
245241 }
@@ -281,7 +277,18 @@ void ModuleIO::write_cube_core(
281277 // / for cube file
282278 }
283279 MPI_Barrier (MPI_COMM_WORLD);
284- #else
280+ }
281+
282+ #else // #ifdef __MPI
283+
284+ void ModuleIO::write_cube_core (
285+ std::ofstream &ofs_cube,
286+ const double *const data,
287+ const int nxy,
288+ const int nz,
289+ const int n_data_newline)
290+ {
291+ ModuleBase::TITLE (" ModuleIO" , " write_cube_core" );
285292 for (int ixy = 0 ; ixy < nxy; ixy++)
286293 {
287294 for (int iz = 0 ; iz < nz; iz++)
@@ -295,5 +302,6 @@ void ModuleIO::write_cube_core(
295302 }
296303 ofs_cube << " \n " ;
297304 }
298- #endif
299- }
305+ }
306+
307+ #endif // #ifdef __MPI
0 commit comments