Don't use fah_fsync
[alexxy/gromacs.git] / src / gromacs / fileio / checkpoint.cpp
index 6aaedafbc5ec9ba9454a6a5877474fa175425a36..9c6cfe42135b6bf4a7e8c98af3786d7abeed11ea 100644 (file)
 #include "gromacs/utility/sysinfo.h"
 #include "gromacs/utility/txtdump.h"
 
-#if GMX_FAHCORE
-#    include "corewrap.h"
-#endif
-
 #define CPT_MAGIC1 171817
 #define CPT_MAGIC2 171819
 
@@ -2470,14 +2466,21 @@ void write_checkpoint(const char*                   fn,
     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);
-    }
-#endif /* end GMX_FAHCORE block */
+    /* 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 a
+     * possible.
+     */
+    fcCheckpoint();
+#endif
 }
 
 static void check_int(FILE* fplog, const char* type, int p, int f, gmx_bool* mm)