This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/37129] Problems with access='direct', recl=1 I/O



------- Comment #3 from kargl at gcc dot gnu dot org  2008-08-15 18:59 -------
(In reply to comment #2)
> (In reply to comment #1)
> 
> Is there a Fortran 77 compatible work-around that will do what this program was
> doing (i.e.: write out a mixed set of 4 byte integers and 8 byte floats to a
> binary file with a specific format since that file will be read by another
> program that we do not control)?

Not that I'm aware of.  I just check the Fortran 77 standard and
the code is definitely nonconforming.  For a file opened with
direct access the F77 standard says:

12.2.4 File Access
12.2.4.2 Direct Access
   ....
   (4) All records of the file have the same length.

12.9.5.1 Unformatted Data Transfer

  On output to a file connected for direct access, the output list must not
  specify more values than can fit into a record.


Now, if you want to use a modern version of Fortran, you may be able to
use access='stream'.  This will allow you to write the values to the 
file as a binary file.

program testing
   open(unit=8, file='out', access='stream')
   write(8) 1, 2, 3
   write(8) dble(1), dble(2), dble(3)
   close(8)
end program testing

mobile:kargl[217] ll out
-rw-r--r--  1 kargl  kargl  - 36 Aug 15 11:57 out

36 bytes = 3 * sizeof(double) + 3 * sizeof(integer)



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37129


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