#include "gromacs/fileio/tngio.h"
#include "gromacs/fileio/trrio.h"
#include "gromacs/fileio/xtcio.h"
-#include "gromacs/fileio/xvgr.h"
#include "gromacs/math/vec.h"
-#include "gromacs/mdlib/trajectory_writing.h"
+#include "gromacs/mdlib/energyoutput.h"
#include "gromacs/mdrunutility/handlerestart.h"
#include "gromacs/mdrunutility/multisim.h"
#include "gromacs/mdtypes/awh_history.h"
#include "gromacs/mdtypes/commrec.h"
-#include "gromacs/mdtypes/df_history.h"
#include "gromacs/mdtypes/edsamhistory.h"
#include "gromacs/mdtypes/energyhistory.h"
#include "gromacs/mdtypes/imdoutputprovider.h"
int natoms_global;
int natoms_x_compressed;
const SimulationGroups* groups; /* for compressed position writing */
- gmx_wallcycle_t wcycle;
+ gmx_wallcycle* wcycle;
rvec* f_global;
gmx::IMDOutputProvider* outputProvider;
const gmx::MDModulesNotifiers* mdModulesNotifiers;
const t_inputrec* ir,
const gmx_mtop_t& top_global,
const gmx_output_env_t* oenv,
- gmx_wallcycle_t wcycle,
+ gmx_wallcycle* wcycle,
const gmx::StartingBehavior startingBehavior,
bool simulationsShareState,
const gmx_multisim_t* ms)
}
}
- if (ir->nstfout && DOMAINDECOMP(cr))
+ if (ir->nstfout && haveDDAtomOrdering(*cr))
{
snew(of->f_global, top_global.natoms);
}
return of->fp_dhdl;
}
-gmx_wallcycle_t mdoutf_get_wcycle(gmx_mdoutf_t of)
+gmx_wallcycle* mdoutf_get_wcycle(gmx_mdoutf_t of)
{
return of->wcycle;
}
char buf[1024], suffix[5 + STEPSTRSIZE], sbuf[STEPSTRSIZE];
t_fileio* ret;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
npmenodes = cr->npmenodes;
}
swaphistory_t* swaphist = observablesHistory->swapHistory.get();
SwapType eSwapCoords = (swaphist ? swaphist->eSwapCoords : SwapType::No);
- CheckpointHeaderContents headerContents = { 0,
+ CheckpointHeaderContents headerContents = { CheckPointVersion::UnknownVersion0,
{ 0 },
{ 0 },
{ 0 },
std::strcpy(headerContents.version, gmx_version());
std::strcpy(headerContents.fprog, gmx::getProgramContext().fullBinaryPath());
std::strcpy(headerContents.ftime, timebuf.c_str());
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
copy_ivec(domdecCells, headerContents.dd_nc);
}
/* Rename the checkpoint file from the temporary to the final name */
mpiBarrierBeforeRename(applyMpiBarrierBeforeRename, mpiBarrierCommunicator);
- if (gmx_file_rename(fntemp, fn) != 0)
+ try
{
- gmx_file("Cannot rename checkpoint file; maybe you are out of disk space?");
+ gmx_file_rename(fntemp, fn);
+ }
+ catch (gmx::FileIOError const&)
+ {
+ // In this case we can be more helpful than the generic message from gmx_file_rename
+ GMX_THROW(gmx::FileIOError(
+ "Cannot rename checkpoint file; maybe you are out of disk space?"));
}
}
#endif /* GMX_NO_RENAME */
sfree(fntemp);
#if GMX_FAHCORE
- /*code for alternate checkpointing scheme. moved from top of loop over
- steps */
- fcRequestCheckPoint();
- if (fcCheckPointParallel(cr->nodeid, NULL, 0) == 0)
- {
- gmx_fatal(3, __FILE__, __LINE__, "Checkpoint error on step %d\n", step);
- }
+ /* Always FAH checkpoint immediately after a GROMACS checkpoint.
+ *
+ * Note that it is critical that we save a FAH checkpoint directly
+ * after writing a GROMACS checkpoint. If the program dies, either
+ * by the machine powering off suddenly or the process being,
+ * killed, FAH can recover files that have only appended data by
+ * truncating them to the last recorded length. The GROMACS
+ * checkpoint does not just append data, it is fully rewritten each
+ * time so a crash between moving the new Gromacs checkpoint file in
+ * to place and writing a FAH checkpoint is not recoverable. Thus
+ * the time between these operations must be kept as short as
+ * possible.
+ */
+ fcCheckpoint();
#endif /* end GMX_FAHCORE block */
}
of->bKeepAndNumCPT,
fplog,
cr,
- DOMAINDECOMP(cr) ? cr->dd->numCells : one_ivec,
- DOMAINDECOMP(cr) ? cr->dd->nnodes : cr->nnodes,
+ haveDDAtomOrdering(*cr) ? cr->dd->numCells : one_ivec,
+ haveDDAtomOrdering(*cr) ? cr->dd->nnodes : cr->nnodes,
of->eIntegrator,
of->simulation_part,
of->bExpanded,
{
const rvec* f_global;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
if (mdof_flags & MDOF_CPT)
{
f_global = of->f_global;
if (mdof_flags & MDOF_F)
{
- auto globalFRef =
- MASTER(cr) ? gmx::arrayRefFromArray(reinterpret_cast<gmx::RVec*>(of->f_global),
- f_local.size())
- : gmx::ArrayRef<gmx::RVec>();
+ auto globalFRef = MASTER(cr) ? gmx::arrayRefFromArray(
+ reinterpret_cast<gmx::RVec*>(of->f_global), of->natoms_global)
+ : gmx::ArrayRef<gmx::RVec>();
dd_collect_vec(cr->dd,
state_local->ddp_count,
state_local->ddp_count_cg_gl,
{
if (of->tng || of->tng_low_prec)
{
- wallcycle_start(of->wcycle, ewcTRAJ);
+ wallcycle_start(of->wcycle, WallCycleCounter::Traj);
gmx_tng_close(&of->tng);
gmx_tng_close(&of->tng_low_prec);
- wallcycle_stop(of->wcycle, ewcTRAJ);
+ wallcycle_stop(of->wcycle, WallCycleCounter::Traj);
}
}