Skip to content

Fix some initialization problems#6921

Merged
mohanchen merged 31 commits intodeepmodeling:developfrom
mohanchen:20260125-fix-initialized
Jan 28, 2026
Merged

Fix some initialization problems#6921
mohanchen merged 31 commits intodeepmodeling:developfrom
mohanchen:20260125-fix-initialized

Conversation

@mohanchen
Copy link
Collaborator

20260125 fix initialized

abacus_fixer and others added 27 commits January 23, 2026 20:25
1. Remove #ifdef __MPI from timer code, encapsulate in timer_wrapper.h
2. Move ESolver clean logic to after_all_runners method
3. Replace clean_esolver calls with direct delete p_esolver
4. Remove #ifdef __MPI from delete p_esolver
5. Add Cblacs_exit(1) in after_all_runners for LCAO calculations
This commit fixes 37 uninitialized variables (19 int, 18 double) in 19 files within the source_pw directory. All variables are initialized to 0 or 0.0 to prevent undefined behavior and improve code safety.

Affected files:
- source_stodft/sto_wf.cpp
- source_stodft/sto_tool.h
- source_stodft/sto_iter.h
- source_stodft/sto_iter.cpp
- source_stodft/sto_forces.cpp
- source_pwdft/stress_func_loc.cpp
- source_pwdft/soc.cpp
- source_pwdft/parallel_grid.cpp
- source_pwdft/onsite_projector.cpp
- source_pwdft/operator_pw/exx_pw_ace.cpp
- source_pwdft/onsite_proj_tools.h
- source_pwdft/nonlocal_maths.hpp
- source_pwdft/fs_nonlocal_tools.h
- source_pwdft/elecond.cpp
- source_pwdft/forces_cc.cpp
- source_pwdft/VNL_in_pw.cpp
- source_pwdft/forces_scc.cpp
- source_pwdft/forces.cpp
- source_pwdft/VNL_grad_pw.cpp
This commit fixes uninitialized variables (int and double) in 18 files within the source_lcao directory. All variables are initialized to 0 or 0.0 to prevent undefined behavior and improve code safety.

Affected files:
- spar_hsr.cpp, spar_dh.cpp
- wavefunc_in_pw.cpp
- module_rt/velocity_op.cpp, module_rt/norm_psi.cpp, module_rt/propagator.cpp, module_rt/td_folding.cpp, module_rt/boundary_fix.cpp
- module_ri/exx_abfs-io.cpp, module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp, module_ri/module_exx_symmetry/symmetry_rotation.cpp
- module_lr/dm_trans/dmr_complex.cpp, module_lr/esolver_lrtd_lcao.cpp
- module_operator_lcao/dspin_force_stress.hpp, module_operator_lcao/dftu_force_stress.hpp
- module_hcontainer/func_folding.cpp, module_hcontainer/test/test_hcontainer.cpp
- module_gint/set_ddphi.cpp
This commit includes:
1. Renamed files in module_pwdft directory:
   - VL_in_pw.cpp/h → vl_pw.cpp/h
   - VNL_in_pw.cpp/h → vnl_pw.cpp/h
   - VNL_grad_pw.cpp → vnl_pw_grad.cpp
   - VSep_in_pw.cpp/h → vsep_pw.cpp/h

2. Updated CMakeLists.txt and Makefile.Objects to use new filenames

3. Updated include paths in 41 files across the codebase:
   - source_cell/test/klist_test.cpp and klist_test_para.cpp
   - source_esolver/esolver_fp.h, esolver_ks_pw.cpp, esolver_ks_pw.h
   - source_estate/module_pot/pot_sep.h, potential_new.h, setup_estate_pw.h
   - source_estate/test/elecstate_pw_test.cpp
   - source_io/test/for_testing_input_conv.h, for_testing_klist.h
   - source_lcao/LCAO_set.h
   - source_psi/psi_initializer.h and related files
   - source_pw/module_ofdft/of_stress_pw.h
   - source_pw/module_pwdft/* (multiple files)
   - source_pw/module_stodft/sto_stress_pw.h

4. Verified compilation success with make -j30

The renaming follows consistent naming conventions and makes filenames more concise.
This commit fixes the CI/CD build error by updating references to the old operator_pw directory structure:

1. Updated source/source_hsolver/test/CMakeLists.txt:
   - Changed all 7 references from '../../source_pw/module_pwdft/operator_pw/operator_pw.cpp' to '../../source_pw/module_pwdft/op_pw.cpp'

2. Updated source/source_hsolver/test/diago_mock.h:
   - Changed '#include "source_pw/module_pwdft/operator_pw/operator_pw.h"' to '#include "source_pw/module_pwdft/op_pw.h"'

The operator_pw directory has been renamed and its files moved to the module_pwdft root directory with op_pw_ prefixes, so these path updates are necessary to ensure CI/CD builds succeed.
@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Jan 28, 2026
@mohanchen mohanchen added the The Absolute Zero Reduce the "entropy" of the code to 0 label Jan 28, 2026
@mohanchen mohanchen changed the title 20260125 fix initialized Fix some initialization problems Jan 28, 2026
@mohanchen mohanchen merged commit 484ccfe into deepmodeling:develop Jan 28, 2026
14 checks passed
@mohanchen mohanchen deleted the 20260125-fix-initialized branch February 1, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants