Skip to content

Commit c7bd18c

Browse files
committed
Feature: output math lib info into a file
1 parent be47750 commit c7bd18c

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

source/module_base/gather_math_lib_info.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This file defines the math lib wrapper for output information before executing computations.
2+
#include <ostream>
23
#undef GATHER_INFO
34
#include "module_base/blas_connector.h"
45
#include "module_base/lapack_connector.h"
@@ -19,8 +20,8 @@ void zgemm_i(const char *transa,
1920
std::complex<double> *c,
2021
const int *ldc)
2122
{
22-
std::cerr << std::defaultfloat << "zgemm " << *transa << " " << *transb << " " << *m << " " << *n << " " << *k
23-
<< " " << *alpha << " " << *lda << " " << *ldb << " " << *beta << " " << *ldc << std::endl;
23+
GlobalV::ofs_info << std::defaultfloat << "zgemm " << *transa << " " << *transb << " " << *m << " " << *n << " "
24+
<< *k << " " << *alpha << " " << *lda << " " << *ldb << " " << *beta << " " << *ldc << std::endl;
2425
zgemm_(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
2526
}
2627

@@ -62,9 +63,9 @@ void zhegvx_i(const int *itype,
6263
int *ifail,
6364
int *info)
6465
{
65-
std::cerr << std::defaultfloat << "zhegvx " << *itype << " " << *jobz << " " << *range << " " << *uplo << " " << *n
66-
<< " " << *lda << " " << *ldb << " " << *vl << " " << *vu << " " << *il << " " << *iu << " " << *abstol
67-
<< " " << *m << " " << *lwork << " " << *info << std::endl;
66+
GlobalV::ofs_info << std::defaultfloat << "zhegvx " << *itype << " " << *jobz << " " << *range << " " << *uplo
67+
<< " " << *n << " " << *lda << " " << *ldb << " " << *vl << " " << *vu << " " << *il << " " << *iu
68+
<< " " << *abstol << " " << *m << " " << *lwork << " " << *info << std::endl;
6869
zhegvx_(itype, jobz, range, uplo, n, a, lda, b, ldb, vl, vu, il, iu, abstol, m, w, z, ldz, work, lwork, rwork,
6970
iwork, ifail, info);
7071
}

source/module_base/global_file.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void ModuleBase::Global_File::make_dir_out(
6464
}
6565
else
6666
{
67-
std::cout << " PROC " << rank << " CAN NOT MAKE THE DIR !!! " << std::endl;
67+
std::cout << " PROC " << rank << " CAN NOT MAKE THE DIR !!! " << std::endl;
6868
make_dir = 0;
6969
}
7070
}
@@ -79,7 +79,7 @@ void ModuleBase::Global_File::make_dir_out(
7979
if(make_dir==0)
8080
{
8181
std::cout << " CAN NOT MAKE THE OUT DIR......." << std::endl;
82-
ModuleBase::QUIT();
82+
ModuleBase::QUIT();
8383
}
8484
MPI_Barrier(MPI_COMM_WORLD);
8585
#endif
@@ -101,7 +101,7 @@ void ModuleBase::Global_File::make_dir_out(
101101
}
102102
else
103103
{
104-
std::cout << " PROC " << rank << " CAN NOT MAKE THE STRU DIR !!! " << std::endl;
104+
std::cout << " PROC " << rank << " CAN NOT MAKE THE STRU DIR !!! " << std::endl;
105105
make_dir_stru = 0;
106106
}
107107
}
@@ -116,7 +116,7 @@ void ModuleBase::Global_File::make_dir_out(
116116
if(make_dir_stru==0)
117117
{
118118
std::cout << " CAN NOT MAKE THE STRU DIR......." << std::endl;
119-
ModuleBase::QUIT();
119+
ModuleBase::QUIT();
120120
}
121121
MPI_Barrier(MPI_COMM_WORLD);
122122
#endif
@@ -141,7 +141,10 @@ void ModuleBase::Global_File::make_dir_out(
141141

142142
if(rank==0)
143143
{
144-
open_log(GlobalV::ofs_warning, "warning", calculation, restart);
144+
open_log(GlobalV::ofs_warning, "warning", calculation, restart);
145+
#ifdef GATHER_INFO
146+
open_log(GlobalV::ofs_info, "math_info", calculation, restart);
147+
#endif
145148
}
146149
return;
147150
}
@@ -220,7 +223,10 @@ void ModuleBase::Global_File::close_all_log(const int rank, const bool out_alllo
220223

221224
if (rank==0)
222225
{
223-
close_log(GlobalV::ofs_warning,"warning.log");
226+
close_log(GlobalV::ofs_warning, "warning.log");
227+
#ifdef GATHER_INFO
228+
close_log(GlobalV::ofs_info, "math_info");
229+
#endif
224230
}
225231
return;
226232
}

source/module_base/global_variable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ std::string global_wannier_card;
128128
std::string global_pseudo_dir = "";
129129
std::string global_orbital_dir = ""; // liuyu add 2021-08-14
130130

131-
std::string global_pseudo_type = "auto";
131+
std::string global_pseudo_type = "auto";
132132
std::string global_epm_pseudo_card;
133133
std::string global_out_dir;
134134
std::string global_readin_dir; // zhengdy modified
135135
std::string global_stru_dir;
136136

137137
std::ofstream ofs_running;
138138
std::ofstream ofs_warning;
139+
std::ofstream ofs_info; // output math lib info
139140

140141
//----------------------------------------------------------
141142
// EXPLAIN : test level for each class

source/module_base/global_variable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ extern std::string global_stru_dir; // liuyu add 2022-05-24 for MD STRU
159159

160160
extern std::ofstream ofs_running;
161161
extern std::ofstream ofs_warning;
162+
extern std::ofstream ofs_info;
162163

163164
//==========================================================
164165
// EXPLAIN : test level for each class

0 commit comments

Comments
 (0)