program addcr ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c /mnt1/data.center/misc/addcr.f c This program will take a file and add a CR before the LF at c the end of each record. c programmer: Edward Hartnett, 8/6/90 c modified by Chuck Browne 8/15/90 to run at the end of the pipe c modified by Ed 8/17/90 to do it correctly c NOTE that some lines of this program are compiler specific - c you may have to alter this program to suit your computer's taste. c CJB 8/21/90 c c Sample UNIX command: ls -1 /tmp/ed/[data dir]*.dat | addcr cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c implicit none character*60 filein character*30 tempfile integer lnblnk,i, c logical wha integer rename, errcode character*1000 linein c 2 read(*,'(a)', end=1000) filein open(10,file=filein) write(*,*) 'file in opened:',filein write(*,*) filein c=1 3 write (tempfile,'(a9,i2.2)') 'temp.file',c inquire(file=tempfile, exist=wha) if (wha) then c=c+1 go to 3 end if open(11,file=tempfile,status='new') write(*,*) 'temp file opened:',tempfile 5 read(10,'(a)',end=999) linein c ** compiler specific line ** i=lnblnk(linein) write(11,'(a)') linein(:i)//char(13) goto 5 999 close (10) close (11) c ** compiler specific line ** errcode=rename (tempfile, filein) if (errcode.ne.0) then write(*,*) 'error renaming ',filein, 'errcode=',errcode stop '-- program stopped --' end if goto 2 1000 continue c write(*,*)'finished with this data set.' end