deal.II version GIT relicensing-2577-g108be0c5b5 2025-02-07 13:10:00+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: 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#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 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:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499