This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: I/O question


Jean-Philippe Chancelier <Jean-Philippe.Chancelier@cergrene.enpc.fr> writes:
> 
> Hello,
> some days ago someone reported that unformated I/O 
> where very slow with GnuWin32 and Fortran code (with f2c or g77) 
> and proposed a solution ? unfortunately I4ve lost that mail 
> and I4d like to get it again.
> 

You can find my comments on libf2c's slow unformatted I/O handling in my
gnu-win32 Web page (along with g77 patches for cygwin32-b17.1). URL after
sig.

This is a general problem with how libf2c handles unformatted I/O records,
specifically how it writes out the record lengths at the beginning of the
record by fseek'ing (and hence flushing the buffers as a side effect). This
is what happens:
    - start a new unformatted record. Remember current record position by
      ftell. <-- causes a fflush()!
    - write out each subrecord and keep a running count of the # of bytes
      written
    - write out the record length at the beginning of the record by
	- remember the end of the record by ftell (another fflush()!)
	- fseek'ing to the beginning (remember the ftell()).
	- write out the length
	- fseek back to the end of the record
    - write out the record length at the end of the record

performance penalty isn't that great on systems with "real" file systems,
on FAT/VFAT, it can be quite bad.

To be fair, it only happens if write *tons* of tiny records. If you write
large records, the penalty is not noticeable.

I had asked the g77 gurus if it is possible to know *how* many bytes will
be written in an unformatted record by prescanning the write statement. If
so, then we can simply write the record length before starting the actual
data write, and no fseek'ing back and forth ...

I didn't really propose a solution, rather showed how I circumvented the
problem by writing the unformatted reader/writer for *our* code in C and
have the FORTRAN routines call the C routines on gnu-win32 and the regular
FORTRAN routines on other systems.

Regards,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/
http://www.xraylith.wisc.edu/~khan/software/gnu-win32

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]