Creating subset of compilation errors


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating subset of compilation errors
# 1  
Old 11-05-2012
Creating subset of compilation errors

I am compiling a fortran program using gfortran and the result looks as below

I want to write a bash or awk script that will scan the information and output
only problems within a range of line numbers

Example: If I specify the file createmodl.f08, start line 1000 and end line 1100, I will only get the lines in the mentioned range. So only errors
between createmodl.f08:1000 and createmodl.f08:1100 are displayed.


Code:
createmodl.f08:585.9:

allocate(posn_outerRect(4))
         1
Error: Allocate-object at (1) is not a nonprocedure pointer or an allocatable variable
createmodl.f08:586.9:

allocate(posn_innerRect(4))
         1
Error: Allocate-object at (1) is not a nonprocedure pointer or an allocatable variable
createmodl.f08:594:

pTopLft = posn_outerRect(1:2)
1
Error: Unclassifiable statement at (1)
createmodl.f08:595:

pBtmRht = posn_outerRect(3:4)
1
Error: Unclassifiable statement at (1)
createmodl.f08:599:

pTopLft = posn_innerRect(1:2)
1
Error: Unclassifiable statement at (1)
createmodl.f08:600:

pBtmRht = posn_innerRect(3:4)
1
Error: Unclassifiable statement at (1)
createmodl.f08:779.46:

    apodw(ix1,ix2) = win_x1(ix1) * win_x2(ix2)
                                              1
Error: Unexpected STATEMENT FUNCTION statement at (1)
createmodl.f08:1001.9:

allocate(val(6))
         1
Error: Allocate-object at (1) is not a nonprocedure pointer or an allocatable variable
createmodl.f08:1008.16:

      read(s, *) (val(k), k = 1, 6)
                1
Error: Expected variable in READ statement at (1)
createmodl.f08:1015.14:

deallocate(val)
              1
Error: 'val' at (1) is not a variable
createmodl.f08:1078.35:

end subroutine compute_bkgrdModl_1d
                                   1
Error: Expected label 'compute_bkgnd_modl_1d' for END SUBROUTINE statement at (1)
createmodl.f08:1101:

subroutine compute_bkgrd_modl_2d(nx, nz, z, bkgrd_m2d)
1
Error: Unclassifiable statement at (1)
createmodl.f08:1102.13:

implicit none
             1
Error: Unexpected IMPLICIT NONE statement at (1)
createmodl.f08:1106.25:

integer, intent(in) :: nx
                         1
Error: Unexpected data declaration statement at (1)
createmodl.f08:1107.25:

integer, intent(in) :: nz
                         1
Error: Symbol 'nz' at (1) already has basic type of INTEGER
createmodl.f08:1108.36:

real, dimension(nz), intent(in) :: z
                                    1
Error: Symbol 'z' at (1) already has basic type of REAL
createmodl.f08:1109.49:

real, dimension(nx, nz), intent(out) :: bkgrd_m2d
                                                 1
Error: Unexpected data declaration statement at (1)
createmodl.f08:1113.42:

real, dimension(:), allocatable :: bgrdm1d
                                          1
Error: Unexpected data declaration statement at (1)
createmodl.f08:1116.13:

integer :: ix
             1
Error: Unexpected data declaration statement at (1)
createmodl.f08:1117.13:

integer :: iz
             1
Error: Unexpected data declaration statement at (1)
createmodl.f08:1121.9:

allocate(bgrdm1d(nz))
         1
Error: Allocate-object at (1) is not a nonprocedure pointer or an allocatable variable
createmodl.f08:1126.36:

      bgrdm2d(ix,iz) = bkgrd_m1d(iz)
                                    1
Error: Unexpected STATEMENT FUNCTION statement at (1)
createmodl.f08:1130.19:

deallocate(bgrd_m1d)
                   1
Error: Allocate-object at (1) is not a nonprocedure pointer or an allocatable variable
createmodl.f08:1132.36:

end subroutine compute_bkgrd_modl_2d
                                    1
Error: Expected label 'compute_bkgnd_modl_1d' for END SUBROUTINE statement at (1)
createmodl.f08:1161:

subroutine compute_prtb_modl_2d(nx, nz, prtbm, pc, z, iPrtb, sTaprs, nTaprs)
1
Error: Unclassifiable statement at (1)
Fatal Error: Error count reached limit of 25.

---------- Post updated 11-05-12 at 06:46 AM ---------- Previous update was 11-04-12 at 08:28 AM ----------

I have created a small awk script

Code:
#!/bin/awk

/createmodl.f08:1000/ {doPrint=1} 
{if (doPrint==1) print} 
/createmodl.f08:1100/ {doPrint=0}

However this will only work if there is an exact match of createmodl.f08:1000 and createmodl.f08:1100
# 2  
Old 11-05-2012
Try something like this.

Code:
awk -F ":" '
$1 == "createmodl.f08" && $2 > 1000{s=1}
$1 == "createmodl.f08" && $2 > 1100{s=""}
{if(s && $0 ~ /Error/){print }}
' file


Last edited by pamu; 11-05-2012 at 08:01 AM..
# 3  
Old 11-05-2012
The problem is that this only matches Error, whereas I want every line in between

createmodl.f08:1000 and
createmodl.f08:1100
# 4  
Old 11-05-2012
Quote:
Originally Posted by kristinu
The problem is that this only matches Error, whereas I want every line in between

createmodl.f08:1000 and
createmodl.f08:1100
then remove error from awk..Smilie

Code:
awk -F ":" '
$1 == "createmodl.f08" && $2 > 1000{s=1}
$1 == "createmodl.f08" && $2 > 1100{s=""}
{if(s){print }}
' file

This User Gave Thanks to pamu For This Post:
# 5  
Old 11-05-2012
This might do what you want:
Code:
 awk -F: '/createmodl.f08/ {P= $2>=1000 && $2<=1100} P' file

# 6  
Old 11-05-2012
I want to use the script as follows

Code:
awk -v fn=createmodl.f08 -v ls=1000 -v le=1100 -f compck.awk cmplnk.smry

Code:
#!/bin/awk

#    compcheck.awk - Checks errors when compiling and linking
#
#! @synopsis
#    awk -v fn=STRING -v ls=NUM -v le=NUM -f compcheck.awk FILE
#
#! @param[in] fn  Name of file to check for compilation errors
#! @param[in] ls  Beginning of line to include information
#! @param[in] le  End of line to include information
#
#! @examples
#    awk -v fn=createmodl.f08 -v ls=1000 -v le=1100 -f compck.awk cmplnk.smry

BEGIN {
  FS = ":"
}

$1 == fn && $2 >= ls { s = 1 }
$1 == fn && $2 >= le { s = "" }
{ if (s) { print } }

---------- Post updated at 07:54 AM ---------- Previous update was at 07:47 AM ----------

Quote:
Originally Posted by RudiC
This might do what you want:
Code:
 awk -F: '/createmodl.f08/ {P= $2>=1000 && $2<=1100} P' file


How does this work exactly?
# 7  
Old 11-05-2012
Quote:
Originally Posted by kristinu
I want to use the script as follows

Code:
awk -v fn=createmodl.f08 -v ls=1000 -v le=1100 -f compck.awk cmplnk.smry

So whats the problem....Smilie

Code:
$ cat file
createmodl.f08:800.36:
createmodl.f08:900.36:
createmodl.f08:1030.36:
createmodl.f08:1050.36:
Error
Error
ErrorError
Error
Error
Error
createmodl.f08:1090.36:
createmodl.f08:1132.36:
Errordfsdf

Code:
$ cat awk.awk
BEGIN {
  FS = ":"
}
$1 == fn && $2 >= ls { s = 1 }
$1 == fn && $2 >= le { s = "" }
{ if (s) { print } }

Code:
$ awk -v fn=createmodl.f08 -v ls=1000 -v le=1100 -f awk.awk file
createmodl.f08:1030.36:
createmodl.f08:1050.36:
Error
Error
ErrorError
Error
Error
Error
createmodl.f08:1090.36:

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Creating a tarball on Solaris issue with errors

Hi All, We are planning to migrate from Solaris to AIX, and we have a requirement to move all files modified in last 7 days to AIX. i found many helpful forums on this site but somehow the issue was still not solved: Used the following command from the directory which we want to scan ... (6 Replies)
Discussion started by: nikhil8
6 Replies

2. Shell Programming and Scripting

Creating subset of a file based on specific columns

Hello Unix experts, I need a help to create a subset file. I know with cut comand, its very easy to select many different columns, or threshold. But here I have a bit problem as in my data file is big. And I don't want to identify the column numbers or names manually. I am trying to find any... (7 Replies)
Discussion started by: smitra
7 Replies

3. UNIX for Dummies Questions & Answers

how to get a subset of such a file

Dear all, I have a file lik below: n of row=420, n of letters in each row=100000 like below: there is no space between the letters. what I want is: the 75000th letter to the 85000th letter in each row. how to do that? thanks a lot! ... (2 Replies)
Discussion started by: forevertl
2 Replies

4. UNIX for Dummies Questions & Answers

XEmacs compilation errors not understandable

Hi all! I am new to this forum. I have recently installed Cygwin and XEmacs on my laptop running Windows Vista. I am studing at the moment and the code I am creating is mainly for that purpose. I am trying to create the algorithm of Insertion sort. When I compile my code in XEmacs i get some... (1 Reply)
Discussion started by: BlueTower
1 Replies

5. UNIX for Dummies Questions & Answers

Help with subset and if-then statements

Hello everyone. I'm new to the boards, I hope I can get and possibly give some help through these forums. I need some help. I have two CSV files, let's call them File A and File B. This is the structure for File A: ID, VAR1, VAR2, VAR3 - VAR50 (where the VAR 1-VAR50 are either 0 or 1) ... (1 Reply)
Discussion started by: JWill
1 Replies

6. Shell Programming and Scripting

Compilation errors in running configure script

Hi all, I tried to cross compile Ghostscript-8.54 source. I am getting some errors during cross compilation. I have pasted the errors below. CC=arm-unknown-linux-gnu-gcc LD=arm-unknown-linux-gnu-ld ./configure --host=i686-pc-linux-gnu --target=arm-unknown-linux-gnu --without-x && make ... (2 Replies)
Discussion started by: siva4ever
2 Replies

7. Programming

xtrlock compilation errors

Hello, Trying to compile xtrlock from source on a RHEL system. It has an Imakefile but not being familiar enough with that system getting errors running imake: #! Imakefile for xtrlock - X Transparent Lock #! #! Copyright (C)1993,1994 Ian Jackson #! #! This is free software; you can... (1 Reply)
Discussion started by: mgb
1 Replies

8. Linux

c++ compilation errors

Hello every one, while compiling c++ modules. i am getting the following 2 errors. 1) /root/cc/unix-ce/root/subsys/cb/cdbh/include/cdbh_TransferFileHeader.h:111: error: âulong_tâ does not name a type /root/cc/unix-ce/root/subsys/cb/cdbh/include/cdbh_TransferFileHeader.h:118: error: âulong_tâ... (0 Replies)
Discussion started by: mannam srinivas
0 Replies

9. AIX

Compilation of gettext produces relink errors

Hi, I'm in the process of compiling gnu gettext on a rs/6000 43p-260 running AIX 5.1 in 64bit-mode. The compilation itself runs fine as I understand it, however the installation itself fails like so: I'm pretty much clueless about this relink stuff, so if anyone has suggestions, I'll try... (0 Replies)
Discussion started by: töfte
0 Replies

10. Shell Programming and Scripting

how to capture compilation errors with Makfile

Hello I have big compilation project when I run the top make file I have problem to find the errors that acres in the sub directories because the make file keeps Running the compilation. is there any way to perform summry of the errors when the Top makefile done running ? thanks (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question