Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions source/module_base/test/complexmatrix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* - set_as_identity_matrix()
* - print():Output the elements of this complex matrix greater than threshold.
* - checkreal()
*
* Tested relative functions
*
* Tested relative functions
* - operator "+" "-" "*" between two ComplexMatrix
* - operator "*" between a ComplexMatrix and double or complex, and reverse.
* - trace()
Expand All @@ -35,13 +35,13 @@
* - conj()
* - scale_accumulate():
* - scaled_sum():
*
*
*/

//a mock function of WARNING_QUIT, to avoid the uncorrected call by matrix.cpp at line 37.
namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
}

inline void EXPECT_COMPLEX_EQ(const std::complex<double>& a,const std::complex<double>& b)
Expand Down Expand Up @@ -104,8 +104,8 @@ TEST_F(ComplexMatrixTest,ConstructorCM)

TEST_F(ComplexMatrixTest,ConstructorCMrvalue)
{
ModuleBase::ComplexMatrix cm2(cm22);
ModuleBase::ComplexMatrix cm1(std::move(cm22));
ModuleBase::ComplexMatrix cm2(cm22);
ModuleBase::ComplexMatrix cm1(std::move(cm22));
EXPECT_EQ(cm1.nr,cm2.nr);
EXPECT_EQ(cm1.nc,cm2.nc);
EXPECT_EQ(cm1.size,cm2.size);
Expand Down Expand Up @@ -338,15 +338,15 @@ TEST_F(ComplexMatrixTest,OperatorMultMatrix)
EXPECT_EQ(cm33.nr,3);
EXPECT_EQ(cm33.nc,3);
EXPECT_EQ(cm33.size,9);
EXPECT_COMPLEX_EQ(cm33(0,0),std::complex<double>{-46.0,72.0 });
EXPECT_COMPLEX_EQ(cm33(0,0),std::complex<double>{-46.0,72.0 });
EXPECT_COMPLEX_EQ(cm33(0,1),std::complex<double>{-46.0,118.0 });
EXPECT_COMPLEX_EQ(cm33(0,2),std::complex<double>{-46.0,164.0 });
EXPECT_COMPLEX_EQ(cm33(1,0),std::complex<double>{-54.0,84.0 });
EXPECT_COMPLEX_EQ(cm33(1,1),std::complex<double>{-54.0,138.0 });
EXPECT_COMPLEX_EQ(cm33(1,2),std::complex<double>{-54.0,192.0 });
EXPECT_COMPLEX_EQ(cm33(1,2),std::complex<double>{-54.0,192.0 });
EXPECT_COMPLEX_EQ(cm33(2,0),std::complex<double>{-62.0,96.0 });
EXPECT_COMPLEX_EQ(cm33(2,1),std::complex<double>{-62.0,158.0 });
EXPECT_COMPLEX_EQ(cm33(2,2),std::complex<double>{-62.0,220.0 });
EXPECT_COMPLEX_EQ(cm33(2,2),std::complex<double>{-62.0,220.0 });

EXPECT_DEATH(cm22 * cm32,"");
}
Expand Down Expand Up @@ -525,7 +525,7 @@ TEST_F(ComplexMatrixTest,ScaleSumArray)
cmout = new ModuleBase::ComplexMatrix*[2];
cmin1 = new ModuleBase::ComplexMatrix*[2];
cmin2 = new ModuleBase::ComplexMatrix*[2];

cmin1[0] = &cm1;
cmin1[1] = &cm2;
cmin2[0] = &cm3;
Expand Down Expand Up @@ -563,7 +563,7 @@ TEST_F(ComplexMatrixTest,print)
EXPECT_THAT(output,testing::HasSubstr("(3,4)\t(4,5)\t"));
ifs.close();
remove("printtest1.log");
// The condition of std::abs(data)>threshold_abs && std::imag(data)) <= threshold_imag
// The condition of std::abs(data)>threshold_abs && std::imag(data)) <= threshold_imag
ofs.open("printtest2.log");
cm22.print(ofs,1e-10,2);
ofs.close();
Expand Down
2 changes: 1 addition & 1 deletion source/module_base/test/inverse_matrix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//a mock function of WARNING_QUIT, to avoid the uncorrected call by matrix.cpp at line 37.
namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
}

TEST(InverseMatrixComplexTest, InverseMatrixComplex)
Expand Down
364 changes: 182 additions & 182 deletions source/module_base/test/math_ylmreal_test.cpp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions source/module_base/tool_quit.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ void WARNING(const std::string &file, const std::string &description);
* @brief Close .log files and exit
*
*/
void QUIT(void);
[[noreturn]] void QUIT(void);

/**
* @brief Close .log files and exit
*
*/
void QUIT(int ret);
[[noreturn]] void QUIT(int ret);

/**
* @brief Combine the functions of WARNING and QUIT
*
* @param file The file where warning happens
* @param description The warning information
*/
void WARNING_QUIT(const std::string &file, const std::string &description);
[[noreturn]] void WARNING_QUIT(const std::string& file, const std::string& description);

/**
* @brief Combine the functions of WARNING and QUIT
*
* @param file The file where warning happens
* @param description The warning information
*/
void WARNING_QUIT(const std::string &file, const std::string &description, int ret);
[[noreturn]] void WARNING_QUIT(const std::string& file, const std::string& description, int ret);

/**
* @brief Check, if true, WARNING_QUIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ TEST_F(SltkAtomInputTest, ConstructorNoExpand)
GlobalV::test_grid = 1;
// this is a bug if radius is too small
// because the expand_flag will be false!
radius = 1e-1000;
radius = 0;
Atom_input Atom_inp(ofs, *ucell, ucell->nat, ucell->ntype, pbc, radius, test_atom_in);
EXPECT_FALSE(Atom_inp.getExpandFlag());
// call set_FAtom and Load_atom
Expand Down
4 changes: 2 additions & 2 deletions source/module_hamilt_general/module_xc/test/test_xc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
}

namespace GlobalV
Expand Down Expand Up @@ -95,7 +95,7 @@ class XCTest_PBEsol : public testing::Test
e_gga.push_back(e);
v1_gga.push_back(v1);
v2_gga.push_back(v2);
}
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion source/module_hamilt_general/module_xc/test/test_xc1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
}

namespace GlobalV
Expand Down
10 changes: 5 additions & 5 deletions source/module_hamilt_general/module_xc/test/test_xc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
}

namespace GlobalV
Expand Down Expand Up @@ -202,7 +202,7 @@ class XCTest_PZ_SPN : public testing::Test
e_lda.push_back(e);
v1_lda.push_back(v1);
v2_lda.push_back(v2);
}
}
}
};

Expand Down Expand Up @@ -238,7 +238,7 @@ class XCTest_SLATER1_SPN : public testing::Test
e_lda.push_back(e);
v1_lda.push_back(v1);
v2_lda.push_back(v2);
}
}
}
};

Expand Down Expand Up @@ -273,7 +273,7 @@ class XCTest_SLATER_RXC_SPN : public testing::Test
e_lda.push_back(e);
v1_lda.push_back(v1);
v2_lda.push_back(v2);
}
}
}
};

Expand Down Expand Up @@ -310,7 +310,7 @@ class XCTest_P86_SPN : public testing::Test
v1_gga.push_back(v1);
v2_gga.push_back(v2);
v3_gga.push_back(v3);
}
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions source/module_hamilt_general/module_xc/test/test_xc4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description) {exit(1);}
}

namespace GlobalV
Expand Down Expand Up @@ -49,7 +49,7 @@ class XCTest_SCAN : public testing::Test
v2_.push_back(v2);
v3_.push_back(v3);
}
}
}
};

TEST_F(XCTest_SCAN, set_xc_type)
Expand Down
16 changes: 10 additions & 6 deletions source/module_hamilt_general/module_xc/test/xc3_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace ModulePW
return x;
}


template <typename FPTYPE, typename Device>
void PW_Basis_K::real_to_recip(const Device* ctx,
const std::complex<FPTYPE>* in,
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace ModulePW
const int ik,
const bool add,
const double factor) const;
#if __CUDA || __ROCM
#if __CUDA || __ROCM
template void PW_Basis_K::real_to_recip<double, psi::DEVICE_GPU>(const psi::DEVICE_GPU* ctx,
const std::complex<double>* in,
std::complex<double>* out,
Expand All @@ -129,7 +129,7 @@ namespace ModulePW
const int ik,
const bool add,
const double factor) const;
#endif
#endif

FFT::FFT(){};
FFT::~FFT(){};
Expand All @@ -144,9 +144,13 @@ namespace ModulePW

namespace ModuleBase
{
void WARNING_QUIT(const std::string &file,const std::string &description) {return ;}
void WARNING_QUIT(const std::string &file,const std::string &description)
{
std::cout << " " << file <<" warning : "<< description<<std::endl;
exit(1);
}
void WARNING(const std::string &file,const std::string &description) {};

void Matrix3::Identity(){};

IntArray::IntArray(int,int){};
Expand Down Expand Up @@ -228,4 +232,4 @@ namespace Parallel_Reduce
template void reduce_pool<float>(float& object);
template void reduce_pool<float>(float* object, const int n);
template void reduce_pool<double>(double* object, const int n);
}
}
3 changes: 2 additions & 1 deletion source/module_hamilt_lcao/module_tddft/test/tddft_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ void MPIInit()
npcol = 1;
Cblacs_pinfo(&myrank, &mysize);
Cblacs_get(-1, 0, &ictxt);
Cblacs_gridinit(&ictxt, "Row", nprow, npcol);
char order[] = "Row";
Cblacs_gridinit(&ictxt, order, nprow, npcol);
Cblacs_gridinfo(ictxt, &nprow, &npcol, &myprow, &mypcol);
}

Expand Down
33 changes: 10 additions & 23 deletions source/module_io/parameter_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int count_ntype(const std::string& fn)
* @param input_value_path parameter default value file path
* @param input_value_path parameter input value file path
*/
bool Init(const std::string& default_type_path,
void Init(const std::string& default_type_path,
const std::string& default_value_path,
const std::string& input_value_path)
{
Expand Down Expand Up @@ -103,10 +103,8 @@ void strtolower(char* sa, char* sb)
* @brief Reads the default parameters from the specified file and saves them to the global variable
* default_parametes_type
* @param fn Specifies the path to the file
* @return true Read successfully
* @return false Read failure
*/
bool default_parametes_reader(const std::string& fn, std::map<std::string, std::string>& default_parametes_type)
void default_parametes_reader(const std::string& fn, std::map<std::string, std::string>& default_parametes_type)
{
std::ifstream inputFile(fn.c_str());
if (inputFile.is_open())
Expand All @@ -122,28 +120,24 @@ bool default_parametes_reader(const std::string& fn, std::map<std::string, std::
}
else
{
std::cout << "Cannot open file !" << std::endl;
ModuleBase::WARNING_QUIT("Input", "Cannot open file" + fn);
}
}
/**
* @brief This function is used to read the input parameter file and store it as a key-value pair
* @param fn Enter the path to the parameter file
*/
bool input_parameters_get(const std::string& fn, std::map<std::string, InputParameter>& input)
void input_parameters_get(const std::string& fn, std::map<std::string, InputParameter>& input)
{
// The module title information is displayed
ModuleBase::TITLE("Input", "Read");
// If it is not the primary node, return false
if (GlobalV::MY_RANK != 0)
return false;
return;

// Open the input parameter file
std::ifstream ifs(fn.c_str(), std::ios::in); // "in_datas/input_parameters"
// If the opening fails, an error message is printed and false is returned
if (!ifs)
{
std::cout << " Can't find the INPUT file." << std::endl;
return false;
ModuleBase::WARNING_QUIT("Input", "Can't find the INPUT file at " + fn);
}
ifs.clear();
ifs.seekg(0);
Expand All @@ -166,8 +160,7 @@ bool input_parameters_get(const std::string& fn, std::map<std::string, InputPara
// If ierr is 0, the word "INPUT_PARAMETERS" is not found, and an error message is printed with false
if (ierr == 0)
{
std::cout << " Error parameter list." << std::endl;
return false; // return error : false
ModuleBase::WARNING_QUIT("Input", "INPUT_PARAMETERS statement not found.");
}
ifs.rdstate();

Expand Down Expand Up @@ -274,15 +267,11 @@ bool input_parameters_get(const std::string& fn, std::map<std::string, InputPara
}
else if (ifs.bad() != 0)
{
std::cout << " Bad input parameters. " << std::endl;
return false;
ModuleBase::WARNING_QUIT("Input", "Bad input parameters.");
}
else if (ifs.fail() != 0)
{
std::cout << " word = " << word << std::endl;
std::cout << " Fail to read parameters. " << std::endl;
ifs.clear();
return false;
ModuleBase::WARNING_QUIT("Input", "Fail to read parameters: word = " + std::string(word));
}
else if (ifs.good() == 0)
{
Expand All @@ -306,11 +295,9 @@ bool input_parameters_get(const std::string& fn, std::map<std::string, InputPara
{
ModuleBase::WARNING_QUIT("Input", "The ntype in INPUT is not equal to the ntype counted in STRU, check it.");
}

return true;
}

bool input_parameters_set(std::map<std::string, InputParameter> input_parameters)
void input_parameters_set(std::map<std::string, InputParameter> input_parameters)
{
if (input_parameters.count("nupdown") != 0)
{
Expand Down
8 changes: 4 additions & 4 deletions source/module_io/parameter_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ class InputParameter
}
}
};
bool Init(const std::string& default_type_path,
void Init(const std::string& default_type_path,
const std::string& default_value_path,
const std::string& input_value_path);
bool default_parametes_reader(const std::string& fn, std::map<std::string, std::string>& default_parametes_type);
bool input_parameters_get(const std::string& fn, std::map<std::string, InputParameter>& input);
bool input_parameters_set(std::map<std::string, InputParameter> input_parameters);
void default_parametes_reader(const std::string& fn, std::map<std::string, std::string>& default_parametes_type);
void input_parameters_get(const std::string& fn, std::map<std::string, InputParameter>& input);
void input_parameters_set(std::map<std::string, InputParameter> input_parameters);

extern std::map<std::string, InputParameter> input_parameters;
extern std::map<std::string, std::string> default_parametes_type;
Expand Down
Loading