[comp.lang.fortran] list directed internal I/O

i91@nikhefh.UUCP (Fons Rademakers) (06/21/87)

Does somebody know what the ANSI FORTRAN 77 standard says about
list directed I/O from internal files? 

A little test program (see listing at end of message) gives on 
the VAX and Gould the expected result of: 
999  111  222  
while the Apollo FTN compiler is giving the following error message:

(00008)       read(ch, *) i, j, k
**** Error #250 on Line 8:
list directed format not allowed with internal file or ENCODE/DECODE
1 errors, no warnings in FOO, Fortran version 8.40

  -- Fons Rademakers
      
======= test program ========
      program foo
      
      character*11 ch
      integer i, j, k
      
      ch = '999,111,222'
      
      read(ch, *) i, j, k
      
      print *, i, j, k
      
      end
-- 
Org:    NIKHEF-H, National Institute for Nuclear and High-Energy Physics.
Mail:   Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands
UUCP:   {decvax,cernvax,uck,unido,vmucnam,seismo}!mcvax!nikhefh!i91
BITNET: nikhefh!i91@mcvax.bitnet                    Telex: 10262 (hef nl)

steve@jplgodo.UUCP (Steve Schlaifer x43171 301/167) (06/24/87)

In article <371@nikhefh.UUCP>, i91@nikhefh.UUCP (Fons Rademakers) writes:
> Does somebody know what the ANSI FORTRAN 77 standard says about
> list directed I/O from internal files? 
> .....

Section 12.2.5.2 of the ANSI standard expressly prohibits the use of list
directed formatting with internal files.  Some comilers support it as an
extension but they are not required to by the standard.
-- 
.....elroy\			Steve Schlaifer
......wlbr->!jplgodo!steve	Advance Projects Group, Jet Propulsion Labs
....logico/			4800 Oak Grove Drive, M/S 301/165
				Pasadena, California, 91109  +1 818 354 3171

bct@its63b.ed.ac.uk (B Tompsett) (06/25/87)

In article <371@nikhefh.UUCP> i91@nikhefh.UUCP (Fons Rademakers) writes:
>Does somebody know what the ANSI FORTRAN 77 standard says about
>list directed I/O from internal files? 
>
 ANSI X3.9-1978 FORTRAN 77, Full Language, Page 12-6, para 12.2.5.2 
  Internal File Restrictions.
 (1) Reading and writing records is accomplished only by sequential access 
     formatted input/output statements (12.8.1) that do not specify list-
     directed formatting.

  Why not just order a copy of the standard (or get your library to do it)?

 X3.9-1978 can be obtained from: American National Standards Institute,
      1430 Broadway, New York, N.Y. 10018, U.S.A.

 Also you might be able to get a copy in Europe from ISO as ISO 1539-1980(E).

If you are really keen on Fortran Standards you should get a copy of FIPS PUB
69 from the National Technical Information Service, U.S. Department of 
Commerce, Springfield, Virginia 22161,

and also a copy of MIL-STD-1753 (probably from the same source).

 It seems silly for just a few of us to have copies, and answer questions by 
mail about it. It's not an expensive book (as computer related books go)!
-- 
--
> Brian Tompsett. Department of Computer Science, University of Edinburgh,
> JCMB, The King's Buildings, Mayfield Road, EDINBURGH, EH9 3JZ, Scotland, U.K.
> Telephone:         +44 31 667 1081 x3332.
> JANET:  bct@uk.ac.ed.ecsvax  ARPA: bct%ecsvax.ed.ac.uk@cs.ucl.ac.uk
> USENET: bct@ecsvax.ed.ac.uk  UUCP: ...!seismo!mcvax!ukc!ecsvax.ed.ac.uk!bct
> BITNET: psuvax1!ecsvax.ed.ac.uk!bct or bct%ecsvax.ed.ac.uk@earn.rl.ac.uk

firth@sei.cmu.edu (Robert Firth) (06/25/87)

In article <371@nikhefh.UUCP> i91@nikhefh.UUCP (Fons Rademakers) writes:
>Does somebody know what the ANSI FORTRAN 77 standard says about
>list directed I/O from internal files? 

ANSI X3.9-1978

12.2.5.2 Internal File Restrictions
	 --------------------------

An internal file has the following restrictions:

    (1) Reading and writing records is accomplished only
	by sequential access formatted input/output
	statements (12.8.1) that do not specify list-
	directed formatting.

--------

The Apollo compiler is right.  The others are non-compliant,
but you might check for some invocation switch or option that
would request compliance.

dwd@sfsup.UUCP (David W. Dougherty) (06/26/87)

In article <371@nikhefh.UUCP> i91@nikhefh.UUCP (Fons Rademakers) writes:
>Does somebody know what the ANSI FORTRAN 77 standard says about
>list directed I/O from internal files? 
>
>
>(00008)       read(ch, *) i, j, k
>**** Error #250 on Line 8:
>      program foo
>      character*11 ch
>      integer i, j, k
>      ch = '999,111,222'
>      read(ch, *) i, j, k
>      print *, i, j, k
>      end
>-- 


Try this instead:

	PROGRAM FEE
	CHARACTER*9 CH
	INTEGER I,J,K
	CH='999111222'
	READ(CH,10)I,J,K
10	FORMAT(3I3)
	PRINT*,I,J,K
	END


This always worked for me.

-----
David Dougherty @ (201) 423-3139 || {ihnp4, allegra}!attunix!dwd
AT&T Bell Laboratories