\section{Resource Management}
 %
Inpak 90 is a Fortran (77/90) collection of routines/functions for 
accessing {\em Resource Files} in ASCII format. 
The package is optimized for minimizing formatted I/O, performing all of 
its string operations in memory using Fortran intrinsic functions.
%  
\subsection{Resource Files}
%
A {\em Resource File} is a text file consisting of variable length lines 
(records), each possibly starting with a {\em label} (or {\em key}), 
followed by some data. 
A simple resource file looks like this:
%
\begin{verbatim}
   # Lines starting with # are comments which are ignored during processing.
   #
   my_file_names:         jan87.dat jan88.dat jan89.dat
   radius_of_the_earth:   6.37E6                   # these are comments too
   constants:             3.1415   25
   my_favourite_colors:   green blue 022           # text & number are OK
\end{verbatim}
%
In this example, {\tt my\_file\_names:} and {\tt constants:}
are labels, while {\tt jan87.dat, jan88.dat} and {\tt jan89.dat} are
data associated with label {\tt my\_file\_names:}.
Resource files can also contain simple tables of the form,
%
\begin{verbatim}
   my_table_name::
    1000     3000     263.0   
     925     3000     263.0
     850     3000     263.0
     700     3000     269.0
     500     3000     287.0
     400     3000     295.8
     300     3000     295.8    
     ::
\end{verbatim}
% 
Resource files are random access, the particular order of the
records are not important (except between ::'s in a table definition).
%
\subsection{A Quick Stroll}
%
The first step is to load the ASCII resource (rc) file into
memory\footnote{See next section for a complete description
of parameters for each routine/function}:
% 
\begin{verbatim}
         call i90_LoadF ( 'my_file.rc', iret )
\end{verbatim}
% 
The next step is to select the label (record) of interest, say
%  
   \begin{verbatim}
         call i90_label ( 'constants:', iret )
   \end{verbatim}
% 
    The two constants above can be retrieved with the following code
    fragment:
%
   \begin{verbatim}
         real    r
         integer i
         call i90_label ( 'constants:', iret )
         r = i90_gfloat(iret)                 ! results in r = 3.1415
         i = i90_gint(iret)                   ! results in i = 25
   \end{verbatim}
%  
    The file names above can be retrieved with the following
    code fragment:
%
   \begin{verbatim}
         character*20 fn1, fn2, fn3
         integer      iret
         call i90_label ( 'my_file_names:', iret )
         call i90_Gtoken ( fn1, iret )            ! ==> fn1 = 'jan87.dat'
         call i90_Gtoken ( fn2, iret )            ! ==> fn1 = 'jan88.dat'
         call i90_Gtoken ( fn3, iret )            ! ==> fn1 = 'jan89.dat'
   \end{verbatim}
%  
   To access the table above, the user first must use {\tt i90\_label()} to 
   locate the beginning of the table, e.g.,
 % 
   \begin{verbatim}
         call i90_label ( 'my_table_name::', iret )
   \end{verbatim}
%  
   Subsequently, {\tt i90\_gline()} can be used to gain access to each
   row of the table. Here is a code fragment to read the above
   table (7 rows, 3 columns):
%  
\begin{verbatim}
         real          table(7,3)
         character*20  word
         integer       iret
         call i90_label ( 'my_table_name::', iret )
         do i = 1, 7
            call i90_gline ( iret )
            do j = 1, 3
               table(i,j) = i90_gfloat ( iret )
            end do                   
         end do
 \end{verbatim}
%
\subsection{Main Routine/Functions}
%  
   \begin{verbatim}
    ------------------------------------------------------------------
           Routine/Function                  Description
    ------------------------------------------------------------------
    I90_LoadF ( filen, iret )     loads resource file into memory
    I90_Label ( label, iret )     selects a label (key)
    I90_GLine ( iret )            selects next line (for tables)
    I90_Gtoken ( word, iret )     get next token 
    I90_Gfloat ( iret )           returns next float number (function)
    I90_GInt ( iret )             returns next integer number (function)
    i90_AtoF ( string, iret )     ASCII to float (function)
    i90_AtoI ( string, iret )     ASCII to integer (function)
    I90_Len ( string )            string length without trailing blanks
    LabLin ( label )              similar to i90_label (no iret)
    FltGet ( default )            returns next float number (function)
    IntGet ( default )            returns next integer number (function)
    ChrGet ( default )            returns next character (function)
    TokGet ( string, default )    get next token
    ------------------------------------------------------------------
   \end{verbatim}
%  
   {\em Common Arguments:}
%  
   \begin{verbatim}
   character*(*)      filen       file name
   integer            iret        error return code (0 is OK)
   character*(*)      label       label (key) to locate record
   character*(*)      word        blank delimited string
   character*(*)      string      a sequence of characters
   \end{verbatim}
 % 
   See the Prologues in the Appendix for additional details.
 %   
\subsection{Package History} 
         Back in the 70's Eli Isaacson wrote IOPACK in Fortran
         66.  In June of 1987 I wrote Inpak77 using
         Fortran 77 string functions; Inpak 77 is a vastly
         simplified IOPACK, but has its own goodies not found in
         IOPACK.  Inpak 90 removes some obsolete functionality in
         Inpak77, and parses the whole resource file in memory for
         performance.  Despite its name, Inpak 90 compiles fine
         under any modern Fortran 77 compiler.
 % 
\subsection{Bugs} 
         Inpak 90 is not very gracious with error messages.  
         The interactive functionality of Inpak77 has not been implemented.
         The comment character \# cannot be escaped.
  
\subsection{Availability}
%  
This software is available at 
   \begin{verbatim}
           ftp://niteroi.gsfc.nasa.gov/pub/packages/i90/ 
   \end{verbatim}
     There you will find the following files:
   \begin{verbatim}
   i90.f      Fortran 77/90 source code
   i90.h      Include file needed by i90.f
   ti90.f     Test code
   i90.ps     Postscript documentation
   \end{verbatim}
   An on-line version of this document is available at
   \begin{verbatim}
          ftp://niteroi.gsfc.nasa.gov/www/packages/i90/i90.html
   \end{verbatim}   
%
\nopagebreak
