11#include " unitcell.h"
2-
2+ #include " module_base/parallel_common.h"
3+ #include " module_parameter/parameter.h"
4+ #ifdef __EXX
5+ #include " module_ri/serialization_cereal.h"
6+ #include " module_hamilt_pw/hamilt_pwdft/global.h"
7+ #endif
38namespace unitcell
49{
510 void bcast_atoms_tau (Atom* atoms,
@@ -12,4 +17,105 @@ namespace unitcell
1217 }
1318 #endif
1419 }
20+
21+ void bcast_atoms_pseudo (Atom* atoms,
22+ const int ntype)
23+ {
24+ #ifdef __MPI
25+ MPI_Barrier (MPI_COMM_WORLD);
26+ for (int i = 0 ; i < ntype; i++)
27+ {
28+ atoms[i].bcast_atom2 ();
29+ }
30+ #endif
31+ }
32+
33+ void bcast_Lattice (Lattice& lat)
34+ {
35+ #ifdef __MPI
36+ MPI_Barrier (MPI_COMM_WORLD);
37+ // distribute lattice parameters.
38+ ModuleBase::Matrix3& latvec = lat.latvec ;
39+ ModuleBase::Matrix3& latvec_supercell = lat.latvec_supercell ;
40+ Parallel_Common::bcast_string (lat.Coordinate );
41+ Parallel_Common::bcast_double (lat.lat0 );
42+ Parallel_Common::bcast_double (lat.lat0_angstrom );
43+ Parallel_Common::bcast_double (lat.tpiba );
44+ Parallel_Common::bcast_double (lat.tpiba2 );
45+ Parallel_Common::bcast_double (lat.omega );
46+ Parallel_Common::bcast_string (lat.latName );
47+
48+ // distribute lattice vectors.
49+ Parallel_Common::bcast_double (latvec.e11 );
50+ Parallel_Common::bcast_double (latvec.e12 );
51+ Parallel_Common::bcast_double (latvec.e13 );
52+ Parallel_Common::bcast_double (latvec.e21 );
53+ Parallel_Common::bcast_double (latvec.e22 );
54+ Parallel_Common::bcast_double (latvec.e23 );
55+ Parallel_Common::bcast_double (latvec.e31 );
56+ Parallel_Common::bcast_double (latvec.e32 );
57+ Parallel_Common::bcast_double (latvec.e33 );
58+
59+ // distribute lattice vectors.
60+ for (int i = 0 ; i < 3 ; i++)
61+ {
62+ Parallel_Common::bcast_double (lat.a1 [i]);
63+ Parallel_Common::bcast_double (lat.a2 [i]);
64+ Parallel_Common::bcast_double (lat.a3 [i]);
65+ Parallel_Common::bcast_double (lat.latcenter [i]);
66+ Parallel_Common::bcast_int (lat.lc [i]);
67+ }
68+
69+ // distribute superlattice vectors.
70+ Parallel_Common::bcast_double (latvec_supercell.e11 );
71+ Parallel_Common::bcast_double (latvec_supercell.e12 );
72+ Parallel_Common::bcast_double (latvec_supercell.e13 );
73+ Parallel_Common::bcast_double (latvec_supercell.e21 );
74+ Parallel_Common::bcast_double (latvec_supercell.e22 );
75+ Parallel_Common::bcast_double (latvec_supercell.e23 );
76+ Parallel_Common::bcast_double (latvec_supercell.e31 );
77+ Parallel_Common::bcast_double (latvec_supercell.e32 );
78+ Parallel_Common::bcast_double (latvec_supercell.e33 );
79+
80+ // distribute Change the lattice vectors or not
81+ #endif
82+ }
83+
84+ void bcast_magnetism (Magnetism& magnet, const int ntype)
85+ {
86+ #ifdef __MPI
87+ MPI_Barrier (MPI_COMM_WORLD);
88+ Parallel_Common::bcast_double (magnet.start_magnetization , ntype);
89+ if (PARAM.inp .nspin == 4 )
90+ {
91+ Parallel_Common::bcast_double (magnet.ux_ [0 ]);
92+ Parallel_Common::bcast_double (magnet.ux_ [1 ]);
93+ Parallel_Common::bcast_double (magnet.ux_ [2 ]);
94+ }
95+ #endif
96+ }
97+
98+ void bcast_unitcell (UnitCell& ucell)
99+ {
100+ #ifdef __MPI
101+ const int ntype = ucell.ntype ;
102+ Parallel_Common::bcast_int (ucell.nat );
103+
104+ bcast_Lattice (ucell.lat );
105+ bcast_magnetism (ucell.magnet ,ntype);
106+ bcast_atoms_tau (ucell.atoms ,ntype);
107+
108+ for (int i = 0 ; i < ntype; i++)
109+ {
110+ Parallel_Common::bcast_string (ucell.orbital_fn [i]);
111+ }
112+
113+ #ifdef __EXX
114+ ModuleBase::bcast_data_cereal (GlobalC::exx_info.info_ri .files_abfs ,
115+ MPI_COMM_WORLD,
116+ 0 );
117+ #endif
118+ return ;
119+ #endif
120+ }
15121}
0 commit comments