20 #include "libmesh/libmesh_config.h" 21 #include "libmesh/libmesh_logging.h" 24 #ifdef LIBMESH_HAVE_SYS_STAT_H 27 #ifdef LIBMESH_HAVE_SYS_TYPES_H 28 #include <sys/types.h> 30 #ifdef LIBMESH_HAVE_UNISTD_H 35 #ifdef LIBMESH_HAVE_SYS_UTSNAME_H 36 #include <sys/utsname.h> 39 #ifdef LIBMESH_HAVE_PWD_H 43 #ifdef LIBMESH_HAVE_DIRECT_H 48 #include "libmesh/utility.h" 49 #include "libmesh/timestamp.h" 65 std::ostringstream oss;
69 #ifdef LIBMESH_HAVE_SYS_UTSNAME_H 71 struct utsname sysInfo;
76 #ifdef LIBMESH_HAVE_GETPWUID 77 struct passwd * p = getpwuid(getuid());
82 <<
" ---------------------------------------------------------------------\n" 83 <<
"| Time: " << date <<
'\n' 84 #ifdef LIBMESH_HAVE_SYS_UTSNAME_H 85 <<
"| OS: " << sysInfo.sysname <<
'\n' 86 <<
"| HostName: " << sysInfo.nodename <<
'\n' 87 <<
"| OS Release " << sysInfo.release <<
'\n' 88 <<
"| OS Version: " << sysInfo.version <<
'\n' 89 <<
"| Machine: " << sysInfo.machine <<
'\n' 91 <<
"| OS: " <<
"Unknown" <<
'\n' 92 <<
"| HostName: " <<
"Unknown" <<
'\n' 93 <<
"| OS Release " <<
"Unknown" <<
'\n' 94 <<
"| OS Version: " <<
"Unknown" <<
'\n' 95 <<
"| Machine: " <<
"Unknown" <<
'\n' 97 #ifdef LIBMESH_HAVE_GETPWUID 98 <<
"| Username: " << p->pw_name <<
'\n' 100 <<
"| Username: " <<
"Unknown" <<
'\n' 102 <<
" ---------------------------------------------------------------------\n";
110 std::size_t first_char = fullname.find_last_of(
"/\\");
111 if (first_char == std::string::npos)
113 return std::string_view(fullname).substr(first_char);
117 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 120 const unsigned int r_o_c)
123 basename.append(
".real");
126 basename.append(
".imag");
134 std::vector<Real> & real_part,
135 std::vector<Real> & imag_part)
137 const unsigned int len = source.size();
139 real_part.resize(len);
140 imag_part.resize(len);
142 for (
unsigned int i=0; i<len; i++)
144 real_part[i] = source[i].real();
145 imag_part[i] = source[i].imag();
149 #endif // #ifdef LIBMESH_USE_COMPLEX_NUMBERS 153 #if defined(LIBMESH_HAVE_MKDIR) 155 #elif LIBMESH_HAVE_DECL__MKDIR 156 return _mkdir(pathname);
158 libmesh_error_msg(
"Function mkdir not available on this system.");
166 std::ostringstream pid_suffix;
167 pid_suffix <<
'_' << getpid();
169 std::string new_name {
name };
170 if (
name.rfind(
".bz2") ==
name.size() - 4)
172 #ifdef LIBMESH_HAVE_BZIP 173 new_name.erase(new_name.end() - 4, new_name.end());
174 new_name += pid_suffix.str();
175 LOG_SCOPE(
"system(bunzip2)",
"Utility");
176 std::string system_string =
"bunzip2 -f -k -c ";
177 system_string.append(
name);
178 system_string +=
" > " + new_name;
179 if (std::system(system_string.c_str()))
180 libmesh_file_error(system_string);
182 libmesh_error_msg(
"ERROR: need bzip2/bunzip2 to open .bz2 file " <<
name);
185 else if (
name.rfind(
".xz") ==
name.size() - 3)
187 #ifdef LIBMESH_HAVE_XZ 188 new_name.erase(new_name.end() - 3, new_name.end());
189 new_name += pid_suffix.str();
190 LOG_SCOPE(
"system(xz -d)",
"Utility");
191 std::string system_string =
"xz -f -d -k -c ";
192 system_string.append(
name);
193 system_string +=
" > " + new_name;
194 if (std::system(system_string.c_str()))
195 libmesh_file_error(system_string);
197 libmesh_error_msg(
"ERROR: need xz to open .xz file " <<
name);
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
std::string get_timestamp()
int mkdir(const char *pathname)
Create a directory.
The libMesh namespace provides an interface to certain functionality in the library.
std::string system_info()
std::string unzip_file(std::string_view name)
Create an unzipped copy of a bz2 or xz file, returning the name of the now-unzipped file that can be ...
void prepare_complex_data(const std::vector< Complex > &source, std::vector< Real > &real_part, std::vector< Real > &imag_part)
Prepare complex data for writing.
std::string complex_filename(std::string basename, unsigned int r_o_c=0)
std::string_view basename_of(const std::string &fullname)