SIONlib
1.7.7
Scalable I/O library for parallel access to task-local files
|
Fortran API. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sion.h"
#include "sion_debug.h"
#include "sion_fd.h"
#include "sion_filedesc.h"
#include "sion_fortran.h"
Go to the source code of this file.
Macros | |
#define | _XOPEN_SOURCE 700 |
#define | DFUNCTION "fsion_open_c" |
#define | DFUNCTION "fsion_seek_c" |
#define | DFUNCTION "fsion_get_mapping_c" |
Functions | |
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. More... | |
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. More... | |
void | fsion_close_c (int *sid, int *ierr) |
Fortran procedure to close a sion file. More... | |
void | fsion_feof_c (int *sid, int *eof) |
Fortran function that indicates the end of file for this task. More... | |
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. More... | |
void | fsion_ensure_free_space_c (int *sid, sion_int64 *bytes, int *ierr) |
Fortran procedure to ensure that enough space is available. More... | |
void | fsion_flush_c (int *sid, int *ierr) |
Fortran procedure to flush a sion file. More... | |
sion_int64 | fsion_bytes_avail_in_block_c (int *sid) |
Fortran function that returns the number of bytes available in the current chunk. More... | |
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. More... | |
sion_int64 | fsion_get_position_c (int *sid) |
Fortran function that returns the current file position. More... | |
void | fsion_get_current_locations_c (int *sid, int *ntasks, sion_int64 **sion_currentpos, sion_int64 **sion_currentblocknr, int *ierr) |
void | fsion_get_chunksizes_c (int *sid, sion_int64 *chunksizes, int *ierr) |
void | fsion_get_globalranks_c (int *sid, int *globalranks, int *ierr) |
void | fsion_get_mapping_spec_c (int *sid, int *mapping_size, int *numfiles, int *ierr) |
void | fsion_get_mapping_c (int *sid, sion_int32 *mapping, int *ierr) |
void | fsion_get_fileno_c (int *sid, int *filenumber) |
Fortran function that returns the current file number. More... | |
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) More... | |
void | fsion_get_endianness_c (int *endianness) |
Fortran function that returns current endianness (1-> big endian, 0 ->little endian) More... | |
void | fsion_endianness_swap_needed_c (int *sid, int *needed) |
Fortran function that returns whether or not byte swapping is needed (1 -> needed, 0 -> not needed) More... | |
void | fsion_swap_c (void *target, void *source, int *size, int *n, int *do_swap, int *rc) |
Fortran procedure to swap endianness of data. More... | |
Fortran API.
Definition in file sion_fortran.c.
sion_int64 fsion_bytes_avail_in_block_c | ( | int * | sid | ) |
Fortran function that returns the number of bytes available in the current chunk.
This function returns the number of bytes currently available in the current chunk (bytes not read). It is a local function, which can be called independently from other MPI tasks.
[in] | sid | sion file handle |
Definition at line 296 of file sion_fortran.c.
References sion_bytes_avail_in_block().
void fsion_close_c | ( | int * | sid, |
int * | ierr | ||
) |
Fortran procedure to close a sion file.
This procedure closes a sion file which was opened in serial mode with sion_open or sion_open_rank. In Write mode this function will also save all meta data to the meta data block of the sion file at the beginning and the end of t he file. The function is a task local function, which can be called independently from other MPI tasks.
[in] | sid | sion file handle |
[out] | ierr | 1 if close is ok |
Definition at line 183 of file sion_fortran.c.
References sion_close().
void fsion_endianness_swap_needed_c | ( | int * | sid, |
int * | needed | ||
) |
Fortran function that returns whether or not byte swapping is needed (1 -> needed, 0 -> not needed)
[in] | sid | sion file handle (in) |
[out] | needed | used for the return value |
Definition at line 512 of file sion_fortran.c.
References sion_endianness_swap_needed().
void fsion_ensure_free_space_c | ( | int * | sid, |
sion_int64 * | bytes, | ||
int * | ierr | ||
) |
Fortran procedure to ensure that enough space is available.
This procedure ensures that there is enough space available for writing numbytes bytes to the sion file. It allocates a new block at the end of the sion file of size chunksize if numbytes cannot be written in the current block. This procedure is only be needed if the caller function from the user program does not count the number of bytes written. It is a task local function, which can be called independently from other MPI tasks, and it moves in some cases the filepointer to a new position and flushes also the local filepointer.
[in] | sid | sion file handle |
[in] | bytes | number of bytes which will be written |
[out] | ierr | 1 if ok |
Definition at line 258 of file sion_fortran.c.
References sion_ensure_free_space().
void fsion_feof_c | ( | int * | sid, |
int * | eof | ||
) |
Fortran function that indicates the end of file for this task.
This function indicates if the end of file is reached for this task. This means that the file pointer is behind of the last bytes of last chunk of this task. If all bytes of the current chunk are already read and there are more chunks available for this task, sion_feof will advance the filepointer to the start position of the next chunk in the sion file. The function is a task local function, which can be called independently from other MPI tasks.
[in] | sid | sion file handle |
[out] | eof | 1 if the End of the File is reached |
1 | if end of last chunk reached 0 otherwise |
Definition at line 205 of file sion_fortran.c.
References sion_feof().
void fsion_flush_c | ( | int * | sid, |
int * | ierr | ||
) |
Fortran procedure to flush a sion file.
This fortran procedure flushes the buffers and writes the data to the sion file.
[in] | sid | sion file handle |
[out] | ierr | 1 if ok |
Definition at line 277 of file sion_fortran.c.
References sion_flush().
void fsion_get_endianness_c | ( | int * | endianness | ) |
Fortran function that returns current endianness (1-> big endian, 0 ->little endian)
[out] | endianness | sion file handle (out) |
Definition at line 499 of file sion_fortran.c.
References sion_get_endianness().
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)
[in] | sid | sion file handle (in) |
[out] | endianness | used for the return value |
Definition at line 486 of file sion_fortran.c.
References sion_get_file_endianness().
void fsion_get_fileno_c | ( | int * | sid, |
int * | filenumber | ||
) |
Fortran function that returns the current file number.
This fortran function returns an INTEGER*8 containing the current file possition.
[in] | sid | sion file handle (in) |
[out] | filenumber | used for return value |
Definition at line 465 of file sion_fortran.c.
References _sion_file_get_fd(), _sion_vcdtovcon(), _sion_vcdtype(), _sion_filedesc_struct::fileptr, and SION_FILEDESCRIPTOR.
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.
This procedure returns pointers to internal fields, containing the number of chunks written by each task (sion_chunkcount) and their sizes (sion_chunksizes). This function is only needed if the sion file was opened for reading in serial mode.
[in] | sid | sion file handle |
[out] | ntasks | number of tasks wrote to the sion file |
[out] | maxblocks | maximum number of chunks per tasks used |
[out] | globalskip | distance in bytes between the first bytes of two subsequent chunks of a task |
[out] | start_of_varheader | start position of the meta data block at the end of sion file |
[out] | sion_localsizes | field containing requested chunk size of each task |
[out] | sion_globalranks | field containing global unique id of each task |
[out] | sion_chunkcount | field containing number of chunks used by each task |
[out] | sion_chunksizes | field containing for each task and chunk the number of bytes used in this chunk e.g. access: sion_chunksizes[rank*chunks+chunknr] |
[out] | ierr | 1 if ok |
Definition at line 323 of file sion_fortran.c.
References sion_get_locations().
sion_int64 fsion_get_position_c | ( | int * | sid | ) |
Fortran function that returns the current file position.
This fortran function returns an INTEGER*8 containing the current file possition.
[in] | sid | sion file handle (in) |
Definition at line 347 of file sion_fortran.c.
References sion_get_position().
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.
This function opens a sion file in serial mode
[in] | fname | name of file, should equal on all tasks |
[in,out] | file_mode | like the type parameter of fopen (currently recognized options: "rb", "wb") |
[in] | ntasks | number of tasks used to write this file |
[in,out] | nfiles | number of physical files |
[in,out] | chunksizes | chunksize for each task |
[in,out] | fsblksize | blocksize of filesystem, must be equal on all processors |
[in] | globalranks | rank numbers for which the file should be open; will be stored in sion file, usefull if comm is not MPI_COMM_WORLD typical: globalrank= rank in MPI_COMM_WORLD |
[in] | fname_len | (internal) length of the fname string |
[in] | file_mode_len | (internal) length of the file_mode string |
sid | sion file handle or -1 if error occured |
Definition at line 56 of file sion_fortran.c.
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.
This function opens a sion file for a specific rank. It can be used to open the sion file independently from each task. (e.g. if no MPI is available or only a subset of tasks chunks are needed)
Using this function the meta data at beginning of the sion file are read from each task instead of read once and distribute (sion_open). sion_open_rank reads only the tasks specific meta data from the meta data block at the end of the sion file.
Warning: Only read operations are currently supported.
[in] | fname | name of file, should equal on all tasks |
[in,out] | file_mode | like the type parameter of fopen (currently recognized options: "rb", "wb") |
[in,out] | chunksize | chunksize for this task |
[in,out] | fsblksize | blocksize of filesystem, must be equal on all processors |
[in] | rank | rank number for which the file should be open; will be stored in sion file, usefull if comm is not MPI_COMM_WORLD typical: globalrank= rank in MPI_COMM_WORLD |
[in] | fname_len | (internal) length of the fname string * |
[in] | file_mode_len | (internal) length of the file_mode string |
sid | sion file handle or -1 if error occured |
Definition at line 143 of file sion_fortran.c.
References sion_open_rank().
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.
This procedure sets the file pointer to a new position according to the specified parameters. It can only be used when the sion file was opened for reading in serial mode. In Write mode currently only the rank can be modified! SION_CURRENT_BLK and SION_CURRENT_POS are required
[in] | sid | sion file handle |
[in] | rank | rank number of the process (SION_CURRENT_RANK to select the current rank) |
[in] | currentblocknr | block number (SION_CURRENT_BLK to select the current block) |
[in] | posinblk | position in the block (SION_CURRENT_POS to select the current position) |
[out] | ierr | 1 if file pointer can be moved to new position 0 otherwise |
Definition at line 229 of file sion_fortran.c.
void fsion_swap_c | ( | void * | target, |
void * | source, | ||
int * | size, | ||
int * | n, | ||
int * | do_swap, | ||
int * | rc | ||
) |
Fortran procedure to swap endianness of data.
n
elements of size
bytes each are swapped if do_swap
is true
. In-place swapping (target == source
) is allowed. If target != source
, the buffers must not overlap.
[in,out] | target | pointer to the store location |
[in] | source | pointer to the source location |
[in] | size | size of the data |
[in] | n | number of items of data to swap |
[in] | do_swap | 1 indicates that coversion should be done |
[out] | rc | number of objects converted, or zero if an error occurs, or the end-of-file is reached |
Definition at line 536 of file sion_fortran.c.
References sion_swap().