darshan-job-summary.pl.in 2.58 KB
Newer Older
1
#!/usr/bin/perl -w
2
#
3
#  (C) 2015 by Argonne National Laboratory.
4 5 6
#      See COPYRIGHT in top-level directory.
#

7
# Set via configure
8
my $PREFIX="@prefix@";
9

10
use lib "@prefix@/lib";
11 12
use TeX::Encode;
use Encode;
13
use File::Temp qw/ tempdir /;
14
use File::Basename;
15
use Cwd;
16 17
use Getopt::Long;
use English;
18
use Number::Bytes::Human qw(format_bytes);
19
use POSIX qw(strftime);
20

21

22 23
sub process_args
{
24
    use vars qw( $opt_help $opt_output $opt_verbose );
25 26 27

    Getopt::Long::Configure("no_ignore_case", "bundling");
    GetOptions( "help",
28 29
        "output=s",
        "verbose");
30 31 32 33 34 35 36 37 38 39 40 41

    if($opt_help)
    {
        print_help();
        exit(0);
    }

    if($opt_output)
    {
        $output_file = $opt_output;
    }

42 43 44 45 46
    if($opt_verbose)
    {
        $verbose_flag = $opt_verbose;
    }

47 48 49 50 51 52 53
    # there should only be one remaining argument: the input file 
    if($#ARGV != 0)
    {
        print "Error: invalid arguments.\n";
        print_help();
        exit(1);
    }
54

55 56
    $input_file = $ARGV[0];

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    # give default output file a similar name to the input file.
    #   log.darshan.gz => log.pdf
    #   log_name => log_name.pdf
    if (not $opt_output)
    {
        $output_file = basename($input_file);
        if ($output_file =~ /\.darshan\.gz$/)
        {
            $output_file =~ s/\.darshan\.gz$/\.pdf/;
        }
        else
        {
            $output_file .= ".pdf";
        }
    }

73 74 75
    return;
}

76 77 78 79 80 81
#
# Check for all support programs needed to generate the summary.
#
sub check_prereqs
{
    my $rc;
82
    my $output;
83 84 85 86 87 88 89 90 91 92 93 94
    my @bins = ($darshan_parser, $pdflatex, $epstopdf,
                $gnuplot, $cp, $mv);
    foreach my $bin (@bins)
    {
        $rc = checkbin($bin);
        if ($rc)
        {
            print("error: $bin not found in PATH\n");
            exit(1);
        }
    }

95 96 97 98 99 100 101
    # check  gnuplot version
    $output = `$gnuplot --version`;
    if($? != 0)
    {
        print("error: failed to execute $gnuplot.\n");
        exit(1);
    }
102

103
    $output =~ /gnuplot (\d+)\.(\d+)/;
104
    if($1 < 4 || ($1 < 5 && $2 < 2))
105 106 107 108 109
    {
        print("error: detected $gnuplot version $1.$2, but darshan-job-summary requires at least 4.2.\n");
        exit(1);
    }

110 111 112
    return;
}

113 114 115 116 117 118 119 120 121
sub print_help
{
    print <<EOF;

Usage: $PROGRAM_NAME <options> input_file

    --help          Prints this help message
    --output        Specifies a file to write pdf output to
                    (defaults to ./summary.pdf)
122 123
    --verbose       Prints and retains tmpdir used for LaTeX output

124 125
Purpose:

126 127
    This script reads a Darshan output file generated by a job and
    generates a pdf file summarizing job behavior.
128 129 130 131

EOF
    return;
}