FEDEM Solver
R8.0
Source code of the dynamics solver
|
Global functions binary file IO. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <unistd.h>
#include "FFaLib/FFaOS/FFaTag_C.h"
#include "FFaLib/FFaOS/FFaFortran.H"
Macros | |
#define | _MAX_DBFIL 50 |
Functions | |
SUBROUTINE (openbinarydb, OPENBINARYDB) const | |
Opens a binary direct access file for read or write. More... | |
SUBROUTINE (setbufdb, SETBUFDB) const | |
Allocates an in-core buffer for the specified file. More... | |
static int | flushBinaryDB (int file, int doFlush) |
Flushes the in-core buffer of the specified file to disk. More... | |
SUBROUTINE (flushbinarydb, FLUSHBINARYDB) const | |
Flushes the in-core buffer of the specified file to disk. More... | |
SUBROUTINE (closebinary_db, CLOSEBINARY_DB) const | |
Closes the specified file. More... | |
SUBROUTINE (deletedb, DELETEDB) const | |
Deletes the named file. More... | |
void | closeAllBinaryDB () |
Closes all opened binary files. More... | |
static int | writeBinaryDB (int ifile, const void *p, size_t nSize, size_t nData) |
Internal generic function to actually write binary data to file. More... | |
static int | writeDoubleDB (int ifile, const double *data, size_t ndat) |
Internal function to write double precision data to file. More... | |
SUBROUTINE (writeintdb, WRITEINTDB) const | |
Writes an integer array to the specified file. More... | |
SUBROUTINE (writefloatdb, WRITEFLOATDB) const | |
Writes a single precision array to the specified file. More... | |
SUBROUTINE (writedoubled4, WRITEDOUBLED4) const | |
Writes a double precision array to the specified file. More... | |
SUBROUTINE (writedoubled8, WRITEDOUBLED8) const | |
Writes a double precision array to the specified file. More... | |
SUBROUTINE (writechardb, WRITECHARDB) const | |
Writes a character string to the specified file. More... | |
static int | swapBytes (char *p, size_t m, size_t n) |
Performs byte swapping of an array in case of endian discrepancies. More... | |
static int | readBinaryDB (int ifile, void *p, size_t nSize, size_t nData, char silence) |
Internal generic function to actually read binary data from file. More... | |
SUBROUTINE (readintdb, READINTDB) const | |
Reads an integer array from the specified file. More... | |
SUBROUTINE (readfloatdb, READFLOATDB) const | |
Reads a single precision array from the specified file. More... | |
SUBROUTINE (readdoubled4, READDOUBLED4) const | |
Reads a double precision array from the specified file. More... | |
SUBROUTINE (readdoubled8, READDOUBLED8) const | |
Reads a double precision array from the specified file. More... | |
SUBROUTINE (readchardb, READCHARDB) const | |
Reads a character string from the specified file. More... | |
SUBROUTINE (writetagdb, WRITETAGDB) const | |
Writes the file tag and checksum to the specified file. More... | |
SUBROUTINE (readtagdb, READTAGDB) const | |
Reads the file tag and checksum from the specified file. More... | |
SUBROUTINE (setpositiondb, SETPOSITIONDB) const | |
Sets the file pointer for next read operation for the specified file. More... | |
SUBROUTINE (getpositiondb, GETPOSITIONDB) const | |
Returns the current file pointer for the specified file. More... | |
SUBROUTINE (putchardb, PUTCHARDB) const | |
Writes a character string at specified location in the specified file. More... | |
SUBROUTINE (copybinarydb, COPYBINARYDB) const | |
Copies data from one binary file to another. More... | |
Variables | |
static char * | fname [_MAX_DBFIL] |
static char * | fbuff [_MAX_DBFIL] |
static size_t | bptr [_MAX_DBFIL] |
static size_t | bsiz [_MAX_DBFIL] |
static FT_FILE | fdb [_MAX_DBFIL] |
static short | doSwap [_MAX_DBFIL] |
static const float | Version = 1.0f |
Global functions binary file IO.
This file contains some Fortran-callable global functions for performing binary file IO based on low-level fwrite/fread calls.
#define _MAX_DBFIL 50 |
Max number of binary files that can be open at the same time
void closeAllBinaryDB | ( | ) |
Closes all opened binary files.
Used by signal handlers only.
|
static |
Flushes the in-core buffer of the specified file to disk.
[in] | file | Index of the file to flush |
[in] | doFlush | If true, perform a physical flush of the file |
|
static |
Internal generic function to actually read binary data from file.
[in] | ifile | File number in range <-_MAX_DBFIL,_MAX_DBFIL> < 0 : rewind the file before reading it |
[out] | p | Pointer to memory segment in which to store the data read |
[in] | nSize | Size of each data item |
[in] | nData | Number of data items to read |
[in] | silence | If > 0 suppress error message on read failure |
SUBROUTINE | ( | closebinary_db | , |
CLOSEBINARY_DB | |||
) | const |
Closes the specified file.
SUBROUTINE | ( | copybinarydb | , |
COPYBINARYDB | |||
) | const |
Copies data from one binary file to another.
SUBROUTINE | ( | deletedb | , |
DELETEDB | |||
) | const |
Deletes the named file.
SUBROUTINE | ( | flushbinarydb | , |
FLUSHBINARYDB | |||
) | const |
Flushes the in-core buffer of the specified file to disk.
SUBROUTINE | ( | getpositiondb | , |
GETPOSITIONDB | |||
) | const |
Returns the current file pointer for the specified file.
SUBROUTINE | ( | openbinarydb | , |
OPENBINARYDB | |||
) | const |
Opens a binary direct access file for read or write.
SUBROUTINE | ( | putchardb | , |
PUTCHARDB | |||
) | const |
Writes a character string at specified location in the specified file.
The actual location is identified by the character string tag. Any existing data at the specified location will be overwritten such that the total file size will not change (unless at the end of the file). If the tag is not found, the file is not touched.
SUBROUTINE | ( | readchardb | , |
READCHARDB | |||
) | const |
Reads a character string from the specified file.
SUBROUTINE | ( | readdoubled4 | , |
READDOUBLED4 | |||
) | const |
Reads a double precision array from the specified file.
SUBROUTINE | ( | readdoubled8 | , |
READDOUBLED8 | |||
) | const |
Reads a double precision array from the specified file.
SUBROUTINE | ( | readfloatdb | , |
READFLOATDB | |||
) | const |
Reads a single precision array from the specified file.
SUBROUTINE | ( | readintdb | , |
READINTDB | |||
) | const |
Reads an integer array from the specified file.
SUBROUTINE | ( | readtagdb | , |
READTAGDB | |||
) | const |
Reads the file tag and checksum from the specified file.
SUBROUTINE | ( | setbufdb | , |
SETBUFDB | |||
) | const |
Allocates an in-core buffer for the specified file.
SUBROUTINE | ( | setpositiondb | , |
SETPOSITIONDB | |||
) | const |
Sets the file pointer for next read operation for the specified file.
SUBROUTINE | ( | writechardb | , |
WRITECHARDB | |||
) | const |
Writes a character string to the specified file.
SUBROUTINE | ( | writedoubled4 | , |
WRITEDOUBLED4 | |||
) | const |
Writes a double precision array to the specified file.
SUBROUTINE | ( | writedoubled8 | , |
WRITEDOUBLED8 | |||
) | const |
Writes a double precision array to the specified file.
SUBROUTINE | ( | writefloatdb | , |
WRITEFLOATDB | |||
) | const |
Writes a single precision array to the specified file.
SUBROUTINE | ( | writeintdb | , |
WRITEINTDB | |||
) | const |
Writes an integer array to the specified file.
SUBROUTINE | ( | writetagdb | , |
WRITETAGDB | |||
) | const |
Writes the file tag and checksum to the specified file.
|
static |
Performs byte swapping of an array in case of endian discrepancies.
|
static |
Internal generic function to actually write binary data to file.
[in] | ifile | File number in range [0,_MAX_DBFIL> |
[in] | p | Pointer to the data to write |
[in] | nSize | Size of each data item |
[in] | nData | Number of data items to write |
|
static |
Internal function to write double precision data to file.
[in] | ifile | File number in range [0,_MAX_DBFIL> |
[in] | data | Pointer to the data to write |
[in] | ndat | Number of doubles to write |
This function is a wrapper for writeBinaryDB() used for large double arrays. The data is written in 2GB chunks on Windows to avoid run-time failure.
|
static |
Indices to next available buffer location
|
static |
The size of each in-core buffer
|
static |
Byte-swapping flags for each file
|
static |
In-core buffers for the binary files
|
static |
File pointers for each file
|
static |
Names of all opened binary files
|
static |
Internal file version tag