sreed - read in an array from a seplib file
int sreed(tag, buffer, nbytes)
tag of history file
number of bytes to be written
values to be written
n = number of bytes read
Reads data from dataset attached to given tag
The tag argument is either the string ``in'' or any tag appropriate for use with auxin(). This means either an explicit filename or a command line redirect parameter tag=filename. Buffer is the location of contiguous bytes into which the input will be placed. Unless an end of file or I/O error is encountered, it is guaranteed that all nbytes bytes will be read; this is true even for terminals and pipes. In any event the number of characters read is returned.
sreed and srite perform conversions from machine independent external data formats to the internal data representation. This is controlled by the ``data_format'' keyword in the header file. The valid types are ``xdr_float'', ``xdr_integer'', ``xdr_byte'' and ``native''. If the keyword is not found the native format is assumed.
If the internal representation is larger than the representation of the external data then you must be careful to make the buffer the correct size for the converted data. e.g. on a cray system when reading xdr_float data, nbytes refers to the number of bytes to be read. This will be in 4-byte xdr_floats, but the internal storage will be in 8-byte cray floats, so the buffer must be 2*nbytes long.
sreed_raw()
just reads the raw bytes with no conversion. The buffer
size and nbytes are the same in this case.
If the returned value is 0, then end-of-file has been reached.
seplib, file, the srite manpage, the auxclose manpage, the auxpar manpage
If an end of file is reached, the returned byte count may be less than the requested amount. The next call will return zero. If the read was otherwise unsuccessful the program will be terminated via seperr(). Many conditions can generate an error: physical I/O errors, bad buffer address, preposterous nbytes, file tag not that of an input file.
read input xdr
sep