This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: force write in Gfortran
Hi,
This happens only when I use Gfortran. I will try to be more accurate in
describing my problem:
If I have several strings to write to a file, my program just writes
the first Write command, and nothing happens for the following write
commands.
For example:
***********************
! part of file test.for
OPEN (6, FILE= 'OUT.txt')
Write(6,*)'test_1'
Write(6,*)'test_2'
Write(6,*)'test_3'
*************************
by this code my OUT.txt will have only as content the "string" "test_1"
It seems the pointer to the file is lost after the first acess.
This happens only when several files are linked to forme one
executable. If the executable is created just from my "test.for"
everthing goes ok and all the string are correctely written.
Because my program is very large and takes a lot of time to execute, I
was in doubt if the program was "waiting" to write or if it was not
writing at all.
I tried to use the Flush statament but also didn't work. It seems he
cannot flush because to pointer to the file is somehow lost.
below is the output of gfortran-v
***********************************************************************************
ziemer@hemo06:/home/ziemer$ gfortran -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared
--with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
***************
thank you very much
Janne Blomqvist wrote:
On Fri, Mar 24, 2006 at 11:44:45AM -0300, Paulo Ziemer wrote:
Hi,
Is there any way to force Gfortran not buffer and write immediately to
a file? I have tried to use the environment GFORTRAN_UNBUFFRED_ALL but
it didn't work.
Using ifort compiler the results are written much more faster than using
Gfortran. Anyone knows a good strategy to debug the file acess / write
process? Sometime files are not created or only the first write command
is correctly written (in the case we have several write commands in
sequence).
You can try the FLUSH statement, which flushes the io buffers for the
unit in question (or all open units, if a unit number is not
specified IIRC).
If you want more specific help, I suggest you post a code snippet that
demonstrates your problem, along with the output of 'gfortran -v'.