BUFPAK
Interface to Unformatted Direct Access Files
BUFPAK is a FORTRAN77 program
which is a simple package for reading and writing data to an
unformatted, direct access file.
An unformatted, direct access file is "compact". This is because
the data is stored in a binary format, which usually takes less
space than the corresponding formatted data. For instance, an
unformatted REAL value takes one word of four bytes, whereas
a REAL value formatted, with say, the "E14.6" format, would take
14 bytes, requiring four words of storage.
Note that the saving will vary depending on the data type. In
particular, BUFPAK does not do a good job of compressing LOGICAL
or CHARACTER data, so that they might actually require MORE space
than in a formatted file... But BUFPAK is designed for space
efficiency in numerical applications.
An unformatted, direct access file is "portable". This is because
the file should contain "pure data". There should be no carriage
returns, record counters, padding blanks, or other items added by
the operating system. Other types of files will usually have such
information inserted into the data, in a system dependent way,
which makes the files much less transportable.
Source Code:
Examples and Tests:
List of Routines:
-
BUFFLS "flushes out" the buffer, that is, it writes it to disk.
-
BUFREF refreshes the buffer, that is, it reads in a new line of data.
-
CAPCHR accepts a STRING of characters and replaces any lowercase
-
FILE_DELETE deletes a file if it exists.
-
GET_UNIT returns a free FORTRAN unit number.
-
IMEMRY "remembers" integer values that the user may set or
-
LENCHR returns the length of STRING up to the last nonblank
-
LEQI returns TRUE if two strings are the same, ignoring case
-
RDBLOK advances through the file to block number IBLOK.
-
RDBUF reads a real value X from the buffer.
-
RDCH reads a single character from the file.
-
RDCHV reads a string of N characters from a file.
-
RDCM reads a complex value from the file.
-
RDCMV reads a vector of complex values from a file.
-
RDDB reads a double precision value from the file.
-
RDDBV reads a vector of double precision values from a file.
-
RDDR reads a real value from a file, and returns it as a
-
RDDRV returns a vector of double precision values, which had
-
RDFRST should be called first, before doing any reading from the file.
-
RDIN reads an integer value from the file.
-
RDINV reads a vector of integer information stored in the file.
-
RDLAST terminates reading from the file, and closes it.
-
RDNEXT reads the next record from the file.
-
RDLG reads a logical value from the file.
-
RDLGV reads a vector of logical values from a file.
-
RDRL reads a real value from the file.
-
RDRLV reads a vector of real data from a file.
-
SMEMRY "remembers" string values that the user may set or
-
TIMESTAMP prints out the current YMDHMS date as a timestamp.
-
WRBLOK writes a block marker to a file.
-
WRBUF "writes" a real value X to the buffer.
-
WRCH writes a single character to a file.
-
WRCHV writes a string of characters to a file.
-
WRCM writes a complex value to a file.
-
WRCMV writes a vector of complex values to a file.
-
WRDB writes a double precision value to a file.
-
WRDBV writes a vector of double precision values to a file.
-
WRDR writes a real copy of a double precision value to a file.
-
WRDRV writes real copies of a vector of double precision values
-
WRFRST prepares the BUFPAK routines WRBUF and BUFFLS for writing
-
WRIN writes an integer to a file.
-
WRINV writes a vector of integers to a file.
-
WRLAST terminates writing to the file, and closes it.
-
WRLG writes a logical value to a file.
-
WRLGV writes a vector of logical values to a file.
-
WRRL writes a real value to a file.
-
WRRLV writes a vector of real values to a file.
You can go up one level to
the FORTRAN77 source codes.
Last revised on 18 August 2008.