This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
fortran/10197: direct acces files not unformatted by default
- From: bdavis9659 at comcast dot net
- To: gcc-gnats at gcc dot gnu dot org
- Date: 24 Mar 2003 00:34:47 -0000
- Subject: fortran/10197: direct acces files not unformatted by default
- Reply-to: bdavis9659 at comcast dot net
>Number: 10197
>Category: fortran
>Synopsis: direct acces files not unformatted by default
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 24 00:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: bud davis
>Release: > g77 2.96
>Organization:
>Environment:
[bdavis at rh gcc]$ /usr/local/bin/g77 -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --enable-languages=f77,c --enable-checking
Thread model: posix
gcc version 3.4 20030323 (experimental)
>Description:
OPEN(..ACCESS='DIRECT'..) should open a file with FORM='UNFORMATTED'.
It is being opened with FORM='FORMATTED', which causes a runtime error on the first unformatted I/O.
This is correct on g77 2.96, and not on the pre-release g77 3.3 or g77 3.4.
At the risk of being proven wrong by a plethora of language lawyers:):)
The FORTAN-77 standard, section 12.10.1 states; when discussing FORM=
"If this specifier is omitted, a value of UNFORMATTED is assumed if the file is being connected for direct access, and a value of FORMATTED is assumed if the file is being connected for sequential access. "
So, IMHO, this is how it should work.
>How-To-Repeat:
C demonstrate a direct access file is by default unformatted
IMPLICIT NONE
LOGICAL*4 ERROR /.FALSE./
CHARACTER*12 FORM
DATA FORM / '' /
OPEN(UNIT=60,
1 ACCESS='DIRECT',
2 STATUS='SCRATCH',
3 RECL=255)
INQUIRE(UNIT=60,FORM=FORM)
IF (FORM.EQ.'UNFORMATTED') THEN
PRINT*,'FORM IS ',FORM,' WHICH IS CORRECT.'
ELSE
PRINT*,'FORM IS ',FORM,' S/B UNFORMATTED.'
ERROR = .TRUE.
ENDIF
CLOSE(UNIT=60)
IF (ERROR) CALL ABORT
END
example run with g77 3.4
[bdavis at rh bin]$ /usr/local/bin/g77 -static -v -g -o open open.f
Driving: /usr/local/bin/g77 -static -v -g -o open open.f -lfrtbegin -lg2c -lm
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --enable-checking --enable-languages=f77,c
Thread model: posix
gcc version 3.4 20030323 (experimental)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/f771 open.f -quiet -dumpbase open.f -auxbase open -g -version -o /tmp/cc7EOAQ9.s
GNU F77 version 3.4 20030323 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.3 2.96-113).
GGC heuristics: --param ggc-min-expand=63 --param ggc-min-heapsize=62241
as -V -Qy -o /tmp/ccwslAzc.o /tmp/cc7EOAQ9.s
GNU assembler version 2.11.93.0.2 (i386-redhat-linux) using BFD version 2.11.93.0.2 20020207
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/collect2 -m elf_i386 -static -o open /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/crtbeginT.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/../../.. /tmp/ccwslAzc.o -lfrtbegin -lg2c -lm -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.4/crtend.o /usr/lib/crtn.o
[bdavis at rh bin]$ ./open
FORM IS FORMATTED S/B UNFORMATTED.
Fortran abort routine called
Abort (core dumped)
run with gcc2.96
[bdavis at rh bin]$ g77 -static -v -g -o open open.f
g77 version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) (from FSF-g77 version 0.5.26 20000731 (Red Hat Linux 7.3 2.96-113))
Driving: g77 -static -v -g -o open open.f -lg2c -lm
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)
/usr/lib/gcc-lib/i386-redhat-linux/2.96/f771 open.f -quiet -dumpbase open.f -g -version -o /tmp/cctO7UwQ.s
GNU F77 version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) (i386-redhat-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.3 2.96-113).
as -V -Qy -o /tmp/ccxotX8Q.o /tmp/cctO7UwQ.s
GNU assembler version 2.11.93.0.2 (i386-redhat-linux) using BFD version 2.11.93.0.2 20020207
/usr/lib/gcc-lib/i386-redhat-linux/2.96/collect2 -m elf_i386 -static -o open /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtbegin.o -L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -L/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../.. /tmp/ccxotX8Q.o -lg2c -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crtn dot o[bdavis at rh bin]$ ./open
FORM IS UNFORMATTED WHICH IS CORRECT.
>Fix:
Index: gcc/libf2c/libI77/open.c
===================================================================
RCS file: /cvs/gcc/gcc/libf2c/libI77/open.c,v
retrieving revision 1.20
diff -c -3 -p -r1.20 open.c
*** gcc/libf2c/libI77/open.c 10 Jul 2002 21:17:29 -0000 1.20
--- gcc/libf2c/libI77/open.c 24 Mar 2003 00:30:17 -0000
*************** f_open (olist * a)
*** 148,154 ****
b->url = (int) a->orl;
b->ublnk = a->oblnk && (*a->oblnk == 'z' || *a->oblnk == 'Z');
if (a->ofm == 0)
! b->ufmt = 1;
else if (*a->ofm == 'f' || *a->ofm == 'F')
b->ufmt = 1;
else
--- 148,159 ----
b->url = (int) a->orl;
b->ublnk = a->oblnk && (*a->oblnk == 'z' || *a->oblnk == 'Z');
if (a->ofm == 0)
! {
! if ((a->oacc) && (*a->oacc == 'D' || *a->oacc == 'd'))
! b->ufmt = 0;
! else
! b->ufmt = 1;
! }
else if (*a->ofm == 'f' || *a->ofm == 'F')
b->ufmt = 1;
else
>Release-Note:
>Audit-Trail:
>Unformatted: