Reference documentation for deal.II version 9.6.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// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1998 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
16
17#include <ctime>
18
19#ifdef DEAL_II_HAVE_UNISTD_H
20# include <unistd.h>
21#endif
22
24
25
26const JobIdentifier &
28{
29 static JobIdentifier dealjobid;
30 return dealjobid;
31}
32
33
34
36{
37 time_t t = std::time(nullptr);
38 id = std::string("JobId ");
39
40#if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
41 char name[100];
42 gethostname(name, 99);
43 id += std::string(name) + std::string(" ");
44#else
45 id += std::string("unknown ");
46#endif
47
48 id += std::string(std::ctime(&t));
49}
50
51
52std::string
54{
55 return id;
56}
57
58
59std::string
60JobIdentifier::base_name(const std::string &filename)
61{
62 std::string name(filename);
63 std::string::size_type pos;
64 pos = name.rfind('/');
65 if (pos != std::string::npos)
66 name.erase(0, pos + 1);
67 pos = name.rfind('.');
68 if (pos != std::string::npos)
69 name.erase(pos, name.size());
70 return name;
71}
72
73
74
static const JobIdentifier & get_dealjobid()
std::string id
static std::string base_name(const std::string &filename)
std::string operator()() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504