1#!/bin/csh -f
2
3if ( $#argv < 2 ) then
4    set in = grompp.log
5    set out = topolout.top
6    set program = $0
7    echo "usage $program:t $in $out"
8    echo "Parses grompp debug logfile into original processed topology file"
9else
10    set in = $1
11    set out = $2
12endif
13
14if ( -f $out ) then
15    if ( $out:h == $out:t ) then
16	set backup = \#$out:t\#
17    else
18	set backup = $out:h/\#$out:t\#
19    endif
20    echo "Back Off! I just backed up $out to $backup"
21    \mv $out $backup
22endif
23if ( ! -f $in ) then
24    echo "FATAL ERROR: input file $in does not exist"
25    exit 1
26endif
27
28echo -n "Processing..."
29grep -E '(\".*\" : .* :)|(found directive)' $in | sed 's/found directive '\''\(.*\)'\''/[ \1 ]/' | sed 's/\".*\" : .* ://' >! $out
30echo "."
31
32#last line
33