Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!rutgers!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!br0w+ From: br0w+@andrew.cmu.edu (Bruno W. Repetto) Newsgroups: comp.lang.fortran Subject: Re: Writing newlines to strings Message-ID: Date: 30 Nov 90 14:45:52 GMT References: <1990Nov29.164527.23915@elroy.jpl.nasa.gov> Organization: Graduate School of Industrial Administration, Carnegie Mellon, Pittsburgh, PA Lines: 46 In-Reply-To: <1990Nov29.164527.23915@elroy.jpl.nasa.gov> Do the following changes to your code: 1) Add char*2 variable 'crlf'. 2) Give 'crlf' the value char(13)+char(10) (carriage-return+line-feed) 3) Change all '/' in your format to 'a2' 4) Include 'crlf' in the appropriate places in the list of variables to write, so that they match with the 'a2' format spec. So the code now reads: character errmsg*512,crlf*2 crlf=char(13)//char(10) WRITE(ERRMSG,1001)crlf,crlf, * 0.7733383D0,crlf,-0.5141431981D0,crlf 1001 FORMAT(a2,'ERROR IN READING PLANETARY EPHEMERIS FILE --', * 'REQUESTED TIME TOO EARLY',a2, * ' REQUESTED TIME = ',D25.15,a2, * ' FILE START TIME = ',D25.15,a2) print *,errmsg end Using f77 on a Sun4/330 (which runs SunOS 4.1), the output is: ERROR IN READING PLANETARY EPHEMERIS FILE --REQUESTED TIME TOO EARLY REQUESTED TIME = .773338300000000D+00 FILE START TIME = -.514143198100000D+00 There are extra blank lines because the 512-char variable errmsg is too long. You may run into aesthetic problems because of this. Maybe a shorter variable will do. Or if you change: print *,errmsg to read: print *,(errmsg(i:i),i=1,length) where 'length' is a variable you compute before printing, you can get rid of the blank spaces. Hope this helps! Bruno. br0w+@andrew.cmu.edu Brought to you by Super Global Mega Corp .com