HPhi++  3.1.0
log.cpp
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 
4 /* This program is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation, either version 3 of the License, or */
7 /* (at your option) any later version. */
8 
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13 
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 
17 #include <ctime>
18 #include "Common.hpp"
19 #include "log.hpp"
20 #include "FileIO.hpp"
21 
41 int TimeKeeper
42 (
43  struct BindStruct *X,
44  const char *cFileName,
45  const char *cTimeKeeper_Message,
46  const char *cWriteType
47  )
48 {
49  FILE *fp;
50  char sdt[D_FileNameMax];
51  struct tm *area;
52  time_t tx;
53 
54  sprintf(sdt, cFileName, X->Def.CDataFileHead);
55  tx = time(NULL);
56  area = localtime(&tx);
57  if(childfopenMPI(sdt, cWriteType, &fp)!=0){
58  return -1;
59  }
60  fprintf(fp, cTimeKeeper_Message, asctime(area));
61  fclose(fp);
62  return 0;
63 }
64 
78 (
79  struct BindStruct *X,
80  const char *cFileName,
81  const char *cTimeKeeper_Message,
82  const char *cWriteType,
83  const int istep
84  )
85 {
86  FILE *fp;
87  char sdt[D_FileNameMax];
88  struct tm *area;
89  time_t tx;
90 
91  sprintf(sdt, cFileName, X->Def.CDataFileHead);
92  tx = time(NULL);
93  area = localtime(&tx);
94  if(childfopenMPI(sdt, cWriteType, &fp)!=0){
95  return -1;
96  }
97  fprintf(fp, cTimeKeeper_Message, istep, asctime(area));
98  fclose(fp);
99  return 0;
100 }
101 
102 
117 (
118  struct BindStruct *X,
119  const char *cFileName,
120  const char *cTimeKeeper_Message,
121  const char *cWriteType,
122  const int irand,
123  const int istep
124  ){
125  FILE *fp;
126  char sdt[D_FileNameMax];
127  struct tm *area;
128  time_t tx;
129 
130  sprintf(sdt, cFileName, X->Def.CDataFileHead);
131  tx = time(NULL);
132  area = localtime(&tx);
133  if(childfopenMPI(sdt, cWriteType, &fp)!=0){
134  return -1;
135  }
136  fprintf(fp, cTimeKeeper_Message, irand, istep, asctime(area));
137  fclose(fp);
138  return 0;
139 
140 }
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
int TimeKeeperWithStep(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType, const int istep)
Functions for writing a time log.
Definition: log.cpp:78
int TimeKeeperWithRandAndStep(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType, const int irand, const int istep)
Functions for writing a time log.
Definition: log.cpp:117
Bind.
Definition: struct.hpp:394
int TimeKeeper(struct BindStruct *X, const char *cFileName, const char *cTimeKeeper_Message, const char *cWriteType)
Functions for writing a time log.
Definition: log.cpp:42
char * CDataFileHead
Read from Calcmod in readdef.h. Header of output file such as Green&#39;s function.
Definition: struct.hpp:42
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
Definition: FileIO.cpp:27