Made related minor simplifications in a few places.
Fixes #2654
Change-Id: Ie3245c78f1f88bd9df6f81c86f8f04dae2ceb45c
#cmakedefine THREAD_WINDOWS
/* Define for busy wait option */
-/* See gmxpre-config.h.cmakein for explanation for the #ifdef */
+/* See gmxpre-config.h.cmakein for explanation for the #ifndef */
#ifndef TMPI_WAIT_FOR_NO_ONE
-#cmakedefine TMPI_WAIT_FOR_NO_ONE
+#cmakedefine01 TMPI_WAIT_FOR_NO_ONE
#endif
/* Define for copy buffer option */
#ifndef TMPI_WAIT_H_
#define TMPI_WAIT_H_
-#ifndef TMPI_WAIT_FOR_NO_ONE
+#if TMPI_WAIT_FOR_NO_ONE
#if !(defined( _WIN32 ) || defined( _WIN64 ) )
#ifdef HAVE_UNISTD_H
system.
This option can be set with cmake. */
-/*#define TMPI_WAIT_FOR_NO_ONE */
+/*#define TMPI_WAIT_FOR_NO_ONE 1 */
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014, by the GROMACS development team, led by
+ * Copyright (c) 2014,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \see gmxpre.h
*/
-/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc
+ * 2.2). This symbol affects non-GROMACS code, so is not subject to
+ * our no-undefined-preprocessor-symbols policy. */
#cmakedefine _LARGEFILE_SOURCE
-/* Define for large files, on AIX-style hosts. */
+/* Define for large files, on AIX-style hosts. This symbol affects
+ * non-GROMACS code, so is not subject to our
+ * no-undefined-preprocessor-symbols policy. */
#cmakedefine _LARGE_FILES
-/* Some systems requires this to be set to 64 for large file support */
+/* Some systems requires this to be set to 64 for large file support.
+ * This symbol affects non-GROMACS code, so is not subject to our
+ * no-undefined-preprocessor-symbols policy. */
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
/* Build special-purpose mdrun library */
-#cmakedefine GMX_FAHCORE
+#cmakedefine01 GMX_FAHCORE
/* This is here for simplicity, since the layout for some thread-MPI structs
* declared in headers depend on this being consistently defined.
* But thread-MPI itself does not include gmxpre.h, so the same define is also
* set in config.h (which gets included by thread-MPI, but only in the source
* files). There are some other config.h defines that appear in thread-MPI
- * headers, but currently Gromacs does not use any code that would depend on
+ * headers, but currently GROMACS does not use any code that would depend on
* those, and for thread-MPI, config.h provides the definitions wherever
* required. */
/* Define for busy wait option */
-#cmakedefine TMPI_WAIT_FOR_NO_ONE
-
+#cmakedefine01 TMPI_WAIT_FOR_NO_ONE
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014, by the GROMACS development team, led by
+ * Copyright (c) 2014,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#define __STDC_LIMIT_MACROS
#define __STDC_FORMAT_MACROS
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
#define FULLINDIRECT 1
#define USE_FAH_XDR 1
#include "swindirect.h"
#include "gromacs/utility/sysinfo.h"
#include "gromacs/utility/txtdump.h"
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
#include "corewrap.h"
#endif
buf[std::strlen(fn) - std::strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0';
std::strcat(buf, "_prev");
std::strcat(buf, fn+std::strlen(fn) - std::strlen(ftp2ext(fn2ftp(fn))) - 1);
-#ifndef GMX_FAHCORE
- /* we copy here so that if something goes wrong between now and
- * the rename below, there's always a state.cpt.
- * If renames are atomic (such as in POSIX systems),
- * this copying should be unneccesary.
- */
- gmx_file_copy(fn, buf, FALSE);
- /* We don't really care if this fails:
- * there's already a new checkpoint.
- */
-#else
- gmx_file_rename(fn, buf);
-#endif
+ if (!GMX_FAHCORE)
+ {
+ /* we copy here so that if something goes wrong between now and
+ * the rename below, there's always a state.cpt.
+ * If renames are atomic (such as in POSIX systems),
+ * this copying should be unneccesary.
+ */
+ gmx_file_copy(fn, buf, FALSE);
+ /* We don't really care if this fails:
+ * there's already a new checkpoint.
+ */
+ }
+ else
+ {
+ gmx_file_rename(fn, buf);
+ }
}
if (gmx_file_rename(fntemp, fn) != 0)
{
sfree(fntemp);
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
/*code for alternate checkpointing scheme. moved from top of loop over
steps */
fcRequestCheckPoint();
" offsets. Can not append. Run mdrun with -noappend",
outputfile.filename);
}
-#ifdef GMX_FAHCORE
- chksum_file = gmx_fio_open(outputfile.filename, "a");
-
-#else
- chksum_file = gmx_fio_open(outputfile.filename, "r+");
-
- /* lock log file */
- if (firstFile)
+ if (GMX_FAHCORE)
{
- /* Note that there are systems where the lock operation
- * will succeed, but a second process can also lock the file.
- * We should probably try to detect this.
- */
+ chksum_file = gmx_fio_open(outputfile.filename, "a");
+ }
+ else
+ {
+ chksum_file = gmx_fio_open(outputfile.filename, "r+");
+
+ /* lock log file */
+ if (firstFile)
+ {
+ /* Note that there are systems where the lock operation
+ * will succeed, but a second process can also lock the file.
+ * We should probably try to detect this.
+ */
#if defined __native_client__
- errno = ENOSYS;
- if (1)
+ errno = ENOSYS;
+ if (1)
#elif GMX_NATIVE_WINDOWS
- if (_locking(fileno(gmx_fio_getfp(chksum_file)), _LK_NBLCK, LONG_MAX) == -1)
+ if (_locking(fileno(gmx_fio_getfp(chksum_file)), _LK_NBLCK, LONG_MAX) == -1)
#else
- if (fcntl(fileno(gmx_fio_getfp(chksum_file)), F_SETLK, &fl) == -1)
+ if (fcntl(fileno(gmx_fio_getfp(chksum_file)), F_SETLK, &fl) == -1)
#endif
- {
- if (errno == ENOSYS)
{
- if (!bForceAppend)
+ if (errno == ENOSYS)
+ {
+ if (!bForceAppend)
+ {
+ gmx_fatal(FARGS, "File locking is not supported on this system. Use -noappend or specify -append explicitly to append anyhow.");
+ }
+ else
+ {
+ if (fplog)
+ {
+ fprintf(fplog, "\nNOTE: File locking not supported on this system, will not lock %s\n\n", outputfile.filename);
+ }
+ }
+ }
+ else if (errno == EACCES || errno == EAGAIN)
{
- gmx_fatal(FARGS, "File locking is not supported on this system. Use -noappend or specify -append explicitly to append anyhow.");
+ gmx_fatal(FARGS, "Failed to lock: %s. Already running "
+ "simulation?", outputfile.filename);
}
else
{
- if (fplog)
- {
- fprintf(fplog, "\nNOTE: File locking not supported on this system, will not lock %s\n\n", outputfile.filename);
- }
+ gmx_fatal(FARGS, "Failed to lock: %s. %s.",
+ outputfile.filename, std::strerror(errno));
}
}
- else if (errno == EACCES || errno == EAGAIN)
- {
- gmx_fatal(FARGS, "Failed to lock: %s. Already running "
- "simulation?", outputfile.filename);
- }
- else
- {
- gmx_fatal(FARGS, "Failed to lock: %s. %s.",
- outputfile.filename, std::strerror(errno));
- }
}
- }
- /* compute md5 chksum */
- if (outputfile.chksum_size != -1)
- {
- if (gmx_fio_get_file_md5(chksum_file, outputfile.offset,
- digest) != outputfile.chksum_size) /*at the end of the call the file position is at the end of the file*/
+ /* compute md5 chksum */
+ if (outputfile.chksum_size != -1)
{
- gmx_fatal(FARGS, "Can't read %d bytes of '%s' to compute checksum. The file has been replaced or its contents have been modified. Cannot do appending because of this condition.",
- outputfile.chksum_size,
- outputfile.filename);
+ if (gmx_fio_get_file_md5(chksum_file, outputfile.offset,
+ digest) != outputfile.chksum_size) /*at the end of the call the file position is at the end of the file*/
+ {
+ gmx_fatal(FARGS, "Can't read %d bytes of '%s' to compute checksum. The file has been replaced or its contents have been modified. Cannot do appending because of this condition.",
+ outputfile.chksum_size,
+ outputfile.filename);
+ }
}
- }
- /* log file needs to be seeked in case we need to truncate
- * (other files are truncated below)*/
- if (firstFile)
- {
- if (gmx_fio_seek(chksum_file, outputfile.offset))
+ /* log file needs to be seeked in case we need to truncate
+ * (other files are truncated below)*/
+ if (firstFile)
{
- gmx_fatal(FARGS, "Seek error! Failed to truncate log-file: %s.", std::strerror(errno));
+ if (gmx_fio_seek(chksum_file, outputfile.offset))
+ {
+ gmx_fatal(FARGS, "Seek error! Failed to truncate log-file: %s.", std::strerror(errno));
+ }
}
}
-#endif
/* open log file here - so that lock is never lifted
* after chksum is calculated */
{
gmx_fio_close(chksum_file);
}
-#ifndef GMX_FAHCORE
/* compare md5 chksum */
- if (outputfile.chksum_size != -1 &&
+ if (!GMX_FAHCORE &&
+ outputfile.chksum_size != -1 &&
memcmp(digest, outputfile.chksum, 16) != 0)
{
if (debug)
gmx_fatal(FARGS, "Checksum wrong for '%s'. The file has been replaced or its contents have been modified. Cannot do appending because of this condition.",
outputfile.filename);
}
-#endif
-
- if (!firstFile) /* log file is already seeked to correct position */
+ // We could preprocess less, but then checkers complain
+ // about possible bugs when using logic on constant
+ // expressions.
+#if !GMX_NATIVE_WINDOWS || !GMX_FAHCORE
+ // The log file is already seeked to correct position, but
+ // others must be truncated.
+ if (!firstFile)
{
-#if !GMX_NATIVE_WINDOWS || !defined(GMX_FAHCORE)
/* For FAHCORE, we do this elsewhere*/
rc = gmx_truncate(outputfile.filename, outputfile.offset);
if (rc != 0)
{
gmx_fatal(FARGS, "Truncation of file %s failed. Cannot do appending because of this failure.", outputfile.filename);
}
-#endif
}
+#endif
firstFile = false;
}
}
/* Get the file position */
gmx_fio_int_get_file_position(cur, &outputfiles.back().offset);
-#ifndef GMX_FAHCORE
- outputfiles.back().chksum_size
- = gmx_fio_int_get_file_md5(cur,
- outputfiles.back().offset,
- outputfiles.back().chksum);
-#endif
+ if (!GMX_FAHCORE)
+ {
+ outputfiles.back().chksum_size
+ = gmx_fio_int_get_file_md5(cur,
+ outputfiles.back().offset,
+ outputfiles.back().chksum);
+ }
}
cur = gmx_fio_get_next(cur);
gmx_incons("Invalid reduced precision file format");
}
}
- if ((EI_DYNAMICS(ir->eI) || EI_ENERGY_MINIMIZATION(ir->eI))
-#ifndef GMX_FAHCORE
- &&
- !(EI_DYNAMICS(ir->eI) &&
- ir->nstxout == 0 &&
- ir->nstvout == 0 &&
- ir->nstfout == 0)
-#endif
+ if ((EI_DYNAMICS(ir->eI) || EI_ENERGY_MINIMIZATION(ir->eI)) &&
+ (!GMX_FAHCORE &&
+ !(EI_DYNAMICS(ir->eI) &&
+ ir->nstxout == 0 &&
+ ir->nstvout == 0 &&
+ ir->nstfout == 0)
+ )
)
{
const char *filename;
mdof_flags |= MDOF_LAMBDA_COMPRESSED;
}
-#if defined(GMX_FAHCORE)
+#if GMX_FAHCORE
if (bLastStep)
{
/* Enforce writing positions and velocities at end of run */
#include "integrator.h"
#include "replicaexchange.h"
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
#include "corewrap.h"
#endif
/* Interactive MD */
gmx_bool bIMDstep = FALSE;
-#ifdef GMX_FAHCORE
- /* Temporary addition for FAHCORE checkpointing */
- int chkpt_ret;
-#endif
/* Domain decomposition could incorrectly miss a bonded
interaction, but checking for that requires a global
communication stage, which does not otherwise happen in DD
wallcycle_start(wcycle, ewcRUN);
print_start(fplog, cr, walltime_accounting, "mdrun");
+#if GMX_FAHCORE
/* safest point to do file checkpointing is here. More general point would be immediately before integrator call */
-#ifdef GMX_FAHCORE
- chkpt_ret = fcCheckPointParallel( cr->nodeid,
- NULL, 0);
+ int chkpt_ret = fcCheckPointParallel( cr->nodeid,
+ NULL, 0);
if (chkpt_ret == 0)
{
gmx_fatal( 3, __FILE__, __LINE__, "Checkpoint error on step %d\n", 0 );
#include "integrator.h"
#include "replicaexchange.h"
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
#include "corewrap.h"
#endif
}
}
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
if (MASTER(cr))
{
fcRegisterSteps(inputrec->nsteps, inputrec->init_step);
"the Royal Institute of Technology, Sweden.",
"check out http://www.gromacs.org for more information."
};
- static const char * const LicenseText[] = {
- "GROMACS is free software; you can redistribute it and/or modify it",
- "under the terms of the GNU Lesser General Public License",
- "as published by the Free Software Foundation; either version 2.1",
- "of the License, or (at your option) any later version."
- };
#define NCONTRIBUTORS static_cast<int>(asize(Contributors))
#define NCR static_cast<int>(asize(CopyrightText))
-// FAH has an exception permission from LGPL to allow digital signatures in Gromacs.
-#ifdef GMX_FAHCORE
-#define NLICENSE 0
-#else
-#define NLICENSE static_cast<int>(asize(LicenseText))
-#endif
-
// TODO a centering behaviour of TextWriter could be useful here
writer->writeLine(formatCentered(78, "GROMACS is written by:"));
for (int i = 0; i < NCONTRIBUTORS; )
writer->writeLine(CopyrightText[i]);
}
writer->ensureEmptyLine();
- for (int i = 0; i < NLICENSE; ++i)
+
+ // Folding At Home has different licence to allow digital
+ // signatures in GROMACS, so does not need to show the normal
+ // license statement.
+ if (!GMX_FAHCORE)
{
- writer->writeLine(LicenseText[i]);
+ writer->writeLine("GROMACS is free software; you can redistribute it and/or modify it");
+ writer->writeLine("under the terms of the GNU Lesser General Public License");
+ writer->writeLine("as published by the Free Software Foundation; either version 2.1");
+ writer->writeLine("of the License, or (at your option) any later version.");
}
}
pstack = ps;
}
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
/* don't use pipes!*/
#define popen fah_fopen
#define pclose fah_fclose
{
int rc = 0;
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
/* the fahcore defines its own os-independent fsync */
rc = fah_fsync(fp);
#else /* GMX_FAHCORE */
}
else
{
-#ifdef GMX_FAHCORE
+#if GMX_FAHCORE
fah_MPI_Init(argc, argv);
#else
# if GMX_OPENMP