File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Use gawk if available, otherwise fall back to awk
4+ if command -v gawk > /dev/null; then
5+ AWK_CMD=" gawk"
6+ IGNORECASE_BLOCK=' BEGIN { IGNORECASE = 1 }'
7+ else
8+ AWK_CMD=" awk"
9+ IGNORECASE_BLOCK=' '
10+ echo " Warning: gawk not found. Case-insensitive matching may not work as expected." >&2
11+ fi
12+
13+ find . -type f \( -name " *.f90" -o -name " *.fpp" \) | while read file; do
14+ " $AWK_CMD " "
15+ $IGNORECASE_BLOCK
16+ /^[ \t]*((pure|elemental|impure)[ \t]+)*subroutine[ \t]+[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\ (/ {
17+ in_sub = 1
18+ match(\$ 0, /subroutine[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)/, arr)
19+ sub_name = arr[1]
20+ start_line = NR
21+ next
22+ }
23+ /^[ \t]*end[ \t]+subroutine[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)?[ \t]*\$ / && in_sub {
24+ end_line = NR
25+ print (end_line - start_line + 1) \" \t\" FILENAME \" : \" sub_name
26+ in_sub = 0
27+ }
28+ " " $file "
29+ done | sort -nr | awk -F' \t' ' {print $2 " : " $1 " lines"}' | head -20
You can’t perform that action at this time.
0 commit comments