gpp4  1.3.1
Classes | Typedefs | Enumerations | Functions
ccp4_diskio_f.c File Reference

FORTRAN API for file i/o. More...

#include <string.h>
#include "ccp4_utils.h"
#include "ccp4_errno.h"
#include "ccp4_fortran.h"
#include "ccp4_file_err.h"

Classes

struct  _CCP4IObj
 

Typedefs

typedef struct _CCP4IObj CCP4IObj
 

Enumerations

enum  FILE_KLASS { NONE, CCP4_FILE, CCP4_MAP }
 

Functions

int _get_channel ()
 
CCP4IObj_iobj_init ()
 
 FORTRAN_SUBR (QOPEN, qopen,(int *iunit, fpstr lognam, fpstr atbuta, int lognam_len, int atbuta_len),(int *iunit, fpstr lognam, fpstr atbuta),(int *iunit, fpstr lognam, int lognam_len, fpstr atbuta, int atbuta_len))
 
 FORTRAN_SUBR (QQOPEN, qqopen,(int *iunit, fpstr lognam, const int *istat, int lognam_len),(int *iunit, fpstr lognam, const int *istat),(int *iunit, fpstr lognam, int lognam_len, const int *istat))
 
 FORTRAN_SUBR (COPEN, copen,(int *iunit, fpstr filename, int *istat, int filename_len),(int *iunit, fpstr filename, int *istat),(int *iunit, fpstr filename, int filename_len, int *istat))
 
 FORTRAN_SUBR (QRARCH, qrarch,(int *iunit, int *ipos, int *ireslt),(int *iunit, int *ipos, int *ireslt),(int *iunit, int *ipos, int *ireslt))
 
 FORTRAN_SUBR (QWARCH, qwarch,(int *iunit, int *ipos),(int *iunit, int *ipos),(int *iunit, int *ipos))
 
 FORTRAN_SUBR (QCLOSE, qclose,(int *iunit),(int *iunit),(int *iunit))
 
 FORTRAN_SUBR (QMODE, qmode,(int *iunit, int *mode, int *size),(int *iunit, int *mode, int *size),(int *iunit, int *mode, int *size))
 
 FORTRAN_SUBR (QREAD, qread,(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result))
 
 FORTRAN_SUBR (QREADI, qreadi,(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result))
 
 FORTRAN_SUBR (QREADI2, qreadi2,(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result))
 
 FORTRAN_SUBR (QREADR, qreadr,(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result))
 
 FORTRAN_SUBR (QREADQ, qreadq,(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result),(int *iunit, uint8 *buffer, int *nitems, int *result))
 
 FORTRAN_SUBR (QREADC, qreadc,(int *iunit, fpstr buffer, int *result, int buffer_len),(int *iunit, fpstr buffer, int *result),(int *iunit, fpstr buffer, int buffer_len, int *result))
 
 FORTRAN_SUBR (QWRITE, qwrite,(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems))
 
 FORTRAN_SUBR (QWRITI, qwriti,(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems))
 
 FORTRAN_SUBR (QWRITR, qwritr,(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems))
 
 FORTRAN_SUBR (QWRITQ, qwritq,(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems),(int *iunit, uint8 *buffer, int *nitems))
 
 FORTRAN_SUBR (QWRITC, qwritc,(int *iunit, fpstr buffer, int buffer_len),(int *iunit, fpstr buffer),(int *iunit, fpstr buffer, int buffer_len))
 
 FORTRAN_SUBR (QSEEK, qseek,(int *iunit, int *irec, int *iel, int *lrecl),(int *iunit, int *irec, int *iel, int *lrecl),(int *iunit, int *irec, int *iel, int *lrecl))
 
 FORTRAN_SUBR (QBACK, qback,(int *iunit, int *lrecl),(int *iunit, int *lrecl),(int *iunit, int *lrecl))
 
 FORTRAN_SUBR (QSKIP, qskip,(int *iunit, int *lrecl),(int *iunit, int *lrecl),(int *iunit, int *lrecl))
 
 FORTRAN_SUBR (QQINQ, qqinq,(int *istrm, fpstr logname, fpstr filename, int *length, int logname_len, int filename_len),(int *istrm, fpstr logname, fpstr filename, int *length),(int *istrm, fpstr logname, int logname_len, fpstr filename, int filename_len, int *length))
 
 FORTRAN_SUBR (QLOCATE, qlocate,(int *iunit, int *locate),(int *iunit, int *locate),(int *iunit, int *locate))
 

Detailed Description

FORTRAN API for file i/o.

Author
Charles Ballard and Martyn Winn

Typedef Documentation

◆ CCP4IObj

typedef struct _CCP4IObj CCP4IObj

_ioChannels: structure to hold files

Function Documentation

◆ FORTRAN_SUBR() [1/20]

FORTRAN_SUBR ( COPEN  ,
copen  ,
(int *iunit, fpstr filename, int *istat, int filename_len)  ,
(int *iunit, fpstr filename, int *istat)  ,
(int *iunit, fpstr filename, int filename_len, int *istat)   
)

Opens filename on io stream iunit. istat corresponds to the open mode.

Parameters
iunitiochannel number
filenamefortran character array giving filename
istatfile mode

References ccp4_FtoCString().

◆ FORTRAN_SUBR() [2/20]

FORTRAN_SUBR ( QBACK  ,
qback  ,
(int *iunit, int *lrecl)  ,
(int *iunit, int *lrecl)  ,
(int *iunit, int *lrecl)   
)

qback: @iunit: @lrecl:

Backspaces one record, of length @lrecl on diskio stream @iunit.

References ccp4_file_seek().

◆ FORTRAN_SUBR() [3/20]

FORTRAN_SUBR ( QCLOSE  ,
qclose  ,
(int *iunit)  ,
(int *iunit)  ,
(int *iunit)   
)

qclose: @iunit: io channel

Closes the file open on diskio stream iunit

References ccp4_file_close().

◆ FORTRAN_SUBR() [4/20]

FORTRAN_SUBR ( QLOCATE  ,
qlocate  ,
(int *iunit, int *locate)  ,
(int *iunit, int *locate)  ,
(int *iunit, int *locate)   
)

qlocate: @iunit: @locate:

Returns the current position \meta{locate} in the diskio stream @iunit.

References ccp4_file_tell().

◆ FORTRAN_SUBR() [5/20]

FORTRAN_SUBR ( QMODE  ,
qmode  ,
(int *iunit, int *mode, int *size)  ,
(int *iunit, int *mode, int *size)  ,
(int *iunit, int *mode, int *size)   
)

qmode: @iunit: io channel @mode: access mode @size: item size

Changes the diskio access mode for stream @iunit to
@mode. The resulting size in bytes of items for transfer is
returned as @size

References ccp4_file_itemsize().

◆ FORTRAN_SUBR() [6/20]

FORTRAN_SUBR ( QQINQ  ,
qqinq  ,
(int *istrm, fpstr logname, fpstr filename, int *length, int logname_len, int filename_len)  ,
(int *istrm, fpstr logname, fpstr filename, int *length)  ,
(int *istrm, fpstr logname, int logname_len, fpstr filename, int filename_len, int *length)   
)

qqinq: @istrm: @filnam: @length:

Returns the name @filnam and @length of the file (if any) open on diskio stream @istrm.

◆ FORTRAN_SUBR() [7/20]

FORTRAN_SUBR ( QRARCH  ,
qrarch  ,
(int *iunit, int *ipos, int *ireslt)  ,
(int *iunit, int *ipos, int *ireslt)  ,
(int *iunit, int *ipos, int *ireslt)   
)

qrarch: @iunit: iochannel @ipos: position in file @ireslt: return value

For binary files with a well-determined structure in terms of
[[float]]s and [[int]]s we may want to set up the connected stream to
do transparent reading of files written on a machine with a different
architecture. This is currently the case for map files and
MTZ files and this routine is called from mtzlib and maplib.

qrarch reads the machine stamp at word ipos
for the diskio file on stream iunit and sets up the appropriate
bit-twiddling for subsequent qreads on that stream. The
information read from the file is returned in \meta{ireslt} in the
form fileFT+16fileIT. If the stamp is zero
(as it would be for files written with a previous version of the
library) we assume the file is in native format and needs no
conversion in qread; in this case ireslt will be zero and
the caller can issue a warning. Iconvert and Fconvert are
used by qread to determine the type of conversion (if any) to be
applied to integers and reals.

Fudge:fudge Ian Tickle reports old VAX files which have a machine stamp which is byte-flipped from the correct VAX value,although it should always have been zero as far as I can see. To accommodate this, set the logical NATIVEMTZ and the machine stamp won't be read for any
input files for which qrarch is called.

Extra feature: logical/environment variable CONVERT_FROM may be set
to one of BEIEEE, LEIEEE, VAX or CONVEXNATIVE to avoid
reading the machine stamp and assume the file is from the stipulated
archictecture for all input MTZ and map files for which qrarch is called.

N.B.: leaves the stream positioned just after the machine stamp.

References ccp4_file_setstamp().

◆ FORTRAN_SUBR() [8/20]

FORTRAN_SUBR ( QREAD  ,
qread  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)   
)

qread: @iunit: io channel @buffer: @nitems: number of items

Returns
: return value

Reads @nitems in the current mode qmode() from diskio
stream @iunit previously opened by qopen() and
returns

Returns
which is %0 on success or %-1 at EOF.
It aborts on an i/o error.
Numbers written in a foreign format will be translated if necessary if
the stream is connected to an MTZ or map file.

References ccp4_file_read().

◆ FORTRAN_SUBR() [9/20]

FORTRAN_SUBR ( QREADC  ,
qreadc  ,
(int *iunit, fpstr buffer, int *result, int buffer_len)  ,
(int *iunit, fpstr buffer, int *result)  ,
(int *iunit, fpstr buffer, int buffer_len, int *result)   
)

qreadc:: @iunit: @buffer:

Returns
:

Fills CHARACTER buffer in byte mode from diskio stream
@iunit previously opened by qopen() and returns

Returns
which is 0 on success or -1 on EOF.
It aborts on an i/o failure.
Call it with a character substring if necessary to control the number of bytes read.

◆ FORTRAN_SUBR() [10/20]

FORTRAN_SUBR ( QREADI  ,
qreadi  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)   
)

qreadi: @iunit: io channel @buffer:

Returns
:

Fills INT buffer in int mode from diskio stream
@iunit previously opened by qopen() and returns

Returns
} which %0 on success or %-1 on EOF.
It aborts on an i/o failure.
Call it with a character substring if necessary to control the number of bytes read.

References ccp4_file_readint().

◆ FORTRAN_SUBR() [11/20]

FORTRAN_SUBR ( QREADI2  ,
qreadi2  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)   
)

qreadi2: @iunit: io channel @buffer:

Returns
:

Fills INT*2 buffer in int mode from diskio stream
@iunit previously opened by qopen() and returns

Returns
} which %0 on success or %-1 on EOF.
It aborts on an i/o failure.
Call it with a character substring if necessary to control the number of bytes read.

References ccp4_file_readshort().

◆ FORTRAN_SUBR() [12/20]

FORTRAN_SUBR ( QREADQ  ,
qreadq  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)   
)

qreadq: @iunit: @buffer: i

Returns
:

Fills COMPLEX buffer in int mode from diskio stream
@iunit previously opened by qopen() and returns

Returns
which 0 on success or -1 on EOF.
It aborts on an i/o failure.
Call it with a character substring if necessary to control the number
of bytes read.

References ccp4_file_readcomp().

◆ FORTRAN_SUBR() [13/20]

FORTRAN_SUBR ( QREADR  ,
qreadr  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)  ,
(int *iunit, uint8 *buffer, int *nitems, int *result)   
)

qreadr: @iunit: @buffer:

Returns
:

Fills REAL] buffer in int mode from diskio stream
@iunit previously opened by qopen() and returns

Returns
which 0 on success or -1 on EOF.
It aborts on an i/o failure.
Call it with a character substring if necessary to control the number of bytes read.

References ccp4_file_readfloat().

◆ FORTRAN_SUBR() [14/20]

FORTRAN_SUBR ( QSEEK  ,
qseek  ,
(int *iunit, int *irec, int *iel, int *lrecl)  ,
(int *iunit, int *irec, int *iel, int *lrecl)  ,
(int *iunit, int *irec, int *iel, int *lrecl)   
)

qseek: @iunit: @irec: @iel: @lrecl:

Seeks to element @iel in record @irec in diskio stream @iunit whose record length is @lrecl.

References ccp4_file_seek().

◆ FORTRAN_SUBR() [15/20]

FORTRAN_SUBR ( QSKIP  ,
qskip  ,
(int *iunit, int *lrecl)  ,
(int *iunit, int *lrecl)  ,
(int *iunit, int *lrecl)   
)

qskip: @iunit: @lrecl:

Skip forward 1 record of length @lrecl on diskio stream @iunit.

References ccp4_file_seek().

◆ FORTRAN_SUBR() [16/20]

FORTRAN_SUBR ( QWARCH  ,
qwarch  ,
(int *iunit, int *ipos)  ,
(int *iunit, int *ipos)  ,
(int *iunit, int *ipos)   
)

qwarch @iunit: io channel @ipos: position

This is the complement of qrarch, writing the native machine
architecture information machine stamp to diskio stream
iunit at word ipos. Currently called from mtzlib and maplib.

The machine stamp in mtstring is four nibbles in order, indicating complex and real format (must both be the same), integer format and character format (currently irrelevant). The last two bytes of
mtstring are currently unused and always zero.

N.B.: leaves the stream positioned just after the machine stamp.

References ccp4_file_setstamp().

◆ FORTRAN_SUBR() [17/20]

FORTRAN_SUBR ( QWRITE  ,
qwrite  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)   
)

qwrite: @iunit: @buffer: @meta:

This write @nitems items from @buffer to qopen() stream \meta{iunit} using the current mode.

References ccp4_file_write().

◆ FORTRAN_SUBR() [18/20]

FORTRAN_SUBR ( QWRITI  ,
qwriti  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)   
)

qwriti: @iunit: @buffer: @nitems:

This write @nitems items from @buffer to qopen() stream @iunit using the INT32 mode.

References ccp4_file_writeint().

◆ FORTRAN_SUBR() [19/20]

FORTRAN_SUBR ( QWRITQ  ,
qwritq  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)   
)

qwrite: @iunit: @buffer: @nitems:

This write @nitems items from @buffer to qopen() stream @iunit using the COMP64 mode.

References ccp4_file_writecomp().

◆ FORTRAN_SUBR() [20/20]

FORTRAN_SUBR ( QWRITR  ,
qwritr  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)  ,
(int *iunit, uint8 *buffer, int *nitems)   
)

qwritr: @iunit: @buffer: @nitems:

This write @nitems items from @buffer to qopen()
stream @iunit using the FLOAT32 mode.

References ccp4_file_writefloat().