Path: utzoo!utgpu!water!watmath!clyde!att!alberta!simon From: simon@alberta.UUCP (Simon Tortike) Newsgroups: comp.lang.fortran Subject: Re: Any way to fseek() in MS-Fortran under DOS? Summary: Inspect first char of line and backspace if not a comment Keywords: free format internal read Message-ID: <1450@pembina.UUCP> Date: 15 Jul 88 02:29:17 GMT References: <5462@orstcs.CS.ORST.EDU> Distribution: na Organization: U. of Alberta, Edmonton, AB Lines: 53 I'm responding to a request for processing comments at the start of lines in a FORTRAN input text file. Rather than reading the whole line in, I always call a "get comment" subroutine that reads in the first character of every line until it finds a line which is not commented out. The routine then backspaces one record and returns to the calling program. The read statements in the original program do not need to be altered, one only has to call the comment-eater before reading in a record. Surely that's easier than reading the entire line first? FYI, I use the following code to inspect data for comments. As I said, a call to this routine is made before reading a line of data, but it in no way affects how the read is performed (e.g. the formatting.) character comment*1 integer infile real foo(5) read (infile,'(a)',ERR=nnn) comment call getcmmt (infile, comment) read (infile, 666) foo(1), foo(2), foo(3), foo(4), foo(5) 666 format (...... subroutine getcmmt (unit, comment) c ********** ******* c routine to inspect line start for comment character. c suggest using 'read (unit,'(a)',ERR=nnn) comment' as first c line before any input. Then any character can serve as c a commented-line indicator by placing it in the first c column of the first line of the data file. see following routine. c implicit logical (a-z) integer unit character thechar*1, comment*1 c 100 read (unit,'(a)',err=998) thechar if (thechar .eq. comment) go to 100 backspace (unit, err=999) return 998 print *, ' Error reading unit ', unit, ' in "getcmmt"!!' return 999 print *, ' Error backspacing unit ', unit, ' in "getcmmt"!!' return end c ------------------- Simon Tortike Dept Min, Met & UUCP: ...{ubc-vision,mnetor}!alberta!simon Petroleum Engg BITNET: stortike@ualtavm Univ. of Alberta AGT: 403/432-3338 Edmonton, AB Canada T6G 2G6 *** No nifty notes or quotes, I'm sorry to say ***