74#define SC_CHECK_MPI_VERBOSE(errcode,user_msg) do { \
75 char sc_msg[sc_MPI_MAX_ERROR_STRING]; \
77 if ((errcode) != sc_MPI_SUCCESS) { \
78 sc_MPI_Error_string (errcode, sc_msg, &sc_msglen); \
79 SC_LERRORF ("%s at %s:%d: %s\n", \
80 (user_msg), __FILE__, __LINE__, sc_msg); \
202 const void *data,
size_t bytes_avail);
223 size_t *bytes_in,
size_t *bytes_out);
269 void *data,
size_t bytes_avail,
391 int zlib_compression_level,
392 int line_break_character);
417 size_t *original_size,
418 char *format_char,
void *re);
479 size_t max_original_size,
void *re);
503FILE *
sc_fopen (
const char *filename,
const char *mode,
515 size_t nmemb, FILE * file,
const char *errmsg);
526 size_t nmemb, FILE * file,
const char *errmsg);
556#define sc_mpi_read sc_io_read
646#define sc_mpi_write sc_io_write
699 const void *ptr,
int zcount,
724 const void *ptr,
size_t zcount,
742 const void *ptr,
size_t zcount,
Dynamic containers such as lists, arrays, and hash tables.
void sc_io_write(sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg)
Write memory content to an MPI file.
struct sc_io_sink sc_io_sink_t
A generic data sink.
void sc_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file, const char *errmsg)
Write memory content to a file.
sc_io_open_mode_t
Open modes for sc_io_open.
Definition: sc_io.h:160
@ SC_IO_WRITE_CREATE
open a file in write-only mode; if the file exists, the file will be truncated to length zero and the...
Definition: sc_io.h:162
@ SC_IO_WRITE_APPEND
append to an already existing file
Definition: sc_io.h:166
@ SC_IO_READ
open a file in read-only mode
Definition: sc_io.h:161
int sc_io_source_read_mirror(sc_io_source_t *source, void *data, size_t bytes_avail, size_t *bytes_out)
Read data from the source's mirror.
int sc_io_read_at(sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int zcount, sc_MPI_Datatype t, int *ocount)
Read MPI file content into memory for an explicit offset.
int sc_io_write_at_all(sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, size_t zcount, sc_MPI_Datatype t, int *ocount)
Write MPI file content collectively into memory for an explicit offset.
sc_io_type_t
The type of I/O operation sc_io_sink and sc_io_source.
Definition: sc_io.h:115
@ SC_IO_TYPE_FILEFILE
Write to an already opened file.
Definition: sc_io.h:118
@ SC_IO_TYPE_LAST
Invalid entry to close list.
Definition: sc_io.h:119
@ SC_IO_TYPE_FILENAME
Write to a file to be opened.
Definition: sc_io.h:117
@ SC_IO_TYPE_BUFFER
Write to a buffer.
Definition: sc_io.h:116
int sc_io_source_read(sc_io_source_t *source, void *data, size_t bytes_avail, size_t *bytes_out)
Read data from a source.
int sc_io_read_all(sc_MPI_File mpifile, void *ptr, int zcount, sc_MPI_Datatype t, int *ocount)
Read memory content collectively from an MPI file.
int sc_io_sink_write(sc_io_sink_t *sink, const void *data, size_t bytes_avail)
Write data to a sink.
int sc_io_read_at_legal(void)
Check for restricted usage of sc_io_read_at.
int sc_io_write_at_legal(void)
Check for restricted usage of sc_io_write_at.
void sc_io_encode_zlib(sc_array_t *data, sc_array_t *out, int zlib_compression_level, int line_break_character)
Encode a block of arbitrary data, compressed, into an ASCII string.
int sc_io_source_align(sc_io_source_t *source, size_t bytes_align)
Align source to a byte boundary by skipping.
sc_io_sink_t * sc_io_sink_new(int iotype, int iomode, int ioencode,...)
Create a generic data sink.
FILE * sc_fopen(const char *filename, const char *mode, const char *errmsg)
Wrapper for fopen(3).
sc_io_source_t * sc_io_source_new(int iotype, int ioencode,...)
Create a generic data source.
void sc_io_encode(sc_array_t *data, sc_array_t *out)
Encode a block of arbitrary data with the default sc_io format.
int sc_io_decode(sc_array_t *data, sc_array_t *out, size_t max_original_size, void *re)
Decode a block of base 64 encoded compressed data.
int sc_io_close(sc_MPI_File *file)
Close collectively a sc_MPI_File.
int sc_io_write_at(sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int zcount, sc_MPI_Datatype t, int *ocount)
Write MPI file content into memory for an explicit offset.
int sc_io_source_destroy(sc_io_source_t *source)
Free data source.
int sc_io_decode_info(sc_array_t *data, size_t *original_size, char *format_char, void *re)
Decode length and format of original input from encoded data.
int sc_io_sink_destroy(sc_io_sink_t *sink)
Free data sink.
int sc_io_open(sc_MPI_Comm mpicomm, const char *filename, sc_io_open_mode_t amode, sc_MPI_Info mpiinfo, sc_MPI_File *mpifile)
Opens a MPI file or without MPI I/O or even without MPI a file context.
sc_io_mode_t
The I/O mode for writing using sc_io_sink.
Definition: sc_io.h:98
@ SC_IO_MODE_LAST
Invalid entry to close list.
Definition: sc_io.h:101
@ SC_IO_MODE_WRITE
Semantics as "w" in fopen.
Definition: sc_io.h:99
@ SC_IO_MODE_APPEND
Semantics as "a" in fopen.
Definition: sc_io.h:100
sc_io_encode_t
Enum to specify encoding for sc_io_sink and sc_io_source.
Definition: sc_io.h:107
@ SC_IO_ENCODE_NONE
No encoding.
Definition: sc_io.h:108
@ SC_IO_ENCODE_LAST
Invalid entry to close list.
Definition: sc_io.h:109
void sc_fread(void *ptr, size_t size, size_t nmemb, FILE *file, const char *errmsg)
Read file content into memory.
struct sc_io_source sc_io_source_t
A generic data source.
int sc_io_read_at_all(sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int zcount, sc_MPI_Datatype t, int *ocount)
Read MPI file content collectively into memory for an explicit offset.
int sc_io_source_activate_mirror(sc_io_source_t *source)
Activate a buffer that mirrors (i.e., stores) the data that was read.
void sc_io_read(sc_MPI_File mpifile, void *ptr, size_t zcount, sc_MPI_Datatype t, const char *errmsg)
Read MPI file content into memory.
int sc_io_sink_align(sc_io_sink_t *sink, size_t bytes_align)
Align sink to a byte boundary by writing zeros.
void sc_fflush_fsync_fclose(FILE *file)
Best effort to flush a file's data to disc and close it.
int sc_vtk_write_compressed(FILE *vtkfile, char *numeric_data, size_t byte_length)
This function writes numeric binary data in VTK compressed format.
int sc_io_sink_complete(sc_io_sink_t *sink, size_t *bytes_in, size_t *bytes_out)
Flush all buffered output data to sink.
int sc_io_source_complete(sc_io_source_t *source, size_t *bytes_in, size_t *bytes_out)
Determine whether all data buffered from source has been returned by read.
sc_io_error_t
Error values for io.
Definition: sc_io.h:88
@ SC_IO_ERROR_NONE
The value of zero means no error.
Definition: sc_io.h:89
@ SC_IO_ERROR_FATAL
The io object is now dysfunctional.
Definition: sc_io.h:90
@ SC_IO_ERROR_AGAIN
Another io operation may resolve it.
Definition: sc_io.h:91
int sc_vtk_write_binary(FILE *vtkfile, char *numeric_data, size_t byte_length)
This function writes numeric binary data in VTK base64 encoding.
int sc_io_write_all(sc_MPI_File mpifile, const void *ptr, size_t zcount, sc_MPI_Datatype t, int *ocount)
Write memory content collectively to an MPI file.
sc3_MPI_Datatype_t sc_MPI_Datatype
Emulate MPI datatypes.
Definition: sc_mpi.h:393
sc3_MPI_Comm_t sc_MPI_Comm
Emulate an MPI communicator.
Definition: sc_mpi.h:391
sc3_MPI_Info_t sc_MPI_Info
Emulate an MPI Info object.
Definition: sc_mpi.h:392
long sc_MPI_Offset
Emulate the MPI offset type.
Definition: sc_mpi.h:652
The sc_array object provides a dynamic array of equal-size elements.
Definition: sc_containers.h:91
A generic data sink.
Definition: sc_io.h:125
sc_io_encode_t encode
encoding of data
Definition: sc_io.h:128
size_t bytes_in
input bytes count
Definition: sc_io.h:134
size_t buffer_bytes
distinguish from array elems
Definition: sc_io.h:131
sc_io_type_t iotype
type of the I/O operation
Definition: sc_io.h:126
sc_io_mode_t mode
write semantics
Definition: sc_io.h:127
size_t bytes_out
written bytes count
Definition: sc_io.h:135
FILE * file
file pointer for iotype unequal to SC_IO_TYPE_BUFFER
Definition: sc_io.h:132
sc_array_t * buffer
buffer for the iotype SC_IO_TYPE_BUFFER
Definition: sc_io.h:129
A generic data source.
Definition: sc_io.h:141
sc_io_encode_t encode
encoding of data
Definition: sc_io.h:143
size_t bytes_out
read bytes count
Definition: sc_io.h:150
sc_io_sink_t * mirror
if activated, a sink to store the data
Definition: sc_io.h:151
FILE * file
file pointer for iotype unequal to SC_IO_TYPE_BUFFER
Definition: sc_io.h:147
size_t bytes_in
input bytes count
Definition: sc_io.h:149
sc_array_t * mirror_buffer
if activated, the buffer for the mirror
Definition: sc_io.h:153
sc_io_type_t iotype
type of the I/O operation
Definition: sc_io.h:142
size_t buffer_bytes
distinguish from array elems
Definition: sc_io.h:146
sc_array_t * buffer
buffer for the iotype SC_IO_TYPE_BUFFER
Definition: sc_io.h:144
Replacement structure for MPI_File.
Definition: sc_mpi.h:658