|
|
BSD 4.3tahoe
.TI F77/ERROR "Sep. 15, 1984" Using the 'error' Command for Syntax Errors This help file describes the use of the UNIX 'error' command with syntax error messages; for execution errors, see "help f77 error_msgs" and for debugging, see "help f77 debugging". Normally, f77 writes syntax error messages on the screen, you copy them down and then edit the source file(s) and correct the errors. If you use the 'error' command, instead of having the error messages displayed on the screen, they are inserted by the appropriate lines in the source file. As an example, suppose prog.f contains: .nf print, " hi " sqr2p = sqrt(2.0) sqr2e = 2.0^0.5 print *, "square root of 2.0 is", sqr2p, sqr2e end .fi Compiling prog.f generates these messages: .nf % f77 prog.f prog.f: MAIN: Error on line 1 of prog.f: syntax error Error on line 3 of prog.f: syntax error Error. No assembly. % .fi These can be piped to the error utility (piping both standard output and standard error): .nf % f77 prog.f |& error 1 file contains errors "prog.f" (2) File "prog.f" has 2 errors. 2 of these errors can be inserted into the file. You touched file(s): "prog.f" .fi The output to your terminal notes that two error messages have been inserted into the file prog.f. Prog.f now contains: .nf C###1 [f77] Error on line 1 of prog.f syntax error%%% print, " hi " sqr2p = sqrt(2.0) C###3 [f77] Error on line 3 of prog.f syntax error%%% sqr2e = 2.0^0.5 print *, "square root of 2.0 is", sqr2p, sqr2e end .fi Each of the syntax errors has been inserted in the file in front of the line causing the error. They are inserted as Fortran comments, so they will not cause new syntax errors if you forget to remove them. You can use the editor and look for `###' in the error messages, and then fix the errors. If the ``-v'' flag is used: % f77 prog.f |& error -v error will finish by invoking the visual editor, vi, with the first source file containing errors. It is easier to see what error does by using it than to understand it by looking at examples. Error is particularly useful when there are few errors in a large source program. If there are too many errors, such as if a dimension statement is missing, the inserted errors can be overwhelming; however: :g /###/d will eliminate them (along with any other lines containing ``###'').
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.