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)
{
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);
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);
}
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))
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: */
{
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;