home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!sol.ctr.columbia.edu!still3.chem.columbia.edu!shenkin
- From: shenkin@still3.chem.columbia.edu (Peter Shenkin)
- Subject: CHARACTER IO question
- Originator: shenkin@still3.chem.columbia.edu
- Sender: nobody@ctr.columbia.edu
- Organization: Columbia U. Chemistry
- Date: Fri, 18 Dec 1992 22:24:40 GMT
- Message-ID: <1992Dec18.222440.19389@sol.ctr.columbia.edu>
- X-Posted-From: still3.chem.columbia.edu
- NNTP-Posting-Host: sol.ctr.columbia.edu
- Lines: 48
-
- Suppose I have the following declaration:
-
- CHARACTER *100 fname
-
- Then, later, the following READ:
-
- READ( 5, '(A)' ) fname
-
- And suppose the next input record reads as follows, where the 'e' in "file"
- is the last character in the record:
-
- /my/file
-
- The question is: does the FORTRAN-77 standard specify what the last 92
- characters in "fname" should contain, after the READ is done? From
- section 13.5.11 of the standard:
-
- ...if the field width... is not specified with the A edit
- descriptor, the number of characters in the field is the length
- of the character input/output list item.
-
- Thus the '(A)' format acts just like '(A100)' in my example. Reading on:
-
- Let LEN be the length of the input/output list item. If the
- specified field width W for A input is greater than or equal
- to LEN, the rightmost LEN characters will be taken from the input
- field.
-
- Here, LEN stands for the value 100 in the declaration of "fname", and
- W is the value of 100 inferred from the naked "A" format specification;
- thus LEN is equal to W; so "fname" will get the rightmost 100 characters
- from the input field. But there are only 8 characters in the input
- field, so this portion of the standard seems to be silent on what
- "fname" will contain after the READ is done.
-
- On most UNIX machines, the last 92 characters of "fname" get filled with
- blanks, but I have found that on the Sparc front-end to the CM-5,
- CMFortran puts a few blanks in, followed by a bunch of ASCII nulls. Is
- there another part of the standard that addresses this? If not, is there
- any standard way to ensure the blank padding? If not, is there any standard
- way to figure out how wide your input field really was?
-
- -P.
- --
- ************************f*u*cn*rd*ths*u*cn*gt*a*gd*jb************************
- Peter S. Shenkin, Box 768 Havemeyer Hall, Dept. of Chemistry, Columbia Univ.,
- New York, NY 10027; shenkin@still3.chem.columbia.edu; (212) 854-5143
- ******* ...ghostlier demarcations, keener sounds. (Wallace Stevens) ********
-