GitLab maintenance scheduled for Tomorrow, 2019-09-24, from 12:00 to 13:00 CT - Services will be unavailable during this time.

Commit 37ec8a46 authored by Philip Carns's avatar Philip Carns

starting point for darshan-convert utility (intended to read from one darshan

log file and write to another, with optional conversions along the way).  This 
is just a place holder; it doesn't write any data to the output file yet.


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@431 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 1b60a103
all: lib/libdarshan-posix.a lib/libdarshan-mpi-io.a darshan-parser darshan-diff darshan-analyzer darshan-log-params
all: lib/libdarshan-posix.a lib/libdarshan-mpi-io.a darshan-parser darshan-convert darshan-diff darshan-analyzer darshan-log-params
DESTDIR =
srcdir = @srcdir@
......@@ -45,6 +45,9 @@ uthash-1.9.2:
darshan-parser: darshan-parser.c darshan.h darshan-log-format.h darshan-logutils.h darshan-logutils.o | uthash-1.9.2
gcc $(CFLAGS) -lz $< darshan-logutils.o -o $@
darshan-convert: darshan-convert.c darshan.h darshan-log-format.h darshan-logutils.h darshan-logutils.o | uthash-1.9.2
gcc $(CFLAGS) -lz $< darshan-logutils.o -o $@
darshan-analyzer: darshan-analyzer.c darshan.h darshan-log-format.h darshan-logutils.h darshan-logutils.o
gcc $(CFLAGS) -lz $< darshan-logutils.o -o $@
......@@ -121,6 +124,7 @@ ifndef DISABLE_LDPRELOAD
endif
install -d $(bindir)
install -m 755 darshan-parser $(bindir)
install -m 755 darshan-convert $(bindir)
install -m 755 darshan-diff $(bindir)
install -m 755 darshan-analyzer $(bindir)
install -m 755 darshan-mk-log-dirs.pl $(bindir)
......@@ -138,7 +142,7 @@ endif
clean::
rm -f *.o *.a lib/*.o lib/*.po lib/*.a lib/*.so darshan-parser darshan-diff darshan-analyzer darshan-log-params
rm -f *.o *.a lib/*.o lib/*.po lib/*.a lib/*.so darshan-parser darshan-convert darshan-diff darshan-analyzer darshan-log-params
distclean:: clean
rm -f darshan-config.h darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-gen-cc.pl darshan-mk-log-dirs.pl aclocal.m4 autom4te.cache/* config.status config.log Makefile util/bin/darshan-job-summary.pl
......
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <zlib.h>
#include <time.h>
#include <stdlib.h>
#include <getopt.h>
#include <assert.h>
#include "darshan-logutils.h"
int usage (char *exename)
{
fprintf(stderr, "Usage: %s [options] <infile> <outfile>\n", exename);
fprintf(stderr, " Converts darshan log from infile to outfile.\n");
fprintf(stderr, " No options supported yet; this utility simply\n");
fprintf(stderr, " rewrites the log file into the newest format.\n");
exit(1);
}
void parse_args (int argc, char **argv, char **infile, char **outfile)
{
int index;
static struct option long_opts[] =
{
{"help", 0, NULL, 0}
};
while(1)
{
int c = getopt_long(argc, argv, "", long_opts, &index);
if (c == -1) break;
switch(c)
{
case 0:
case '?':
default:
usage(argv[0]);
break;
}
}
if (optind + 2 == argc)
{
*infile = argv[optind];
*outfile = argv[optind+1];
}
else
{
usage(argv[0]);
}
return;
}
int main(int argc, char **argv)
{
int ret;
char *infile_name;
char *outfile_name;
struct darshan_job job;
struct darshan_file cp_file;
char tmp_string[1024];
int no_files_flag = 0;
darshan_fd infile;
darshan_fd outfile;
int i;
int mount_count;
int64_t* devs;
char** mnt_pts;
char** fs_types;
int last_rank = 0;
parse_args(argc, argv, &infile_name, &outfile_name);
infile = darshan_log_open(infile_name, "r");
if(!infile)
{
perror("darshan_log_open");
return(-1);
}
/* TODO: safety check that outfile_name doesn't exist; we don't want to
* overwrite something by accident.
*/
outfile = darshan_log_open(outfile_name, "w");
if(!outfile)
{
perror("darshan_log_open");
return(-1);
}
/* TODO: for now this tool is just reading the input file and throwing
* away the data. Need to write the log_put*() functions and use this
* program as a test harness
*/
/* read job info */
ret = darshan_log_getjob(infile, &job);
if(ret < 0)
{
fprintf(stderr, "Error: unable to read job information from log file.\n");
darshan_log_close(infile);
return(-1);
}
/* warn user about any missing information in this log format */
darshan_log_print_version_warnings(&job);
/* TODO: yuck. It would be nice to have this tool write into the newest
* format always, but that may lose some information about what fields
* are and are not valid. Need to think through the various old log
* format scenarios.
*/
ret = darshan_log_getexe(infile, tmp_string, &no_files_flag);
if(ret < 0)
{
fprintf(stderr, "Error: unable to read trailing job information.\n");
darshan_log_close(infile);
return(-1);
}
ret = darshan_log_getmounts(infile, &devs, &mnt_pts, &fs_types, &mount_count,
&no_files_flag);
if(ret < 0)
{
fprintf(stderr, "Error: unable to read trailing job information.\n");
darshan_log_close(infile);
return(-1);
}
if(no_files_flag)
{
/* TODO: cut short here */
}
while((ret = darshan_log_getfile(infile, &job, &cp_file)) == 1)
{
if(cp_file.rank != -1 && cp_file.rank < last_rank)
{
fprintf(stderr, "Error: log file contains out of order rank data.\n");
fflush(stderr);
return(-1);
}
if(cp_file.rank != -1)
last_rank = cp_file.rank;
}
if(ret < 0)
{
fprintf(stderr, "Error: failed to parse log file.\n");
fflush(stderr);
return(-1);
}
for(i=0; i<mount_count; i++)
{
free(mnt_pts[i]);
free(fs_types[i]);
}
if(mount_count > 0)
{
free(devs);
free(mnt_pts);
free(fs_types);
}
darshan_log_close(infile);
darshan_log_close(outfile);
return(0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment