write(8,'(" This is the first line of output")') write(8,'("0This is the second line of output")')will produce the following output
This is the first line of output 0This is the second line of outputThe "blank" and "0" carriage control characters are treated like ordinary text. You can activate carriage control characters on UNIX in one of two ways:
or
% cat sample1.f c** This program demonstrates the use of the c open statement "form" attribute to activate c carriage control symbols. open(unit=8,file='output.dat',form='print') . write(8,1000).... 1000 format('1',..... write(8,1010).... 1010 format('0',.... . end % f77 sample1.f % qpr -q smips output.dat
% cat sample2.f c*** This program does not use the open statement c "form" attribute. Therefore, to activate c the carriage control symbols in the output file, c "output.dat", the file must be processed by "asa". open(unit=8,file='output.dat') . write(8,1000).... 1000 format('1',..... write(8,1010).... 1010 format('0',.... end % f77 sample2.f % asa output.dat | qpr -q smips
% cat sample3.f c** This program demonstrates the use of carriage control characters. open(unit=8,file='output.dat') write(8,'(" Carriage Control Demo Program")') write(8,'(" Blank advances 1 line")') write(8,'("0Zero advances 2 lines")') write(8,'(" A $ at the end suppress the CR",$)') write(8,'(" , OK?")') write(6,'(" A $ allows input on the same line as", 1 " a prompt."/" For example, enter x: ",$)') read(5,*)x write(8,'(" Let''s underline this statement")') write(8,'("+_______________________________")') write(8,'("1One advances to the top of the next page")') end % f77 sample3.f % a.out A $ allows input on the same line as a prompt. For example, enter x: 1 % asa output.dat | qpr -q smipsNote: Also see tip sheet: "Printing VS FORTRAN Output Files with Carriage Control Symbols on UNIX".
**************************************************************** * * * Correspondence to VS FORTRAN * * ============================ * * * **************************************************************** * * * VS FORTRAN UNIX * * ========== ==== * * * * Implementing Carriage Control * * ============================= * * * * Under VS FORTRAN, carriage Under UNIX, carriage control * * control characters appearing is not implemented by * * in output statements are default. To implement * * implemented by default. carriage control, * * (1) Define form='print' in * * an "open" statement: * * * * open(unit=9,form='print',..) * * * * or * * * * (2) Use the "asa" filter * * on the output file: * * * * Examples: * * * * Output from stdout,unit 6: * * a.out | asa | qpr -q smips * * * * Output from disk file, "out": * * asa out | qpr -q smips * * * * Note: Use the "asa" filter * * for programs that use * * the "+" carriage * * control symbol. * * * * * * Carriage Control Examples * * ========================= * * * * write(8,'(" Blank adv. 1 line")') * * * * write(8,'(" Blank adv. 1 line")') * * * * write(8,'("0Zero adv. 2 lines")') * * * * write(8,'("0Zero adv. 2 lines")') * * * * write(8,'("-Minus adv. 3 lines")') * * * * write(8,'(" ")') * * write(8,'("0Blank and 0 for 3")') * * * * write(8,'("1One to top of page")') * * * * write(8,'("1One to top of page")') * * * * write(8,'(" Plus for")') * * write(8,'("+____ overstrike")') * * * * write(8,'(" Plus for")') * * write(8,'("+____ overstrike")') * * * * Note: Overstriking can only be * * implemented by using asa. * * See Example 3 above. * * * * * ****************************************************************