Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: inline two functions
[simgrid.git] / tools / fix-paje-trace.sh
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the license (GNU LGPL) which comes with this package.
7
8 if [ -z $1 ]
9 then
10   echo "Usage: $0 {X.trace}"
11   exit
12 fi
13
14 TRACE=$1
15 echo "input: $TRACE"
16 OUTPUT=$( echo $TRACE | cut -d\. -f1 ).fix.trace
17
18 grep ^% < $TRACE > header
19 DEFEVENTS=$(grep Define < header | awk '{ print $3 }')
20
21 GREP=""
22 GREP2=""
23 for i in $DEFEVENTS
24 do
25   GREP="/^$i /d; $GREP"
26   GREP2="-e '^$i ' $GREP2"
27 done
28 GREP="/^%\ /d; /^%      /d; /^%E/d; $GREP"
29
30 grep $GREP2 < $TRACE > types
31 /bin/sed -e "$GREP" $TRACE > events
32 sort -n -k 2 -s < events > events.sorted
33 cat header types events.sorted > $OUTPUT
34 rm types events events.sorted header
35
36 echo "output: $OUTPUT"