darshan-summary-per-file.sh 1.7 KB
Newer Older
1
#!/bin/bash
2 3

#
Shane Snyder's avatar
Shane Snyder committed
4 5
# Copyright (C) 2015 University of Chicago.
# See COPYRIGHT notice in top-level directory.
6 7
#

8 9 10
# change behavior of shell error code following failure of a piped command
set -o pipefail

11
if [ $# -ne 2 ]; then
12
    echo "Usage: darshan-summary-per-file.sh <input_file.darshan> <output_directory>"
13 14 15
    exit 1
fi

16
# count number of files present in log
17
filecount=`darshan-parser --file-list $1| egrep -v '^(#|$)' | cut -f 1-2 | sort -n | uniq | wc -l`
18 19 20 21 22 23
rc=$?
if [ $rc -ne 0 ]; then
   exit $rc
fi

# create output file directory
24 25 26 27 28 29
mkdir $2
rc=$?
if [ $rc -ne 0 ]; then
   exit $rc
fi

30 31
# loop through all files in log
counter=0
32 33
darshan-parser --file-list $1| egrep -v '^(#|$)' | cut -f 1-2 | sort -n | uniq |
while read -r hash filepath stuff ; do
34 35 36 37 38 39 40 41 42 43
    counter=$((counter+1))
    file=$(basename $filepath)

    if [ -x $file.darshan ] ; then
        $file = $file.$hash.darshan
    fi

    echo Status: Generating summary for file $counter of $filecount: $file
    echo =======================================================
    darshan-convert --file $hash $1 $2/$file.darshan
44 45 46 47
        rc=$?
        if [ $rc -ne 0 ]; then
           exit $rc
        fi
48 49 50 51 52 53 54 55 56 57 58

    # XXX: manually escape STDIO stdin/stdout/stderr name strings before passing to perl
    if [ $file == "<STDIN>" ] ; then
        file="\<STDIN\>"
    elif [ $file == "<STDOUT>" ] ; then
        file="\<STDOUT\>"
    elif [ $file == "<STDERR>" ] ; then
        file="\<STDERR\>"
    fi

    darshan-job-summary.pl $2/$file.darshan --output $2/$file.pdf
59 60 61 62
        rc=$?
        if [ $rc -ne 0 ]; then
           exit $rc
        fi
63
done 
Philip Carns's avatar
Philip Carns committed
64 65 66

echo =======================================================
echo darshan-summary-per-file.sh done.  Results can be found in $2/\*.pdf.