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)) |
FORTRAN API for file i/o.
FORTRAN_SUBR | ( | QLOCATE | , | |
qlocate | , | |||
(int *iunit, int *locate) | , | |||
(int *iunit, int *locate) | , | |||
(int *iunit, int *locate) | ||||
) |
qlocate: : :
Returns the current position {locate} in the diskio stream .
References ccp4_file_tell(), and ccp4_signal().
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: : : :
Returns the name and of the file (if any) open on diskio stream .
References ccp4_file_length(), ccp4_FtoCString(), ccp4_signal(), and MIN.
FORTRAN_SUBR | ( | QSKIP | , | |
qskip | , | |||
(int *iunit, int *lrecl) | , | |||
(int *iunit, int *lrecl) | , | |||
(int *iunit, int *lrecl) | ||||
) |
qskip: : :
Skip forward 1 record of length on diskio stream .
References ccp4_file_seek(), and ccp4_signal().
FORTRAN_SUBR | ( | QBACK | , | |
qback | , | |||
(int *iunit, int *lrecl) | , | |||
(int *iunit, int *lrecl) | , | |||
(int *iunit, int *lrecl) | ||||
) |
qback: : :
Backspaces one record, of length on diskio stream .
References ccp4_file_seek(), and ccp4_signal().
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: : : : :
Seeks to element in record in diskio stream whose record length is .
References ccp4_file_seek(), and ccp4_signal().
FORTRAN_SUBR | ( | QWRITQ | , | |
qwritq | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | ||||
) |
qwrite: : : :
This write items from to qopen() stream using the COMP64 mode.
References ccp4_file_writecomp(), and ccp4_signal().
FORTRAN_SUBR | ( | QWRITR | , | |
qwritr | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | ||||
) |
qwritr: : : :
This write items from to qopen() stream using the FLOAT32 mode.
References ccp4_file_writefloat(), and ccp4_signal().
FORTRAN_SUBR | ( | QWRITI | , | |
qwriti | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | ||||
) |
qwriti: : : :
This write items from to qopen() stream using the INT32 mode.
References ccp4_file_writeint(), and ccp4_signal().
FORTRAN_SUBR | ( | QWRITE | , | |
qwrite | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | , | |||
(int *iunit, uint8 *buffer, int *nitems) | ||||
) |
qwrite: : : :
This write items from to qopen() stream {iunit} using the current mode.
References ccp4_file_write(), and ccp4_signal().
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:: : :
Fills CHARACTER buffer in byte mode from diskio stream previously opened by qopen() and returns
References ccp4_file_readchar(), and ccp4_signal().
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: : : i
Fills COMPLEX buffer in int mode from diskio stream previously opened by qopen() and returns
References ccp4_file_feof(), ccp4_file_readcomp(), and ccp4_signal().
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: : :
Fills REAL] buffer in int mode from diskio stream previously opened by qopen() and returns
References ccp4_file_feof(), ccp4_file_readfloat(), and ccp4_signal().
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: : io channel :
Fills INT*2 buffer in int mode from diskio stream previously opened by qopen() and returns
References ccp4_file_feof(), ccp4_file_readshort(), and ccp4_signal().
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: : io channel :
Fills INT buffer in int mode from diskio stream previously opened by qopen() and returns
References ccp4_file_feof(), ccp4_file_readint(), and ccp4_signal().
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: : io channel : : number of items
Reads in the current mode qmode() from diskio stream previously opened by qopen() and returns
References ccp4_file_feof(), ccp4_file_read(), and ccp4_signal().
FORTRAN_SUBR | ( | QMODE | , | |
qmode | , | |||
(int *iunit, int *mode, int *size) | , | |||
(int *iunit, int *mode, int *size) | , | |||
(int *iunit, int *mode, int *size) | ||||
) |
qmode: : io channel : access mode : item size
Changes the diskio access mode for stream to . The resulting size in bytes of items for transfer is returned as
References ccp4_file_itemsize(), ccp4_file_setmode(), and ccp4_signal().
FORTRAN_SUBR | ( | QCLOSE | , | |
qclose | , | |||
(int *iunit) | , | |||
(int *iunit) | , | |||
(int *iunit) | ||||
) |
qclose: : io channel
Closes the file open on diskio stream iunit
References ccp4_file_close(), and ccp4_signal().
FORTRAN_SUBR | ( | QWARCH | , | |
qwarch | , | |||
(int *iunit, int *ipos) | , | |||
(int *iunit, int *ipos) | , | |||
(int *iunit, int *ipos) | ||||
) |
qwarch : io channel : 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(), ccp4_file_warch(), and ccp4_signal().
FORTRAN_SUBR | ( | QRARCH | , | |
qrarch | , | |||
(int *iunit, int *ipos, int *ireslt) | , | |||
(int *iunit, int *ipos, int *ireslt) | , | |||
(int *iunit, int *ipos, int *ireslt) | ||||
) |
qrarch: : iochannel : position in file : 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 {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_rarch(), ccp4_file_setstamp(), and ccp4_signal().
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.
iunit | iochannel number | |
filename | fortran character array giving filename | |
istat | file mode |
References ccp4_file_open(), ccp4_FtoCString(), and ccp4_signal().