Serial example showing the very basic usage of SIONlib using the serial API.
More examples can be found in 'examples' folder of the SIONlib installation.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FNAMELEN 255
int main(int argc, char** argv)
{
sion_int32 fsblksize = -1;
sion_int64* chunksizes = NULL;
int* globalranks = NULL;
int ntasks = -1;
int nfiles = 1;
int sid = 0;
int task = 0;
size_t buffer_size = 1024;
char* buffer = NULL;
size_t bavail = 0;
size_t bread = 0;
size_t bwrote = 0;
ntasks = 4;
chunksizes = (sion_int64*)malloc(ntasks * sizeof (sion_int64));
globalranks = (int*)malloc(ntasks * sizeof (int));
buffer = (char*)malloc(buffer_size);
for (task = 0; task < ntasks; ++task) {
chunksizes[task] = 100;
globalranks[task] = task;
}
memset(buffer, 'A', buffer_size);
sid =
sion_open(
"serfile.sion",
"wb", &ntasks, &nfiles, &chunksizes,
&fsblksize, &globalranks, NULL);
printf("Wrote %zd bytes\n", bwrote);
free(chunksizes);
chunksizes = NULL;
free(globalranks);
globalranks = NULL;
free(buffer);
buffer = NULL;
sid =
sion_open(
"serfile.sion",
"rb", &ntasks, &nfiles, &chunksizes,
&fsblksize, &globalranks, NULL);
buffer = (char*)malloc(bavail);
printf("Read %zd bytes\n", bread);
free(chunksizes);
chunksizes = NULL;
free(globalranks);
globalranks = NULL;
free(buffer);
buffer = NULL;
return 0;
}