void printBinaryInformation(FILE *fp, const ProgramContextInterface &programContext, const BinaryInformationSettings &settings) { const char *prefix = settings.prefix_; const char *suffix = settings.suffix_; const char *precisionString = ""; #ifdef GMX_DOUBLE precisionString = " (double precision)"; #endif const char *const name = programContext.displayName(); if (settings.bGeneratedByHeader_) { fprintf(fp, "%sCreated by:%s\n", prefix, suffix); } if (settings.bCopyright_) { GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0', "Prefix/suffix not supported with copyright"); // This line is printed again after the copyright notice to make it // appear together with all the other information, so that it is not // necessary to read stuff above the copyright notice. // The line above the copyright notice puts the copyright notice is // context, though. // TODO: It would be nice to know here whether we are really running a // Gromacs binary or some other binary that is calling Gromacs; we // could then print "%s is part of GROMACS" or some alternative text. fprintf(fp, "%sGROMACS: %s, %s%s%s\n", prefix, name, gmx_version(), precisionString, suffix); fprintf(fp, "\n"); printCopyright(fp); fprintf(fp, "\n"); } fprintf(fp, "%sGROMACS: %s, %s%s%s\n", prefix, name, gmx_version(), precisionString, suffix); const char *const binaryPath = programContext.fullBinaryPath(); if (binaryPath != NULL && binaryPath[0] != '\0') { fprintf(fp, "%sExecutable: %s%s\n", prefix, binaryPath, suffix); } const char *const libraryPath = programContext.defaultLibraryDataPath(); if (libraryPath != NULL && libraryPath[0] != '\0') { fprintf(fp, "%sLibrary dir: %s%s\n", prefix, libraryPath, suffix); } const char *const commandLine = programContext.commandLine(); if (commandLine != NULL && commandLine[0] != '\0') { fprintf(fp, "%sCommand line:%s\n%s %s%s\n", prefix, suffix, prefix, commandLine, suffix); } if (settings.bExtendedInfo_) { GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0', "Prefix/suffix not supported with extended info"); fprintf(fp, "\n"); gmx_print_version_info(fp); } }
void printFatalErrorHeader(FILE *fp, const char *title, const char *func, const char *file, int line) { // In case ProgramInfo is not initialized and there is an issue with the // initialization, fall back to "GROMACS". const char *programName = "GROMACS"; try { programName = getProgramContext().displayName(); } catch (const std::exception &) { } std::fprintf(fp, "\n-------------------------------------------------------\n"); std::fprintf(fp, "Program: %s, version %s\n", programName, gmx_version()); if (file != nullptr) { std::fprintf(fp, "Source file: %s (line %d)\n", Path::stripSourcePrefix(file), line); } if (func != nullptr) { std::fprintf(fp, "Function: %s\n", func); } if (gmx_node_num() > 1) { std::fprintf(fp, "MPI rank: %d (out of %d)\n", gmx_node_rank(), gmx_node_num()); } std::fprintf(fp, "\n"); std::fprintf(fp, "%s:\n", title); }
void printFatalErrorHeader(FILE *fp, const char *title, const char *func, const char *file, int line) { // In case ProgramInfo is not initialized and there is an issue with the // initialization, fall back to "GROMACS". const char *programName = "GROMACS"; try { programName = getProgramContext().displayName(); } catch (const std::exception &) { } std::fprintf(fp, "\n-------------------------------------------------------\n"); std::fprintf(fp, "Program: %s, %s\n", programName, gmx_version()); if (file != NULL) { // TODO: Check whether this works on Windows. If it doesn't, perhaps // add Path::startsWith(). if (startsWith(file, CMAKE_SOURCE_DIR)) { file += std::strlen(CMAKE_SOURCE_DIR); if (file[0] == '/' || file[0] == '\\') { ++file; } } std::fprintf(fp, "Source file: %s (line %d)\n", file, line); } if (func != NULL) { std::fprintf(fp, "Function: %s\n", func); } std::fprintf(fp, "\n"); std::fprintf(fp, "%s:\n", title); }
static void gmx_print_version_info(FILE *fp) { fprintf(fp, "Gromacs version: %s\n", gmx_version()); const char *const git_hash = gmx_version_git_full_hash(); if (git_hash[0] != '\0') { fprintf(fp, "GIT SHA1 hash: %s\n", git_hash); } const char *const base_hash = gmx_version_git_central_base_hash(); if (base_hash[0] != '\0') { fprintf(fp, "Branched from: %s\n", base_hash); } #ifdef GMX_DOUBLE fprintf(fp, "Precision: double\n"); #else fprintf(fp, "Precision: single\n"); #endif fprintf(fp, "Memory model: %u bit\n", (unsigned)(8*sizeof(void *))); #ifdef GMX_THREAD_MPI fprintf(fp, "MPI library: thread_mpi\n"); #elif defined(GMX_MPI) fprintf(fp, "MPI library: MPI\n"); #else fprintf(fp, "MPI library: none\n"); #endif #ifdef GMX_OPENMP fprintf(fp, "OpenMP support: enabled (GMX_OPENMP_MAX_THREADS = %d)\n", GMX_OPENMP_MAX_THREADS); #else fprintf(fp, "OpenMP support: disabled\n"); #endif #ifdef GMX_GPU fprintf(fp, "GPU support: enabled\n"); #else fprintf(fp, "GPU support: disabled\n"); #endif /* A preprocessor trick to avoid duplicating logic from vec.h */ #define gmx_stringify2(x) #x #define gmx_stringify(x) gmx_stringify2(x) fprintf(fp, "invsqrt routine: %s\n", gmx_stringify(gmx_invsqrt(x))); fprintf(fp, "SIMD instructions: %s\n", GMX_SIMD_STRING); fprintf(fp, "FFT library: %s\n", gmx_fft_get_version_info()); #ifdef HAVE_RDTSCP fprintf(fp, "RDTSCP usage: enabled\n"); #else fprintf(fp, "RDTSCP usage: disabled\n"); #endif #ifdef GMX_CXX11 fprintf(fp, "C++11 compilation: enabled\n"); #else fprintf(fp, "C++11 compilation: disabled\n"); #endif #ifdef GMX_USE_TNG fprintf(fp, "TNG support: enabled\n"); #else fprintf(fp, "TNG support: disabled\n"); #endif #ifdef HAVE_EXTRAE unsigned major, minor, revision; Extrae_get_version(&major, &minor, &revision); fprintf(fp, "Tracing support: enabled. Using Extrae-%d.%d.%d\n", major, minor, revision); #else fprintf(fp, "Tracing support: disabled\n"); #endif fprintf(fp, "Built on: %s\n", BUILD_TIME); fprintf(fp, "Built by: %s\n", BUILD_USER); fprintf(fp, "Build OS/arch: %s\n", BUILD_HOST); fprintf(fp, "Build CPU vendor: %s\n", BUILD_CPU_VENDOR); fprintf(fp, "Build CPU brand: %s\n", BUILD_CPU_BRAND); fprintf(fp, "Build CPU family: %d Model: %d Stepping: %d\n", BUILD_CPU_FAMILY, BUILD_CPU_MODEL, BUILD_CPU_STEPPING); /* TODO: The below strings can be quite long, so it would be nice to wrap * them. Can wait for later, as the master branch has ready code to do all * that. */ fprintf(fp, "Build CPU features: %s\n", BUILD_CPU_FEATURES); fprintf(fp, "C compiler: %s\n", BUILD_C_COMPILER); fprintf(fp, "C compiler flags: %s\n", BUILD_CFLAGS); fprintf(fp, "C++ compiler: %s\n", BUILD_CXX_COMPILER); fprintf(fp, "C++ compiler flags: %s\n", BUILD_CXXFLAGS); #ifdef HAVE_LIBMKL /* MKL might be used for LAPACK/BLAS even if FFTs use FFTW, so keep it separate */ fprintf(fp, "Linked with Intel MKL version %d.%d.%d.\n", __INTEL_MKL__, __INTEL_MKL_MINOR__, __INTEL_MKL_UPDATE__); #endif #ifdef GMX_EXTERNAL_BOOST const bool bExternalBoost = true; #else const bool bExternalBoost = false; #endif fprintf(fp, "Boost version: %d.%d.%d%s\n", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100, bExternalBoost ? " (external)" : " (internal)"); #ifdef GMX_GPU gmx_print_version_info_gpu(fp); #endif }
const char *GromacsVersion() { return gmx_version(); }
void gmx_mtxio_write(const char * filename, int nrow, int ncol, real * full_matrix, gmx_sparsematrix_t * sparse_matrix) { t_fileio *fio; int i, j, prec; size_t sz; if (full_matrix != nullptr && sparse_matrix != nullptr) { gmx_fatal(FARGS, "Both full AND sparse matrix specified to gmx_mtxio_write().\n"); } fio = gmx_fio_open(filename, "w"); /* Write magic number */ i = GMX_MTXIO_MAGIC_NUMBER; gmx_fio_do_int(fio, i); /* Write generating Gromacs version */ gmx_fio_write_string(fio, gmx_version()); /* Write 1 for double, 0 for single precision */ if (sizeof(real) == sizeof(double)) { prec = 1; } else { prec = 0; } gmx_fio_do_int(fio, prec); gmx_fio_do_int(fio, nrow); gmx_fio_do_int(fio, ncol); if (full_matrix != nullptr) { /* Full matrix storage format */ i = GMX_MTXIO_FULL_MATRIX; gmx_fio_do_int(fio, i); sz = nrow*ncol; gmx_fio_ndo_real(fio, full_matrix, sz); } else { /* Sparse storage */ i = GMX_MTXIO_SPARSE_MATRIX; gmx_fio_do_int(fio, i); gmx_fio_do_gmx_bool(fio, sparse_matrix->compressed_symmetric); gmx_fio_do_int(fio, sparse_matrix->nrow); if (sparse_matrix->nrow != nrow) { gmx_fatal(FARGS, "Internal inconsistency in sparse matrix.\n"); } gmx_fio_ndo_int(fio, sparse_matrix->ndata, sparse_matrix->nrow); for (i = 0; i < sparse_matrix->nrow; i++) { for (j = 0; j < sparse_matrix->ndata[i]; j++) { gmx_fio_do_int(fio, sparse_matrix->data[i][j].col); gmx_fio_do_real(fio, sparse_matrix->data[i][j].value); } } } gmx_fio_close(fio); }
void printBinaryInformation(FILE *fp, const ProgramContextInterface &programContext, const BinaryInformationSettings &settings) { const char *prefix = settings.prefix_; const char *suffix = settings.suffix_; const char *precisionString = ""; #ifdef GMX_DOUBLE precisionString = " (double precision)"; #endif const char *const name = programContext.displayName(); if (settings.bGeneratedByHeader_) { fprintf(fp, "%sCreated by:%s\n", prefix, suffix); } // TODO: It would be nice to know here whether we are really running a // Gromacs binary or some other binary that is calling Gromacs; we // could then print "%s is part of GROMACS" or some alternative text. std::string title = formatString(":-) GROMACS - %s, %s%s (-:", name, gmx_version(), precisionString); const int indent = centeringOffset(78 - strlen(prefix) - strlen(suffix), title.length()) + 1; fprintf(fp, "%s%*c%s%s\n", prefix, indent, ' ', title.c_str(), suffix); fprintf(fp, "%s%s\n", prefix, suffix); if (settings.bCopyright_) { GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0', "Prefix/suffix not supported with copyright"); printCopyright(fp); fprintf(fp, "\n"); // This line is printed again after the copyright notice to make it // appear together with all the other information, so that it is not // necessary to read stuff above the copyright notice. // The line above the copyright notice puts the copyright notice is // context, though. fprintf(fp, "%sGROMACS: %s, %s%s%s\n", prefix, name, gmx_version(), precisionString, suffix); } const char *const binaryPath = programContext.fullBinaryPath(); if (!gmx::isNullOrEmpty(binaryPath)) { fprintf(fp, "%sExecutable: %s%s\n", prefix, binaryPath, suffix); } const gmx::InstallationPrefixInfo installPrefix = programContext.installationPrefix(); if (!gmx::isNullOrEmpty(installPrefix.path)) { fprintf(fp, "%sData prefix: %s%s%s\n", prefix, installPrefix.path, installPrefix.bSourceLayout ? " (source tree)" : "", suffix); } const char *const commandLine = programContext.commandLine(); if (!gmx::isNullOrEmpty(commandLine)) { fprintf(fp, "%sCommand line:%s\n%s %s%s\n", prefix, suffix, prefix, commandLine, suffix); } if (settings.bExtendedInfo_) { GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0', "Prefix/suffix not supported with extended info"); fprintf(fp, "\n"); gmx_print_version_info(fp); } }