CHRPAK
routines for handling character strings
CHRPAK is a FORTRAN77 library
which can handle characters and strings of characters.
CHRPAK began when I simply wanted to be able to capitalize
a string. Now it has expanded to a number of interesting uses.
Many unusual situations are provided for, including
-
string '31.2' <=> numeric value 31.2;
-
uppercase <=> lowercase;
-
removal of control characters or blanks;
-
sorting, merging, searching.
Many of the routine names begin with the name of the data type they
operate on:
-
B4 - a 4 byte word;
-
CH - a character;
-
CHVEC - a vector of characters;
-
DEC - a decimal fraction;
-
DIGIT - a character representing a numeric digit;
-
I4 - an integer ( kind = 4 );
-
R4 - a real ( kind = 4 );
-
R8 - a real ( kind = 8 );
-
RAT - a ratio I/J;
-
S - a string;
-
SVEC - a vector of strings;
-
SVECI - a vector of strings, implicitly capitalized;
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Related Data and Programs:
CHRPAK is also available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version.
Reference:
-
Carl Branden, John Tooze,
Introduction to Protein Structure,
Second Edition,
Garland Publishing, 1999,
ISBN: 0815323050,
LC: QP551.B7635.
-
Paul Bratley, Bennett Fox, Linus Schrage,
A Guide to Simulation,
Second Edition,
Springer, 1987,
ISBN: 0387964673,
LC: QA76.9.C65.B73.
-
IEEE Standards Committee 754,
IEEE Standard for Binary Floating Point Arithmetic,
ANSI/IEEE Standard 754-1985,
SIGPLAN Notices,
Volume 22, Number 2, 1987, pages 9-25.
-
Donald Knuth,
The Art of Computer Programming,
Volume 3, Sorting and Searching,
Second Edition,
Addison Wesley, 1998,
ISBN: 0201896850,
LC: QA76.6.K64.
-
Albert Nijenhuis, Herbert Wilf,
Combinatorial Algorithms for Computers and Calculators,
Academic Press, 1978,
ISBN: 0-12-519260-6,
LC: QA164.N54.
Source Code:
Examples and Tests:
List of Routines:
-
A_TO_I4 returns the index of an alphabetic character.
-
CH_CAP capitalizes a single character.
-
CH_EQI is a case insensitive comparison of two characters for equality.
-
CH_IS_DIGIT returns TRUE if a character is a decimal digit.
-
CH_IS_SPACE is TRUE if a character is a whitespace character.
-
CH_IS_UPPER is TRUE if CH is an upper case letter.
-
CH_LOW lowercases a single character.
-
CH_SWAP swaps two characters.
-
CH_TO_DIGIT returns the integer value of a base 10 digit.
-
CH_TO_DIGIT_HEX returns the integer value of a hexadecimal digit.
-
CH_TO_DIGIT_OCT returns the integer value of an octal digit.
-
CH_TO_ROT13 converts a character to its ROT13 equivalent.
-
CH_TO_SCRABBLE returns the Scrabble index of a character.
-
CH_UNIFORM returns a scaled pseudorandom CH.
-
DIGIT_INC increments a decimal digit.
-
DIGIT_TO_CH returns the character representation of a decimal digit.
-
FILE_NAME_INC generates the next filename in a series.
-
HEX_TO_I4 converts a hexadecimal string to its integer value.
-
HEX_TO_S converts a hexadecimal string into characters.
-
I4_LENGTH computes the number of characters needed to print an integer.
-
I4_SWAP switches two I4's.
-
I4_TO_A returns the I-th alphabetic character.
-
I4_UNIFORM returns a scaled pseudorandom I4.
-
I4VEC_INDICATOR sets an I4VEC to the indicator vector.
-
I4VEC_PRINT prints an I4VEC.
-
R4_UNIFORM_01 returns a unit pseudorandom R4.
-
S_ADJUSTL flushes a string left.
-
S_ADJUSTR flushes a string right.
-
S_BLANK_DELETE removes blanks from a string, left justifying the remainder.
-
S_BLANKS_DELETE replaces consecutive blanks by one blank.
-
S_EQI is a case insensitive comparison of two strings for equality.
-
S_LEN_TRIM returns the length of a string to the last nonblank.
-
S_LOW replaces all uppercase letters by lowercase ones.
-
S_TO_I4 reads an I4 from a string.
-
S_TO_I4VEC reads an I4VEC from a string.
-
S_TO_R8 reads an R8 from a string.
-
S_TO_R8VEC reads an R8VEC from a string.
-
S_WORD_COUNT counts the number of "words" in a string.
-
S_WORD_EXTRACT_FIRST extracts the first word from a string.
-
TIMESTAMP prints out the current YMDHMS date as a timestamp.
You can go up one level to
the FORTRAN77 source codes.
Last revised on 04 June 2008.