Skip to content

Commit 605f64e

Browse files
committed
Fix(build): add #ifdef __LCAO guards for LCAO-only code in DeltaSpin
lcao_subspace.cpp: wrap entire file in #ifdef __LCAO since it only contains LCAO subspace diagonalization code. lambda_loop.cpp: guard LCAO-specific code in: - run_lambda_local_diagnostic: wrap body in #ifndef __LCAO return; #else - run_lambda_loop: guard free_lcao_subspace_cache() calls - run_lambda_linear_scan: wrap body in #ifndef __LCAO return; #else - run_lambda_scan_diagnostic: change #ifdef __LCAO guard to cover entire function body instead of just initial checks Fixes CI failure: 'Build without LCAO' (-DENABLE_LCAO=OFF)
1 parent 8557d68 commit 605f64e

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

source/source_lcao/module_deltaspin/lambda_loop.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ template <>
9898
void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_local_diagnostic(
9999
int outer_step, double lambda_ref_ry, const std::string& label)
100100
{
101-
#ifdef __LCAO
101+
#ifndef __LCAO
102+
return;
103+
#else
102104
if (PARAM.inp.basis_type != "lcao") return;
103105
if (this->nspin_ != 2) return;
104-
#else
105-
return;
106-
#endif
107106

108107
int nat = this->get_nat();
109108
double scan_half_range_ev = 0.5;
@@ -447,6 +446,7 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_local_diagno
447446
ofs_diag.close();
448447
std::cout << "[DS-LOCAL] Results written to: " << fname << std::endl;
449448
std::cout << std::string(80, '-') << "\n" << std::endl;
449+
#endif
450450
}
451451

452452
template <>
@@ -470,7 +470,9 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_loop(int out
470470
this->acceleration_active_ = false;
471471
this->acceleration_subspace_built_ = false;
472472
this->subspace_just_activated_ = false;
473+
#ifdef __LCAO
473474
this->free_lcao_subspace_cache();
475+
#endif
474476

475477
// =============================================================
476478
// STATE VECTORS (all sized [nat][3])
@@ -718,7 +720,9 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_loop(int out
718720
this->lambda_at_acceleration_ = this->lambda_;
719721

720722
// Free any cached subspace data from previous SCF iterations
723+
#ifdef __LCAO
721724
this->free_lcao_subspace_cache();
725+
#endif
722726

723727
// Build fresh subspace at current lambda using full diagonalization.
724728
// i_step=-2 triggers the special cache-build branch in cal_mw_from_lambda.
@@ -932,6 +936,9 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_loop(int out
932936
template <>
933937
void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_linear_scan(int outer_step)
934938
{
939+
#ifndef __LCAO
940+
return;
941+
#else
935942
int nat = this->get_nat();
936943
int ntype = this->get_ntype();
937944

@@ -1459,6 +1466,7 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_linear_scan(
14591466
std::cout << std::string(80, '=') << "\n" << std::endl;
14601467

14611468
return;
1469+
#endif
14621470
}
14631471

14641472
/**
@@ -1474,7 +1482,9 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_linear_scan(
14741482
template <>
14751483
void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_scan_diagnostic(int outer_step)
14761484
{
1477-
#ifdef __LCAO
1485+
#ifndef __LCAO
1486+
return;
1487+
#else
14781488
if (PARAM.inp.basis_type != "lcao")
14791489
{
14801490
std::cout << "[DS-DIAG] scan_diagnostic: only supported for LCAO basis" << std::endl;
@@ -1485,9 +1495,6 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_scan_diagnos
14851495
std::cout << "[DS-DIAG] scan_diagnostic: only supported for nspin=2" << std::endl;
14861496
return;
14871497
}
1488-
#else
1489-
return;
1490-
#endif
14911498

14921499
int nat = this->get_nat();
14931500

@@ -1769,6 +1776,7 @@ void spinconstrain::SpinConstrain<std::complex<double>>::run_lambda_scan_diagnos
17691776
std::cout << "[DS-DIAG] === DIAGNOSTIC SCAN COMPLETE ===" << std::endl;
17701777
std::cout << "[DS-DIAG] Results written to: subspace_vs_full_scan.dat" << std::endl;
17711778
std::cout << std::string(80, '=') << "\n" << std::endl;
1779+
#endif
17721780
}
17731781

17741782

source/source_lcao/module_deltaspin/lcao_subspace.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include <cassert>
4343
#include <algorithm>
4444

45+
#ifdef __LCAO
46+
4547
namespace spinconstrain
4648
{
4749

@@ -868,3 +870,5 @@ void SpinConstrain<std::complex<double>>::cal_mi_lcao_subspace(
868870
}
869871

870872
} // namespace spinconstrain
873+
874+
#endif // __LCAO

0 commit comments

Comments
 (0)