From 9a4be9e7627bd4ee0426d121a45b98e8aed45795 Mon Sep 17 00:00:00 2001
From: David Bigagli <david@schedmd.com>
Date: Tue, 30 Jul 2013 17:10:51 -0700
Subject: [PATCH] Print the header in the csv file only once, set the debug
 messages at debug() level, make the argument check case insensitive, avoid
 printing duplicate \n.

---
 .../hdf5/sh5util/sh5util.c                    | 26 ++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c b/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
index 5f2b66bd58d..ca2745c5306 100644
--- a/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
+++ b/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
@@ -1074,6 +1074,7 @@ static void _extract_data()
 		return;
 	}
 	nsteps = get_int_attribute(jgid_root, ATTR_NSTEPS);
+	header = true;
 	for (stepx=0; stepx<nsteps; stepx++) {
 		if ((params.step_id != -1) && (stepx != params.step_id))
 			continue;
@@ -1119,13 +1120,14 @@ static void _extract_data()
 			H5Gclose(jgid_node);
 			if (!params.series || !strcmp(params.series, "*")) {
 				for (isx=0; isx<num_series; isx++) {
-					_extract_node_level(
-						fp, stepx, jgid_nodes,
-						nnodes, true,
-						series_names[isx]);
+					_extract_node_level(fp, stepx, jgid_nodes,
+					                    nnodes, header,
+					                    series_names[isx]);
+					header = false;
+
 				}
-			} else if (!strcmp(params.series, GRP_TASKS)) {
-				header = true;
+			} else if (strcasecmp(params.series, GRP_TASKS) == 0
+			           || strcasecmp(params.series, GRP_TASK) == 0) {
 				for (isx=0; isx<num_series; isx++) {
 					if (strstr(series_names[isx],
 						   GRP_TASK)) {
@@ -1138,8 +1140,8 @@ static void _extract_data()
 				}
 			} else {
 				_extract_node_level(fp, stepx, jgid_nodes,
-						    nnodes, true,
-						    params.series);
+				                    nnodes, true,
+				                    params.series);
 			}
 			_delete_string_list(series_names, num_series);
 			series_names = NULL;
@@ -1168,13 +1170,13 @@ int main (int argc, char **argv)
 	profile_init();
 	switch (params.mode) {
 	case SH5UTIL_MODE_MERGE:
-		info("Merging node-step files into %s",
-		     params.output);
+		debug("Merging node-step files into %s",
+		      params.output);
 		_merge_step_files();
 		break;
 	case SH5UTIL_MODE_EXTRACT:
-		info("Extracting job data from %s into %s\n",
-		     params.input, params.output);
+		debug("Extracting job data from %s into %s",
+		      params.input, params.output);
 		_extract_data();
 		break;
 	default:
-- 
GitLab