Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site nbs-amrf.UUCP Path: utzoo!linus!philabs!seismo!rlgvax!cvl!umcp-cs!nbs-amrf!hopp From: hopp@nbs-amrf.UUCP Newsgroups: net.lang.f77 Subject: Re: How can I get free-form input to work? Message-ID: <166@nbs-amrf.UUCP> Date: Tue, 17-Jan-84 16:33:30 EST Article-I.D.: nbs-amrf.166 Posted: Tue Jan 17 16:33:30 1984 Date-Received: Thu, 19-Jan-84 05:12:35 EST References: <568@houxf.UUCP> Organization: National Bureau of Standards Lines: 43 | V The easiest way to deal with your problem is to use the internal I/O capabilities of Fortran 77. (Internal reads are the replacement for the encode/decode statements found in many fortran 66 implementations.) The idea is to read the line into an internal character variable and then read from that variable into the program variables that you want. For instance, the following code reads a line and, based on the first character, reads the next field as either character or logical data: character*80 line, text logical dosay read (5,1000) line 6000 format(A) if (line(1:1) .eq. 'L') then C logical data... read (line(2:), 1000) dosay 1000 format (L7) write (6,6000) dosay 6000 format (' Logical data: ',L7) else if (line(1:1) .eq. 'A') then C text data... read (line(2:), 1010) text 1010 format(A) write (6,6010) text 6010 format (' Text data: ', A) else write (6,6020) line(1:1) 6020 format (' Error on input field specifier: ',A) end if stop end The syntax for internal I/O is that a character expression is used instead of a logical unit number, and I/O is directed to the data area for that character data rather than to an external file. Ted Hopp National Bureau of Standards Metrology A127 Washington, DC 20234 UUCP: ..!umcp-cs!nbs-amrf!hopp