SURFEX v8.1
General documentation of Surfex
Functions | Variables
bytes_io.c File Reference

Go to the source code of this file.

Functions

void c_bytes_io_open_ (int *unit, char *name, char *mode, int *iret, int l1, int l2)
 
void c_bytes_io_open__ (int *unit, char *name, char *mode, int *iret, int l1, int l2)
 
void c_bytes_io_open (int *unit, char *name, char *mode, int *iret, int l1, int l2)
 
void c_bytes_io_seek_ (int *unit, int *offset, int *whence, int *iret)
 
void c_bytes_io_seek (int *unit, int *offset, int *whence, int *iret)
 
void c_bytes_io_tell_ (int *unit, int *iret)
 
void c_bytes_io_tell__ (int *unit, int *iret)
 
void c_bytes_io_tell (int *unit, int *iret)
 
void c_bytes_io_read_ (int *unit, char *buffer, int *nbytes, int *iret)
 
void c_bytes_io_read__ (int *unit, char *buffer, int *nbytes, int *iret)
 
void c_bytes_io_read (int *unit, char *buffer, int *nbytes, int *iret)
 
void c_bytes_io_write_ (int *unit, char *buffer, int *nbytes, int *iret)
 
void c_bytes_io_write__ (int *unit, char *buffer, int *nbytes, int *iret)
 
void c_bytes_io_write (int *unit, char *buffer, int *nbytes, int *iret)
 
void c_bytes_io_close_ (int *unit, int *iret)
 
void c_bytes_io_close__ (int *unit, int *iret)
 
void c_bytes_io_close (int *unit, int *iret)
 
void c_bytes_io_flush_ (int *unit)
 
void c_bytes_io_flush__ (int *unit)
 
void c_bytes_io_flush (int *unit)
 

Variables

static FILE ** fptable = NULL
 
static int fptableSize = 0
 
static pthread_mutex_t fpTableBusy = PTHREAD_MUTEX_INITIALIZER
 
static long size = SIZE
 
static int sizeSet = 0
 
static char * envSize
 
static char ** fileBuffer = NULL
 
static char * debugLevel
 
static int debugSet = 0
 

Function Documentation

◆ c_bytes_io_close()

void c_bytes_io_close ( int *  unit,
int *  iret 
)

Definition at line 801 of file bytes_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_bytes_io_close_()

void c_bytes_io_close_ ( int *  unit,
int *  iret 
)

Definition at line 775 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_close__()

void c_bytes_io_close__ ( int *  unit,
int *  iret 
)

Definition at line 797 of file bytes_io.c.

Here is the call graph for this function:

◆ c_bytes_io_flush()

void c_bytes_io_flush ( int *  unit)

Definition at line 824 of file bytes_io.c.

Here is the call graph for this function:

◆ c_bytes_io_flush_()

void c_bytes_io_flush_ ( int *  unit)

Definition at line 810 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_flush__()

void c_bytes_io_flush__ ( int *  unit)

Definition at line 820 of file bytes_io.c.

Here is the call graph for this function:

◆ c_bytes_io_open()

void c_bytes_io_open ( int *  unit,
char *  name,
char *  mode,
int *  iret,
int  l1,
int  l2 
)

Definition at line 530 of file bytes_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_bytes_io_open_()

void c_bytes_io_open_ ( int *  unit,
char *  name,
char *  mode,
int *  iret,
int  l1,
int  l2 
)

Definition at line 285 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_open__()

void c_bytes_io_open__ ( int *  unit,
char *  name,
char *  mode,
int *  iret,
int  l1,
int  l2 
)

Definition at line 527 of file bytes_io.c.

Here is the call graph for this function:

◆ c_bytes_io_read()

void c_bytes_io_read ( int *  unit,
char *  buffer,
int *  nbytes,
int *  iret 
)

Definition at line 718 of file bytes_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_bytes_io_read_()

void c_bytes_io_read_ ( int *  unit,
char *  buffer,
int *  nbytes,
int *  iret 
)

Definition at line 671 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_read__()

void c_bytes_io_read__ ( int *  unit,
char *  buffer,
int *  nbytes,
int *  iret 
)

Definition at line 714 of file bytes_io.c.

Here is the call graph for this function:

◆ c_bytes_io_seek()

void c_bytes_io_seek ( int *  unit,
int *  offset,
int *  whence,
int *  iret 
)

Definition at line 608 of file bytes_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_bytes_io_seek_()

void c_bytes_io_seek_ ( int *  unit,
int *  offset,
int *  whence,
int *  iret 
)

Definition at line 539 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_tell()

void c_bytes_io_tell ( int *  unit,
int *  iret 
)

Definition at line 661 of file bytes_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_bytes_io_tell_()

void c_bytes_io_tell_ ( int *  unit,
int *  iret 
)

Definition at line 618 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_tell__()

void c_bytes_io_tell__ ( int *  unit,
int *  iret 
)

Definition at line 657 of file bytes_io.c.

Here is the call graph for this function:

◆ c_bytes_io_write()

void c_bytes_io_write ( int *  unit,
char *  buffer,
int *  nbytes,
int *  iret 
)

Definition at line 766 of file bytes_io.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_bytes_io_write_()

void c_bytes_io_write_ ( int *  unit,
char *  buffer,
int *  nbytes,
int *  iret 
)

Definition at line 728 of file bytes_io.c.

Here is the caller graph for this function:

◆ c_bytes_io_write__()

void c_bytes_io_write__ ( int *  unit,
char *  buffer,
int *  nbytes,
int *  iret 
)

Definition at line 762 of file bytes_io.c.

Here is the call graph for this function:

Variable Documentation

◆ debugLevel

char* debugLevel
static

Definition at line 272 of file bytes_io.c.

◆ debugSet

int debugSet = 0
static

Definition at line 273 of file bytes_io.c.

◆ envSize

char* envSize
static

Definition at line 264 of file bytes_io.c.

◆ fileBuffer

char** fileBuffer = NULL
static

Definition at line 265 of file bytes_io.c.

◆ fptable

FILE** fptable = NULL
static

Copyright 1981-2016 ECMWF.

This software is licensed under the terms of the Apache Licence Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.

In applying this licence, ECMWF does not waive the privileges and immunities granted to it by virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.

This file describes a number of subroutines which can be called from FORTRAN to handle an unblocked binary file:

BYTES_IO_OPEN to open the file BYTES_IO_CLOSE to close the file BYTES_IO_TELL to give position in the file (optional) BYTES_IO_SEEK to position the file (optional) BYTES_IO_READ to read from the file BYTES_IO_WRITE to write to the file BYTES_IO_FLUSH to flush the file

The subroutines are written in C and use standard library functions for file handling (fopen, fclose, fseek, ftell, fread and fwrite).

These routines are a direct replacement for:

  • PBOPEN
  • PBCLOSE
  • PBTELL
  • PBSEEK
  • PBREAD
  • PBWRITE
  • PBFLUSH

BYTES_IO_OPEN

A subroutine which can be called from FORTRAN to open an unblocked binary file and return a suitable unit number for use in calls to BYTES_IO_READ, and BYTES_IO_WRITE, BYTES_IO_SEEK, BYTES_IO_TELL.

The format and arguments for the subroutine are as follows:

SUBROUTINE BYTES_IO_OPEN(KUNIT,FILENAME,MODE,KRET)

where:

Input parameters are CHARACTERs:

FILENAME = a character string describing the file

MODE = a character string describing the mode of access to the file: r for read w for write a for append

Output parameters are INTEGERs:

KUNIT = unit number for the file - it is a C FILE pointer and not a FORTRAN unit number.

KRET = -1 = Could not open file. -2 = Invalid file name. -3 = Invalid open mode specified 0 = OK.

BYTES_IO_CLOSE

A subroutine which can be called from FORTRAN to close an unblocked binary file previously opened with BYTES_IO_OPEN.

The format and arguments for the subroutine are as follows:

SUBROUTINE BYTES_IO_CLOSE(KUNIT,KRET)

where:

Input parameter is an INTEGER:

KUNIT = unit number for the file; this must have been obtained by calling BYTES_IO_OPEN (see below) - it is a C FILE pointer and not a FORTRAN unit number.

Output parameter is an INTEGER:

KRET = -1 error in handling the file. 0 = OK.

BYTES_IO_SEEK

A subroutine which can be called from FORTRAN to position an unblocked binary file at any desired byte position.

The format and arguments for the subroutine are as follows:

SUBROUTINE BYTES_IO_SEEK(KUNIT,KOFFSET,KSTART,KRET)

where:

Input parameters are INTEGERs:

KUNIT = unit number for the file; this must have been obtained by calling BYTES_IO_OPEN (see below) - it is a C FILE pointer and not a FORTRAN unit number.

KOFFSET = number of bytes to offset the file; this is used as either an absolute or relative offset depending on the value of KSTART.

KSTART = 0 if KOFFSET is an absolute count from the beginning of the file,

1 if KOFFSET is a relative offset from the current byte position in the file,

2 if KOFFSET is an absolute offset from the end of file.

Output parameter is an INTEGER:

KRET = -2 if there is an error in handling the file

            -1      if end-of-file is encountered
                    (Note that EOF does not cause a program fail, 
                    so this value must be explicitly caught by 
                    the caller to avoid looping at the EOF)

            >= 0    byte offset from the start of file after
                    positioning.

BYTES_IO_READ

A subroutine which can be called from FORTRAN to read a block of bytes from an unblocked binary file. ( Note that this routine behaves differently from BYTES_IO_READ2 on hitting end-of-file. )

The format and arguments for the subroutine are as follows:

SUBROUTINE BYTES_IO_READ(KUNIT,KARRAY,KOUNT,KRET)

where:

Input parameters are INTEGERs:

KUNIT = unit number for the file; this must have been obtained by calling BYTES_IO_OPEN (see below) - it is a C FILE pointer and not a FORTRAN unit number.

KOUNT = number of BYTES to read from the file.

Output parameters are INTEGERs:

KARRAY = an INTEGER array to accept the bytes from the read.

KRET = -2 if there is an error in handling the file

            -1      if end-of-file is encountered
                    (Note that EOF does not cause a program fail, 
                    so this value must be explicitly caught by 
                    the caller to avoid looping at the EOF)

            >= 0    number of BYTES read from the file.

BYTES_IO_WRITE

A subroutine which can be called from FORTRAN to write a block of bytes to an unblocked binary file.

The format and arguments for the subroutine are as follows:

SUBROUTINE BYTES_IO_WRITE(KUNIT,KARRAY,KOUNT,KRET)

where:

Input parameters are INTEGERs:

KUNIT = unit number for the file; this must have been obtained by calling BYTES_IO_OPEN (see below) - it is a C FILE pointer and not a FORTRAN unit number.

KARRAY = an INTEGER array holding the bytes for the write.

KOUNT = number of BYTES to write to the file.

Output parameter is an INTEGER:

KRET = -1 if there is an error in writing to the file

            >= 0    number of BYTES written to the file.

Definition at line 250 of file bytes_io.c.

◆ fpTableBusy

pthread_mutex_t fpTableBusy = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 254 of file bytes_io.c.

◆ fptableSize

int fptableSize = 0
static

Definition at line 251 of file bytes_io.c.

◆ size

long size = SIZE
static

Definition at line 262 of file bytes_io.c.

◆ sizeSet

int sizeSet = 0
static

Definition at line 263 of file bytes_io.c.