Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
job_identifier.cc
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 1998 - 2018 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
17
18#include <ctime>
19
20#ifdef DEAL_II_HAVE_UNISTD_H
21# include <unistd.h>
22#endif
23
25
26
27const JobIdentifier &
29{
30 static JobIdentifier dealjobid;
31 return dealjobid;
32}
33
34
35
37{
38 time_t t = std::time(nullptr);
39 id = std::string("JobId ");
40
41#if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
42 char name[100];
43 gethostname(name, 99);
44 id += std::string(name) + std::string(" ");
45#else
46 id += std::string("unknown ");
47#endif
48
49 id += std::string(std::ctime(&t));
50}
51
52
53const std::string
55{
56 return id;
57}
58
59
60std::string
61JobIdentifier::base_name(const std::string &filename)
62{
63 std::string name(filename);
64 std::string::size_type pos;
65 pos = name.rfind('/');
66 if (pos != std::string::npos)
67 name.erase(0, pos + 1);
68 pos = name.rfind('.');
69 if (pos != std::string::npos)
70 name.erase(pos, name.size());
71 return name;
72}
73
74
75
static const JobIdentifier & get_dealjobid()
std::string id
static std::string base_name(const std::string &filename)
const std::string operator()() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473