add function to print information about available compressions tools
This commit is contained in:
@ -42,6 +42,9 @@ Platform information functions
|
|||||||
.. doxygenfunction:: mpi_info
|
.. doxygenfunction:: mpi_info
|
||||||
:project: progguide
|
:project: progguide
|
||||||
|
|
||||||
|
.. doxygenfunction:: compress_info
|
||||||
|
:project: progguide
|
||||||
|
|
||||||
|
|
||||||
File and path functions and global constants
|
File and path functions and global constants
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
@ -309,6 +309,7 @@ void Info::command(int narg, char **arg)
|
|||||||
#else // defined(LAMMPS_SMALLSMALL)
|
#else // defined(LAMMPS_SMALLSMALL)
|
||||||
fputs("-DLAMMPS_SMALLSMALL\n",out);
|
fputs("-DLAMMPS_SMALLSMALL\n",out);
|
||||||
#endif
|
#endif
|
||||||
|
if (has_gzip_support()) fmt::print(out,"\n{}\n",platform::compress_info());
|
||||||
|
|
||||||
int ncword, ncline = 0;
|
int ncword, ncline = 0;
|
||||||
fputs("\nInstalled packages:\n\n",out);
|
fputs("\nInstalled packages:\n\n",out);
|
||||||
|
|||||||
@ -1379,6 +1379,8 @@ void LAMMPS::print_config(FILE *fp)
|
|||||||
sizeof(smallint)*8, sizeof(imageint)*8,
|
sizeof(smallint)*8, sizeof(imageint)*8,
|
||||||
sizeof(tagint)*8, sizeof(bigint)*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);
|
fputs("\nInstalled packages:\n\n",fp);
|
||||||
for (int i = 0; nullptr != (pkg = installed_packages[i]); ++i) {
|
for (int i = 0; nullptr != (pkg = installed_packages[i]); ++i) {
|
||||||
ncword = strlen(pkg);
|
ncword = strlen(pkg);
|
||||||
|
|||||||
@ -418,6 +418,24 @@ std::string platform::mpi_info(int &major, int &minor)
|
|||||||
return {version};
|
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
|
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)
|
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)
|
#if defined(LAMMPS_GZIP)
|
||||||
auto compress = find_compress_type(file);
|
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())
|
if (find_exe_path(compress.command).size())
|
||||||
// put quotes around file name so that they may contain blanks
|
// 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)
|
#if defined(LAMMPS_GZIP)
|
||||||
auto compress = find_compress_type(file);
|
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())
|
if (find_exe_path(compress.command).size())
|
||||||
// put quotes around file name so that they may contain blanks
|
// put quotes around file name so that they may contain blanks
|
||||||
|
|||||||
@ -109,6 +109,15 @@ namespace platform {
|
|||||||
|
|
||||||
std::string mpi_info(int &major, int &minor);
|
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
|
/*! Add variable to the environment
|
||||||
*
|
*
|
||||||
* \param vardef variable name or variable definition (NAME=value)
|
* \param vardef variable name or variable definition (NAME=value)
|
||||||
|
|||||||
Reference in New Issue
Block a user