From shawnhar@chopin.udel.edu Fri Jun 17 15:20:42 1994
Date: Fri, 17 Jun 1994 15:12:32 -0400
From: Shawn Wilson Harvell <shawnhar@chopin.udel.edu>
To: shawnhar@warthog.cns.udel.edu

Subject: The Compilation Listing File

The Compilation Listing File

FORTRAN Conversion Series
    
1 Compiling and Executing 

1.5 The Compilation Listing File

============================ 


VS Fortran compilation produces a listing file which contains the
source listing of your program plus any syntax errors.  Under UNIX, you
can get a similar result by using the utility program, "error".  When
you compile your program and pipe the results through the program
"error", any syntax errors that occur during compilation are written
onto your source file as comment lines.  This allows you to view the
error messages and source code simultaneously.  Each error appears
immediately BEFORE the source line that caused the error.  For example,
consider the following program, main.f, with errors on lines 3, 5, 11,
13 and 17.

                                                               
  **     Test Program
  C
          dimension x(50),y(50),
          complex*16 z(50)
          print *, 'Enter number of elements to process
          read *, num
          do 5 i = 1,num
            x(i) = i
            y(i) = i
      5   continue
          do 10 i = 1,num
            z(i) = sqrt(cmplx(x(i),y(i)))
          print *, 'Complex Number Output
          print *
          print *, '   x         y               z   '
          print *
          write(6,'(2(f7.3,2x),5x,''('',f5.1,'','',f5.1,''  )'')')
       1    ((x(i),y(i),z(i),i=1,num)
          end

                                                                
If we compile this program using the utility program "error" by typing

        f77 main.f  |&  error

the file "main.f" is overwritten with diagnostic messages indicating
those lines with syntax errors.  Note the use of the "|" followed by
the "&".  Here is the file main.f after the compilation.

                                                                
 C**     Test Program
 C
 C###3 [Sunf77] Error: syntax error at or near end of statement%
         dimension x(50),y(50),
         complex*16 z(50)
 C###5 [Sunf77] Error: unbalanced quotes; closing quote supplied%
         print *, 'Enter number of elements to process
         read *, num
         do 5 i = 1,num
           x(i) = i
           y(i) = i
     5   continue
 C###11 [Sunf77] Error: do not closed%
 C###11 [Sunf77] Error: missing statement number 10%
         do 10 i = 1,num
           z(i) = sqrt(cmplx(x(i),y(i)))
 C###13 [Sunf77] Error: unbalanced quotes; closing quote supplied%
         print *, 'Complex Number Output
         print *
         print *, '   x         y               z   '
         print *
 C###17 [Sunf77] Error: unclassifiable statement%
 C###17 [Sunf77] Error: unbalanced parentheses, statement skipped%
         write(6,'(2(f7.3,2x),5x,''('',f5.1,'','',f5.1,''  )'')')
      1    ((x(i),y(i),z(i),i=1,num)
         end
                                                                
                                                    
You can now edit the file and make the indicated corrections.  If you
use the editor "vi", you can have the compilation output immediately go
into the vi editor by using the option "-v".  For example,

                f77 main.f  |&  error  -v


For a complete description of the error utility see the man pages or
the SPARCompiler FORTRAN User's Guide.




                                                                
******************************************************************
*                                                                *
*                Correspondence to VS FORTRAN                    *
*                                                                *
****************************************************************** 
*                                                                *
*             VS FORTRAN                          UNIX           *
*             ==========                          ====           *
*                                                                *
* The following command compiles        The following command    *   
* the program "main fortran a" and      compiles the program     *
* produces the listing file, "main      "main.f"and superimposes *
* listing a" which contains the         any syntax errors that   *
* source program and any syntax         occurred during the      *
* errors that wre found during          compilation onto the     *
* the compilation.                      source file as comments. *
*                                                                *
* fortvs2 main                            f77 main.f |& error    *
*                                                                *
*                                       Note the use of the "&"  *
*                                                                *
*                                                                *
******************************************************************


University of Delaware
Last revised: 5/31/94
