Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

io.c File Reference

Routines for producing a snapshot file on disk. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <mpi.h>
#include <errno.h>
#include <hdf5.h>
#include "allvars.h"
#include "proto.h"

Go to the source code of this file.

Defines

#define SKIP   {my_fwrite(&blksize,sizeof(int),1,fd);}

Functions

void savepositions (int num)
void fill_write_buffer (enum iofields blocknr, int *startindex, int pc, int type)
int get_bytes_per_blockelement (enum iofields blocknr)
int get_datatype_in_block (enum iofields blocknr)
int get_values_per_blockelement (enum iofields blocknr)
int get_particles_in_block (enum iofields blocknr, int *typelist)
int blockpresent (enum iofields blocknr)
void fill_Tab_IO_Labels (void)
void get_dataset_name (enum iofields blocknr, char *buf)
void write_file (char *fname, int writeTask, int lastTask)
void write_header_attributes_in_hdf5 (hid_t handle)
size_t my_fwrite (void *ptr, size_t size, size_t nmemb, FILE *stream)
size_t my_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)


Detailed Description

Routines for producing a snapshot file on disk.

Definition in file io.c.


Define Documentation

#define SKIP   {my_fwrite(&blksize,sizeof(int),1,fd);}
 


Function Documentation

int blockpresent enum iofields  blocknr  ) 
 

This function tells whether or not a given block in the output file is present, depending on the type of simulation run and the compile-time options. If one wants to add a new output-block, this function should be augmented accordingly.

Definition at line 532 of file io.c.

Referenced by read_file(), and write_file().

void fill_Tab_IO_Labels void   ) 
 

This function associates a short 4-character block name with each block number. This is stored in front of each block for snapshot FileFormat=2. If one wants to add a new output-block, this function should be augmented accordingly.

< total number of defined information blocks for snapshot files. Must be equal to the number of entries in "enum iofields"

Definition at line 566 of file io.c.

References IO_ACCEL, IO_DTENTR, IO_HSML, IO_ID, IO_MASS, IO_POS, IO_POT, IO_RHO, IO_TSTP, IO_U, IO_VEL, iofields, and Tab_IO_Labels.

Referenced by read_ic(), and savepositions().

void fill_write_buffer enum iofields  blocknr,
int *  startindex,
int  pc,
int  type
 

This function fills the write buffer with particle data. New output blocks can in principle be added here.

< adiabatic index of simulated gas

< adiabatic index of simulated gas

< adiabatic index of simulated gas

Definition at line 129 of file io.c.

References All, global_data_all_processes::BoxSize, global_data_all_processes::ComovingIntegrationOn, sph_particle_data::Density, dmax(), sph_particle_data::DtEntropy, sph_particle_data::Entropy, FLOAT, GAMMA, GAMMA_MINUS1, get_gravkick_factor(), get_hydrokick_factor(), particle_data::GravAccel, particle_data::GravPM, sph_particle_data::Hsml, sph_particle_data::HydroAccel, particle_data::ID, IO_ACCEL, IO_DTENTR, IO_HSML, IO_ID, IO_MASS, IO_POS, IO_POT, IO_RHO, IO_TSTP, IO_U, IO_VEL, particle_data::Mass, global_data_all_processes::MinEgySpec, P, global_data_all_processes::PM_Ti_begstep, global_data_all_processes::PM_Ti_endstep, particle_data::Pos, particle_data::Potential, pow(), SphP, particle_data::Ti_begstep, global_data_all_processes::Ti_Current, particle_data::Ti_endstep, global_data_all_processes::Time, global_data_all_processes::Timebase_interval, particle_data::Type, and particle_data::Vel.

Referenced by write_file().

int get_bytes_per_blockelement enum iofields  blocknr  ) 
 

This function tells the size of one data entry in each of the blocks defined for the output file. If one wants to add a new output-block, this function should be augmented accordingly.

Definition at line 366 of file io.c.

References IO_ACCEL, IO_DTENTR, IO_HSML, IO_ID, IO_MASS, IO_POS, IO_POT, IO_RHO, IO_TSTP, IO_U, and IO_VEL.

Referenced by read_file(), and write_file().

void get_dataset_name enum iofields  blocknr,
char *  buf
 

This function returns a descriptive character string that describes the name of the block when the HDF5 file format is used. If one wants to add a new output-block, this function should be augmented accordingly.

Definition at line 614 of file io.c.

References IO_ACCEL, IO_DTENTR, IO_HSML, IO_ID, IO_MASS, IO_POS, IO_POT, IO_RHO, IO_TSTP, IO_U, and IO_VEL.

Referenced by read_file(), and write_file().

int get_datatype_in_block enum iofields  blocknr  ) 
 

This function returns the type of the data contained in a given block of the output file. If one wants to add a new output-block, this function should be augmented accordingly.

Definition at line 405 of file io.c.

References IO_ID.

Referenced by read_file(), and write_file().

int get_particles_in_block enum iofields  blocknr,
int *  typelist
 

This function determines how many particles there are in a given block, based on the information in the header-structure. It also flags particle types that are present in the block in the typelist array. If one wants to add a new output-block, this function should be augmented accordingly.

Definition at line 465 of file io.c.

References All, endrun(), header, IO_ACCEL, IO_DTENTR, IO_HSML, IO_ID, IO_MASS, IO_POS, IO_POT, IO_RHO, IO_TSTP, IO_U, IO_VEL, global_data_all_processes::MassTable, and io_header::npart.

Referenced by read_file(), and write_file().

int get_values_per_blockelement enum iofields  blocknr  ) 
 

This function informs about the number of elements stored per particle for the given block of the output file. If one wants to add a new output-block, this function should be augmented accordingly.

Definition at line 432 of file io.c.

References IO_ACCEL, IO_DTENTR, IO_HSML, IO_ID, IO_MASS, IO_POS, IO_POT, IO_RHO, IO_TSTP, IO_U, and IO_VEL.

Referenced by read_file(), and write_file().

size_t my_fread void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream
 

This catches I/O errors occuring for fread(). In this case we better stop.

Definition at line 1141 of file io.c.

References endrun(), and ThisTask.

Referenced by read_file().

size_t my_fwrite void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream
 

This catches I/O errors occuring for my_fwrite(). In this case we better stop.

Definition at line 1124 of file io.c.

References endrun(), and ThisTask.

Referenced by write_file().

void savepositions int  num  ) 
 

This function writes a snapshot of the particle distribution to one or several files using the selected file format. If NumFilesPerSnapshot>1, the snapshot is distributed onto several files, several of them can be written simultaneously (up to NumFilesWrittenInParallel). Each file contains data from a group of processors.

Definition at line 33 of file io.c.

References All, global_data_all_processes::CPU_Snapshot, distribute_file(), endrun(), fill_Tab_IO_Labels(), NTask, global_data_all_processes::NumFilesPerSnapshot, global_data_all_processes::NumFilesWrittenInParallel, global_data_all_processes::NumForcesSinceLastDomainDecomp, global_data_all_processes::OutputDir, P, second(), global_data_all_processes::SnapFormat, global_data_all_processes::SnapshotFileBase, ThisTask, timediff(), global_data_all_processes::TotNumPart, global_data_all_processes::TreeDomainUpdateFrequency, particle_data::Type, and write_file().

Referenced by run().

void write_file char *  fname,
int  writeTask,
int  lastTask
 

This function writes an actual snapshot file containing the data from processors 'writeTask' to 'lastTask'. 'writeTask' is the one that actually writes. Each snapshot file contains a header first, then particle positions, velocities and ID's. Particle masses are written only for those particle types with zero entry in MassTable. After that, first the internal energies u, and then the density is written for the SPH particles. If cooling is enabled, mean molecular weight and neutral hydrogen abundance are written for the gas particles. This is followed by the SPH smoothing length and further blocks of information, depending on included physics and compile-time flags. If HDF5 is used, the header is stored in a group called "/Header", and the particle data is stored separately for each particle type in groups calles "/PartType0", "/PartType1", etc. The sequence of the blocks is unimportant in this case.

< Various tags used for labelling MPI messages

< Various tags used for labelling MPI messages

< total number of defined information blocks for snapshot files. Must be equal to the number of entries in "enum iofields"

Definition at line 673 of file io.c.

References All, blockpresent(), io_header::BoxSize, global_data_all_processes::BoxSize, global_data_all_processes::BufferSize, CommBuffer, global_data_all_processes::ComovingIntegrationOn, endrun(), fill_write_buffer(), io_header::flag_cooling, io_header::flag_feedback, io_header::flag_metals, io_header::flag_sfr, io_header::flag_stellarage, get_bytes_per_blockelement(), get_dataset_name(), get_datatype_in_block(), get_particles_in_block(), get_values_per_blockelement(), header, io_header::HubbleParam, global_data_all_processes::HubbleParam, iofields, io_header::mass, global_data_all_processes::MassTable, my_fwrite(), io_header::npart, io_header::npartTotal, io_header::npartTotalHighWord, io_header::num_files, global_data_all_processes::NumFilesPerSnapshot, io_header::Omega0, global_data_all_processes::Omega0, io_header::OmegaLambda, global_data_all_processes::OmegaLambda, io_header::redshift, global_data_all_processes::SnapFormat, Tab_IO_Labels, TAG_LOCALN, TAG_N, TAG_NFORTHISTASK, TAG_PDATA, ThisTask, io_header::time, global_data_all_processes::Time, and write_header_attributes_in_hdf5().

Referenced by savepositions().

void write_header_attributes_in_hdf5 hid_t  handle  ) 
 

This function writes the header information in case HDF5 is selected as file format.

Definition at line 1000 of file io.c.

Referenced by write_file().


Generated on Sun May 22 17:33:30 2005 for GADGET-2 by  doxygen 1.3.9.1