/*! This routine writes one line for every timestep to two log-files. In * FdInfo, we just list the timesteps that have been done, while in FdCPU the * cumulative cpu-time consumption in various parts of the code is stored. */ void every_timestep_stuff(void) { double z; if(ThisTask == 0) { if(All.ComovingIntegrationOn) { z = 1.0 / (All.Time) - 1; fprintf(FdInfo, "\nBegin Step %d, Time: %15.11g, Redshift: %g, Systemstep: %g, Dloga: %g\n", All.NumCurrentTiStep, All.Time, z, All.TimeStep, log(All.Time) - log(All.Time - All.TimeStep)); printf("\nBegin Step %d, Time: %15.11g, Redshift: %g, Systemstep: %g, Dloga: %g\n", All.NumCurrentTiStep, All.Time, z, All.TimeStep, log(All.Time) - log(All.Time - All.TimeStep)); fflush(FdInfo); } else { fprintf(FdInfo, "\nBegin Step %d, Time: %15.11g, Systemstep: %g\n", All.NumCurrentTiStep, All.Time, All.TimeStep); printf("\nBegin Step %d, Time: %15.11g, Systemstep: %g\n", All.NumCurrentTiStep, All.Time, All.TimeStep); fflush(FdInfo); } fprintf(FdCPU, "Step %d, Time: %g, CPUs: %d\n", All.NumCurrentTiStep, All.Time, NTask); fprintf(FdCPU, "%10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f ", All.CPU_Total, All.CPU_Gravity, All.CPU_Hydro, All.CPU_Domain, All.CPU_Potential, All.CPU_Predict, All.CPU_TimeLine, All.CPU_Snapshot, All.CPU_TreeWalk, All.CPU_TreeConstruction, All.CPU_CommSum, All.CPU_Imbalance, All.CPU_HydCompWalk, All.CPU_HydCommSumm, All.CPU_HydImbalance, All.CPU_EnsureNgb, All.CPU_PM, All.CPU_Peano, All.CPU_Sinks); #ifdef TURBULENCE fprintf(FdCPU, "%10.2f ", All.CPU_Turbulence); #endif #ifdef CHEMCOOL fprintf(FdCPU, "%10.2f ", All.CPU_Chemcool); #ifdef RAYTRACE fprintf(FdCPU, "%10.2f ", All.CPU_Raytrace); #endif /* RAYTRACE */ #endif /* CHEMCOOL */ fprintf(FdCPU, "\n"); fflush(FdCPU); } set_random_numbers(); }
/*! This routine writes one line for every timestep to two log-files. In * FdInfo, we just list the timesteps that have been done, while in FdCPU the * cumulative cpu-time consumption in various parts of the code is stored. */ void every_timestep_stuff(void) { double z; if(ThisTask == 0) { if(All.ComovingIntegrationOn) { z = 1.0 / (All.Time) - 1; fprintf(FdInfo, "\nBegin Step %d, Time: %g, Redshift: %g, Systemstep: %g, Dloga: %g\n", All.NumCurrentTiStep, All.Time, z, All.TimeStep, log(All.Time) - log(All.Time - All.TimeStep)); printf("\nBegin Step %d, Time: %g, Redshift: %g, Systemstep: %g, Dloga: %g\n", All.NumCurrentTiStep, All.Time, z, All.TimeStep, log(All.Time) - log(All.Time - All.TimeStep)); fflush(FdInfo); } else { fprintf(FdInfo, "\nBegin Step %d, Time: %g, Systemstep: %g\n", All.NumCurrentTiStep, All.Time, All.TimeStep); printf("\nBegin Step %d, Time: %g, Systemstep: %g\n", All.NumCurrentTiStep, All.Time, All.TimeStep); fflush(FdInfo); } fprintf(FdCPU, "Step %d, Time: %g, CPUs: %d\n", All.NumCurrentTiStep, All.Time, NTask); fprintf(FdCPU, "%10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f\n", All.CPU_Total, All.CPU_Gravity, All.CPU_Hydro, All.CPU_Domain, All.CPU_Potential, All.CPU_Predict, All.CPU_TimeLine, All.CPU_Snapshot, All.CPU_TreeWalk, All.CPU_TreeConstruction, All.CPU_CommSum, All.CPU_Imbalance, All.CPU_HydCompWalk, All.CPU_HydCommSumm, All.CPU_HydImbalance, All.CPU_EnsureNgb, All.CPU_PM, All.CPU_Peano); fflush(FdCPU); } set_random_numbers(); }
void lineofsight_output(void) { char buf[500]; int n, s, next; double ti; next = find_next_lineofsighttime(All.Ti_nextlineofsight); ti = All.TimeBegin * exp(next * All.Timebase_interval); if(ThisTask == 0) { printf("Line of sight output! ThisTask=%d Time=%g NextTime=%g\n", ThisTask, All.Time, ti); fflush(stdout); } H_a = hubble_function(All.Time); Wmax = All.Time * H_a * All.BoxSize; if(ThisTask == 0) { sprintf(buf, "%s/los", All.OutputDir); mkdir(buf, 02755); } Los = mymalloc(sizeof(struct line_of_sight)); LosGlobal = mymalloc(sizeof(struct line_of_sight)); for(n = 0, s = 0; n < N_LOS; n++) { if(s + 3 >= RNDTABLE) { set_random_numbers(); s = 0; } Los->zaxis = (int) (3.0 * get_random_number(s++)); switch (Los->zaxis) { case 2: Los->xaxis = 0; Los->yaxis = 1; break; case 0: Los->xaxis = 1; Los->yaxis = 2; break; case 1: Los->xaxis = 2; Los->yaxis = 0; break; } Los->Xpos = All.BoxSize * get_random_number(s++); Los->Ypos = All.BoxSize * get_random_number(s++); #ifdef OUTPUTLINEOFSIGHT_SPECTRUM add_along_lines_of_sight(); sum_over_processors_and_normalize(); absorb_along_lines_of_sight(); output_lines_of_sight(n); #endif #ifdef OUTPUTLINEOFSIGHT_PARTICLES find_particles_and_save_them(n); #endif } myfree(LosGlobal); myfree(Los); }
/*! This function performs the initial set-up of the simulation. First, the * parameterfile is set, then routines for setting units, reading * ICs/restart-files are called, auxialiary memory is allocated, etc. */ void begrun(void) { struct global_data_all_processes all; if(ThisTask == 0) { printf("\nThis is Gadget, version `%s'.\n", GADGETVERSION); printf("\nRunning on %d processors.\n", NTask); } read_parameter_file(ParameterFile); /* ... read in parameters for this run */ allocate_commbuffers(); /* ... allocate buffer-memory for particle exchange during force computation */ set_units(); #if defined(PERIODIC) && (!defined(PMGRID) || defined(FORCETEST)) ewald_init(); #endif open_outputfiles(); random_generator = gsl_rng_alloc(gsl_rng_ranlxd1); gsl_rng_set(random_generator, 42); /* start-up seed */ #ifdef PMGRID long_range_init(); #endif All.TimeLastRestartFile = CPUThisRun; if(RestartFlag == 0 || RestartFlag == 2) { set_random_numbers(); init(); /* ... read in initial model */ } else { all = All; /* save global variables. (will be read from restart file) */ restart(RestartFlag); /* ... read restart file. Note: This also resets all variables in the struct `All'. However, during the run, some variables in the parameter file are allowed to be changed, if desired. These need to copied in the way below. Note: All.PartAllocFactor is treated in restart() separately. */ All.MinSizeTimestep = all.MinSizeTimestep; All.MaxSizeTimestep = all.MaxSizeTimestep; All.BufferSize = all.BufferSize; All.BunchSizeForce = all.BunchSizeForce; All.BunchSizeDensity = all.BunchSizeDensity; All.BunchSizeHydro = all.BunchSizeHydro; All.BunchSizeDomain = all.BunchSizeDomain; All.TimeLimitCPU = all.TimeLimitCPU; All.ResubmitOn = all.ResubmitOn; All.TimeBetSnapshot = all.TimeBetSnapshot; All.TimeBetStatistics = all.TimeBetStatistics; All.CpuTimeBetRestartFile = all.CpuTimeBetRestartFile; All.ErrTolIntAccuracy = all.ErrTolIntAccuracy; All.MaxRMSDisplacementFac = all.MaxRMSDisplacementFac; All.ErrTolForceAcc = all.ErrTolForceAcc; All.TypeOfTimestepCriterion = all.TypeOfTimestepCriterion; All.TypeOfOpeningCriterion = all.TypeOfOpeningCriterion; All.NumFilesWrittenInParallel = all.NumFilesWrittenInParallel; All.TreeDomainUpdateFrequency = all.TreeDomainUpdateFrequency; All.SnapFormat = all.SnapFormat; All.NumFilesPerSnapshot = all.NumFilesPerSnapshot; All.MaxNumNgbDeviation = all.MaxNumNgbDeviation; All.ArtBulkViscConst = all.ArtBulkViscConst; All.OutputListOn = all.OutputListOn; All.CourantFac = all.CourantFac; All.OutputListLength = all.OutputListLength; memcpy(All.OutputListTimes, all.OutputListTimes, sizeof(double) * All.OutputListLength); strcpy(All.ResubmitCommand, all.ResubmitCommand); strcpy(All.OutputListFilename, all.OutputListFilename); strcpy(All.OutputDir, all.OutputDir); strcpy(All.RestartFile, all.RestartFile); strcpy(All.EnergyFile, all.EnergyFile); strcpy(All.InfoFile, all.InfoFile); strcpy(All.CpuFile, all.CpuFile); strcpy(All.TimingsFile, all.TimingsFile); strcpy(All.SnapshotFileBase, all.SnapshotFileBase); if(All.TimeMax != all.TimeMax) readjust_timebase(All.TimeMax, all.TimeMax); } #ifdef PMGRID long_range_init_regionsize(); #endif if(All.ComovingIntegrationOn) init_drift_table(); if(RestartFlag == 2) All.Ti_nextoutput = find_next_outputtime(All.Ti_Current + 1); else All.Ti_nextoutput = find_next_outputtime(All.Ti_Current); All.TimeLastRestartFile = CPUThisRun; }