subroutine aptffin (ius, idmax, iemax, aword, iword, fword, mtype, & nword, achar, nerr) ccbeg. cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c SUBROUTINE APTFFIN (OBSOLETE, USE APTFFIP) c c Version: aptffin Updated 1992 August 21 14:00. c aptffin Originated 1992 August 21 14:00. c c Author: Arthur L. Edwards, LLNL, L-298, Telephone (925) 422-4123. c c c Purpose: To read a free-field input line from I/O unit ius in format c (10a8), store the ASCII result in achar, then crack the input c line into fields, storing the results into aword, iword and c fword according to the field type mtype, and also return the c number of fields, nword, and a result flag nerr. c The maximum number of digits in an integer, and the maximum c magnitude of floating point exponents are specified by idmax c and iemax, to allow use on computers with different word sizes. c c Input: ius, idmax, iemax. c c Output: aword, iword, fword, mtype, nword, achar, nerr. c c Calls: aptchat c c Glossary: c c achar Output A character*8 array of 10 words, the uncracked input c line. c c aword Output A character*8 array of input line fields. Size 40. c Initialized to blank characters. If the n'th data c field translated is a character field (mtype = 0, c 1 or 4), it will be stored in the leftmost characters c of aword(n), and right-filled with blank characters, c as necessary. c c fword Output A floating-point array, size 40. c Initialized to zero. c The maximum allowable exponent is iemax. c If the data field is translated into an integer c (mtype = 2) or into a floating-point number c (mtype = 3), its floating-point value will be c returned in fword. If the field is formatted as an c integer, but contains more than idmax digits after c any leading zeros, it will be translated into a c floating-point number, and returned in fword. c The data field may have leading or trailing c blanks. The first non-blank character may be a "+" c or "-". The mantissa may contain any number of c digits, but no more than one decimal point, and c may have trailing blanks. If an exponent is given, c it must begin with "e", "E", "d", "D", "+" or "-". c An initial "e", "E", "d" or "D" may be followed by c a "+" or "-". The digits of the exponent may have c leading and trailing blanks, but no additional c characters following any trailing blanks. c Note: do not equivalence iword to fword. c Note: the largest floating-point value possible on c the Cray is approximately 1.e+2465. c c idmax Input Maximum number of digits in an integer. Depends on c the machine. At least 13 on a Cray. c c iemax Input Maximum size (positive or negative) of the exponent c of a floating-point number. Depends on the machine. c Approximately 2465 on a Cray. c c ius Input Input file I/O unit, for reading next input line. c c iword Output An integer array, size 40. Initialized to zero. c If the n'th data field translated is c an integer (mtype = 2), its integer value will be c stored in iword(n), and its floating-point value c stored in fword(n). The maximum number of digits c is idmax. The data field may have leading or c trailing blanks. The first non-blank character may c be a "+" or "-". All other characters must be c digits, with no more than idmax digits following any c leading zeros. c Note: the largest integer possible on the Cray c is 2**46 - 1 = 7.03687e+13. c Note: do not equivalence iword to fword. c c mtype Output An integer array, size 40. The first nword values c indicate the data types of the data fields c translated from the character string in achar: c 0: Not recognizable as an integer or floating-point c number, and longer than 8 characters (nerr = 0), c or a floating-point number whose exponent exceeds c the limit iemax (nerr = 5). Returned in aword. c Also, blank fields after last non-blank field. c 1: Not recognizable as an integer or floating-point c number. Field has 1-8 characters. Returned in c aword, left-adjusted, right-filled with blanks, c as necessary. c 2: Data field translated into integer mode. c The integer value is returned in iword, and the c floating-point value is returned in fword. c Also returned in aword, as for mtype = 0 or 1. c 3: Data field translated into floating-point c mode, and returned in fword. The integer value c can not be stored in iword, because of the c possibility of overflow of numbers with large c exponents. If nerr = 4, the data field was c an integer with more than idmax digits. c Also returned in aword, as for mtype = 1. c c nerr Output Result sentinal. 0 if input line was cracked. c -1 if an end-of-file was reached in the input file. c 4 if an integer exceeds idmax characters (in any c field). If so, a floating-point result is returned c in fword, with mtype = 3. c 5 if a floating-point exponent exceeds iemax (in any c field). If so, a character string is returned in c aword, with mtype = 0. c 10 if the system could not read the input line. c c nword Output The number of data fields found in achar. c Zero if input line was blank. c c Example: Following is an example of a valid input line, and how it would c be cracked and typed by aptffin. c Input: abc charstring 10 1.0e+01 6 7.12 c c word aword iword fword mtype nword = 6 c 1 abc 0 0.0 1 ASCII c 2 charstring 0 0.0 0 ASCII (9 characters) c 3 10 10 10.0 2 integer c 4 1.0e+01 0 10.0 3 floating-point c 5 6 6 6.0 2 integer c 6 7.12 0 7.12 3 floating-point c c Changes: c c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ccend. c.... Dimensioned arguments. c---- Input line uncracked ASCII words. dimension achar (1) c---- Input line uncracked ASCII words. character*8 achar c---- Cracked fields. ASCII (mtype = 0, 1). dimension aword (1) c---- Cracked fields. ASCII (mtype = 0, 1). character*8 aword c---- Cracked fields. Real (mtype = 2, 3). dimension fword (1) c---- Cracked fields. Integer (mtype = 2). dimension iword (1) c---- Cracked field types (0, 1, 2 or 3). dimension mtype (1) c.... Local variables. c---- Field delimiter. Blank used here. common /captffin/ fd c---- Field delimiter. Blank used here. character*1 fd c---- Index in several arrays. common /laptffin/ i c---- Max # of characters to translate. common /laptffin/ nchar c---- Max # of fields to translate. common /laptffin/ nwordm c.... Initialize. c---- Field delimiter. Blank used here. fd = ' ' c---- Max # of characters to translate. nchar = 80 c---- Max # of fields to translate. nwordm = 40 c---- Result sentinal. nerr = 0 cbugc***DEBUG begins. cbug 9801 format (/ 'aptffin parsing an input line. ius=',i3 / cbug & ' idmax=',i3,' iemax=',i5) cbug write (3, 9801) ius, idmax, iemax cbugc***DEBUG ends. do 110 i = 1, nwordm aword(i) = ' ' iword(i) = 0 fword(i) = 0.0 mtype(i) = 0 110 continue cbugc***DEBUG begins. cbug 9802 format (/ 'aptffin initial aword is' / ('"',a,'"')) cbug write (3, 9802) aword(1) cbugc***DEBUG ends. c.... Read a line from the input disk file. 800 format (10a8) c++++ Read input line. read (unit=ius, fmt=800, err=120, end=130) & (achar(i), i = 1, 10) c.... Crack space delimited fields to ASCII, integer and floating-point. call aptchat (achar, 1, nchar, nwordm, fd, idmax, iemax, & aword, iword, fword, mtype, nword, nerr) go to 210 c---- System can not read input line. 120 nerr = 10 go to 210 c---- Found end-of-file. 130 nerr = -1 210 return c.... End of subroutine aptffin. (+ 1 line). end UCRL-WEB-209832