add function to print information about available compressions tools

This commit is contained in:
Axel Kohlmeyer
2021-10-26 19:54:09 -04:00
parent f0318fb874
commit 1247f4d67b
5 changed files with 36 additions and 3 deletions

View File

@ -42,6 +42,9 @@ Platform information functions
.. doxygenfunction:: mpi_info
:project: progguide
.. doxygenfunction:: compress_info
:project: progguide
File and path functions and global constants
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -309,6 +309,7 @@ void Info::command(int narg, char **arg)
#else // defined(LAMMPS_SMALLSMALL)
fputs("-DLAMMPS_SMALLSMALL\n",out);
#endif
if (has_gzip_support()) fmt::print(out,"\n{}\n",platform::compress_info());
int ncword, ncline = 0;
fputs("\nInstalled packages:\n\n",out);

View File

@ -1379,6 +1379,8 @@ void LAMMPS::print_config(FILE *fp)
sizeof(smallint)*8, sizeof(imageint)*8,
sizeof(tagint)*8, sizeof(bigint)*8);
if (Info::has_gzip_support()) fmt::print(fp,"\n{}\n",platform::compress_info());
fputs("\nInstalled packages:\n\n",fp);
for (int i = 0; nullptr != (pkg = installed_packages[i]); ++i) {
ncword = strlen(pkg);

View File

@ -418,6 +418,24 @@ std::string platform::mpi_info(int &major, int &minor)
return {version};
}
/* ----------------------------------------------------------------------
collect available compression tool info
------------------------------------------------------------------------- */
std::string platform::compress_info()
{
std::string buf = "Available compression formats:\n\n";
bool none_found = true;
for (const auto &cmpi : compress_styles) {
if (cmpi.style == ::compress_info::NONE) continue;
if (find_exe_path(cmpi.command).size()) {
none_found = false;
buf += fmt::format("Extension: .{:6} Command: {}\n", cmpi.extension, cmpi.command);
}
}
if (none_found) buf += "None\n";
return buf;
}
/* ----------------------------------------------------------------------
set environment variable
------------------------------------------------------------------------- */
@ -930,7 +948,7 @@ bool platform::file_is_readable(const std::string &path)
bool platform::has_compress_extension(const std::string &file)
{
return find_compress_type(file).style != compress_info::NONE;
return find_compress_type(file).style != ::compress_info::NONE;
}
/* ----------------------------------------------------------------------
@ -943,7 +961,7 @@ FILE *platform::compressed_read(const std::string &file)
#if defined(LAMMPS_GZIP)
auto compress = find_compress_type(file);
if (compress.style == compress_info::NONE) return nullptr;
if (compress.style == ::compress_info::NONE) return nullptr;
if (find_exe_path(compress.command).size())
// put quotes around file name so that they may contain blanks
@ -962,7 +980,7 @@ FILE *platform::compressed_write(const std::string &file)
#if defined(LAMMPS_GZIP)
auto compress = find_compress_type(file);
if (compress.style == compress_info::NONE) return nullptr;
if (compress.style == ::compress_info::NONE) return nullptr;
if (find_exe_path(compress.command).size())
// put quotes around file name so that they may contain blanks

View File

@ -109,6 +109,15 @@ namespace platform {
std::string mpi_info(int &major, int &minor);
/*! Return string with list of available compression types and executables
*
* This function tests which of the supported compression executables
* are available for reading or writing compressed files where supported.
*
* \return string with list of available compression tools */
std::string compress_info();
/*! Add variable to the environment
*
* \param vardef variable name or variable definition (NAME=value)