[Darshan-commits] [Darshan] branch, dev-modular, updated. darshan-2.3.1-146-gdcc9c7f

Service Account git at mcs.anl.gov
Mon Aug 17 22:19:18 CDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".

The branch, dev-modular has been updated
       via  dcc9c7feafae1d129b5ce5e4d6db38b10344259a (commit)
       via  eb0e5f5b95d4dda633ee97208b658e9d45a331df (commit)
       via  d4db229887c798c5b3cb3d2f9ce7e6f531f9a050 (commit)
       via  093b9f22baae4320fe61e8903b721d29e7a8feed (commit)
      from  d8b6e0dc9610db8dcec6a4dce64b12d906526239 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dcc9c7feafae1d129b5ce5e4d6db38b10344259a
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Mon Aug 17 22:18:51 2015 -0500

    initial hooks for bzip2 compression

commit eb0e5f5b95d4dda633ee97208b658e9d45a331df
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Mon Aug 17 21:18:36 2015 -0500

    log util bug fixes

commit d4db229887c798c5b3cb3d2f9ce7e6f531f9a050
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Mon Aug 17 15:31:44 2015 -0500

    update current utilities to build properly

commit 093b9f22baae4320fe61e8903b721d29e7a8feed
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Mon Aug 17 15:31:13 2015 -0500

    update log put functions for new log format

-----------------------------------------------------------------------

Summary of changes:
 darshan-log-format.h            |   31 ++-
 darshan-util/Makefile.in        |    6 +-
 darshan-util/darshan-analyzer.c |   90 ++++++----
 darshan-util/darshan-convert.c  |  175 ++++++++++++-----
 darshan-util/darshan-logutils.c |  390 +++++++++++++++++++++++++++++----------
 darshan-util/darshan-logutils.h |    6 +-
 darshan-util/darshan-parser.c   |    5 +-
 7 files changed, 507 insertions(+), 196 deletions(-)


Diff of changes:
diff --git a/darshan-log-format.h b/darshan-log-format.h
index 8dd1e8f..4f7cc6a 100644
--- a/darshan-log-format.h
+++ b/darshan-log-format.h
@@ -31,21 +31,30 @@
 /* max length of exe string within job record (not counting '\0') */
 #define DARSHAN_EXE_LEN (DARSHAN_JOB_RECORD_SIZE - sizeof(struct darshan_job) - 1)
 
-typedef uint64_t darshan_record_id;
-
 #define DARSHAN_MAX_MODS 16
+
+/* TODO: do we want the logutil defs here ? */
+/* X-macro for keeping module ordering consistent */
+/* NOTE: first val used to define module enum values, 
+ * second val used to define module name strings, and
+ * third val is used to provide the name of a 
+ * corresponding logutils structure for parsing module
+ * data out of the log file (only used in darshan-util,
+ * just pass NULL (no quotes) if no log parsing
+ * functions are required).
+ */
 #define DARSHAN_MODULE_IDS \
-    X(DARSHAN_NULL_MOD,     "NULL") \
-    X(DARSHAN_POSIX_MOD,    "POSIX") \
-    X(DARSHAN_MPIIO_MOD,    "MPI-IO") \
-    X(DARSHAN_HDF5_MOD,     "HDF5") \
-    X(DARSHAN_PNETCDF_MOD,  "PNETCDF")
+    X(DARSHAN_NULL_MOD, "NULL", NULL) \
+    X(DARSHAN_POSIX_MOD, "POSIX", posix_logutils) \
+    X(DARSHAN_MPIIO_MOD, "MPI-IO", mpiio_logutils) \
+    X(DARSHAN_HDF5_MOD, "HDF5", hdf5_logutils) \
+    X(DARSHAN_PNETCDF_MOD, "PNETCDF", pnetcdf_logutils)
 
 /* unique identifiers to distinguish between available darshan modules */
 /* NOTES: - valid ids range from [0...DARSHAN_MAX_MODS-1]
  *        - order of ids control module shutdown order (and consequently, order in log file)
  */
-#define X(a, b) a,
+#define X(a, b, c) a,
 typedef enum
 {
     DARSHAN_MODULE_IDS
@@ -53,7 +62,7 @@ typedef enum
 #undef X
 
 /* module name strings */
-#define X(a, b) b,
+#define X(a, b, c) b,
 static char * const darshan_module_names[] =
 {
     DARSHAN_MODULE_IDS
@@ -67,6 +76,8 @@ enum darshan_comp_type
     DARSHAN_BZIP2_COMP,
 };
 
+typedef uint64_t darshan_record_id;
+
 /* the darshan_log_map structure is used to indicate the location of
  * specific module data in a Darshan log. Note that 'off' and 'len' are
  * the respective offset and length of the data in the file, in *uncompressed*
@@ -87,7 +98,7 @@ struct darshan_header
 {
     char version_string[8];
     int64_t magic_nr;
-    enum darshan_comp_type comp_type;
+    unsigned char comp_type;
     struct darshan_log_map rec_map;
     struct darshan_log_map mod_map[DARSHAN_MAX_MODS];
 };
diff --git a/darshan-util/Makefile.in b/darshan-util/Makefile.in
index 246683f..11bdbf1 100644
--- a/darshan-util/Makefile.in
+++ b/darshan-util/Makefile.in
@@ -1,4 +1,4 @@
-all: libdarshan-util.a darshan-parser
+all: libdarshan-util.a darshan-analyzer darshan-convert darshan-parser
 
 DESTDIR =
 srcdir = @srcdir@
@@ -106,8 +106,8 @@ install:: all
 	install -d $(libdir)
 	install -d $(includedir)
 	install -d $(pkgconfigdir)
-#	install -m 755 darshan-analyzer $(bindir)
-#	install -m 755 darshan-convert $(bindir)
+	install -m 755 darshan-analyzer $(bindir)
+	install -m 755 darshan-convert $(bindir)
 #	install -m 755 darshan-diff $(bindir)
 	install -m 755 darshan-parser $(bindir)
 #	install -m 755 $(srcdir)/darshan-summary-per-file.sh $(bindir)
diff --git a/darshan-util/darshan-analyzer.c b/darshan-util/darshan-analyzer.c
index f16d98f..409b480 100644
--- a/darshan-util/darshan-analyzer.c
+++ b/darshan-util/darshan-analyzer.c
@@ -1,6 +1,13 @@
+/*
+ * Copyright (C) 2015 University of Chicago.
+ * See COPYRIGHT notice in top-level directory.
+ *
+ */
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 #include <ftw.h>
 #include <zlib.h>
 
@@ -13,8 +20,7 @@
 
 char * base = NULL;
 
-int total_single = 0;
-int total_multi  = 0;
+int total_shared = 0;
 int total_mpio   = 0;
 int total_pnet   = 0;
 int total_hdf5   = 0;
@@ -27,38 +33,47 @@ int bucket4 = 0;
 int bucket5 = 0;
 int fail    = 0;
 
-int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_pnet, int *used_hdf5, int *used_multi, int *used_single)
+int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_pnet, int *used_hdf5, int *used_shared)
 {
-    struct darshan_job job;
-    struct darshan_file cp_file;
-    char tmp_string[4096];
     darshan_fd zfile;
+    struct darshan_header header;
+    struct darshan_job job;
+    struct darshan_mod_logutil_funcs *psx_mod = mod_logutils[DARSHAN_POSIX_MOD];
+    struct darshan_mod_logutil_funcs *mpiio_mod = mod_logutils[DARSHAN_MPIIO_MOD];
+    struct darshan_mod_logutil_funcs *hdf5_mod = mod_logutils[DARSHAN_HDF5_MOD];
+    struct darshan_mod_logutil_funcs *pnetcdf_mod = mod_logutils[DARSHAN_PNETCDF_MOD];
+    struct darshan_posix_file *psx_rec;
+    darshan_record_id rec_id;
     int ret;
     int f_count;
     double total_io_time;
     double total_job_time;
 
-    zfile = darshan_log_open(fname, "r");
+    assert(psx_mod);
+    assert(mpiio_mod);
+    assert(hdf5_mod);
+    assert(pnetcdf_mod);
+
+    zfile = darshan_log_open(fname);
     if (zfile == NULL)
     {
-        fprintf(stderr, "darshan_log_open() failed to open %s\n.", fname);
+        fprintf(stderr, "darshan_log_open() failed to open %s.\n", fname);
         return -1;
     }
 
-    ret = darshan_log_getjob(zfile, &job);
+#if 0
+    ret = darshan_log_getheader(zfile, &header);
     if (ret < 0)
     {
-        perror("darshan_log_getjob");
-        fprintf(stderr, "%s\n", fname);
+        fprintf(stderr, "darshan_log_getheader() failed on file %s.\n", fname);
         darshan_log_close(zfile);
         return -1;
     }
 
-    ret = darshan_log_getexe(zfile, tmp_string);
+    ret = darshan_log_getjob(zfile, &job);
     if (ret < 0)
     {
-        perror("darshan_log_getexe");
-        fprintf(stderr, "%s\n", fname);
+        fprintf(stderr, "darshan_log_getjob() failed on file %s.\n", fname);
         darshan_log_close(zfile);
         return -1;
     }
@@ -66,14 +81,16 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
     f_count = 0;
     total_io_time = 0.0;
 
-    while ((ret = darshan_log_getfile(zfile, &job, &cp_file)) == 1)
+    while ((ret = psx_mod->log_get_record(zfile, (void **)&psx_rec, &rec_id)) == 1)
     {
+        void *tmp_rec;
         f_count   += 1;
 
-        if (cp_file.rank == -1)
-            *used_single = 1;
-        else
-            *used_multi = 1;
+        if (psx_rec->rank == -1)
+            *used_shared = 1;
+
+
+        while((ret = mpiio_mod->log_get_record(
 
         *used_mpio += cp_file.counters[CP_INDEP_OPENS];
         *used_mpio += cp_file.counters[CP_COLL_OPENS];
@@ -100,6 +117,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
     {
         *io_ratio = 0.0;
     }
+#endif
 
     darshan_log_close(zfile);
 
@@ -112,20 +130,19 @@ int tree_walk (const char *fpath, const struct stat *sb, int typeflag)
     int used_mpio = 0;
     int used_pnet = 0;
     int used_hdf5 = 0;
-    int used_multi = 0;
-    int used_single = 0;
+    int used_shared = 0;
 
     if (typeflag != FTW_F) return 0;
 
-    process_log(fpath,&io_ratio,&used_mpio,&used_pnet,&used_hdf5,&used_multi,&used_single);
+    process_log(fpath,&io_ratio,&used_mpio,&used_pnet,&used_hdf5,&used_shared);
 
+    /* XXX */
     total_count++;
 
     if (used_mpio > 0) total_mpio++;
     if (used_pnet > 0) total_pnet++;
     if (used_hdf5 > 0) total_hdf5++;
-    if (used_single > 0) total_single++;
-    if (used_multi  > 0) total_multi++;
+    if (used_shared > 0) total_shared++;
 
     if (io_ratio <= BUCKET1)
         bucket1++;
@@ -152,7 +169,7 @@ int main(int argc, char **argv)
 
     if(argc != 2)
     {
-        fprintf(stderr, "Error: bad arguments.\n");
+        fprintf(stderr, "Error: directory of Darshan logs required as argument.\n");
         return(-1);
     }
 
@@ -165,13 +182,13 @@ int main(int argc, char **argv)
         return(-1);
     }
 
-    printf ("   log: %s\n", base);
-    printf (" total: %d\n", total_count);
-    printf ("single: %lf [%d]\n", (double)total_single/(double)total_count, total_single);
-    printf (" multi: %lf [%d]\n", (double)total_multi/(double)total_count, total_multi);
-    printf ("  mpio: %lf [%d]\n", (double)total_mpio/(double)total_count, total_mpio);
-    printf ("  pnet: %lf [%d]\n", (double)total_pnet/(double)total_count, total_pnet);
-    printf ("  hdf5: %lf [%d]\n", (double)total_hdf5/(double)total_count, total_hdf5);
+    /* XXX */
+    printf ("log dir: %s\n", base);
+    printf ("  total: %d\n", total_count);
+    printf (" single: %lf [%d]\n", (double)total_shared/(double)total_count, total_shared);
+    printf ("   mpio: %lf [%d]\n", (double)total_mpio/(double)total_count, total_mpio);
+    printf ("   pnet: %lf [%d]\n", (double)total_pnet/(double)total_count, total_pnet);
+    printf ("   hdf5: %lf [%d]\n", (double)total_hdf5/(double)total_count, total_hdf5);
     printf ("%.2lf-%.2lf: %d\n", (double)0.0,     (double)BUCKET1, bucket1);
     printf ("%.2lf-%.2lf: %d\n", (double)BUCKET1, (double)BUCKET2, bucket2);
     printf ("%.2lf-%.2lf: %d\n", (double)BUCKET2, (double)BUCKET3, bucket3);
@@ -179,3 +196,12 @@ int main(int argc, char **argv)
     printf ("%.2lf-%.2lf: %d\n", (double)BUCKET4, (double)100.0,   bucket5);
     return 0;
 }
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/darshan-util/darshan-convert.c b/darshan-util/darshan-convert.c
index fb39570..b8bc455 100644
--- a/darshan-util/darshan-convert.c
+++ b/darshan-util/darshan-convert.c
@@ -1,6 +1,7 @@
 /*
- *  (C) 2011 by Argonne National Laboratory.
- *      See COPYRIGHT in top-level directory.
+ * Copyright (C) 2015 University of Chicago.
+ * See COPYRIGHT notice in top-level directory.
+ *
  */
 
 #include <stdio.h>
@@ -25,6 +26,7 @@ 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, "       rewrites the log file into the newest format.\n");
+    fprintf(stderr, "       --bzip2 Use bzip2 compression instead of zlib.\n");
     fprintf(stderr, "       --obfuscate Obfuscate items in the log.\n");
     fprintf(stderr, "       --key <key> Key to use when obfuscating.\n");
     fprintf(stderr, "       --annotate <string> Additional metadata to add.\n");
@@ -35,15 +37,15 @@ int usage (char *exename)
 }
 
 void parse_args (int argc, char **argv, char **infile, char **outfile,
-                 int *obfuscate, int *reset_md, int *key, char **annotate, uint64_t* hash)
+                 int *bzip2, int *obfuscate, int *reset_md, int *key,
+                 char **annotate, uint64_t* hash)
 {
     int index;
     int ret;
 
-    *reset_md = 0;
-
     static struct option long_opts[] =
     {
+        {"bzip2", 0, NULL, 'b'},
         {"annotate", 1, NULL, 'a'},
         {"obfuscate", 0, NULL, 'o'},
         {"reset-md", 0, NULL, 'r'},
@@ -53,6 +55,8 @@ void parse_args (int argc, char **argv, char **infile, char **outfile,
         { 0, 0, 0, 0 }
     };
 
+    *bzip2 = 0;
+    *reset_md = 0;
     *hash = 0;
 
     while(1)
@@ -63,6 +67,9 @@ void parse_args (int argc, char **argv, char **infile, char **outfile,
 
         switch(c)
         {
+            case 'b':
+                *bzip2 = 1;
+                break;
             case 'a':
                 *annotate = optarg;
                 break;
@@ -101,6 +108,7 @@ void parse_args (int argc, char **argv, char **infile, char **outfile,
     return;
 }
 
+#if 0
 static void reset_md_job(struct darshan_job *job)
 {
     job->metadata[0] = '\0';
@@ -181,70 +189,90 @@ void add_annotation (char *annotation,
 
     return;
 }
+#endif
 
 int main(int argc, char **argv)
 {
     int ret;
     char *infile_name;
     char *outfile_name;
+    struct darshan_header header;
     struct darshan_job job;
-    struct darshan_file cp_file;
     char tmp_string[4096];
     darshan_fd infile;
     darshan_fd outfile;
     int i;
     int mount_count;
-    int64_t* devs;
     char** mnt_pts;
+    struct darshan_record_ref *rec_hash = NULL;
+    struct darshan_record_ref *ref, *tmp;
+    char *mod_buf;
+    int mod_buf_sz;
     char** fs_types;
-    int last_rank = 0;
+    int bzip2;
+    enum darshan_comp_type comp_type;
+
     int obfuscate = 0;
     int key = 0;
     char *annotation = NULL;
     uint64_t hash;
     int reset_md = 0;
 
-    parse_args(argc, argv, &infile_name, &outfile_name, &obfuscate, &reset_md, &key, &annotation, &hash);
+    parse_args(argc, argv, &infile_name, &outfile_name, &bzip2, &obfuscate,
+               &reset_md, &key, &annotation, &hash);
 
-    infile = darshan_log_open(infile_name, "r");
+    infile = darshan_log_open(infile_name);
     if(!infile)
     {
         fprintf(stderr, "darshan_log_open() failed to open %s\n.", infile_name);
         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");
+    comp_type = bzip2 ? comp_type = DARSHAN_BZIP2_COMP : DARSHAN_ZLIB_COMP;
+    outfile = darshan_log_create(outfile_name, comp_type);
     if(!outfile)
     {
-        fprintf(stderr, "darshan_log_open() failed to open %s\n.", outfile_name);
+        fprintf(stderr, "darshan_log_create() failed to create %s\n.", outfile_name);
+        darshan_log_close(infile);
+        return(-1);
+    }
+
+    /* read header from input file */
+    ret = darshan_log_getheader(infile, &header);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: unable to read header from input log file %s.\n", infile_name);
+        darshan_log_close(infile);
+        darshan_log_close(outfile);
         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
+    /* NOTE: we do not write the header to the output file until the end, as
+     * the mapping data stored in this structure may change in the conversion
+     * process (particularly, if we are converting between libz/bz2 compression)
      */
-  
+
     /* 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);
+        darshan_log_close(outfile);
         return(-1);
     }
 
+#if 0
     if (reset_md) reset_md_job(&job);
     if (obfuscate) obfuscate_job(key, &job);
     if (annotation) add_annotation(annotation, &job);
+#endif
 
     ret = darshan_log_putjob(outfile, &job);
     if (ret < 0)
     {
         fprintf(stderr, "Error: unable to write job information to log file.\n");
+        darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
     }
@@ -254,77 +282,97 @@ int main(int argc, char **argv)
     {
         fprintf(stderr, "Error: unable to read trailing job information.\n");
         darshan_log_close(infile);
+        darshan_log_close(outfile);
         return(-1);
     }
 
+#if 0
     if (obfuscate) obfuscate_exe(key, tmp_string);
+#endif
 
     ret = darshan_log_putexe(outfile, tmp_string);
     if(ret < 0)
     {
         fprintf(stderr, "Error: unable to write trailing job information.\n");
+        darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
     }
-   
-    ret = darshan_log_getmounts(infile, &devs, &mnt_pts, &fs_types, &mount_count);
+
+    ret = darshan_log_getmounts(infile, &mnt_pts, &fs_types, &mount_count);
     if(ret < 0)
     {
         fprintf(stderr, "Error: unable to read trailing job information.\n");
         darshan_log_close(infile);
+        darshan_log_close(outfile);
         return(-1);
     }
 
-    ret = darshan_log_putmounts(outfile, devs, mnt_pts, fs_types, mount_count);
+    ret = darshan_log_putmounts(outfile, mnt_pts, fs_types, mount_count);
     if(ret < 0)
     {
         fprintf(stderr, "Error: unable to write mount information.\n");
+        darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
     }
 
-    ret = darshan_log_getfile(infile, &job, &cp_file);
+    ret = darshan_log_gethash(infile, &rec_hash);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: failed to process log file.\n");
-        fflush(stderr);
+        fprintf(stderr, "Error: unable to read darshan record hash.\n");
+        darshan_log_close(infile);
+        darshan_log_close(outfile);
+        return(-1);
     }
-    if(ret == 0)
+
+    ret = darshan_log_puthash(outfile, rec_hash);
+    if(ret < 0)
     {
-        goto done;
+        fprintf(stderr, "Error: unable to write darshan record hash.\n");
+        darshan_log_close(infile);
+        darshan_log_close(outfile);
+        return(-1);
     }
 
-    do
+    mod_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
+    if(!mod_buf)
+        return(-1);
+
+    for(i=0; i<DARSHAN_MAX_MODS; i++)
     {
-        if(cp_file.rank != -1 && cp_file.rank < last_rank)
+        memset(mod_buf, 0, DARSHAN_DEF_COMP_BUF_SZ);
+        mod_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
+
+        /* check each module for any data */
+        ret = darshan_log_getmod(infile, i, mod_buf, &mod_buf_sz);
+        if(ret < 0)
         {
-            fprintf(stderr, "Error: log file contains out of order rank data.\n");
-            fflush(stderr);
+            fprintf(stderr, "Error: failed to get module %s data.\n",
+                darshan_module_names[i]);
+            darshan_log_close(infile);
+            darshan_log_close(outfile);
             return(-1);
         }
-        if(cp_file.rank != -1)
-            last_rank = cp_file.rank;
-
-        if(!hash || hash == cp_file.hash)
+        else if(ret == 0)
         {
-            if (obfuscate) obfuscate_file(key, &cp_file);
-
-            ret = darshan_log_putfile(outfile, &job, &cp_file);
-            if (ret < 0)
-            {
-                fprintf(stderr, "Error: failed to write file record.\n");
-                break;
-            }
+            /* skip modules not present in log file */
+            continue;
         }
-    } while((ret = darshan_log_getfile(infile, &job, &cp_file)) == 1);
 
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: failed to process log file.\n");
-        fflush(stderr);
+        /* we have module data to convert */
+        ret = darshan_log_putmod(outfile, i, mod_buf, mod_buf_sz);
+        if(ret < 0)
+        {
+            fprintf(stderr, "Error: failed to put module %s data.\n",
+                darshan_module_names[i]);
+            darshan_log_close(infile);
+            darshan_log_close(outfile);
+            return(-1);
+        }
     }
+    free(mod_buf);
 
-done:
     for(i=0; i<mount_count; i++)
     {
         free(mnt_pts[i]);
@@ -332,15 +380,38 @@ done:
     }
     if(mount_count > 0)
     {
-        free(devs);
         free(mnt_pts);
         free(fs_types);
     }
- 
+
+    HASH_ITER(hlink, rec_hash, ref, tmp)
+    {
+        HASH_DELETE(hlink, rec_hash, ref);
+        free(ref->rec.name);
+        free(ref);
+    }
+
+    /* write header to output file */
+    ret = darshan_log_putheader(outfile);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: unable to write header to output log file %s.\n", outfile_name);
+        darshan_log_close(infile);
+        darshan_log_close(outfile);
+        return(-1);
+    }
+
     darshan_log_close(infile);
     darshan_log_close(outfile);
 
     return(ret);
 }
 
-
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/darshan-util/darshan-logutils.c b/darshan-util/darshan-logutils.c
index 2bfe73d..33fb8a0 100644
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -19,13 +19,26 @@
 
 #include "darshan-logutils.h"
 
-/* TODO: for log reads, we need to make sure the header has been read prior */
-
 static int darshan_log_seek(darshan_fd fd, off_t offset);
 static int darshan_log_read(darshan_fd fd, void *buf, int len);
 static int darshan_log_write(darshan_fd fd, void *buf, int len);
 static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
+    char* decomp_buf, int* inout_decomp_buf_sz,
+    enum darshan_comp_type comp_type);
+static int darshan_compress_buf(char* decomp_buf, int decomp_buf_sz,
+    char* comp_buf, int* inout_comp_buf_sz,
+    enum darshan_comp_type comp_type);
+static int darshan_zlib_decomp(char* comp_buf, int comp_buf_sz,
+    char* decomp_buf, int* inout_decomp_buf_sz);
+static int darshan_zlib_comp(char* decomp_buf, int decomp_buf_sz,
+    char* comp_buf, int* inout_comp_buf_sz);
+#ifdef HAVE_LIBBZ2
+static int darshan_bzip2_decomp(char* comp_buf, int comp_buf_sz,
     char* decomp_buf, int* inout_decomp_buf_sz);
+static int darshan_bzip2_comp(char* decomp_buf, int decomp_buf_sz,
+    char* comp_buf, int* inout_comp_buf_sz);
+#endif
+
 
 /* TODO: can we make this s.t. we don't care about ordering (i.e., X macro it ) */
 struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
@@ -50,40 +63,54 @@ struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
 
 /* darshan_log_open()
  *
- * open a darshan log file for reading/writing
+ * open an existing darshan log file for reading only
  *
  * returns 0 on success, -1 on failure
  */
-darshan_fd darshan_log_open(const char *name, const char *mode)
+darshan_fd darshan_log_open(const char *name)
 {
-    int o_flags;
     darshan_fd tmp_fd;
 
-    /* we only allow "w" or "r" modes, nothing fancy */
-    assert(strlen(mode) == 1);
-    assert(mode[0] == 'r' || mode[0] == 'w');
+    tmp_fd = malloc(sizeof(*tmp_fd));
+    if(!tmp_fd)
+        return(NULL);
+    memset(tmp_fd, 0, sizeof(*tmp_fd));
 
-    if(mode[0] == 'r')
-    {
-        o_flags = O_RDONLY;
-    }
-    else if (mode[0] == 'w')
+    tmp_fd->fildes = open(name, O_RDONLY);
+    if(tmp_fd->fildes < 0)
     {
-        /* when writing, we create the log file making sure not to overwrite
-         * an existing log
-         */
-        o_flags = O_WRONLY | O_CREAT | O_EXCL;
+        perror("darshan_log_open: ");
+        free(tmp_fd);
+        tmp_fd = NULL;
     }
 
+    return(tmp_fd);
+}
+
+/* darshan_log_create()
+ *
+ * create a darshan log file for writing with the given compression method
+ *
+ * returns 0 on success, -1 on failure
+ */
+darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type)
+{
+    darshan_fd tmp_fd;
+
     tmp_fd = malloc(sizeof(*tmp_fd));
     if(!tmp_fd)
         return(NULL);
     memset(tmp_fd, 0, sizeof(*tmp_fd));
 
-    tmp_fd->fildes = open(name, o_flags);
+    /* TODO: permissions when creating?  umask */
+    /* when writing, we create the log file making sure not to overwrite
+     * an existing log
+     */
+    tmp_fd->comp_type = comp_type;
+    tmp_fd->fildes = open(name, O_WRONLY | O_CREAT | O_EXCL, 0400);
     if(tmp_fd->fildes < 0)
     {
-        perror("darshan_log_open: ");
+        perror("darshan_log_create: ");
         free(tmp_fd);
         tmp_fd = NULL;
     }
@@ -152,6 +179,8 @@ int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
         }
     }
 
+    fd->comp_type = header->comp_type;
+
     /* save the mapping of data within log file to this file descriptor */
     fd->job_map.off = sizeof(struct darshan_header);
     fd->job_map.len = header->rec_map.off - fd->job_map.off;
@@ -161,15 +190,17 @@ int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
     return(0);
 }
 
-#if 0
 /* darshan_log_putheader()
  *
  * write a darshan header to log file
+ * NOTE: the header is not passed in, and is instead built using
+ * contents of the given file descriptor
  *
  * returns 0 on success, -1 on failure
  */
-int darshan_log_putheader(darshan_fd fd, struct darshan_header *header)
+int darshan_log_putheader(darshan_fd fd)
 {
+    struct darshan_header header;
     int ret;
 
     ret = darshan_log_seek(fd, 0);
@@ -179,21 +210,24 @@ int darshan_log_putheader(darshan_fd fd, struct darshan_header *header)
         return(-1);
     }
 
+    memset(&header, 0, sizeof(header));
+    strcpy(header.version_string, DARSHAN_LOG_VERSION);
+    header.magic_nr = DARSHAN_MAGIC_NR;
+
+    /* copy the mapping information to the header */
+    memcpy(&header.rec_map, &fd->rec_map, sizeof(struct darshan_log_map));
+    memcpy(&header.mod_map, &fd->mod_map, DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
+
     /* write header to file */
-    ret = darshan_log_write(fd, header, sizeof(*header));
-    if(ret != sizeof(*header))
+    ret = darshan_log_write(fd, &header, sizeof(header));
+    if(ret != sizeof(header))
     {
         fprintf(stderr, "Error: failed to write Darshan log file header.\n");
         return(-1);
     }
 
-    /* copy the mapping information to the file descriptor */
-    memcpy(&fd->rec_map, &header->rec_map, sizeof(struct darshan_log_map));
-    memcpy(&fd->mod_map, &header->mod_map, DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
-
     return(0);
 }
-#endif
 
 /* darshan_log_getjob()
  *
@@ -208,6 +242,8 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
     int job_buf_sz = DARSHAN_JOB_RECORD_SIZE;
     int ret;
 
+    assert(fd->job_map.len > 0 && fd->job_map.off > 0);
+
     /* allocate buffer to store compressed job info */
     comp_buf = malloc(fd->job_map.len);
     if(!comp_buf)
@@ -231,14 +267,14 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
     }
 
     /* decompress the job data */
-    ret = darshan_decompress_buf(comp_buf, fd->job_map.len, job_buf, &job_buf_sz);
+    ret = darshan_decompress_buf(comp_buf, fd->job_map.len,
+        job_buf, &job_buf_sz, fd->comp_type);
     if(ret < 0)
     {
         fprintf(stderr, "Error: failed to decompress darshan job data.\n");
         free(comp_buf);
         return(-1);
     }
-    assert(job_buf_sz == DARSHAN_JOB_RECORD_SIZE);
     free(comp_buf);
 
     memcpy(job, job_buf, sizeof(*job));
@@ -263,7 +299,6 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
     return(0);
 }
 
-#if 0
 /* darshan_log_putjob()
  *
  * write job level metadat to darshan log file
@@ -273,6 +308,8 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
 int darshan_log_putjob(darshan_fd fd, struct darshan_job *job)
 {
     struct darshan_job job_copy;
+    char *comp_buf;
+    int comp_buf_sz;
     int len;
     int ret;
 
@@ -297,9 +334,24 @@ int darshan_log_putjob(darshan_fd fd, struct darshan_job *job)
         }
     }
 
+    comp_buf = malloc(sizeof(*job));
+    if(!comp_buf)
+        return(-1);
+    comp_buf_sz = sizeof(*job);
+
+    /* compress the job data */
+    ret = darshan_compress_buf((char*)&job_copy, sizeof(*job),
+        comp_buf, &comp_buf_sz, fd->comp_type);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: failed to decompress darshan job data.\n");
+        free(comp_buf);
+        return(-1);
+    }    
+
     /* write job data to file */
-    ret = darshan_log_write(fd, job, sizeof(*job));
-    if(ret != sizeof(*job))
+    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
+    if(ret != comp_buf_sz)
     {
         fprintf(stderr, "Error: failed to write darshan log file job data.\n");
         return(-1);
@@ -307,7 +359,6 @@ int darshan_log_putjob(darshan_fd fd, struct darshan_job *job)
 
     return(0);
 }
-#endif
 
 /* darshan_log_getexe()
  *
@@ -340,30 +391,34 @@ int darshan_log_getexe(darshan_fd fd, char *buf)
     return (0);
 }
 
-#if 0
 /* darshan_log_putexe()
  *
  * wrties the application exe name to darshan log file
+ * NOTE: this needs to be called immediately following put_job as it
+ * expects the final pointer to be positioned immediately following
+ * the darshan job information
  *
  * returns 0 on success, -1 on failure 
  */
 int darshan_log_putexe(darshan_fd fd, char *buf)
 {
-    int tmp_off = sizeof(struct darshan_header) + sizeof(struct darshan_job);
     int len;
     int ret;
+    char comp_buf[DARSHAN_EXE_LEN] = {0};
+    int comp_buf_sz = DARSHAN_EXE_LEN;
 
-    ret = darshan_log_seek(fd, tmp_off);
+    len = strlen(buf);
+
+    /* compress the input exe string */
+    ret = darshan_compress_buf(buf, len, comp_buf, &comp_buf_sz, fd->comp_type);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
+        fprintf(stderr, "Error: unable to compress exe string.\n");
         return(-1);
     }
 
-    len = strlen(buf);
-
-    ret = darshan_log_write(fd, buf, len);
-    if(ret != len)
+    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
+    if(ret != comp_buf_sz)
     {
         fprintf(stderr, "Error: failed to write exe string to darshan log file.\n");
         return(-1);
@@ -371,7 +426,6 @@ int darshan_log_putexe(darshan_fd fd, char *buf)
 
     return(0);
 }
-#endif
 
 /* darshan_log_getmounts()
  * 
@@ -445,7 +499,6 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
     return(0);
 }
 
-#if 0
 /* darshan_log_putmounts()
  *
  * writes mount information to the darshan log file
@@ -459,31 +512,40 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co
 {
     int i;
     char line[1024];
+    char mnt_dat[DARSHAN_EXE_LEN] = {0};
+    int mnt_dat_sz = 0;
+    char comp_buf[DARSHAN_EXE_LEN] = {0};
+    int comp_buf_sz = DARSHAN_EXE_LEN;
+    char *tmp;
     int ret;
 
     /* write each mount entry to file */
+    tmp = mnt_dat;
     for(i=count-1; i>=0; i--)
     {
         sprintf(line, "\n%s\t%s", fs_types[i], mnt_pts[i]);
-        ret = darshan_log_write(fd, line, strlen(line));
-        if (ret != strlen(line))
-        {
-            fprintf(stderr, "Error: failed to write darshan log mount entry.\n");
-            return(-1);
-        }
+
+        memcpy(tmp, line, strlen(line));
+        tmp += strlen(line);
+        mnt_dat_sz += strlen(line);
     }
 
-    /* seek ahead to end of exe region, will be zero filled */
-    ret = darshan_log_seek(fd, DARSHAN_JOB_RECORD_SIZE);
-    if (ret < 0)
+    ret = darshan_compress_buf(mnt_dat, mnt_dat_sz, comp_buf, &comp_buf_sz, fd->comp_type);
+    if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to seek forward in darshan log file.\n");
+        fprintf(stderr, "Error: unable to compress mount data.\n");
+        return(-1);
+    }
+
+    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
+    if (ret != comp_buf_sz)
+    {
+        fprintf(stderr, "Error: failed to write darshan log mount data.\n");
         return(-1);
     }
 
     return(0);
 }
-#endif
 
 /* darshan_log_gethash()
  *
@@ -518,6 +580,7 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
     {
         fprintf(stderr, "Error: unable to seek in darshan log file.\n");
         free(comp_buf);
+        free(hash_buf);
         return(-1);
     }
 
@@ -527,16 +590,18 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
     {
         fprintf(stderr, "Error: failed to read record hash from darshan log file.\n");
         free(comp_buf);
+        free(hash_buf);
         return(-1);
     }
 
     /* decompress the record hash buffer */
     ret = darshan_decompress_buf(comp_buf, fd->rec_map.len,
-        hash_buf, &hash_buf_sz);
+        hash_buf, &hash_buf_sz, fd->comp_type);
     if(ret < 0)
     {
         fprintf(stderr, "Error: unable to decompress darshan job data.\n");
         free(comp_buf);
+        free(hash_buf);
         return(-1);
     }
     free(comp_buf);
@@ -568,12 +633,14 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
             ref = malloc(sizeof(*ref));
             if(!ref)
             {
+                free(hash_buf);
                 return(-1);
             }
             ref->rec.name = malloc(*path_len_ptr + 1);
             if(!ref->rec.name)
             {
                 free(ref);
+                free(hash_buf);
                 return(-1);
             }
 
@@ -591,10 +658,12 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
     return(0);
 }
 
-#if 0
 /* darshan_log_puthash()
  *
  * writes the hash table of records to the darshan log file
+ * NOTE: this function call should follow immediately after the call
+ * to darshan_log_putmounts(), as it assumes the darshan log file pointer
+ * is pointing to the offset immediately following the mount information
  *
  * returns 0 on success, -1 on failure
  */
@@ -606,15 +675,10 @@ int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash)
     struct darshan_record_ref *ref, *tmp;
     uint32_t name_len;
     size_t record_sz;
+    char *comp_buf;
+    int comp_buf_sz;
     int ret;
 
-    ret = darshan_log_seek(fd, fd->rec_map.off);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        return(-1);
-    }
-
     /* allocate a buffer to store 2 MiB worth of record data */
     /* NOTE: this buffer may be reallocated if estimate is too small */
     hash_buf_sz = 2 * 1024 * 1024;
@@ -663,23 +727,43 @@ int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash)
         memcpy(hash_buf_off, ref->rec.name, name_len);
         hash_buf_off += name_len;
     }
-
-    /* collectively write out the record hash to the darshan log */
     hash_buf_sz = hash_buf_off - hash_buf;
 
+    comp_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
+    if(!comp_buf)
+        return(-1);
+    comp_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
+
+    /* compress the record hash */
+    ret = darshan_compress_buf(hash_buf, hash_buf_sz,
+        comp_buf, &comp_buf_sz, fd->comp_type);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: unable to compress darshan record hash.\n");
+        free(comp_buf);
+        free(hash_buf);
+        return(-1);
+    }
+
+    /* set the appropriate mapping info for the record hash in the file descriptor */
+    fd->rec_map.off = fd->pos;
+    fd->rec_map.len = comp_buf_sz;
+
     /* write the record hash to file */
-    ret = darshan_log_write(fd, hash_buf, hash_buf_sz);
-    if(ret != hash_buf_sz)
+    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
+    if(ret != comp_buf_sz)
     {
         fprintf(stderr, "Error: failed to write record hash to darshan log file.\n");
+        free(comp_buf);
+        free(hash_buf);
         return(-1);
     }
 
+    free(comp_buf);
     free(hash_buf);
 
     return(0);
 }
-#endif
 
 /* darshan_log_getmod()
  *
@@ -725,7 +809,7 @@ int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id,
 
     /* decompress this module's data */
     ret = darshan_decompress_buf(comp_buf, fd->mod_map[mod_id].len,
-        mod_buf, mod_buf_sz);
+        mod_buf, mod_buf_sz, fd->comp_type);
     if(ret < 0)
     {
         fprintf(stderr, "Error: unable to decompress module %s data.\n",
@@ -738,50 +822,54 @@ int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id,
     return(1);
 }
 
-#if 0
 /* darshan_log_putmod()
  *
  * write a chunk of module data to the darshan log file
+ * NOTE: this function call should be called directly after the
+ * put_hash() function, as it expects the file pointer to be
+ * positioned directly past the record hash location. Also,
+ * for a set of modules with data to write to file, this function
+ * should be called in order of increasing module identifiers,
+ * as the darshan log file format expects this ordering.
  *
  * returns 0 on success, -1 on failure
  */
 int darshan_log_putmod(darshan_fd fd, darshan_module_id mod_id,
     void *mod_buf, int mod_buf_sz)
 {
-    int mod_buf_end = fd->mod_map[mod_id].off + fd->mod_map[mod_id].len;
+    char *comp_buf;
+    int comp_buf_sz;
     int ret;
 
-    if(!fd->mod_map[mod_id].len)
+    if(mod_id < 0 || mod_id >= DARSHAN_MAX_MODS)
     {
-        fprintf(stderr, "Error: attempting to write data for empty module.\n");
+        fprintf(stderr, "Error: invalid Darshan module id.\n");
         return(-1);
     }
 
-    /* only seek to start of module data if current log file position 
-     * is not within the given mod_id's range. This allows one to
-     * repeatedly call this function and put chunks of a module's
-     * data piecemeal.
-     */
-    if((fd->pos < fd->mod_map[mod_id].off) || (fd->pos > mod_buf_end))
-    {
-        ret = darshan_log_seek(fd, fd->mod_map[mod_id].off);
-        if(ret < 0)
-        {
-            fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-            return(-1);
-        }
-    }
+    comp_buf = malloc(mod_buf_sz);
+    if(!comp_buf)
+        return(-1);
+    comp_buf_sz = mod_buf_sz;
 
-    /* if the given data violates stored mapping info, error out */
-    if(mod_buf_sz > (mod_buf_end - fd->pos))
+    /* compress the module's data */
+    ret = darshan_compress_buf(mod_buf, mod_buf_sz,
+        comp_buf, &comp_buf_sz, fd->comp_type);
+    if(ret < 0)
     {
-        fprintf(stderr, "Error: module data write violates stored mapping information.\n");
+        fprintf(stderr, "Error: unable to compress module %s data.\n",
+            darshan_module_names[mod_id]);
+        free(comp_buf);
         return(-1);
     }
 
+    /* set the appropriate mapping information for this module */
+    fd->mod_map[mod_id].off = fd->pos;
+    fd->mod_map[mod_id].len = comp_buf_sz;
+
     /* write the module chunk to the log file */
-    ret = darshan_log_write(fd, mod_buf, mod_buf_sz);
-    if(ret != mod_buf_sz)
+    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
+    if(ret != comp_buf_sz)
     {
         fprintf(stderr,
             "Error: failed to write module %s data to darshan log file.\n",
@@ -791,7 +879,6 @@ int darshan_log_putmod(darshan_fd fd, darshan_module_id mod_id,
 
     return(0);
 }
-#endif 
 
 /* darshan_log_close()
  *
@@ -863,6 +950,32 @@ static int darshan_log_write(darshan_fd fd, void* buf, int len)
 /* return 0 on successful decompression, -1 on failure
  */
 static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
+    char* decomp_buf, int* inout_decomp_buf_sz,
+    enum darshan_comp_type comp_type)
+{
+    int ret;
+
+    switch(comp_type)
+    {
+        case DARSHAN_ZLIB_COMP:
+            ret = darshan_zlib_decomp(comp_buf, comp_buf_sz,
+                decomp_buf, inout_decomp_buf_sz);
+            break;
+#ifdef HAVE_LIBBZ2
+        case DARSHAN_BZIP2_COMP:
+            ret = darshan_bzip2_decomp(comp_buf, comp_buf_sz,
+                decomp_buf, inout_decomp_buf_sz);
+            break;
+#endif
+        default:
+            fprintf(stderr, "Error: invalid decompression method.\n");
+            return(-1);
+    }
+
+    return(ret);
+}
+
+static int darshan_zlib_decomp(char* comp_buf, int comp_buf_sz,
     char* decomp_buf, int* inout_decomp_buf_sz)
 {
     int ret;
@@ -892,7 +1005,7 @@ static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
     {
         if(tmp_stream.avail_out == 0)
         {
-            /* We ran out of buffer space for compression.  In theory,
+            /* We ran out of buffer space for decompression.  In theory,
              * we could just alloc more space, but probably just easier
              * to bump up the default size of the output buffer.
              */
@@ -919,12 +1032,99 @@ static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
 }
 
 static int darshan_compress_buf(char* decomp_buf, int decomp_buf_sz,
+    char* comp_buf, int* inout_comp_buf_sz,
+    enum darshan_comp_type comp_type)
+{
+    int ret;
+
+    switch(comp_type)
+    {
+        case DARSHAN_ZLIB_COMP:
+            ret = darshan_zlib_comp(decomp_buf, decomp_buf_sz,
+                comp_buf, inout_comp_buf_sz);
+            break;
+#ifdef HAVE_LIBBZ2
+        case DARSHAN_BZIP2_COMP:
+            ret = darshan_bzip2_comp(decomp_buf, decomp_buf_sz,
+                comp_buf, inout_comp_buf_sz);
+            break;
+#endif
+        default:
+            fprintf(stderr, "Error: invalid compression method.\n");
+            return(-1);
+    }
+
+    return(ret);
+
+}
+
+static int darshan_zlib_comp(char* decomp_buf, int decomp_buf_sz,
     char* comp_buf, int* inout_comp_buf_sz)
 {
+    int ret;
+    int total_out = 0;
+    z_stream tmp_stream;
+
+    memset(&tmp_stream, 0, sizeof(tmp_stream));
+    tmp_stream.zalloc = Z_NULL;
+    tmp_stream.zfree = Z_NULL;
+    tmp_stream.opaque = Z_NULL;
+    tmp_stream.next_in = (unsigned char*)decomp_buf;
+    tmp_stream.avail_in = decomp_buf_sz;
+    tmp_stream.next_out = (unsigned char*)comp_buf;
+    tmp_stream.avail_out = *inout_comp_buf_sz;
+
+    ret = deflateInit(&tmp_stream, Z_DEFAULT_COMPRESSION);
+    if(ret != Z_OK)
+    {
+        return(-1);
+    }
 
+    /* while we have not finished consuming all of the uncompressed input data */
+    while(tmp_stream.avail_in)
+    {
+        if(tmp_stream.avail_out == 0)
+        {
+            /* We ran out of buffer space for compression.  In theory,
+             * we could just alloc more space, but probably just easier
+             * to bump up the default size of the output buffer.
+             */
+            deflateEnd(&tmp_stream);
+            return(-1);
+        }
+
+        /* compress data */
+        ret = deflate(&tmp_stream, Z_FINISH);
+        if(ret != Z_STREAM_END)
+        {
+            deflateEnd(&tmp_stream);
+            return(-1);
+        }
+
+        total_out += tmp_stream.total_out;
+        if(tmp_stream.avail_in)
+            deflateReset(&tmp_stream);
+    }
+    deflateEnd(&tmp_stream);
+
+    *inout_comp_buf_sz = total_out;
     return(0);
 }
 
+#ifdef HAVE_LIBBZ2
+static int darshan_bzip2_decomp(char* comp_buf, int comp_buf_sz,
+    char* decomp_buf, int* inout_decomp_buf_sz)
+{
+    return(-1);
+}
+
+static int darshan_bzip2_comp(char* decomp_buf, int decomp_buf_sz,
+    char* comp_buf, int* inout_comp_buf_sz)
+{
+    return(-1);
+}
+#endif
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/darshan-util/darshan-logutils.h b/darshan-util/darshan-logutils.h
index d00ab5f..f6b5d9f 100644
--- a/darshan-util/darshan-logutils.h
+++ b/darshan-util/darshan-logutils.h
@@ -27,6 +27,7 @@ struct darshan_fd_s
 {
     int fildes;
     int64_t pos;
+    enum darshan_comp_type comp_type;
     char version[8];
     int swap_flag;
     char *exe_mnt_data;
@@ -66,9 +67,10 @@ extern struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS];
 #include "darshan-hdf5-logutils.h"
 #include "darshan-pnetcdf-logutils.h"
 
-darshan_fd darshan_log_open(const char *name, const char* mode);
+darshan_fd darshan_log_open(const char *name);
+darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type);
 int darshan_log_getheader(darshan_fd fd, struct darshan_header *header);
-int darshan_log_putheader(darshan_fd fd, struct darshan_header *header);
+int darshan_log_putheader(darshan_fd fd);
 int darshan_log_getjob(darshan_fd fd, struct darshan_job *job);
 int darshan_log_putjob(darshan_fd fd, struct darshan_job *job);
 int darshan_log_getexe(darshan_fd fd, char *buf);
diff --git a/darshan-util/darshan-parser.c b/darshan-util/darshan-parser.c
index c5aacf9..ba4aa79 100644
--- a/darshan-util/darshan-parser.c
+++ b/darshan-util/darshan-parser.c
@@ -46,7 +46,7 @@ int main(int argc, char **argv)
     assert(argc == 2);
     filename = argv[1];
 
-    fd = darshan_log_open(filename, "r");
+    fd = darshan_log_open(filename);
     if(!fd)
     {
         fprintf(stderr, "darshan_log_open() failed to open %s\n.", filename);
@@ -246,6 +246,8 @@ int main(int argc, char **argv)
     if(empty_mods == DARSHAN_MAX_MODS)
         printf("# no module data available.\n");
 
+    free(mod_buf);
+
     /* free record hash data */
     HASH_ITER(hlink, rec_hash, ref, tmp)
     {
@@ -266,7 +268,6 @@ int main(int argc, char **argv)
         free(fs_types);
     }
 
-    free(mod_buf);
     darshan_log_close(fd);
 
     return(0);


hooks/post-receive
--



More information about the Darshan-commits mailing list