19 #define _XOPEN_SOURCE 700
35 #define DFUNCTION "fsion_open_c"
60 sion_int64 *chunksizes,
61 sion_int32 *fsblksize,
68 char *fname_tmp, *fmode_tmp;
71 fname_tmp = (
char *) malloc((
size_t) ((fname_len + 1) *
sizeof(
char)));
72 if(fname_tmp == NULL) {
73 fprintf(stderr,
"could not allocate memory for internal filename buffer, returning ...\n");
78 fmode_tmp = (
char *) malloc((
size_t) ((file_mode_len + 1) *
sizeof(
char)));
79 if(fmode_tmp == NULL) {
80 fprintf(stderr,
"could not allocate memory for internal filemode buffer, returning ...\n");
82 free(fname_tmp); fname_tmp=NULL;
92 strncpy(fname_tmp, fname, fname_len);
93 strncpy(fmode_tmp, file_mode, file_mode_len);
95 fname_tmp[fname_len] =
'\0';
96 fmode_tmp[file_mode_len] =
'\0';
100 DPRINTFP((2, DFUNCTION, -1,
"params: %s %s %d %ld \n", fname_tmp, fmode_tmp, (
int) *ntasks, (
long) *fsblksize));
102 if (!strcmp(fmode_tmp,
"bw") || !strcmp(fmode_tmp,
"wb")) {
104 (*sid) =
sion_open(fname_tmp, fmode_tmp, ntasks, nfiles, &chunksizes, fsblksize, &globalranks, NULL);
106 (*sid) =
sion_open(fname_tmp, fmode_tmp, ntasks, nfiles, NULL, fsblksize, NULL, NULL);
108 DPRINTFP((2, DFUNCTION, -1,
"sid: %d\n", *sid));
111 free(fname_tmp); fname_tmp=NULL;
112 free(fmode_tmp); fmode_tmp=NULL;
145 sion_int64 *chunksize,
146 sion_int32 *fsblksize,
153 char *fname_tmp, *fmode_tmp;
155 fname_tmp = (
char *) malloc((
size_t) ((fname_len + 1) *
sizeof(
char)));
156 fmode_tmp = (
char *) malloc((
size_t) ((file_mode_len + 1) *
sizeof(
char)));
158 strncpy(fname_tmp, fname, fname_len);
159 strncpy(fmode_tmp, file_mode, file_mode_len);
160 fname_tmp[fname_len] =
'\0';
161 fmode_tmp[file_mode_len] =
'\0';
163 (*sid) =
sion_open_rank(fname_tmp, fmode_tmp, chunksize, fsblksize, rank, NULL);
212 #define DFUNCTION "fsion_seek_c"
232 sion_int64 *posinblk,
236 DPRINTFP((2, DFUNCTION, -1,
"params: %d %d %d %lld\n", *sid, *rank, *currentblocknr, *posinblk));
238 (*ierr) =
sion_seek(*sid, *rank, *currentblocknr, *posinblk);
326 sion_int64 *globalskip,
327 sion_int64 *start_of_varheader,
328 sion_int64 **sion_localsizes,
329 sion_int64 **sion_globalranks,
330 sion_int64 **sion_chunkcount,
331 sion_int64 **sion_chunksizes,
335 (*ierr) =
sion_get_locations(*sid, ntasks, maxblocks, globalskip, start_of_varheader, sion_localsizes,
336 sion_globalranks, sion_chunkcount, sion_chunksizes);
355 void fsion_get_current_locations_c(
int *sid,
357 sion_int64 **sion_currentpos,
358 sion_int64 **sion_currentblocknr,
366 void fsion_get_chunksizes_c(
int *sid,
367 sion_int64 *chunksizes,
374 fprintf(stderr,
"invalid sion_filedesc, aborting %d ...\n", *sid);
382 for(i=0;i<sion_filedesc->
ntasks;i++) {
389 void fsion_get_globalranks_c(
int *sid,
397 fprintf(stderr,
"invalid sion_filedesc, aborting %d ...\n", *sid);
405 for(i=0;i<sion_filedesc->
ntasks;i++) {
412 void fsion_get_mapping_spec_c(
int *sid,
420 fprintf(stderr,
"invalid sion_filedesc, aborting %d ...\n", *sid);
427 *numfiles = sion_filedesc->
nfiles;
431 #define DFUNCTION "fsion_get_mapping_c"
432 void fsion_get_mapping_c(
int *sid,
440 fprintf(stderr,
"invalid sion_filedesc, aborting %d ...\n", *sid);
444 if(sion_filedesc->
nfiles>1) {
446 for (rank = 0; rank < sion_filedesc->
mapping_size; rank++) {
447 DPRINTFP((32, DFUNCTION, 0,
" mapping[%d] = %d , %d \n", rank,sion_filedesc->
mapping[rank*2+0],sion_filedesc->
mapping[rank*2+1]));
448 mapping[rank*2+0]=sion_filedesc->
mapping[rank*2+0];
449 mapping[rank*2+1]=sion_filedesc->
mapping[rank*2+1];
471 fprintf(stderr,
"invalid sion_filedesc, aborting %d ...\n", *sid);
int sion_get_current_locations(int sid, int *ntasks, sion_int64 **sion_currentpos, sion_int64 **sion_currentblocknr)
Returns current position in file and pointer fiels containing chunk sizes.
int sion_get_file_endianness(int sid)
Returns edianness of data in file sid.
int sion_endianness_swap_needed(int sid)
Returns whether or not byte swapping is needed for sid.
int sion_get_locations(int sid, int *ntasks, int *maxchunks, sion_int64 *globalskip, sion_int64 *start_of_varheader, sion_int64 **sion_chunksizes, sion_int64 **sion_globalranks, sion_int64 **sion_blockcount, sion_int64 **sion_blocksizes)
Returns pointers to internal fields.
sion_int64 sion_get_position(int sid)
Function that returns the current file position.
int sion_flush(int sid)
Flushed sion file.
int sion_ensure_free_space(int sid, sion_int64 bytes)
Funtion to ensure that enough space is available for writing.
int sion_feof(int sid)
Function that indicates whether the end of file is reached for this task.
sion_int64 sion_bytes_avail_in_block(int sid)
Return the number of bytes available in the current chunk.
int sion_seek(int sid, int rank, int currentblocknr, sion_int64 posinblk)
Function to set the file pointer to a new position.
int sion_get_endianness(void)
Return endianness.
void sion_swap(void *target, void *source, int size, int n, int do_swap)
void * _sion_vcdtovcon(int sid)
int _sion_vcdtype(int sid)
#define SION_FILEDESCRIPTOR
int _sion_file_get_fd(_sion_fileptr *sion_fileptr)
Utility function: Get POSIX fp.
void fsion_get_endianness_c(int *endianness)
Fortran function that returns current endianness (1-> big endian, 0 ->little endian)
void fsion_feof_c(int *sid, int *eof)
Fortran function that indicates the end of file for this task.
sion_int64 fsion_bytes_avail_in_block_c(int *sid)
Fortran function that returns the number of bytes available in the current chunk.
void fsion_get_fileno_c(int *sid, int *filenumber)
Fortran function that returns the current file number.
void fsion_seek_c(int *sid, int *rank, int *currentblocknr, sion_int64 *posinblk, int *ierr)
Fortran procedure to set the file pointer to a new position.
void fsion_endianness_swap_needed_c(int *sid, int *needed)
Fortran function that returns whether or not byte swapping is needed (1 -> needed,...
void fsion_open_c(char *fname, char *file_mode, int *ntasks, int *nfiles, sion_int64 *chunksizes, sion_int32 *fsblksize, int *globalranks, int *sid, int fname_len, int file_mode_len)
Fortran procedure to open a sion file in serial mode.
void fsion_get_file_endianness_c(int *sid, int *endianness)
Fortran function that returns endianness of a sion file (1-> big endian, 0 ->little endian)
void fsion_flush_c(int *sid, int *ierr)
Fortran procedure to flush a sion file.
sion_int64 fsion_get_position_c(int *sid)
Fortran function that returns the current file position.
void fsion_get_locations_c(int *sid, int *ntasks, int *maxblocks, sion_int64 *globalskip, sion_int64 *start_of_varheader, sion_int64 **sion_localsizes, sion_int64 **sion_globalranks, sion_int64 **sion_chunkcount, sion_int64 **sion_chunksizes, int *ierr)
Fortran procedure that returns pointers to internal fields.
void fsion_open_rank_c(char *fname, char *file_mode, sion_int64 *chunksize, sion_int32 *fsblksize, int *rank, int *sid, int fname_len, int file_mode_len)
Fortran procedure to open a sion file for a specific rank.
void fsion_swap_c(void *target, void *source, int *size, int *n, int *do_swap, int *rc)
Fortran procedure to swap endianness of data.
void fsion_close_c(int *sid, int *ierr)
Fortran procedure to close a sion file.
void fsion_ensure_free_space_c(int *sid, sion_int64 *bytes, int *ierr)
Fortran procedure to ensure that enough space is available.
int sion_open_rank(char *fname, const char *file_mode, sion_int64 *chunksize, sion_int32 *fsblksize, int *rank, FILE **fileptr)
Open a sion file for a specific rank.
int sion_open(char *fname, const char *file_mode, int *ntasks, int *nfiles, sion_int64 **chunksizes, sion_int32 *fsblksize, int **globalranks, FILE **fileptr)
Open a sion file in serial mode.
int sion_close(int sid)
Close a sion file.
Sion File Descriptor Structure.
sion_int64 * all_chunksizes
sion_int64 * all_globalranks