CHRPAK - Characters and Strings
CHRPAK is a collection of FORTRAN subroutines and functions
for dealing with characters and strings. 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.
A C version of some CHRPAK routines is available in
CHRPAKC.
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;
-
D - a double precision real;
-
DEC - a decimal fraction;
-
DIGIT - a character representing a numeric digit;
-
I - an integer;
-
R - a real;
-
RAT - a ratio I/J;
-
S - a string;
-
SVEC - a vector of strings;
-
SVECI - a vector of strings, implicitly capitalized;
Files you may copy include:
The list of routines includes:
-
A_TO_I returns the index of an alphabetic character.
-
B4_IEEE_TO_R converts a 4 byte IEEE word into a real value.
-
B4_IEEE_TO_SEF converts an IEEE real word to S * 2**E * F format.
-
B4_ULTRIX_TO_R converts a 4 byte ULTRIX word into a real value.
-
B4_VMS_TO_R converts a 4 byte VMS word into a real value.
-
BASE_TO_I returns the value of an integer represented in some base.
-
BINARY_TO_I converts a binary representation into an integer value.
-
BINARY_TO_R converts a binary representation into a real value.
-
BITS_TO_I converts a bit string into a 32 bit integer.
-
BITS_TO_R converts a bit string into a 32 bit real.
-
CH_CAP capitalizes a single character.
-
CH_COUNT_CHVEC_ADD adds a character vector to a character count.
-
CH_COUNT_FILE_ADD adds characters in a file to a character count.
-
CH_COUNT_HISTOGRAM_PRINT prints a histogram of a set of character counts.
-
CH_COUNT_INIT initializes a character count.
-
CH_COUNT_PRINT prints a set of character counts.
-
CH_COUNT_S_ADD adds a character string to a character histogram.
-
CH_EQI is a case insensitive comparison of two characters for equality.
-
CH_EXTRACT extracts the next nonblank character from a string.
-
CH_INDEX is the first occurrence of a character in a string.
-
CH_INDEXI is the (case insensitive) first occurrence of a character in a string.
-
CH_IS_ALPHA returns TRUE if C is an alphabetic character.
-
CH_IS_ALPHANUMERIC = the character C is alphanumeric.
-
CH_IS_CONTROL reports whether a character is a control character or not.
-
CH_IS_DIGIT returns .TRUE. if a character is a decimal digit.
-
CH_IS_LOWER returns .TRUE. if a character is a lower case letter.
-
CH_IS_PRINTABLE determines if a character is printable.
-
CH_IS_UPPER returns .TRUE. if a character is an upper case letter.
-
CH_LOW lowercases a single character.
-
CH_NEXT reads the next character from a string, ignoring blanks and commas.
-
CH_NOT_CONTROL = character is NOT a control character.
-
CH_RANDOM returns a random character in a given range.
-
CH_ROMAN_TO_I returns the integer value of a single digit of a Roman numeral.
-
CH_SWAP swaps two characters.
-
CH_TO_AMINO_NAME converts a character to an amino acid name.
-
CH_TO_BRAILLE converts an ASCII character to a Braille character string.
-
CH_TO_CH3_AMINO converts a 1 character code to a 3 character code for an amino acid.
-
CH_TO_DIGIT returns the integer value of a base 10 digit.
-
CH_TO_DIGIT_BIN returns the integer value of a binary 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_EBCDIC converts a character to EBCDIC.
-
CH_TO_MILITARY converts an ASCII character to a Military code word.
-
CH_TO_MORSE converts an ASCII character to a Morse character string.
-
CH_TO_ROT13 converts a character to its ROT13 equivalent.
-
CH_TO_SOUNDEX converts an ASCII character to a Soundex character.
-
CH_TO_SYM returns a printable symbol for any ASCII character.
-
CH3_TO_CH_AMINO converts a 3 character code to a 1 character code for an amino acid.
-
CH4_TO_I converts a four character string to an integer.
-
CH4_TO_R converts a 4 character string to a real.
-
CH4VEC_TO_IVEC converts an string of characters into an array of integers.
-
CENTER inserts one string into the center of another.
-
CHR4_TO_8 replaces pairs of hexadecimal digits by a character.
-
CHR8_TO_4 replaces characters by a pair of hexadecimal digits.
-
CHRA_TO_S replaces control characters by printable symbols.
-
CHRASC converts a vector of ASCII codes into character strings.
-
CHRASS "understands" an assignment statement of the form LHS = RHS.
-
CHRCTF reads an integer or rational fraction from a string.
-
CHRCTG reads an integer, decimal fraction or a ratio from a string.
-
CHRCTI2 finds and reads an integer from a string.
-
CHRCTP reads a parenthesized complex number from a string.
-
CHRINS inserts one string into another.
-
CHRS_TO_A replaces all control symbols by control characters.
-
CHVEC_PERMUTE permutes a character vector in place.
-
CHVEC_PRINT prints a character vector.
-
CHVEC_REVERSE reverses the elements of a character vector.
-
CHVEC_TO_S converts a character vector to a string.
-
CHVEC2_PRINT prints two vectors of characters.
-
COMMA moves commas left through blanks in a string.
-
D_TO_S_LEFT writes a double precision value into a left justified string.
-
D_TO_S_LEFT writes a double precision value into a right justified string.
-
DEC_TO_S_LEFT returns a left-justified representation of IVAL * 10**JVAL.
-
DEC_TO_S_RIGHT returns a right justified representation of IVAL * 10**JVAL.
-
DEGREES_TO_RADIANS converts an angle from degrees to radians.
-
DIGIT_BIN_TO_CH returns the character representation of a binary digit.
-
DIGIT_HEX_TO_CH returns the character representation of a hexadecimal digit.
-
DIGIT_INC increments a decimal digit.
-
DIGIT_OCT_TO_CH returns the character representation of an octal digit.
-
DIGIT_TO_CH returns the character representation of a decimal digit.
-
EBCDIC_TO_CH converts an EBCDIC character to ASCII.
-
EBCDIC_TO_S converts a string of EBCDIC characters to ASCII.
-
FILLCH writes a string into a subfield of a string.
-
FILLIN writes an integer into a subfield of a string.
-
FILLRL writes a real into a subfield of a string.
-
FLT_TO_S returns a representation of MANT * 10**IEXP.
-
FORCOM splits a FORTRAN line into "fortran" and "comment".
-
GET_UNIT returns a free FORTRAN unit number.
-
HEX_TO_I converts a hexadecimal string to its integer value.
-
HEX_TO_S converts a hexadecimal string into characters.
-
I_BYTE_SWAP swaps bytes in a 4-byte word.
-
I_GCD finds the greatest common divisor of I and J.
-
I_EXTRACT "extracts" an integer from the beginning of a string.
-
I_INPUT prints a prompt string and reads an integer from the user.
-
I_LENGTH computes the number of characters needed to print an integer.
-
I_NEXT "reads" integers from a string, one at a time.
-
I_NEXT_READ finds and reads the next integer in a string.
-
I_RANDOM returns a random integer in a given range.
-
I_RANGE_INPUT reads a pair of integers from the user, representing a range.
-
I_SQZ compresses the integer information in IVEC into JVEC.
-
I_TO_A returns the I-th alphabetic character.
-
I_TO_AMINO_CODE converts an integer to an amino code.
-
I_TO_BASE represents an integer in any base up to 16.
-
I_TO_BINARY produces the binary representation of an integer.
-
I_TO_BINHEX returns the I-th character in the BINHEX encoding.
-
I_TO_BITS converts an integer to a string of 32 bits.
-
I_TO_CH4 converts an integer to a 4 character string.
-
I_TO_HEX produces the hexadecimal representation of an integer.
-
I_TO_MONTH_NAME returns the name of a given month.
-
I_TO_NUNARY produces the "base -1" representation of an integer.
-
I_TO_OCT produces the octal representation of an integer.
-
I_TO_S_LEFT converts an integer to a left-justified string.
-
I_TO_S_RIGHT converts an integer to a right justified string.
-
I_TO_S_ROMAN converts an integer to a string of Roman numerals.
-
I_TO_S_ZERO converts an integer to a string, with zero padding.
-
I_TO_S32 converts an integer to a 32 character string.
-
I_TO_UNARY produces the "base 1" representation of an integer.
-
I_TO_UUDECODE returns the I-th character in the UUDECODE encoding.
-
I_TO_XXDECODE returns the I-th character in the XXDECODE encoding.
-
I2_BYTE_SWAP swaps bytes in an 8-byte word.
-
IC_TO_IBRAILLE converts an ASCII integer code to a Braille code.
-
IC_TO_IEBCDIC converts an ASCII character code to an EBCDIC code.
-
IC_TO_IMORSE converts an ASCII integer code to a Morse integer code.
-
IC_TO_ISOUNDEX converts an ASCII integer code to a Soundex integer code.
-
IEBCDIC_TO_IC converts an EBCDIC character code to ASCII.
-
ISTRCMP compares two strings, returning +1, 0, or -1.
-
ISTRNCMP compares the start of two strings, returning +1, 0, or -1.
-
IVEC_PRINT prints an integer vector.
-
IVEC_TO_CH4VEC converts an array of integers into a string.
-
LEFT inserts one string flush left into another.
-
LEN_NONNULL returns the length of a string up to the last non-null character.
-
LGEI = ( S1 is lexically greater than or equal to S2 ).
-
LGTI = ( S1 is lexically greater than S2 ).
-
LLEI = ( S1 is lexically less than or equal to S2 ).
-
LLTI = ( S1 is lexically less than S2 ).
-
LNEI compares two strings for non-equality, ignoring case.
-
LOWER returns a lowercase version of a string.
-
MALPHNUM2 returns .TRUE. if a string contains only alphanumerics and underscores.
-
MILITARY_TO_CH converts a Military code word to an ASCII character.
-
MONTH_NAME_TO_I returns the month number of a given month
-
NAMEFL replaces "lastname, firstname" by "firstname lastname".
-
NAMELF replaces "firstname lastname" by "lastname, firstname".
-
NAMELS reads a NAMELIST line, returning the variable name and value.
-
NEXCHR returns the next nonblank character from a string.
-
NEXSTR returns the next nonblank characters from a string.
-
NUMBER_INC increments the integer represented by a string.
-
OCT_TO_I converts an octal string to its integer value.
-
R_EXTRACT "extracts" a real from the beginning of a string.
-
R_INPUT prints a prompt string and reads a real value from the user.
-
R_NEXT "reads" real numbers from a string, one at a time.
-
R_PRINT prints a scalar, vector or array.
-
R_TO_B4_IEEE converts a real value to a 4 byte IEEE word.
-
R_TO_B4_ULTRIX converts a real value to a 4 byte ULTRIX word.
-
R_TO_BINARY represents a real value as a string of binary digits.
-
R_TO_BITS converts a real to a string of 32 bits.
-
R_TO_CH4 converts a real value to a 4 character string.
-
R_TO_FLT computes the scientific representation of a real number.
-
R_TO_S_LEFT writes a real into a left justified character string.
-
R_TO_S_RIGHT writes a real into a right justified character string.
-
R_TO_S32 encodes a real number as 32 characters.
-
R_TO_SEF represents a real number as R = S * 2**E * F.
-
RANGER "understands" a range defined by a string like '4:8'.
-
RAT_TO_S_LEFT returns a left-justified representation of IVAL/JVAL.
-
RAT_TO_S_RIGHT returns a right-justified representation of IVAL/JVAL.
-
RIGHT inserts a string flush right into another.
-
RUBOUT deletes the pair "character" + Backspace from a string.
-
RVEC_TO_S "writes" a real vector into a string.
-
S_AFTER_SS_COPY copies a string after a given substring.
-
S_ALPHA_LAST returns the location of the last alphabetic character.
-
S_ANY_ALPHA is TRUE if a string contains any alphabetic character.
-
S_ANY_CONTROL is TRUE if a string contains any control characters.
-
S_BEFORE_SS_COPY copies a string up to a given substring.
-
S_BEGIN is TRUE if one string matches the beginning of the other.
-
S_BLANK_DELETE removes blanks from a string, left justifying the remainder.
-
S_BLANKS_DELETE replaces consecutive blanks by one blank.
-
S_BLANKS_INSERT inserts blanks into a string, sliding old characters over.
-
S_CH_BLANK replaces each occurrence of a particular character by a blank.
-
S_CH_DELETE removes all occurrences of a character from a string.
-
S_CH_LAST returns the last nonblank character in a string.
-
S_CAP replaces any lowercase letters by uppercase ones in a string.
-
S_CAT concatenates two strings to make a third string.
-
S_CAT1 concatenates two strings, with a single blank separator.
-
S_CHOP "chops out" a portion of a string, and closes up the hole.
-
S_CONTROL_BLANK replaces control characters with blanks.
-
S_CONTROL_COUNT returns the number of control characters in a string.
-
S_CONTROL_DELETE removes all control characters from a string.
-
S_DETAG removes from a string all substrings marked by angle brackets.
-
S_EQI is a case insensitive comparison of two strings for equality.
-
S_EQIDB compares two strings, ignoring case and blanks.
-
S_FILL overwrites every character of a string by a given character.
-
S_FIRST_NONBLANK returns the location of the first nonblank.
-
S_INDEX_SET searches a string for any of a set of characters.
-
S_INDEXI is a case-insensitive INDEX function.
-
S_INDEX_LAST finds the LAST occurrence of a given substring.
-
S_INPUT prints a prompt string and reads a string from the user.
-
S_IS_ALPHA returns .TRUE. if the string contains only alphabetic characters.
-
S_IS_ALPHANUMERIC = string contains only alphanumeric characters.
-
S_IS_DIGIT returns .TRUE. if a string contains only decimal digits.
-
S_IS_F77_NAME = input string represent a legal FORTRAN-77 identifier.
-
S_IS_F90_NAME = input string represent a legal FORTRAN 90 identifier.
-
S_IS_I is TRUE if a string represents an integer.
-
S_IS_R is TRUE if a string represents a real number.
-
S_LEFT flushes a string left.
-
S_LOW replaces all uppercase letters by lowercase ones.
-
S_NO_CONTROL = string contains no control characters.
-
S_OF_I converts an integer to a left-justified string.
-
S_ONLY_ALPHAB checks if a string is only alphabetic and blanks.
-
S_ONLY_DIGITB returns .TRUE. if the string contains only digits or blanks.
-
S_OVERLAP determines the overlap between two strings.
-
S_PAREN_CHECK checks the parentheses in a string.
-
S_PLOT plots a character string onto a graphics image.
-
S_REP_CH replaces all occurrences of one character by another.
-
S_REP_REC is a recursive replacement of one string by another.
-
S_REP replaces all occurrences of SUB1 by SUB2 in a string.
-
S_REPI replaces all occurrences of SUB1 by SUB2 in a string.
-
S_REVERSE reverses the characters in a string.
-
S_RIGHT flushes a string right.
-
S_ROMAN_TO_I converts a Roman numeral to an integer.
-
S_S_DELETE removes all occurrences of a substring from a string.
-
S_S_DELETE2 recursively removes a substring from a string.
-
S_SET_DELETE removes any characters in one string from another string.
-
S_SHIFT_CIRCULAR circular shifts the characters in a string to the right.
-
S_SHIFT_LEFT shifts the characters in a string to the left and blank pads.
-
S_SHIFT_RIGHT shifts the characters in a string to the right and blank pads.
-
S_SKIP_SET finds the first entry of a string that is NOT in a set.
-
S_SPLIT divides a string into three parts, given the middle.
-
S_SWAP swaps two strings.
-
S_TAB_BLANK replaces each TAB character by one space.
-
S_TAB_BLANKS replaces TAB characters by 6 spaces.
-
S_TO_CHVEC converts a string to a character vector.
-
S_TO_D reads a double precision number from a string.
-
S_TO_DATE converts the F90 date string to a more usual format.
-
S_TO_DEC reads a number from a string, returning a decimal result.
-
S_TO_EBCDIC converts a character string from ASCII to EBCDIC.
-
S_TO_HEX replaces a character string by a hexadecimal representation.
-
S_TO_I reads an integer value from a string.
-
S_TO_L reads a logical value from a string.
-
S_TO_R reads a real number from a string.
-
S_TO_RVEC reads a real vector from a string.
-
S_TO_ROT13 "rotates" the alphabetical characters in a string by 13 positions.
-
S_TO_SOUNDEX computes the Soundex code of a string.
-
S_TO_Z reads a complex number from a string.
-
S_TOKEN_EQUAL checks whether a string is equal to any of a set of strings.
-
S_TOKEN_MATCH matches the beginning of a string and a set of tokens.
-
S_TRIM_ZEROS removes trailing zeros from a string.
-
S_W_CAP capitalizes the first character of each word in a string.
-
S32_TO_I returns an integer equivalent to a 32 character string.
-
S32_TO_R converts a 32-character variable into a real.
-
SEF_TO_B4_IEEE converts SEF information to a 4 byte IEEE real word.
-
SEF_TO_B4_IEEE converts SEF information to a 4 byte IEEE real word.
-
SEF_TO_R converts SEF information to a real number as R = S * 2.0**E * F.
-
SORT_HEAP_EXTERNAL externally sorts a list of items into linear order.
-
SQZ_I uncompresses JVEC to extract integers stored there.
-
SVEC_LAB makes an index array for an array of (repeated) strings.
-
SVEC_MERGE merges two sorted string arrays.
-
SVEC_SORT_HEAP_A ascending sorts a vector of character strings using heap sort.
-
SVEC_SORT_HEAP_A_INDEX does a case-sensitive indexed heap sort of a vector of strings.
-
SVECI_SORT_HEAP_A heap sorts a vector of implicitly capitalized strings.
-
SVECI_SORT_HEAP_A_INDEX index heap sorts a vector of implicitly capitalized strings.
-
SYM_TO_CH returns the character represented by a symbol.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
-
TOKEN_EXPAND makes sure certain tokens have spaces surrounding them.
-
TOKEN_EXTRACT "extracts" a token from the beginning of a string.
-
TOKEN_INDEX finds the N-th FORTRAN variable name in a string.
-
TOKEN_NEXT finds the next FORTRAN variable name in a string.
-
UPPER returns an uppercase version of a string.
-
WORD_CAP capitalizes the first character of each word in a string.
-
WORD_COUNT counts the number of "words" in a string.
-
WORD_EXTRACT extracts the next word from a string.
-
WORD_FIND finds the word of a given index in a string.
-
WORD_INC "increments" a word.
-
WORD_LAST_READ returns the last word from a string.
-
WORD_INDEX finds the word of a given index in a string.
-
WORD_NEXT finds the next (blank separated) word in a string.
-
WORD_NEXT2 returns the first word in a string.
-
WORD_NEXT_READ "reads" words from a string, one at a time.
-
WORD_NEXT_WR tries to append a word to a line.
-
WORD_SWAP swaps two words in a given string.
Back to the FORTRAN software page.
Last revised on 27 March 2002.