Millepede-II V04-17-04
Functions | Variables
readc.c File Reference

Read from C/C++ binary files. More...

#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

void initc (int nFiles)
 Initialises the 'global' variables used for file handling. More...
 
void openc (const char *fileName, int lfn, int nFileIn, int *errorFlag)
 Open file. More...
 
void closec (int nFileIn)
 Close file. More...
 
void resetc (int nFileIn)
 Rewind file. More...
 
void readc (double *bufferDouble, float *bufferFloat, int *bufferInt, int *lengthBuffers, int nFileIn, int *errorFlag)
 Read record from file. More...
 

Variables

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

Detailed Description

Read from C/C++ binary files.

Author
Gero Flucke, University Hamburg, 2006
Claus Kleinwort, DESY (maintenance and developement)

C-methods to handle input of C/C++ binary files as input for the fortran pede program (see peread).

Deprecated:
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

Major updates on April 24th, 2012 by C.Kleinwort:

Major update on February 26th, 2014 by C.Kleinwort:

Major update on April 10th, 2019 by C.Kleinwort:

Last major update on March 21th, 2023 by C.Kleinwort:

Definition in file readc.c.

Function Documentation

◆ closec()

void closec ( int  nFileIn)

Close file.

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

Definition at line 168 of file readc.c.

References files.

Referenced by bincls().

◆ initc()

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 91 of file readc.c.

References files, readMilleBinary::i, maxNumFiles, and numAllFiles.

Referenced by filetc().

◆ openc()

void openc ( const char *  fileName,
int  lfn,
int  nFileIn,
int *  errorFlag 
)

Open file.

Parameters
[in]fileNameFile name
[in]lfnLength of file name
[in]nFileInFile number (1 .. maxNumFiles) or <=0 for next one
[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 110 of file readc.c.

References files, readMilleBinary::i, maxNumFiles, and numAllFiles.

Referenced by binopn().

◆ readc()

void readc ( double *  bufferDouble,
float *  bufferFloat,
int *  bufferInt,
int *  lengthBuffers,
int  nFileIn,
int *  errorFlag 
)

Read record from file.

Parameters
[out]bufferDoubleread buffer for doubles
[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
  • -32: problem with stream or EOF reading doubles
  • =0: reached end of file (or read empty record?!)
  • =4: found floats
  • =8: found doubles

Definition at line 219 of file readc.c.

References files, and readMilleBinary::i.

Referenced by peread().

◆ resetc()

void resetc ( int  nFileIn)

Rewind file.

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

Definition at line 185 of file readc.c.

References files.

Referenced by binrwd().

Variable Documentation

◆ files

FILE** files

pointer to list of pointers to opened binary files

Definition at line 80 of file readc.c.

Referenced by closec(), initc(), openc(), readc(), and resetc().

◆ maxNumFiles

unsigned int maxNumFiles

max number of files

Definition at line 83 of file readc.c.

Referenced by initc(), and openc().

◆ numAllFiles

unsigned int numAllFiles

number of opened files

Definition at line 84 of file readc.c.

Referenced by initc(), and openc().