Help Files: Fortran77: Error Command





     HELP                      Sep. 15, 1984                 F77/ERROR



                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:

                     print, " hi "
                     sqr2p = sqrt(2.0)
                     sqr2e = 2.0^0.5
                     print *, "square root of 2.0 is", sqr2p, sqr2e
                     end

     Compiling prog.f generates these messages:

             % 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.
             %

     These can be piped to the error  utility  (piping  both  standard
     output and standard error):

             % 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"

     The output to your terminal notes that two  error  messages  have
     been inserted into the file prog.f.  Prog.f now contains:

             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

     Each of the syntax errors has been inserted in the file in  front
     of the line causing the error.  They are inserted as Fortran com-
     ments, 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  under-
     stand  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
     ``###'').

     If there are multiple links to a source file,  error  breaks  the
     multiple  links  when  it puts the error messages into the files.
     This is normally not a problem since most users do not use multi-
     ple links.


             


Comments to decf@euler.berkeley.edu
© 1998 UC Regents