aboutsummaryrefslogtreecommitdiff
path: root/src/portal.cc
blob: 93fed0177d0446d6064494fe162f6ee60c014c52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// $Header$

#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "cctk_Version.h"
#include "util_Network.h"

#include "connection.hh"



extern "C"
void
Formaline_Portal (CCTK_ARGUMENTS)
{
  if (CCTK_MyProc (cctkGH) != 0) return;
  
  /* Create a unique job id */
  char const * restrict const jobid = "not unique";
  
  connection conn (jobid);
  
  
  
  /* Cactus */
  
  {
    char const * const cactus_version = CCTK_FullVersion();
    conn.store ("Cactus version", cactus_version);
  }
  
  
  
  /* Compiling */
  
  {
    char const * const compile_user = CCTK_CompileUser();
    conn.store ("compile user", compile_user);
  }
  
  {
    char const * const compile_date = CCTK_CompileDate();
    conn.store ("compile date", compile_date);
  }
  
  {
    char const * const compile_time = CCTK_CompileTime();
    conn.store ("compile time", compile_time);
  }
  
  
  
  /* Running */
  
  {
    char const * const run_user = CCTK_RunUser();
    conn.store ("run user", run_user);
  }
  
  {
    char run_date [1000];
    Util_CurrentDate (sizeof run_date, run_date);
    conn.store ("run date", run_date);
  }
  
  {
    char run_time [1000];
    Util_CurrentTime (sizeof run_time, run_time);
    conn.store ("run time", run_time);
  }
  
  {
    char run_host [1000];
    Util_GetHostName (run_host, sizeof run_host);
    conn.store ("run host", run_host);
  }
  
  {
    int type;
    void const * const ptr
      = CCTK_ParameterGet ("run_title", "Cactus", & type);
    assert (type == CCTK_VARIABLE_STRING);
    char const * const run_title = static_cast<char const *> (ptr);
    conn.store ("run title", run_title);
  }
  
  
  
  /* Parameters */
  
  {
    char ** argv;
    int argc;
    int n;
    CCTK_CommandLine (& argv);
    for (argc = 0; argv [argc]; ++ argc);
    conn.store ("argc", argc);
    for (n = 0; n < argc; ++ n)
    {
      char buffer [1000];
      snprintf (buffer, sizeof buffer, "argv[%d]", n);
      conn.store (buffer, argv[n]);
    }
  }
  
  {
    char parameter_filename [10000];
    CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
    conn.store ("parameter filename", parameter_filename);
  }
  
  {
    char parameter_filename [10000];
    char parameter_file [1000000];
    size_t count;
    FILE * file;
    CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename);
    file = fopen (parameter_filename, "r");
    count = fread (parameter_file, 1, sizeof parameter_file - 1, file);
    fclose (file);
    assert (count < sizeof parameter_file - 1);
    parameter_file [count] = '\0';
    conn.store ("parameter file", parameter_file);
  }
  
  {
    int type;
    void const * const ptr
      = CCTK_ParameterGet ("out_dir", "IO", & type);
    assert (type == CCTK_VARIABLE_STRING);
    char const * const out_dir = static_cast<char const *> (ptr);
    conn.store ("out dir", out_dir);
  }
  
  {
    int nprocs;
    nprocs = CCTK_nProcs (cctkGH);
    conn.store ("nprocs", nprocs);
  }
  
}