Hi Thomas,

OK so i took your example ( exact copy) and compile it

with gfortran 11.2.

Then without setting the environment variable:

export GFORTRAN_UNFORMATTED_BUFFER_SIZE=200000
i got
dbertini@lxbk0596:/lustre/rz/dbertini/fio > strace -e write ./fio
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 408) = 
408
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 
100368) = 100368
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 
100368) = 100368
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 
100368) = 100368
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 
100368) = 100368
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 6120) 
= 6120
+++ exited with 0 +++

setting for example
dbertini@lxbk0596:/lustre/rz/dbertini/fio > export 
GFORTRAN_UNFORMATTED_BUFFER_SIZE=400000
dbertini@lxbk0596:/lustre/rz/dbertini/fio > strace -e write ./fio
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 408) = 
408
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 
200328) = 200328
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 
200328) = 200328
write(3, 
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"..., 6936) 
= 6936
+++ exited with 0 +++

So it seems to work right?
But do you understand the strace output in both cases ?
What means the data buffer distribution?
Is there some data alignment alforithm working in the background here?
Cheers.
Denis






________________________________
From: Thomas Koenig <tkoe...@netcologne.de>
Sent: Saturday, February 26, 2022 10:20:25 AM
To: Bertini, Denis Dr.; Harald Anlauf
Cc: Tobias Burnus; fortran@gcc.gnu.org
Subject: Re: Problem setting buffer size for gfortran ( v 11.2)

On 25.02.22 21:53, Bertini, Denis Dr. via Fortran wrote:
> It seems that the value set in the foreseen environment variable is just
> ignored.
> And always a buffer size of 8kiB is used, which is the default values
> for formatted I/O harcoded in libgfortran.
> The only way to change this value is editing and recompiling the libgfortran.

This is really strange, I also cannot reproduce this.

With the Ubuntu-supplied gfortran 9.3.0 I get (just setting a few
semi-random numbers for the unformatted buffer size).

$ cat write.f90
program main
   implicit none
   integer, parameter :: n=100
   integer, dimension(n) :: x
   integer :: i
   x = [(i,i=1,n)]
   open (10,file="tst.dat",form="unformatted",action="write")
   do i=1,1000
     write (10) x
   end do
end program main
$ gfortran write.f90
$ strace -e write ./a.out
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
408) = 408
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
65688) = 65688
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
65688) = 65688
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
65688) = 65688
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
65688) = 65688
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
65688) = 65688
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
65688) = 65688
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
13464) = 13464
+++ exited with 0 +++
$ GFORTRAN_UNFORMATTED_BUFFER_SIZE=200000 strace -e write ./a.out
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
408) = 408
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
100368) = 100368
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
100368) = 100368
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
100368) = 100368
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
100368) = 100368
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
6120) = 6120
+++ exited with 0 +++
$ GFORTRAN_UNFORMATTED_BUFFER_SIZE=210000 strace -e write ./a.out
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
408) = 408
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
105264) = 105264
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
105264) = 105264
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
105264) = 105264
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
91800) = 91800
+++ exited with 0 +++
$ GFORTRAN_UNFORMATTED_BUFFER_SIZE=2100000 strace -e write ./a.out
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
408) = 408
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
407592) = 407592
+++ exited with 0 +++
$ GFORTRAN_UNFORMATTED_BUFFER_SIZE=21000000 strace -e write ./a.out
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
408) = 408
write(3,
"\220\1\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0\0\6\0\0\0\7\0\0\0"...,
407592) = 407592

Reply via email to