Millepede-II  V04-00-00_preview
 All Classes Files Functions Variables Enumerator Pages
Functions/Subroutines | Variables
readc.c File Reference

Read C-binary files. More...

#include <stdio.h>
#include "cfortran.h"

Go to the source code of this file.

Functions/Subroutines

void initC (int *nFiles)
 Initialises the 'global' variables used for file handling.
void resetC (int *nFileIn)
 Rewind file.
void openC (const char *fileName, int *errorFlag)
 Open file.
void readC (float *bufferFloat, int *bufferInt, int *lengthBuffers, int *nFileIn, int *errorFlag)
 Read record from file.

Variables

FILE ** files
 pointer to list of pointers to opened binary files
unsigned int maxNumFiles
 max number of files
unsigned int numAllFiles
 number of opened files

Detailed Description

Read C-binary files.

C-methods to handle input of C/C++ binary files as input for the fortran pede program (see peread). This includes macros utilising cfortran.h to allow direct callability from fortran.

initC() has to be called once in the beginning, followed by one or several calls to openC() to open one or several files. readC() is then called to read the records sequentially. resetC() allows to rewind files.

If compiled with preprocessor macro USE_SHIFT_RFIO, uses libRFIO, i.e. includes shift.h instead of stdio.h

If compiled with preprocessor macro USE_ZLIB, uses libz, enables direct reading of gzipped files.

Written by Gero Flucke (gero..nosp@m.fluc.nosp@m.ke@ce.nosp@m.rn.c.nosp@m.h) in 2006/7

Last major update on April 24th, 2012 by C.Kleinwort:

Definition in file readc.c.


Function/Subroutine Documentation

void initC ( int *  nFiles)

Initialises the 'global' variables used for file handling.

Parameters:
[in]nFilesMaximal number of C binary files to use.

Definition at line 61 of file readc.c.

References files, maxNumFiles, and numAllFiles.

void openC ( const char *  fileName,
int *  errorFlag 
)

Open file.

Parameters:
[in]fileNameFile name
[out]errorFlagerror flag:
  • 0: if file opened and OK,
  • 1: if too many files open,
  • 2: if file could not be opened
  • 3: if file opened, but with error (can that happen?)

Definition at line 113 of file readc.c.

References files, maxNumFiles, and numAllFiles.

void readC ( float *  bufferFloat,
int *  bufferInt,
int *  lengthBuffers,
int *  nFileIn,
int *  errorFlag 
)

Read record from file.

Parameters:
[out]bufferFloatread buffer for floats
[out]bufferIntread buffer for integers
[in,out]lengthBuffersin: buffer length, out: number of floats/ints in records (> buffer size: record skipped)
[in]nFileInFile number (1 .. maxNumFiles)
[out]errorFlagerror flag:
  • -1: pointer to a buffer or lengthBuffers are null
  • -2: problem reading record length
  • -4: given buffers too short for record
  • -8: problem with stream or EOF reading floats
  • -16: problem with stream or EOF reading ints
  • =0: reached end of file (or read empty record?!)
  • >0: number of words (floats + integers) read and stored in buffers

Definition at line 170 of file readc.c.

References files.

void resetC ( int *  nFileIn)

Rewind file.

Parameters:
[in]nFileInFile number (1 .. maxNumFiles)

Definition at line 97 of file readc.c.

References files.


Variable Documentation

FILE** files

pointer to list of pointers to opened binary files

Definition at line 49 of file readc.c.

Referenced by initC(), openC(), peread(), readC(), and resetC().

unsigned int maxNumFiles

max number of files

Definition at line 52 of file readc.c.

Referenced by initC(), and openC().

unsigned int numAllFiles

number of opened files

Definition at line 53 of file readc.c.

Referenced by initC(), and openC().