This directory contains two programs which are useful for handling "foreign" data. The program STREAM and its subroutine FTLOCC were written to break apart stream-CR or stream-LF data files. The subroutine NEXT has been used to swap bytes on data tapes from IBM and HP machines and to convert IBM floating point into VAX floating point. NEXTTEST is an example program which shows the usage of NEXT in picking up the "next" bits in a word. As usual with DECUS SIG TAPE programs, I do not warrant the usefulness or accuracy of any of these programs. We do use them at the Oceanographic with good results and i expect that they will work for you as well. I will try to help anyone who needs help using them. You may contact me at Thomas W. Danforth Woods Hole Oceanographic Institution Woods Hole, MA 02574 617-548-1400 x2876 ========================================================================== STREAM The program STREAM was written to read STREAM-LF or STREAM-CR files and break them into variable length record files. The program opens the input file and reads the data into a large buffer. It then searches for a CR or LF depending on the type of search the user specified. The data are then written to an output file in list format without the CR or LF. The user is prompted at the beginning of the program for the type of search and for the input and output file names. There are some restrictions on the use of the program. It will only read a data file which can be opened with a FORTRAN OPEN statement and read sequentially. The largest record must be less than 16000 bytes. STREAM will allow the input stream records to span the physical records in the input file. Because of this capability, STREAM must restrict the input records to 16000 bytes. Stream can remove both CR and LF from a file if the program is run once to remove the CR and a second time to remove the LF. The program prompts the user for the type of search to be done with: "Stream_LF or Stream_CR? :" Indicate the search to be performed by entering "CR" or "LF" in upper-case. The program will then ask for the input file name and the output file name. Following the processing, it will ask if another file is to be processed - enter a "Y" to process another file using the same search. If there are any errors, STREAM will print an error message and the user can respond appropriatly. The program is written in FORTRAN and is linked to the subroutine FTLOCC which is written in MACRO. To build the program: 1. FORTRAN STREAM 2. MACRO FTLOCC 3. LINK STREAM,FTLOCC If there any comments or problems wi the program, you may contact me: Thomas W. Danforth Woods Hole Oceanographic Institution Woods Hole, MA 02543 617-548-1400 x2876 ============================================================================= NAME: NEXT TYPE: Subroutine PURPOSE: Pick up bits from successive positions in a byte array. MACHINE: VAX ll/780 SOURCE LANGUAGE: FORTRAN 77 DESCRIPTION: NEXT allows the user to step through a bit string picking up a specified number of bits on each call. An initializing call reverses the order of bytes and NEXT reads from end to beginning. Although this feature is transparent to the user, the reversal is necessary to allow access from most significant to least significant bit. USAGE: We assume the bit string is stored in a non-character array. User must make an initializing call to INEXT for each new bit string to be accessed. After that call, the initial array will be replaced by one in which the bytes have been reversed. The user is responsible for providing a duplicate array (or for calling INEXT again to reverse the bytes back) if the original array is needed. The initializing call has the form: CALL INEXT(N, BYTES) where N = number of bytes passed; BYTES = a numeric array. Subsequent calls to NEXT will step through the array by the number of bits the user specifies, returning a longword represented by those bits. The user may elect to have IVAR sign-filled or zero-filled. These calls have the following form: CALL NEXT(NBITS, NUSED, IVAR, IND) where NBITS = user-specified number of bits to extract (from 1-32). NUSED = integer returned by NEXT containing number of bits picked up. NUSED = NBITS on normal completion. NUSED = the number found if IND = 3 condition encountered. Otherwise NUSED = 0. IVAR = a longword of the bits extracted and returned by NEXT. IND = integer variable. If NEXT is called with IND less than zero, IVAR will be sign-filled. Otherwise IVAR will be zero filled. After the call to NEXT, IND will reflect the status as follows: 0 = end of buffer - no execution. 1 = normal completion. 2 = buffer overflow condition - attempt to read at point beyond end of buffer. 3 = partial overflow. End of buffer encountered before NBITS used up. Execution continued with reduced number of bits. 4 = illegal bits request - i.e. NBITS less than or equal to 0 or NBITS greater than 32. LIMITATIONS: Two arrays may not be accessed simultaneously. A sequence of calls to one array must be completed before another is initialized. BYTES in the call to INEXT must be of numeric type; i.e., not a character string. This routine is designed to deal with bit strings stored in byte variables. Therefore, records should have been written from byte variables and should be read into byte variables. For writing and reading foreign tapes, we recommend the TAPESUBS routines on the Spring 1982 VAX SIG tape. Although NEXT will accept any numeric type variable or array, bytes are accessed in the order in which they reside on the tape or file; great confusion can occur with records written by the VAX if the records contain multi-byte entities. ERRORS AND DIAGNOSTICS: None PROGRAMMER: Susan Volkmann DATE: September 1982 As an addendum, the program NEXTTEST uses NEXT to pick bits from a byte string and write the results to a data file (OUT.DAT). For an example of how to use this subroutine, examine NEXTTEST. Again, if you need help you may call me. T. Danforth