FILUM
File Utilities
FILUM
is a FORTRAN90 library which
can work with information in text files.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
FILUM is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and Programs:
F90_FILES,
programs which
illustrate the use of files in the FORTRAN90 language.
FILE_MERGE,
a FORTRAN90 program which
merges two sorted files.
FILE_NAME_SEQUENCE,
a FORTRAN90 program which
demonstrates ways to generate a sequence of filenames
that can be used when generating images for an animation.
FILE_ROW_REVERSE,
a FORTRAN90 program which
makes a copy of a file with the lines ("rows") in reverse order.
FILE_TRANSPOSE,
a FORTRAN90 program which
makes a "transposed" copy of a file, in which the I-th "word" of the J-th line
becomes the J-th word of the I-th line.
FILES_MULTIPLE,
a FORTRAN90 program which
demonstrates how a program can open multiple output files at one time,
and write data to any one specific file it chooses.
REFORMAT,
a FORTRAN90 program which
makes a copy of a file with a given number of "words" per line.
Reference:
-
Paul Bratley, Bennett Fox, Linus Schrage,
A Guide to Simulation,
Springer Verlag, pages 201-202, 1983.
-
Tom Christiansen, Nathan Torkington,
"8.6: Picking a Random Line from a File",
Perl Cookbook, pages 284-285,
O'Reilly, 1999.
-
Pierre L'Ecuyer,
Random Number Generation,
in Handbook of Simulation,
edited by Jerry Banks,
Wiley Interscience, page 95, 1998.
-
Bennett Fox,
Algorithm 647:
Implementation and Relative Efficiency of Quasirandom
Sequence Generators,
ACM Transactions on Mathematical Software,
Volume 12, Number 4, pages 362-376, 1986.
-
Philip Lewis, Allen Goodman, James Miller,
A Pseudo-Random Number Generator for the System/360,
IBM Systems Journal,
Volume 8, pages 136-143, 1969.
Source Code:
Examples and Tests:
Files used for some of the tests include:
-
filum_test_4by5.txt, a file with
missing right parentheses.
-
filum_test_test.txt, a sample file.
-
filum_test_append.txt, an
example of FILE_APPEND.
-
filum_test_braces.txt, a file
with balanced and legal braces.
-
filum_test_columns.txt, a file
of 4 rows and 5 columns of numeric data.
-
filum_test_copy.txt, an example of
FILE_COPY.
-
filum_test_reverse_columns.txt,
an example of FILE_REVERSE_COLUMNS.
-
filum_test_parens1.txt, a file
with missing right parentheses.
-
filum_test_parens2.txt, a file
with illegally occurring right parentheses.
-
filum_test_parens3.txt, a file
with balanced and legal parentheses.
-
filum_test_reverse_rows.txt,
an example of FILE_REVERSE_ROWS.
-
integers.txt,
a file containing text and integers.
-
story.txt,
a file containing a title line and 5 paragraphs of text.
-
story_rot13.txt,
the story, encoded by ROT13.
-
story_rot26.txt,
the story, decoded by a second application of ROT13.
DATA_***.TXT is a short sequence of three files, each having 8 data
items, 3 on the first line, 3 on the second, and 2 on the third line,
to be examined by FILE_SEQUENCE_SIZE.
List of Routines:
-
CH_CAP capitalizes a single character.
-
CH_EQI is a case insensitive comparison of two characters for equality.
-
CH_INDEX_LAST is the last occurrence of a character in a string.
-
CH_IS_DIGIT returns .TRUE. if a character is a decimal digit.
-
CH_LOW lowercases a single character.
-
CH_TO_DIGIT returns the integer value of a base 10 digit.
-
CH_TO_ROT13 converts a character to its ROT13 equivalent.
-
DIGIT_INC increments a decimal digit.
-
DIGIT_TO_CH returns the character representation of a decimal digit.
-
FILE_ADVANCE_TO_STRING searches ahead in a text file for a string.
-
FILE_APPEND allows a user to append new information to an old file.
-
FILE_CHAR_COUNT counts the number of characters in a file.
-
FILE_COLUMN_COUNT counts the number of columns in the first line of a file.
-
FILE_COLUMN_RANGE determines the minimum and maximum ranges of each column.
-
FILE_COPY makes a copy of a file.
-
FILE_DELETE deletes a named file if it exists.
-
FILE_EXIST reports whether a file exists.
-
FILE_GET_NEXT_INTEGER returns the next integer from a file.
-
FILE_GET_NEXT_WORD returns the next word and trailing context from a file.
-
FILE_INSERT copies the contents of an input file into an output file.
-
FILE_LINE_GET gets a particular line of a file.
-
FILE_LINE_UNIFORM returns a random line from a file.
-
FILE_LINE_WIDTH returns the length of the longest line in a file.
-
FILE_LINES_UNIFORM selects N random lines from a file.
-
FILE_MERGE merges two sorted files into a third.
-
FILE_NAME_APPEND appends a string to a filename, before the extension.
-
FILE_NAME_DEC decrements a partially numeric file name.
-
FILE_NAME_EXT_GET determines the "extension" of a file name.
-
FILE_NAME_EXT_SWAP replaces the current "extension" of a file name.
-
FILE_NAME_INC increments a partially numeric filename.
-
FILE_NAME_INC_NOWRAP increments a partially numeric filename.
-
FILE_IS_OPEN reports whether a file (specified by filename) is open.
-
FILE_PARA_COUNT counts the number of paragraphs in a file.
-
FILE_PAREN_CHECK checks a file for generalized parenthesis errors.
-
FILE_PRINT prints the contents of a text file.
-
FILE_RENAME renames a file.
-
FILE_REVERSE_COLUMNS makes a copy of a file with each lines reversed.
-
FILE_REVERSE_ROWS makes a copy of a file with the lines in reverse order.
-
FILE_ROT13 makes a ROT13-encoded copy of a file.
-
FILE_ROW_COUNT counts the number of rows in a file.
-
FILE_SEQUENCE_DELETE deletes a file sequence.
-
FILE_SEQUENCE_SIZE sizes a file sequence.
-
FILE_TAG_CHECK checks a file for generalized parenthesis errors.
-
FILE_UNIQUE_LINES makes a copy of the unique lines of a sorted file.
-
FILE_WORD_COUNT counts the number of words in a file.
-
GET_UNIT returns a free FORTRAN unit number.
-
I4_UNIFORM returns a scaled pseudorandom I4.
-
LEN_NONNULL returns the length of a string up to the last non-null character.
-
NUMBER_INC increments the integer represented by a string.
-
R8_UNIFORM_01 returns a unit pseudorandom R8.
-
S_EQI is a case insensitive comparison of two strings for equality.
-
S_LOW replaces all uppercase letters by lowercase ones.
-
S_REVERSE reverses the characters in a string.
-
S_TO_I4 reads an I4 from a string.
-
S_TO_R8 reads an R8 from a string.
-
S_TO_R8VEC reads an R8VEC from a string.
-
S_TO_ROT13 "rotates" the alphabetical characters in a string by 13 positions.
-
S_WORD_COUNT counts the number of "words" in a string.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the FORTRAN90 source codes.
Last revised on 21 November 2011.