}
if (outftp == efG87)
fprintf(gmx_fio_getfp(trx_get_fileio(trxout)),"Generated by %s. #atoms=%d, a BOX is"
- " stored in this file.\n",Program(),nout);
+ " stored in this file.\n",ShortProgram(),nout);
}
if (natoms > atoms->nr) {
}
if (!impl_->bQuiet_)
{
- printBinaryInformation(impl_->bStdOutInfo_ ? stdout : stderr,
- impl_->programInfo_, impl_->binaryInfoSettings_);
+ FILE *out = (impl_->bStdOutInfo_ ? stdout : stderr);
+ printBinaryInformation(out, impl_->programInfo_,
+ impl_->binaryInfoSettings_);
+ fprintf(out, "\n");
}
if (module == NULL)
{
#include "binsearch.h"
#include "powerspect.h"
#include "gmx_ana.h"
+#include "copyrite.h"
+
+#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/programinfo.h"
#ifdef GMX_DOUBLE
#define FLOOR(x) ((int) floor(x))
raw1 = ffopen(fnms[0], "w");
raw2 = ffopen(fnms[1], "w");
- fprintf(raw1, "#Produced by: %s #\n", command_line());
- fprintf(raw2, "#Produced by: %s #\n", command_line());
- fprintf(raw1, "#Legend: nt nx ny\n#Xbin Ybin Z t\n");
- fprintf(raw2, "#Legend: nt nx ny\n#Xbin Ybin Z t\n");
+ try
+ {
+ gmx::BinaryInformationSettings settings;
+ settings.generatedByHeader(true);
+ settings.linePrefix("# ");
+ gmx::printBinaryInformation(raw1, gmx::ProgramInfo::getInstance(),
+ settings);
+ gmx::printBinaryInformation(raw2, gmx::ProgramInfo::getInstance(),
+ settings);
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
+ fprintf(raw1, "# Legend: nt nx ny\n# Xbin Ybin Z t\n");
+ fprintf(raw2, "# Legend: nt nx ny\n# Xbin Ybin Z t\n");
fprintf(raw1, "%i %i %i\n", tblocks, xbins, ybins);
fprintf(raw2, "%i %i %i\n", tblocks, xbins, ybins);
for (n = 0; n < tblocks; n++)
#include "nrjac.h"
#include "matio.h"
#include "gmx_ana.h"
+#include "copyrite.h"
+#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/programinfo.h"
#define e2d(x) ENM2DEBYE*(x)
#define EANG2CM E_CHARGE*1.0e-10 /* e Angstrom to Coulomb meter */
ffclose(dip3d);
dip3d = (FILE *)ffopen(fndip3d, "w");
- fprintf(dip3d, "# This file was created by %s\n", Program());
- fprintf(dip3d, "# which is part of G R O M A C S:\n");
- fprintf(dip3d, "#\n");
+ try
+ {
+ gmx::BinaryInformationSettings settings;
+ settings.generatedByHeader(true);
+ settings.linePrefix("# ");
+ gmx::printBinaryInformation(dip3d, gmx::ProgramInfo::getInstance(),
+ settings);
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
}
/* Write legends to all the files */
{
fprintf(gmx_fio_getfp(trx_get_fileio(trxout)),
"Generated by %s. #atoms=%d, a BOX is"
- " stored in this file.\n", Program(), nout);
+ " stored in this file.\n", ShortProgram(), nout);
}
/* Start the big loop over frames */
#include "gromacs/legacyheaders/vec.h"
#include "gromacs/fft/fft.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/programinfo.h"
#include "buildinfo.h"
return _gmx_ver_string;
}
-void gmx_print_version_info_gpu(FILE *fp);
+extern void gmx_print_version_info_gpu(FILE *fp);
-void gmx_print_version_info(FILE *fp)
+static void gmx_print_version_info(FILE *fp)
{
fprintf(fp, "Gromacs version: %s\n", _gmx_ver_string);
#ifdef GMX_GIT_VERSION_INFO
{
BinaryInformationSettings::BinaryInformationSettings()
- : bExtendedInfo_(false), bCopyright_(false)
+ : bExtendedInfo_(false), bCopyright_(false),
+ bGeneratedByHeader_(false), prefix_(""), suffix_("")
{
}
void printBinaryInformation(FILE *fp, const ProgramInfo &programInfo,
const BinaryInformationSettings &settings)
{
+ const char *prefix = settings.prefix_;
+ const char *suffix = settings.suffix_;
const char *precisionString = "";
#ifdef GMX_DOUBLE
precisionString = " (double precision)";
#endif
const std::string &name = programInfo.programName();
- fprintf(fp, "GROMACS: %s, %s%s\n", name.c_str(),
- GromacsVersion(), precisionString);
- fprintf(fp, "Executable: %s\n", programInfo.programNameWithPath().c_str());
- fprintf(fp, "Command line:\n %s\n", programInfo.commandLine().c_str());
+ if (settings.bGeneratedByHeader_)
+ {
+ fprintf(fp, "%sCreated by:%s\n", prefix, suffix);
+ }
+ fprintf(fp, "%sGROMACS: %s, %s%s%s\n", prefix, name.c_str(),
+ GromacsVersion(), precisionString, suffix);
+ fprintf(fp, "%sExecutable: %s%s\n", prefix,
+ programInfo.programNameWithPath().c_str(), suffix);
+ fprintf(fp, "%sCommand line:%s\n%s %s%s\n",
+ prefix, suffix, prefix, programInfo.commandLine().c_str(), suffix);
if (settings.bCopyright_)
{
+ GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0',
+ "Prefix/suffix not supported with copyright");
fprintf(fp, "\n");
CopyRight(fp);
}
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);
}
- fprintf(fp, "\n");
}
} // namespace gmx
#include "thread_mpi.h"
#endif
+#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/programinfo.h"
+
/* The source code in this file should be thread-safe.
Please keep it that way. */
"Log file opened on %s"
"Host: %s pid: %d nodeid: %d nnodes: %d\n",
timebuf, host, pid, cr->nodeid, cr->nnodes);
- gmx_print_version_info(fp);
+ try
+ {
+ gmx::BinaryInformationSettings settings;
+ settings.extendedInfo(true);
+ settings.copyright(!bAppendFiles);
+ gmx::printBinaryInformation(fp, gmx::ProgramInfo::getInstance(), settings);
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
fprintf(fp, "\n\n");
fflush(fp);
#include "statutil.h"
#include "gmxfio.h"
#include "maths.h"
+#include "copyrite.h"
+
+#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/programinfo.h"
#define round(a) (int)(a+0.5)
gmx_bool bDiscrete)
{
fprintf(out, "/* XPM */\n");
- fprintf(out, "/* Generated by %s */\n", Program());
+ try
+ {
+ gmx::BinaryInformationSettings settings;
+ settings.generatedByHeader(true);
+ settings.linePrefix("/* ");
+ settings.lineSuffix(" */");
+ gmx::printBinaryInformation(out, gmx::ProgramInfo::getInstance(),
+ settings);
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
fprintf(out, "/* This file can be converted to EPS by the GROMACS program xpm2ps */\n");
fprintf(out, "/* title: \"%s\" */\n", title);
fprintf(out, "/* legend: \"%s\" */\n", legend);
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
}
-const char *command_line(void)
-{
- try
- {
- return gmx::ProgramInfo::getInstance().commandLine().c_str();
- }
- GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
-}
-
/* utility functions */
gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble)
gmx_fatal(f_errno, file, line,
"Too many warnings (%d), %s terminated.\n"
"If you are sure all warnings are harmless, use the -maxwarn option.",
- wi->nwarn_warn, Program());
+ wi->nwarn_warn, ShortProgram());
}
sfree(wi);
#include "vec.h"
#include "gmxfio.h"
+#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/programinfo.h"
+
gmx_bool output_env_get_print_xvgr_codes(const output_env_t oenv)
{
int xvg_format;
time(&t);
gmx_ctime_r(&t, buf, STRLEN);
fprintf(fp, "# This file was created %s", buf);
- fprintf(fp, "# by the following command:\n# %s\n#\n", command_line());
+ try
+ {
+ gmx::BinaryInformationSettings settings;
+ settings.generatedByHeader(true);
+ settings.linePrefix("# ");
+ gmx::printBinaryInformation(fp, gmx::ProgramInfo::getInstance(),
+ settings);
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
fprintf(fp, "# %s is part of G R O M A C S:\n#\n", ShortProgram());
bromacs(pukestr, 99);
fprintf(fp, "# %s\n#\n", pukestr);
#include "toputil.h"
#include "fflibutil.h"
#include "strdb.h"
+#include "copyrite.h"
+
+#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/programinfo.h"
/* this must correspond to enum in pdb2top.h */
const char *hh[ehisNR] = { "HISD", "HISE", "HISH", "HIS1" };
void print_top_comment(FILE *out,
const char *filename,
- const char *generator,
const char *ffdir,
gmx_bool bITP)
{
nice_header(out, filename);
fprintf(out, ";\tThis is a %s topology file\n;\n", bITP ? "include" : "standalone");
- fprintf(out, ";\tIt was generated using program:\n;\t%s\n;\n",
- (NULL == generator) ? "unknown" : generator);
- fprintf(out, ";\tCommand line was:\n;\t%s\n;\n", command_line());
+ try
+ {
+ gmx::BinaryInformationSettings settings;
+ settings.generatedByHeader(true);
+ settings.linePrefix(";\t");
+ gmx::printBinaryInformation(out, gmx::ProgramInfo::getInstance(),
+ settings);
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
if (strchr(ffdir, '/') == NULL)
{
}
void print_top_header(FILE *out, const char *filename,
- const char *title, gmx_bool bITP, const char *ffdir, real mHmult)
+ gmx_bool bITP, const char *ffdir, real mHmult)
{
const char *p;
- print_top_comment(out, filename, title, ffdir, bITP);
+ print_top_comment(out, filename, ffdir, bITP);
print_top_heavy_H(out, mHmult);
fprintf(out, "; Include forcefield parameters\n");
/* Has to be a function, so we can get version number from autoconf */
const char *GromacsVersion(void);
-void
-gmx_print_version_info(FILE *fp);
-
/* For both bromacs() and cool_quote() you have to provide a pointer to
* a string of reasonable length (say 256) and the string length. This
* is necessary to make the routines threadsafe and avoid allocating
bCopyright_ = bEnabled;
return *this;
}
+ BinaryInformationSettings &generatedByHeader(bool bEnabled)
+ {
+ bGeneratedByHeader_ = bEnabled;
+ return *this;
+ }
+ BinaryInformationSettings &linePrefix(const char *prefix)
+ {
+ prefix_ = prefix;
+ return *this;
+ }
+ BinaryInformationSettings &lineSuffix(const char *suffix)
+ {
+ suffix_ = suffix;
+ return *this;
+ }
private:
bool bExtendedInfo_;
bool bCopyright_;
+ bool bGeneratedByHeader_;
+ const char *prefix_;
+ const char *suffix_;
//! Needed to read the members without otherwise unnecessary accessors.
friend void printBinaryInformation(FILE *fp, const ProgramInfo &programInfo,
* add these atoms to restp.
*/
-void print_top_comment(FILE *out, const char *filename, const char *generator, const char *ffdir, gmx_bool bITP);
+void print_top_comment(FILE *out, const char *filename, const char *ffdir, gmx_bool bITP);
-void print_top_header(FILE *out, const char *filename, const char *title, gmx_bool bITP,
+void print_top_header(FILE *out, const char *filename, gmx_bool bITP,
const char *ffdir, real mHmult);
void print_top_mols(FILE *out,
global informaion, their existence in a multi-threaded environment is not
a real problem. */
-/* Return the name of the program */
-const char *command_line(void);
-
/* set the program name to the provided string, but note
* that it must be a real file - we determine the library
* directory from its location!
if (bTOP)
{
fp = ftp2FILE(efTOP, NFILE, fnm, "w");
- print_top_header(fp, ftp2fn(efTOP, NFILE, fnm),
- "Generated by x2top", TRUE, ffdir, 1.0);
+ print_top_header(fp, ftp2fn(efTOP, NFILE, fnm), TRUE, ffdir, 1.0);
write_top(fp, NULL, mymol.name, atoms, FALSE, bts, plist, excls, atype,
cgnr, rtp_header_settings.nrexcl);
close_symtab(&symtab);
free(mymol.name);
- printf("\nWARNING: topologies generated by %s can not be trusted at face value.\n", Program());
+ printf("\nWARNING: topologies generated by %s can not be trusted at face value.\n",
+ ShortProgram());
printf(" Please verify atomtypes and charges by comparison to other\n");
printf(" topologies.\n");
gmx_residuetype_t rt;
const char *top_fn;
char fn[256], itp_fn[STRLEN], posre_fn[STRLEN], buf_fn[STRLEN];
- char molname[STRLEN], title[STRLEN], quote[STRLEN], generator[STRLEN];
+ char molname[STRLEN], title[STRLEN], quote[STRLEN];
char *c, forcefield[STRLEN], ffdir[STRLEN];
char ffname[STRLEN], suffix[STRLEN], buf[STRLEN];
char *watermodel;
top_fn = ftp2fn(efTOP, NFILE, fnm);
top_file = gmx_fio_fopen(top_fn, "w");
- sprintf(generator, "%s - %s", ShortProgram(), GromacsVersion() );
-
- print_top_header(top_file, top_fn, generator, FALSE, ffdir, mHmult);
+ print_top_header(top_file, top_fn, FALSE, ffdir, mHmult);
nincl = 0;
nmol = 0;
if (bITP)
{
- print_top_comment(itp_file, itp_fn, generator, ffdir, TRUE);
+ print_top_comment(itp_file, itp_fn, ffdir, TRUE);
}
if (cc->bAllWat)