[Darshan-commits] [Darshan] branch, master, updated. darshan-2.3.1-pre1-3-gc768c10

Service Account git at mcs.anl.gov
Wed Jan 7 15:33:47 CST 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, master has been updated
       via  c768c10e29b9a89b17ccae91b029c32a22cc66d0 (commit)
      from  f32fc8df6dcfada5071e9b1f2a3939d940b4e056 (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 c768c10e29b9a89b17ccae91b029c32a22cc66d0
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Wed Jan 7 15:33:16 2015 -0600

    add support for user specified logfile path

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

Summary of changes:
 darshan-runtime/doc/darshan-runtime.txt |    3 +-
 darshan-runtime/lib/darshan-mpi-io.c    |  238 +++++++++++++++++--------------
 2 files changed, 134 insertions(+), 107 deletions(-)


Diff of changes:
diff --git a/darshan-runtime/doc/darshan-runtime.txt b/darshan-runtime/doc/darshan-runtime.txt
index ade9171..5864574 100644
--- a/darshan-runtime/doc/darshan-runtime.txt
+++ b/darshan-runtime/doc/darshan-runtime.txt
@@ -414,4 +414,5 @@ behavior at runtime:
 in which files that were accessed by all ranks are collapsed into a single
 cumulative file record at rank 0.  This option retains more per-process
 information at the expense of creating larger log files.
-
+* DARSHAN_LOGPATH: specifies the path to write Darshan log files to. Note that this directory needs to be formatted using the darshan-mk-log-dirs script.
+* DARSHAN_LOGFILE: specifies the path (directory + Darshan log file name) to write the output Darshan log to. This overrides the default Darshan behavior of automatically generating a log file name and adding to a log file directory formatted using darshan-mk-log-dirs script.
diff --git a/darshan-runtime/lib/darshan-mpi-io.c b/darshan-runtime/lib/darshan-mpi-io.c
index 7f880f5..3b37a24 100644
--- a/darshan-runtime/lib/darshan-mpi-io.c
+++ b/darshan-runtime/lib/darshan-mpi-io.c
@@ -278,6 +278,7 @@ void darshan_shutdown(int timing_flag)
     int all_ret = 0;
     int local_ret = 0;
     MPI_Offset next_offset = 0;
+    char* user_logfile_name;
     char* jobid_str;
     char* envjobid;
     char* logpath;
@@ -366,9 +367,6 @@ void darshan_shutdown(int timing_flag)
     /* construct log file name */
     if(rank == 0)
     {
-        char cuser[L_cuserid] = {0};
-        struct tm* my_tm;
-
         /* Use CP_JOBID_OVERRIDE for the env var or CP_JOBID */
         envjobid = getenv(CP_JOBID_OVERRIDE);
         if (!envjobid)
@@ -376,15 +374,6 @@ void darshan_shutdown(int timing_flag)
             envjobid = CP_JOBID;
         }
 
-        /* Use CP_LOG_PATH_OVERRIDE for the value or __CP_LOG_PATH */
-        logpath = getenv(CP_LOG_PATH_OVERRIDE);
-        if (!logpath)
-        {
-#ifdef __CP_LOG_PATH
-            logpath = __CP_LOG_PATH;
-#endif
-        }
-
         /* find a job id */
         jobid_str = getenv(envjobid);
         if(jobid_str)
@@ -398,122 +387,150 @@ void darshan_shutdown(int timing_flag)
             jobid = getpid();
         }
 
-        /* break out time into something human readable */
-        start_time_tmp += final_job->log_job.start_time;
-        my_tm = localtime(&start_time_tmp);
-
-        /* get the username for this job.  In order we will try each of the
-         * following until one of them succeeds:
-         *
-         * - cuserid()
-         * - getenv("LOGNAME")
-         * - snprintf(..., geteuid());
-         *
-         * Note that we do not use getpwuid() because it generally will not
-         * work in statically compiled binaries.
-         */
+        /* add jobid to darshan runtime info */
+        final_job->log_job.jobid = (int64_t)jobid;
+
+        /* if user specifies a logfile name (and path), use that. otherwise automatically generate */
+        user_logfile_name = getenv("DARSHAN_LOGFILE");
+        if(user_logfile_name)
+        {
+            if(strlen(user_logfile_name) >= PATH_MAX)
+            {
+                logfile_name[0] = '\0';
+                fprintf(stderr, "darshan library warning: user given log file path too long\n");
+            }
+            else
+            {
+                strncpy(logfile_name, user_logfile_name, PATH_MAX);
+            }
+        }
+        else
+        {
+            char cuser[L_cuserid] = {0};
+            struct tm* my_tm;
+
+            /* Use CP_LOG_PATH_OVERRIDE for the value or __CP_LOG_PATH */
+            logpath = getenv(CP_LOG_PATH_OVERRIDE);
+            if (!logpath)
+            {
+#ifdef __CP_LOG_PATH
+                logpath = __CP_LOG_PATH;
+#endif
+            }
+
+            /* break out time into something human readable */
+            start_time_tmp += final_job->log_job.start_time;
+            my_tm = localtime(&start_time_tmp);
+
+            /* get the username for this job.  In order we will try each of the
+             * following until one of them succeeds:
+             *
+             * - cuserid()
+             * - getenv("LOGNAME")
+             * - snprintf(..., geteuid());
+             *
+             * Note that we do not use getpwuid() because it generally will not
+             * work in statically compiled binaries.
+             */
 
 #ifndef DARSHAN_DISABLE_CUSERID
-        cuserid(cuser);
+            cuserid(cuser);
 #endif
 
-        /* if cuserid() didn't work, then check the environment */
-        if (strcmp(cuser, "") == 0)
-        {
-            char* logname_string;
-            logname_string = getenv("LOGNAME");
-            if(logname_string)
+            /* if cuserid() didn't work, then check the environment */
+            if (strcmp(cuser, "") == 0)
             {
-                strncpy(cuser, logname_string, (L_cuserid-1));
-            }
+                char* logname_string;
+                logname_string = getenv("LOGNAME");
+                if(logname_string)
+                {
+                    strncpy(cuser, logname_string, (L_cuserid-1));
+                }
 
-        }
+            }
 
-        /* if cuserid() and environment both fail, then fall back to uid */
-        if (strcmp(cuser, "") == 0)
-        {
-            uid_t uid = geteuid();
-            snprintf(cuser, sizeof(cuser), "%u", uid);
-        }
+            /* if cuserid() and environment both fail, then fall back to uid */
+            if (strcmp(cuser, "") == 0)
+            {
+                uid_t uid = geteuid();
+                snprintf(cuser, sizeof(cuser), "%u", uid);
+            }
 
-        /* generate a random number to help differentiate the log */
-        hlevel=DARSHAN_MPI_CALL(PMPI_Wtime)() * 1000000;
-        (void) gethostname(hname, sizeof(hname));
-        logmod = darshan_hash((void*)hname,strlen(hname),hlevel);
+            /* generate a random number to help differentiate the log */
+            hlevel=DARSHAN_MPI_CALL(PMPI_Wtime)() * 1000000;
+            (void) gethostname(hname, sizeof(hname));
+            logmod = darshan_hash((void*)hname,strlen(hname),hlevel);
 
-        /* see if darshan was configured using the --with-logpath-by-env
-         * argument, which allows the user to specify an absolute path to
-         * place logs via an env variable.
-         */
+            /* see if darshan was configured using the --with-logpath-by-env
+             * argument, which allows the user to specify an absolute path to
+             * place logs via an env variable.
+             */
 #ifdef __CP_LOG_ENV
-        /* just silently skip if the environment variable list is too big */
-        if(strlen(__CP_LOG_ENV) < 256)
-        {
-            /* copy env variable list to a temporary buffer */
-            strcpy(env_check, __CP_LOG_ENV);
-            /* tokenize the comma-separated list */
-            env_tok = strtok(env_check, ",");
-            if(env_tok)
+            /* just silently skip if the environment variable list is too big */
+            if(strlen(__CP_LOG_ENV) < 256)
             {
-                do
+                /* copy env variable list to a temporary buffer */
+                strcpy(env_check, __CP_LOG_ENV);
+                /* tokenize the comma-separated list */
+                env_tok = strtok(env_check, ",");
+                if(env_tok)
                 {
-                    /* check each env variable in order */
-                    logpath_override = getenv(env_tok); 
-                    if(logpath_override)
+                    do
                     {
-                        /* stop as soon as we find a match */
-                        break;
-                    }
-                }while((env_tok = strtok(NULL, ",")));
+                        /* check each env variable in order */
+                        logpath_override = getenv(env_tok); 
+                        if(logpath_override)
+                        {
+                            /* stop as soon as we find a match */
+                            break;
+                        }
+                    }while((env_tok = strtok(NULL, ",")));
+                }
             }
-        }
 #endif
-
-       
-        if(logpath_override)
-        {
-            ret = snprintf(logfile_name, PATH_MAX, 
-                "%s/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial",
-                logpath_override, 
-                cuser, __progname, jobid,
-                (my_tm->tm_mon+1), 
+           
+            if(logpath_override)
+            {
+                ret = snprintf(logfile_name, PATH_MAX, 
+                    "%s/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial",
+                    logpath_override, 
+                    cuser, __progname, jobid,
+                    (my_tm->tm_mon+1), 
                 my_tm->tm_mday, 
                 (my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec),
                 logmod);
-            if(ret == (PATH_MAX-1))
+                if(ret == (PATH_MAX-1))
+                {
+                    /* file name was too big; squish it down */
+                    snprintf(logfile_name, PATH_MAX,
+                        "%s/id%d.darshan_partial",
+                        logpath_override, jobid);
+                }
+            }
+            else if(logpath)
             {
-                /* file name was too big; squish it down */
-                snprintf(logfile_name, PATH_MAX,
-                    "%s/id%d.darshan_partial",
-                    logpath_override, jobid);
+                ret = snprintf(logfile_name, PATH_MAX, 
+                    "%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial",
+                    logpath, (my_tm->tm_year+1900), 
+                    (my_tm->tm_mon+1), my_tm->tm_mday, 
+                    cuser, __progname, jobid,
+                    (my_tm->tm_mon+1), 
+                    my_tm->tm_mday, 
+                    (my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec),
+                    logmod);
+                if(ret == (PATH_MAX-1))
+                {
+                    /* file name was too big; squish it down */
+                    snprintf(logfile_name, PATH_MAX,
+                        "%s/id%d.darshan_partial",
+                        logpath, jobid);
+                }
             }
-        }
-        else if(logpath)
-        {
-            ret = snprintf(logfile_name, PATH_MAX, 
-                "%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%" PRIu64 ".darshan_partial",
-                logpath, (my_tm->tm_year+1900), 
-                (my_tm->tm_mon+1), my_tm->tm_mday, 
-                cuser, __progname, jobid,
-                (my_tm->tm_mon+1), 
-                my_tm->tm_mday, 
-                (my_tm->tm_hour*60*60 + my_tm->tm_min*60 + my_tm->tm_sec),
-                logmod);
-            if(ret == (PATH_MAX-1))
+            else
             {
-                /* file name was too big; squish it down */
-                snprintf(logfile_name, PATH_MAX,
-                    "%s/id%d.darshan_partial",
-                    logpath, jobid);
+                logfile_name[0] = '\0';
             }
         }
-        else
-        {
-            logfile_name[0] = '\0';
-        }
-
-        /* add jobid */
-        final_job->log_job.jobid = (int64_t)jobid;
     }
 
     /* broadcast log file name */
@@ -525,7 +542,7 @@ void darshan_shutdown(int timing_flag)
     {
         /* failed to generate log file name */
         darshan_finalize(final_job);
-	return;
+        return;
     }
 
     final_job->log_job.end_time = time(NULL);
@@ -609,6 +626,15 @@ void darshan_shutdown(int timing_flag)
              */
             unlink(logfile_name);
         }
+        else if (user_logfile_name)
+        {
+            /* we do not need to rename file, just change the permissions */
+#ifdef __CP_GROUP_READABLE_LOGS
+            chmod(user_logfile_name, (S_IRUSR|S_IRGRP));
+#else
+            chmod(user_logfile_name, (S_IRUSR));
+#endif
+        }
         else
         {
             /* rename from *.darshan_partial to *-<logwritetime>.darshan.gz,


hooks/post-receive
--



More information about the Darshan-commits mailing list