Skip to content

Commit

Permalink
hush some (not all) VLA-related warnings by using constexpr size
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Jun 21, 2024
1 parent d34a2ea commit 96ac90e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/madness/chem/MolecularOrbitals.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class MolecularOrbitals : public archive::ParallelSerializableObject {
print("orbital # irrep energy occupation localize_set");
for (int i=mo.size()-1; i>=0; --i) {
// double n=get_mos()[i].norm2();
std::size_t bufsize=1024;
constexpr std::size_t bufsize=1024;
char buf[bufsize];
snprintf(buf,bufsize,"%5d %10s %12.8f %6.2f %8d %15s", i, irreps[i].c_str(),get_eps()[i],
get_occ()[i],get_localize_sets()[i], flags[i].c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/madness/chem/ccpairfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ using pureT=Function<T,NDIM>;
for (auto& b : vb) {
double tmp=a.inner_internal(b,R2);
double wall1=cpu_time();
std::size_t bufsize=256;
constexpr std::size_t bufsize=256;
char buf[bufsize];
snprintf(buf,bufsize,"result from inner %10s %10s %12.8f %4.1fs",a.name(true).c_str(),b.name().c_str(),tmp,wall1-wall0);
print(std::string(buf));
Expand Down
16 changes: 8 additions & 8 deletions src/madness/chem/mp3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ double MP3::compute_mp3_cd(World& world,
double tmp2 = inner(bra, g12 * pair_square(j, i), Rsquare);
double fac = (i == j) ? 0.5 : 1.0;
double result = fac * (4.0 * tmp1 - 2.0 * tmp2);
std::size_t bufsize=256;
char buf[bufsize];
constexpr std::size_t bufsize=256;
char buf[bufsize];
snprintf(buf,bufsize,"mp3 energy: term_CD %2ld %2ld: %12.8f\n", i, j, result);
print(std::string(buf));
return result;
Expand Down Expand Up @@ -721,8 +721,8 @@ double MP3::compute_mp3_ef(World& world,
}
tmp_tau=consolidate(tmp_tau,{"remove_lindep"});
double result=inner(pair_square(i,j),tmp_tau,Rsquare);
std::size_t bufsize=256;
char buf[bufsize];
constexpr std::size_t bufsize=256;
char buf[bufsize];
snprintf(buf, bufsize,"mp3 energy: term_EF %2ld %2ld %12.8f\n",i,j,result);
print(std::string(buf));

Expand Down Expand Up @@ -806,8 +806,8 @@ double MP3::compute_mp3_ghij(World& world,
auto bra_intermediate = multiply(intermediate, Rsquare, {3, 4, 5});
t4.tag("multiply");
double tmp = 2.0*inner(bra_intermediate, gintermediate);
std::size_t bufsize=256;
char buf[bufsize];
constexpr std::size_t bufsize=256;
char buf[bufsize];
snprintf(buf, bufsize,"mp3 energy: term_GHIJ %2ld %12.8f\n", i, tmp);
print(std::string(buf));
t4.tag("inner");
Expand Down Expand Up @@ -872,8 +872,8 @@ double MP3::compute_mp3_klmn(World& world,
double result = -2.0*inner(lhs, rhs, Rsquare);
inner_KLMN.interrupt();

std::size_t bufsize=256;
char buf[bufsize];
constexpr std::size_t bufsize=256;
char buf[bufsize];
snprintf(buf,bufsize,"mp3 energy: term_KLMN %2ld %2ld %12.8f\n", i, j, result);
print(std::string(buf));

Expand Down
4 changes: 2 additions & 2 deletions src/madness/mra/macrotaskq.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ class MacroTask {
bool debug=false;

io_redirect(const long task_number, std::string filename, bool debug=false) : debug(debug) {
std::size_t bufsize=256;
char cfilename[bufsize];
constexpr std::size_t bufsize=256;
char cfilename[bufsize];
std::snprintf(cfilename,bufsize,"%s.%5.5ld",filename.c_str(),task_number);
ofile=std::ofstream(cfilename);
if (debug) std::cout << "redirecting to file " << cfilename << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/madness/mra/mraimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ namespace madness {

if (this->world.rank()==0) {

std::size_t bufsize=128;
constexpr std::size_t bufsize=128;
char buf[bufsize];
snprintf(buf, bufsize, "%40s at time %.1fs: norm/tree/#coeff/size: %7.5f %zu, %6.3f m, %6.3f GByte",
(name.c_str()), wall, norm, tsize,double(ncoeff)*1.e-6,double(ncoeff)/fac*d);
Expand Down
6 changes: 3 additions & 3 deletions src/madness/world/parallel_archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace madness {
MADNESS_ASSERT(filename);
MADNESS_ASSERT(strlen(filename)-1<sizeof(fname));
strcpy(fname,filename); // Save the filename for later
std::size_t bufsize=256;
constexpr std::size_t bufsize=256;
char buf[bufsize];
MADNESS_ASSERT(strlen(filename)+7 <= sizeof(buf));
snprintf(buf, bufsize, "%s.%5.5d", filename, world.rank());
Expand Down Expand Up @@ -222,7 +222,7 @@ namespace madness {
typename std::enable_if_t<std::is_same<X,BinaryFstreamInputArchive>::value || std::is_same<X,BinaryFstreamOutputArchive>::value,
bool>
exists(World& world, const char* filename) {
std::size_t bufsize=256;
constexpr std::size_t bufsize=256;
char buf[bufsize];
MADNESS_ASSERT(strlen(filename)+7 <= sizeof(buf));
snprintf(buf,bufsize, "%s.%5.5d", filename, world.rank());
Expand Down Expand Up @@ -273,7 +273,7 @@ namespace madness {
void>
remove(World& world, const char* filename) {
if (world.rank() == 0) {
std::size_t bufsize=268;
constexpr std::size_t bufsize=268;
char buf[bufsize];
MADNESS_ASSERT(strlen(filename)+7 <= sizeof(buf));
for (ProcessID p=0; p<world.size(); ++p) {
Expand Down
2 changes: 1 addition & 1 deletion src/madness/world/redirectio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ using std::endl;
static std::ofstream fout;
namespace madness {
void redirectio(const World& world, bool split) {
std::size_t bufsize=256;
constexpr std::size_t bufsize=256;
char filename[bufsize];
std::snprintf(filename,bufsize,"log.%5.5d",world.mpi.rank());
char errfilename[bufsize];
Expand Down

0 comments on commit 96ac90e

Please sign in to comment.