58 #define SC_CHECK_MPI_VERBOSE(errcode,user_msg) do { \
59 char sc_msg[sc_MPI_MAX_ERROR_STRING]; \
61 if ((errcode) != sc_MPI_SUCCESS) { \
62 sc_MPI_Error_string (errcode, sc_msg, &sc_msglen); \
63 SC_LERRORF ("%s at %s:%d: %s\n", \
64 (user_msg), __FILE__, __LINE__, sc_msg); \
201 const void *data,
size_t bytes_avail);
222 size_t *bytes_in,
size_t *bytes_out);
283 void *data,
size_t bytes_avail,
427 int zlib_compression_level,
428 int line_break_character);
453 size_t *original_size,
454 char *format_char,
void *re);
515 size_t max_original_size,
void *re);
539 FILE *
sc_fopen (
const char *filename,
const char *mode,
551 size_t nmemb, FILE * file,
const char *errmsg);
562 size_t nmemb, FILE * file,
const char *errmsg);
593 #define sc_mpi_read sc_io_read
648 #define sc_mpi_write sc_io_write
683 const void *ptr,
int count,
702 const void *ptr,
int count,
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.
int sc_io_file_load(const char *filename, sc_array_t *buffer)
Read a file into a buffer in one call.
int sc_io_read_at_all(sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount)
Read MPI file content collectively into memory for an explicit offset.
int sc_io_write_at(sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount)
Write MPI file content into memory for an explicit offset.
int sc_io_read_at(sc_MPI_File mpifile, sc_MPI_Offset offset, void *ptr, int count, sc_MPI_Datatype t, int *ocount)
Read MPI file content into memory for an explicit offset.
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:146
@ 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:148
@ SC_IO_WRITE_APPEND
append to an already existing file
Definition: sc_io.h:152
@ SC_IO_READ
open a file in read-only mode
Definition: sc_io.h:147
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.
sc_io_type_t
The type of I/O operation sc_io_sink and sc_io_source.
Definition: sc_io.h:99
@ SC_IO_TYPE_FILEFILE
Write to an already opened file.
Definition: sc_io.h:102
@ SC_IO_TYPE_LAST
Invalid entry to close list.
Definition: sc_io.h:103
@ SC_IO_TYPE_FILENAME
Write to a file to be opened.
Definition: sc_io.h:101
@ SC_IO_TYPE_BUFFER
Write to a buffer.
Definition: sc_io.h:100
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_source_destroy_null(sc_io_source_t **source)
Free data source and NULL the pointer to it.
FILE * sc_fopen(const char *filename, const char *mode, const char *errmsg)
Wrapper for fopen(3).
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_sink_destroy_null(sc_io_sink_t **sink)
Free data sink and NULL the pointer to it.
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.
int sc_io_write_at_all(sc_MPI_File mpifile, sc_MPI_Offset offset, const void *ptr, int count, sc_MPI_Datatype t, int *ocount)
Write MPI file content collectively into memory for an explicit offset.
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_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 a file context.
int sc_io_file_save(const char *filename, sc_array_t *buffer)
Save a buffer to a file in one call.
sc_io_mode_t
The I/O mode for writing using sc_io_sink.
Definition: sc_io.h:82
@ SC_IO_MODE_LAST
Invalid entry to close list.
Definition: sc_io.h:85
@ SC_IO_MODE_WRITE
Semantics as "w" in fopen.
Definition: sc_io.h:83
@ SC_IO_MODE_APPEND
Semantics as "a" in fopen.
Definition: sc_io.h:84
sc_io_sink_t * sc_io_sink_new(int iotype, int iomode, int ioencode,...)
Create a generic data sink.
sc_io_encode_t
Enum to specify encoding for sc_io_sink and sc_io_source.
Definition: sc_io.h:91
@ SC_IO_ENCODE_NONE
No encoding.
Definition: sc_io.h:92
@ SC_IO_ENCODE_LAST
Invalid entry to close list.
Definition: sc_io.h:93
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_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.
sc_io_source_t * sc_io_source_new(int iotype, int ioencode,...)
Create a generic data source.
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:72
@ SC_IO_ERROR_NONE
The value of zero means no error.
Definition: sc_io.h:73
@ SC_IO_ERROR_FATAL
The io object is now dysfunctional.
Definition: sc_io.h:74
@ SC_IO_ERROR_AGAIN
Another io operation may resolve it.
Definition: sc_io.h:75
int sc_vtk_write_binary(FILE *vtkfile, char *numeric_data, size_t byte_length)
This function writes numeric binary data in VTK base64 encoding.
sc3_MPI_Datatype_t sc_MPI_Datatype
Emulate MPI datatypes.
Definition: sc_mpi.h:452
sc3_MPI_Comm_t sc_MPI_Comm
Emulate an MPI communicator.
Definition: sc_mpi.h:450
sc3_MPI_Info_t sc_MPI_Info
Emulate an MPI Info object.
Definition: sc_mpi.h:451
long sc_MPI_Offset
Emulate the MPI offset type.
Definition: sc_mpi.h:780
The sc_array object provides a dynamic array of equal-size elements.
Definition: sc_containers.h:117
A generic data sink.
Definition: sc_io.h:109
int is_eof
Have we reached the end of file?
Definition: sc_io.h:120
sc_io_encode_t encode
encoding of data
Definition: sc_io.h:112
size_t bytes_in
input bytes count
Definition: sc_io.h:118
size_t buffer_bytes
distinguish from array elements
Definition: sc_io.h:115
sc_io_type_t iotype
type of the I/O operation
Definition: sc_io.h:110
sc_io_mode_t mode
write semantics
Definition: sc_io.h:111
size_t bytes_out
written bytes count
Definition: sc_io.h:119
FILE * file
file pointer for iotype unequal to SC_IO_TYPE_BUFFER
Definition: sc_io.h:116
sc_array_t * buffer
buffer for the iotype SC_IO_TYPE_BUFFER
Definition: sc_io.h:113
A generic data source.
Definition: sc_io.h:126
sc_io_encode_t encode
encoding of data
Definition: sc_io.h:128
size_t bytes_out
read bytes count
Definition: sc_io.h:135
sc_io_sink_t * mirror
if activated, a sink to store the data
Definition: sc_io.h:137
FILE * file
file pointer for iotype unequal to SC_IO_TYPE_BUFFER
Definition: sc_io.h:132
int is_eof
Have we reached the end of file?
Definition: sc_io.h:136
size_t bytes_in
input bytes count
Definition: sc_io.h:134
sc_array_t * mirror_buffer
if activated, the buffer for the mirror
Definition: sc_io.h:139
sc_io_type_t iotype
type of the I/O operation
Definition: sc_io.h:127
size_t buffer_bytes
distinguish from array elements
Definition: sc_io.h:131
sc_array_t * buffer
buffer for the iotype SC_IO_TYPE_BUFFER
Definition: sc_io.h:129
Replacement structure for MPI_File.
Definition: sc_mpi.h:786