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.
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
#!/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