Modifications in fsync routines for checkpoints.
authorPeter Kasson <kasson@DN0a20fa8d.SUNet>
Fri, 11 Jun 2010 20:53:05 +0000 (22:53 +0200)
committerserver <server@folding-1.pdc.kth.se>
Fri, 11 Jun 2010 20:53:58 +0000 (22:53 +0200)
src/gmxlib/checkpoint.c
src/gmxlib/gmxfio.c

index 00eed9d8adfb962abf2f07f3256a0dd4a45f2484..3c943359e4a5507c9066c57a4b041a2d83e3293f 100644 (file)
@@ -1170,11 +1170,15 @@ void write_checkpoint(const char *fn,FILE *fplog,t_commrec *cr,
         buf[strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0';
         strcat(buf,"_prev");
         strcat(buf,fn+strlen(fn) - 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_file_rename(fntemp, fn) != 0)
     {
index bc36d5fcd1ee54edb0672eec6d14450642bd6eca..c55523ea3a78c18b6bd53d181766db9b6c6d3d1b 100644 (file)
@@ -1528,8 +1528,9 @@ static int gmx_fio_fsync_lock(int fio, bool do_lock)
     int rc = 0;
     int filen=-1;
 
-#if ( (defined(HAVE_FILENO) && defined(HAVE_FSYNC))  || \
-      (defined(HAVE__FILENO) && defined(HAVE__COMMIT)) )
+#if ( ( (defined(HAVE_FILENO) || (defined(HAVE__FILENO) ) ) && \
+       (defined(HAVE_FSYNC))  || defined(HAVE__COMMIT)  ) || \
+        defined(FAHCORE) )
 #ifdef GMX_THREADS
     if (do_lock)
         tMPI_Thread_mutex_lock(&fio_mutex);
@@ -1537,7 +1538,10 @@ static int gmx_fio_fsync_lock(int fio, bool do_lock)
     gmx_fio_check(fio);
     if (FIO[fio].fp)
     {
-#ifdef HAVE_FILENO
+#ifdef GMX_FAHCORE
+       /* the fahcore defines its own os-independent fsync */
+       rc=fah_fsync(FIO[fio].fp); 
+#elif HAVE_FILENO
         filen=fileno(FIO[fio].fp);
 #elif HAVE__FILENO
         filen=_fileno(FIO[fio].fp);
@@ -1545,13 +1549,17 @@ static int gmx_fio_fsync_lock(int fio, bool do_lock)
     }
     else if (FIO[fio].xdr)
     {
-#ifdef HAVE_FILENO
+#ifdef GMX_FAHCORE
+       /* the fahcore defines its own os-independent fsync */
+        rc=fah_fsync((FILE *) FIO[fio].xdr->x_private);
+#elif HAVE_FILENO
         filen=fileno((FILE *) FIO[fio].xdr->x_private);
 #elif HAVE__FILENO
         filen=_fileno((FILE *) FIO[fio].xdr->x_private);
 #endif
     }
 
+#ifndef GMX_FAHCORE
     if (filen>0)
     {
 #if (defined(HAVE_FSYNC))
@@ -1561,6 +1569,7 @@ static int gmx_fio_fsync_lock(int fio, bool do_lock)
         rc=_commit(filen);
 #endif
     }
+#endif
 
     /* We check for these error codes this way because POSIX requires them
        to be defined, and using anything other than macros is unlikely: */
@@ -1617,7 +1626,7 @@ int gmx_fio_all_output_fsync(void)
             {
                 char buf[STRLEN];
                 sprintf(buf,
-                        "Cannot write file '%s'; maybe you are out of disk space or quota?",
+                        "Cannot fsync file '%s'; maybe you are out of disk space or quota?",
                         FIO[i].fn);
                 gmx_file(buf);
                 ret=-1;