home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / fortran / 4804 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.5 KB  |  62 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!sol.ctr.columbia.edu!still3.chem.columbia.edu!shenkin
  3. From: shenkin@still3.chem.columbia.edu (Peter Shenkin)
  4. Subject: CHARACTER IO question
  5. Originator: shenkin@still3.chem.columbia.edu
  6. Sender: nobody@ctr.columbia.edu
  7. Organization: Columbia U. Chemistry
  8. Date: Fri, 18 Dec 1992 22:24:40 GMT
  9. Message-ID: <1992Dec18.222440.19389@sol.ctr.columbia.edu>
  10. X-Posted-From: still3.chem.columbia.edu
  11. NNTP-Posting-Host: sol.ctr.columbia.edu
  12. Lines: 48
  13.  
  14. Suppose I have the following declaration:
  15.  
  16.       CHARACTER *100 fname
  17.  
  18. Then, later, the following READ:
  19.  
  20.       READ( 5, '(A)' ) fname
  21.  
  22. And suppose the next input record reads as follows, where the 'e' in "file"
  23. is the last character in the record:
  24.  
  25. /my/file
  26.        
  27. The question is:  does the FORTRAN-77 standard specify what the last 92
  28. characters in "fname" should contain, after the READ is done?  From 
  29. section 13.5.11 of the standard: 
  30.  
  31.     ...if the field width... is not specified with the A edit 
  32.     descriptor, the number of characters in the field is the length 
  33.     of the character input/output list item.
  34.  
  35. Thus the '(A)' format acts just like '(A100)' in my example.  Reading on:
  36.  
  37.     Let LEN be the length of the input/output list item.  If the 
  38.     specified field width W for A input is greater than or equal 
  39.     to LEN, the rightmost LEN characters will be taken from the input
  40.     field.
  41.  
  42. Here, LEN stands for the value 100 in the declaration of "fname", and
  43. W is the value of 100 inferred from the naked "A" format specification;
  44. thus LEN is equal to W;  so "fname" will get the rightmost 100 characters
  45. from the input field.  But there are only 8 characters  in the input
  46. field, so this portion of the standard seems to be silent on what
  47. "fname" will contain after the READ is done.
  48.  
  49. On most UNIX machines, the last 92 characters of "fname" get filled with
  50. blanks, but I have found that on the Sparc front-end to the CM-5,
  51. CMFortran puts a few blanks in, followed by a bunch of ASCII nulls.  Is
  52. there another part of the standard that addresses this?  If not, is there
  53. any standard way to ensure the blank padding?  If not, is there any standard
  54. way to figure out how wide your input field really was?
  55.  
  56.     -P.
  57. -- 
  58. ************************f*u*cn*rd*ths*u*cn*gt*a*gd*jb************************
  59. Peter S. Shenkin, Box 768 Havemeyer Hall, Dept. of Chemistry, Columbia Univ.,
  60. New York, NY  10027;  shenkin@still3.chem.columbia.edu;  (212) 854-5143
  61. ******* ...ghostlier demarcations, keener sounds.  (Wallace Stevens) ********
  62.