rdnbl |
Table of contents
ProcedureRDNBL ( Read non-blank line ) SUBROUTINE RDNBL ( FILE, LINE, EOF ) AbstractRead the next non-blank line of text from a text file. Required_ReadingNone. KeywordsFILES TEXT DeclarationsIMPLICIT NONE CHARACTER*(*) FILE CHARACTER*(*) LINE LOGICAL EOF Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- FILE I Input text file. LINE O Next non-blank line from the input text file. EOF O End-of-file indicator. Detailed_InputFILE is the name of the text file from which the next line is to be read. If the file is not currently open, it is opened with a logical unit determined at run time, and the first line of the file is returned. Otherwise, the next line not yet read from the file is read and returned. Detailed_OutputLINE is next non-blank line of text in the specified file. EOF is .TRUE. when the end of the file is reached, and is otherwise .FALSE. ParametersNone. Exceptions1) If either the end of the file is reached or an error occurs before a non-blank line is found, LINE is blank. FilesSee input FILES. ParticularsRDNBL simply calls RDTEXT until one of two things happens: 1. A non-blank line is found (in which case the line is returned). 2. The end of the file is reached (in which case the file is closed, a blank line is returned, and the end-of-file indicator becomes .TRUE.) ExamplesLet FILE.1 contain the following lines. Mary had a little lamb Everywhere that Mary went Its fleece was white as snow. The lamb was sure to go. Then the code fragment DO I = 1, 4 CALL RDNBL ( 'FILE.1', LINE, EOF ) WRITE (*,*) LINE END DO produces the following output: Mary had a little lamb Everywhere that Mary went Its fleece was white as snow. The lamb was sure to go. In fact, the following code fragment removes all of the blank lines from an arbitrary text file (FILE). CALL RDNBL ( FILE, LINE, EOF ) DO WHILE ( .NOT. EOF ) WRITE (*,*) LINE( : RTRIM(LINE) ) CALL RDNBL ( FILE, LINE, EOF ) END DO Note that because RDNBL calls RDTEXT, calls to either routine can be interspersed. For example, RDNBL can be used to skip blank lines at the beginning of the file, leaving the rest to be processed: CALL RDNBL ( FILE, LINE, EOF ) DO WHILE ( .NOT. EOF ) < do something with LINE > CALL RDTEXT ( FILE, LINE, EOF ) END DO Restrictions1) Any restrictions that apply to RDTEXT apply to RDNBL as well. Literature_ReferencesNone. Author_and_InstitutionJ. Diaz del Rio (ODC Space) I.M. Underwood (JPL) VersionSPICELIB Version 1.1.0, 12-AUG-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. SPICELIB Version 1.0.0, 07-AUG-1994 (IMU) |
Fri Dec 31 18:36:41 2021