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