SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
Macros | Functions
sion_fortran.h File Reference

Fortran API. More...

#include "sion.h"
Include dependency graph for sion_fortran.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SWAP_2(x)   ( (((x) & 0xff) << 8) | ((unsigned short)(x) >> 8) )
 
#define SWAP_4(x)
 
#define FIX_SHORT(x)   (*(unsigned short *)&(x) = SWAP_2(*(unsigned short *)&(x)))
 
#define FIX_LONG(x)   (*(unsigned *)&(x) = SWAP_4(*(unsigned *)&(x)))
 
#define FIX_FLOAT(x)   FIX_LONG(x)
 

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_chunksizes, sion_int64 **sion_globalranks, sion_int64 **sion_blockcount, sion_int64 **sion_fsblksizes, int *ierr)
 Fortran procedure that returns pointers to internal fields. 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)
 
sion_int64 fsion_get_position_c (int *sid)
 Fortran function that returns the current file position. More...
 
void fsion_get_fileno_c (int *sid, int *filenumber)
 Fortran function that returns the current file number. More...
 
void fsion_set_fp_closed_c (int *sid, int *ierr)
 
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 *filenumber)
 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...
 

Detailed Description

Fortran API.

Author
Ventsislav Petkov
Date
14.08.2008
03.05.2013 modifications to support different Fortran interfaces, Florian Janetzko

Definition in file sion_fortran.h.

Macro Definition Documentation

◆ SWAP_4

#define SWAP_4 (   x)
Value:
( ((x) << 24) | (((x) << 8) & 0x00ff0000) | \
(((x) >> 8) & 0x0000ff00) | ((x) >> 24) )

Definition at line 479 of file sion_fortran.h.

Function Documentation

◆ fsion_bytes_avail_in_block_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.

Parameters
[in]sidsion file handle
Returns
INTEGER*4 rc>0 number of bytes rc<=0 file position is after end of block

Definition at line 296 of file sion_fortran.c.

References sion_bytes_avail_in_block().

◆ fsion_close_c()

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.

Parameters
[in]sidsion file handle
[out]ierr1 if close is ok

Definition at line 183 of file sion_fortran.c.

References sion_close().

◆ fsion_endianness_swap_needed_c()

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)

Parameters
[in]sidsion file handle (in)
[out]neededused for the return value

Definition at line 512 of file sion_fortran.c.

References sion_endianness_swap_needed().

◆ fsion_ensure_free_space_c()

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.

Parameters
[in]sidsion file handle
[in]bytesnumber of bytes which will be written
[out]ierr1 if ok

Definition at line 258 of file sion_fortran.c.

References sion_ensure_free_space().

◆ fsion_feof_c()

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.

Parameters
[in]sidsion file handle
[out]eof1 if the End of the File is reached
Return values
1if end of last chunk reached 0 otherwise

Definition at line 205 of file sion_fortran.c.

References sion_feof().

◆ fsion_flush_c()

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.

Parameters
[in]sidsion file handle
[out]ierr1 if ok

Definition at line 277 of file sion_fortran.c.

References sion_flush().

◆ fsion_get_endianness_c()

void fsion_get_endianness_c ( int *  endianness)

Fortran function that returns current endianness (1-> big endian, 0 ->little endian)

Parameters
[out]endiannesssion file handle (out)

Definition at line 499 of file sion_fortran.c.

References sion_get_endianness().

◆ fsion_get_file_endianness_c()

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)

Parameters
[in]sidsion file handle (in)
[out]endiannessused for the return value

Definition at line 486 of file sion_fortran.c.

References sion_get_file_endianness().

◆ fsion_get_fileno_c()

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.

Parameters
[in]sidsion file handle (in)
[out]filenumberused 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.

◆ fsion_get_locations_c()

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.

Parameters
[in]sidsion file handle
[out]ntasksnumber of tasks wrote to the sion file
[out]maxblocksmaximum number of chunks per tasks used
[out]globalskipdistance in bytes between the first bytes of two subsequent chunks of a task
[out]start_of_varheaderstart position of the meta data block at the end of sion file
[out]sion_localsizesfield containing requested chunk size of each task
[out]sion_globalranksfield containing global unique id of each task
[out]sion_chunkcountfield containing number of chunks used by each task
[out]sion_chunksizesfield containing for each task and chunk the number of bytes used in this chunk e.g. access: sion_chunksizes[rank*chunks+chunknr]
[out]ierr1 if ok

Definition at line 323 of file sion_fortran.c.

References sion_get_locations().

◆ fsion_get_position_c()

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.

Parameters
[in]sidsion file handle (in)
Returns
INTEGER*8 current file position

Definition at line 347 of file sion_fortran.c.

References sion_get_position().

◆ fsion_open_c()

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

Parameters
[in]fnamename of file, should equal on all tasks
[in,out]file_modelike the type parameter of fopen (currently recognized options: "rb", "wb")
[in]ntasksnumber of tasks used to write this file
[in,out]nfilesnumber of physical files
[in,out]chunksizeschunksize for each task
[in,out]fsblksizeblocksize of filesystem, must be equal on all processors
[in]globalranksrank 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
Return values
sidsion file handle or -1 if error occured

Definition at line 56 of file sion_fortran.c.

◆ fsion_open_rank_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.

Parameters
[in]fnamename of file, should equal on all tasks
[in,out]file_modelike the type parameter of fopen (currently recognized options: "rb", "wb")
[in,out]chunksizechunksize for this task
[in,out]fsblksizeblocksize of filesystem, must be equal on all processors
[in]rankrank 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
Return values
sidsion file handle or -1 if error occured

Definition at line 143 of file sion_fortran.c.

References sion_open_rank().

◆ fsion_seek_c()

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

Parameters
[in]sidsion file handle
[in]rankrank number of the process (SION_CURRENT_RANK to select the current rank)
[in]currentblocknrblock number (SION_CURRENT_BLK to select the current block)
[in]posinblkposition in the block (SION_CURRENT_POS to select the current position)
[out]ierr1 if file pointer can be moved to new position 0 otherwise

Definition at line 229 of file sion_fortran.c.

◆ fsion_swap_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.

Parameters
[in,out]targetpointer to the store location
[in]sourcepointer to the source location
[in]sizesize of the data
[in]nnumber of items of data to swap
[in]do_swap1 indicates that coversion should be done
[out]rcnumber 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().