MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Classes | Functions
stats.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  OutputFD
 

Functions

void set_stats_params (ParameterSet *ps)
 
void open_outputfiles (int RestartSnapNum, struct OutputFD *fds, const char *OutputDir, int BlackHoleOn, int StarformationOn)
 
void close_outputfiles (struct OutputFD *fds)
 
void write_cpu_log (int NumCurrentTiStep, const double atime, FILE *FdCPU, double ElapsedTime)
 
void energy_statistics (FILE *FdEnergy, const double Time, struct part_manager_type *PartManager)
 

Function Documentation

◆ close_outputfiles()

void close_outputfiles ( struct OutputFD fds)

This function closes the global log-files.

Definition at line 150 of file stats.c.

151 {
152  if(fds->FdCPU)
153  fclose(fds->FdCPU);
154  if(fds->FdEnergy)
155  fclose(fds->FdEnergy);
156  if(fds->FdSfr)
157  fclose(fds->FdSfr);
158  if(fds->FdBlackHoles)
159  fclose(fds->FdBlackHoles);
160  if(fds->FdBlackholeDetails)
161  fclose(fds->FdBlackholeDetails);
162 }
FILE * FdBlackHoles
Definition: stats.h:12
FILE * FdBlackholeDetails
Definition: stats.h:13
FILE * FdEnergy
Definition: stats.h:9
FILE * FdSfr
Definition: stats.h:11
FILE * FdCPU
Definition: stats.h:10

References OutputFD::FdBlackholeDetails, OutputFD::FdBlackHoles, OutputFD::FdCPU, OutputFD::FdEnergy, and OutputFD::FdSfr.

Referenced by run().

Here is the caller graph for this function:

◆ energy_statistics()

void energy_statistics ( FILE *  FdEnergy,
const double  Time,
struct part_manager_type PartManager 
)

This routine first calls a computation of various global quantities of the particle distribution, and then writes some statistics about the energies in the various particle components to the file FdEnergy.

Definition at line 334 of file stats.c.

335 {
336  if(!FdEnergy)
337  return;
338 
340 
341  message(0, "Time %g Mean Temperature of Gas %g\n",
342  Time, SysState.TemperatureComp[0]);
343 
344  fprintf(FdEnergy,
345  "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g\n",
346  Time, SysState.TemperatureComp[0], SysState.EnergyInt, SysState.EnergyPot, SysState.EnergyKin, SysState.EnergyIntComp[0],
347  SysState.EnergyPotComp[0], SysState.EnergyKinComp[0], SysState.EnergyIntComp[1],
348  SysState.EnergyPotComp[1], SysState.EnergyKinComp[1], SysState.EnergyIntComp[2],
349  SysState.EnergyPotComp[2], SysState.EnergyKinComp[2], SysState.EnergyIntComp[3],
350  SysState.EnergyPotComp[3], SysState.EnergyKinComp[3], SysState.EnergyIntComp[4],
351  SysState.EnergyPotComp[4], SysState.EnergyKinComp[4], SysState.EnergyIntComp[5],
352  SysState.EnergyPotComp[5], SysState.EnergyKinComp[5], SysState.MassComp[0],
353  SysState.MassComp[1], SysState.MassComp[2], SysState.MassComp[3], SysState.MassComp[4],
354  SysState.MassComp[5]);
355 
356  fflush(FdEnergy);
357 }
void message(int where, const char *fmt,...)
Definition: endrun.c:175
struct part_manager_type PartManager[1]
Definition: partmanager.c:11
struct state_of_system compute_global_quantities_of_system(const double Time, struct part_manager_type *PartManager)
Definition: stats.c:185
double MassComp[6]
Definition: stats.c:31
double EnergyKinComp[6]
Definition: stats.c:35
double EnergyInt
Definition: stats.c:25
double EnergyKin
Definition: stats.c:23
double TemperatureComp[6]
Definition: stats.c:33
double EnergyPot
Definition: stats.c:24
double EnergyPotComp[6]
Definition: stats.c:36
double EnergyIntComp[6]
Definition: stats.c:37

References compute_global_quantities_of_system(), state_of_system::EnergyInt, state_of_system::EnergyIntComp, state_of_system::EnergyKin, state_of_system::EnergyKinComp, state_of_system::EnergyPot, state_of_system::EnergyPotComp, state_of_system::MassComp, message(), PartManager, and state_of_system::TemperatureComp.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_outputfiles()

void open_outputfiles ( int  RestartSnapNum,
struct OutputFD fds,
const char *  OutputDir,
int  BlackHoleOn,
int  StarformationOn 
)

This function opens various log-files that report on the status and performance of the simulstion. On restart from restart-files (start-option 1), the code will append to these files.

Definition at line 73 of file stats.c.

74 {
75  const char mode[3]="a+";
76  char * buf;
77  char * postfix;
78  int ThisTask;
79  MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
80  memset(fds, 0, sizeof(struct OutputFD));
81  fds->FdCPU = NULL;
82  fds->FdEnergy = NULL;
83  fds->FdBlackHoles = NULL;
84  fds->FdSfr = NULL;
85  fds->FdBlackholeDetails = NULL;
86  fds->FdHelium = NULL;
87 
88  if(RestartSnapNum != -1) {
89  postfix = fastpm_strdup_printf("-R%03d", RestartSnapNum);
90  } else {
91  postfix = fastpm_strdup_printf("%s", "");
92  }
93 
94  /* all the processors write to separate files*/
95  if(BlackHoleOn && StatsParams.WriteBlackHoleDetails){
96  buf = fastpm_strdup_printf("%s/%s%s/%06X", OutputDir,"BlackholeDetails",postfix,ThisTask);
98  if(!(fds->FdBlackholeDetails = fopen(buf,"a")))
99  endrun(1, "Failed to open blackhole detail %s\n", buf);
100  myfree(buf);
101  }
102 
103  /* only the root processors writes to the log files */
104  if(ThisTask != 0) {
105  return;
106  }
107 
108  if(BlackHoleOn) {
109  buf = fastpm_strdup_printf("%s/%s%s", OutputDir, "blackholes.txt", postfix);
111  if(!(fds->FdBlackHoles = fopen(buf, mode)))
112  endrun(1, "error in opening file '%s'\n", buf);
113  myfree(buf);
114  }
115 
116  buf = fastpm_strdup_printf("%s/%s%s", OutputDir, StatsParams.CpuFile, postfix);
118  if(!(fds->FdCPU = fopen(buf, mode)))
119  endrun(1, "error in opening file '%s'\n", buf);
120  myfree(buf);
121 
123  buf = fastpm_strdup_printf("%s/%s%s", OutputDir, StatsParams.EnergyFile, postfix);
125  if(!(fds->FdEnergy = fopen(buf, mode)))
126  endrun(1, "error in opening file '%s'\n", buf);
127  myfree(buf);
128  }
129 
130  if(StarformationOn) {
131  buf = fastpm_strdup_printf("%s/%s%s", OutputDir, "sfr.txt", postfix);
133  if(!(fds->FdSfr = fopen(buf, mode)))
134  endrun(1, "error in opening file '%s'\n", buf);
135  myfree(buf);
136  }
137 
138  if(qso_lightup_on()) {
139  buf = fastpm_strdup_printf("%s/%s%s", OutputDir, "helium.txt", postfix);
141  if(!(fds->FdHelium = fopen(buf, mode)))
142  endrun(1, "error in opening file '%s'\n", buf);
143  myfree(buf);
144  }
145 }
int qso_lightup_on(void)
void endrun(int where, const char *fmt,...)
Definition: endrun.c:147
#define myfree(x)
Definition: mymalloc.h:19
static struct stats_params StatsParams
void fastpm_path_ensure_dirname(const char *path)
Definition: string.c:70
char * fastpm_strdup_printf(const char *fmt,...)
Definition: string.c:41
Definition: stats.h:8
FILE * FdHelium
Definition: stats.h:14
char CpuFile[100]
Definition: stats.c:48
char EnergyFile[100]
Definition: stats.c:47
int OutputEnergyDebug
Definition: stats.c:50
int WriteBlackHoleDetails
Definition: stats.c:51
int ThisTask
Definition: test_exchange.c:23

References stats_params::CpuFile, endrun(), stats_params::EnergyFile, fastpm_path_ensure_dirname(), fastpm_strdup_printf(), OutputFD::FdBlackholeDetails, OutputFD::FdBlackHoles, OutputFD::FdCPU, OutputFD::FdEnergy, OutputFD::FdHelium, OutputFD::FdSfr, myfree, stats_params::OutputEnergyDebug, qso_lightup_on(), StatsParams, ThisTask, and stats_params::WriteBlackHoleDetails.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_stats_params()

void set_stats_params ( ParameterSet ps)

Definition at line 55 of file stats.c.

56 {
57  int ThisTask;
58  MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
59  if(ThisTask == 0) {
61  param_get_string2(ps, "CpuFile", StatsParams.CpuFile, sizeof(StatsParams.CpuFile));
62  StatsParams.OutputEnergyDebug = param_get_int(ps, "OutputEnergyDebug");
63  StatsParams.WriteBlackHoleDetails = param_get_int(ps,"WriteBlackHoleDetails");
64  }
65  MPI_Bcast(&StatsParams, sizeof(struct stats_params), MPI_BYTE, 0, MPI_COMM_WORLD);
66 }
void param_get_string2(ParameterSet *ps, const char *name, char *dst, size_t len)
Definition: paramset.c:355
int param_get_int(ParameterSet *ps, const char *name)
Definition: paramset.c:368

References stats_params::CpuFile, stats_params::EnergyFile, stats_params::OutputEnergyDebug, param_get_int(), param_get_string2(), StatsParams, ThisTask, and stats_params::WriteBlackHoleDetails.

Referenced by read_parameter_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_cpu_log()

void write_cpu_log ( int  NumCurrentTiStep,
const double  atime,
FILE *  FdCPU,
double  ElapsedTime 
)

Definition at line 165 of file stats.c.

166 {
167  walltime_summary(0, MPI_COMM_WORLD);
168 
169  if(FdCPU)
170  {
171  int NTask;
172  MPI_Comm_size(MPI_COMM_WORLD, &NTask);
173  fprintf(FdCPU, "Step %d, Time: %g, MPIs: %d Threads: %d Elapsed: %g\n", NumCurrentTiStep, atime, NTask, omp_get_max_threads(), ElapsedTime);
174  walltime_report(FdCPU, 0, MPI_COMM_WORLD);
175  fflush(FdCPU);
176  }
177 }
int NTask
Definition: test_exchange.c:23
void walltime_summary(int root, MPI_Comm comm)
Definition: walltime.c:55
void walltime_report(FILE *fp, int root, MPI_Comm comm)
Definition: walltime.c:220

Referenced by run().

Here is the caller graph for this function: