aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2010-06-10 19:14:12 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2010-06-10 19:14:12 +0000
commitda12c99723e07b1cd4bdd72c721e7c0fd2ffd1e1 (patch)
tree0a1e16a67d7bec53679bc6cb4e472574fc95eef7
parent84efddb2006d83cfe7d250ac4556442b98ba4bf5 (diff)
downloadgcc-da12c99723e07b1cd4bdd72c721e7c0fd2ffd1e1.zip
gcc-da12c99723e07b1cd4bdd72c721e7c0fd2ffd1e1.tar.gz
gcc-da12c99723e07b1cd4bdd72c721e7c0fd2ffd1e1.tar.bz2
re PR fortran/43032 (FLUSH: Document that it does not call fsync() but fflush())
PR fortran/43032 * intrinsic.texi (FLUSH): Note the difference between FLUSH and POSIX's fsync(), and how to call the latter from Fortran code. From-SVN: r160568
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/intrinsic.texi38
2 files changed, 44 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index acb5fe1..87e4c3c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-10 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/43032
+ * intrinsic.texi (FLUSH): Note the difference between FLUSH and
+ POSIX's fsync(), and how to call the latter from Fortran code.
+
2010-06-10 Daniel Franke <franke.daniel@gmail.com>
PR fortran/44457
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index aa3241d..a24ad91 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -4185,6 +4185,44 @@ Subroutine
Beginning with the Fortran 2003 standard, there is a @code{FLUSH}
statement that should be preferred over the @code{FLUSH} intrinsic.
+The @code{FLUSH} intrinsic and the Fortran 2003 @code{FLUSH} statement
+have identical effect: they flush the runtime library's I/O buffer so
+that the data becomes visible to other processes. This does not guarantee
+that the data is committed to disk.
+
+On POSIX systems, you can request that all data is transferred to the
+storage device by calling the @code{fsync} function, with the POSIX file
+descriptor of the I/O unit as argument (retrieved with GNU intrinsic
+@code{FNUM}). The following example shows how:
+
+@smallexample
+ ! Declare the interface for POSIX fsync function
+ interface
+ function fsync (fd) bind(c,name="fsync")
+ use iso_c_binding, only: c_int
+ integer(c_int), value :: fd
+ integer(c_int) :: fsync
+ end function fsync
+ end interface
+
+ ! Variable declaration
+ integer :: ret
+
+ ! Opening unit 10
+ open (10,file="foo")
+
+ ! ...
+ ! Perform I/O on unit 10
+ ! ...
+
+ ! Flush and sync
+ flush(10)
+ ret = fsync(fnum(10))
+
+ ! Handle possible error
+ if (ret /= 0) stop "Error calling FSYNC"
+@end smallexample
+
@end table