

                   Sounding (SN) Library 


The sounding library subroutines allow the programmer to access
GEMPAK upper-air data files.  These files contain meteorological
observations from many locations for different times.  The 
library contains modules which create and open files and read or
write data to these files. 

There are two types of GEMPAK sounding files:  merged and unmerged.
Merged files may contain an arbitrary set of parameters which
report at every level.  Unmerged files store mandatory and
significant data separately in the following parts with the 
given parameters:

  TTAA  mandatory data below 100 mb  PRES TEMP DWPT DRCT SPED HGHT
  TTBB  sig temp data below 100 mb   PRES TEMP DWPT
  PPBB  sig wind data below 100 mb   HGHT DRCT SPED or
                                     PRES DRCT SPED
  TTCC  mandatory data above 100 mb  PRES TEMP DWPT DRCT SPED HGHT
  TTDD  sig temp data above 100 mb   PRES TEMP DWPT
  PPDD  sig wind data above 100 mb   HGHT DRCT SPED or
                                     PRES DRCT SPED
When wind data appear on pressure surfaces, the first pressure is 
set to the negative of its value as a flag.

Data that are to be written to an unmerged file must be in the 
specified order.  When data are returned from an unmerged file, 
data from all the parts will be merged.  Interpolation will be 
used to fill in the significant data levels. 

Merged data files can be created using SN_CREF or SN_CRFP; 
unmerged files can be created using SN_CRUA.  SN_OPNF will open 
either file type.  SN_RDAT will read data from all files; 
unmerged data will be returned as a merged data set.  SN_RTYP can 
be called to determine whether each level is mandatory, significant
temperature, or significant wind level data.  SN_MAND can 
be called to request that only mandatory data below 100 mb be 
returned when SN_RDAT is called.  SN_WDAT writes to merged files; 
SN_WPRT writes to unmerged files.

The subroutines to create or open a sounding file return a file 
number which must be used in later subroutines to access the file.

The file GEMPRM.PRM contains the maximum values for array
dimensions when using GEMPAK subroutines.  A copy of this file has
been included in the appendix for easy reference.  MMFILE is the 
maximum number of files that can be open.  LLMXTM is the maximum 
number of times that can be saved in a GEMPAK5 file. The maximum 
number of stations is LLSTFL and the maximum number of parameters 
is MMPARM.

After a file is opened, both the time and station must be selected
before data can be read or written.  There are two groups of 
subroutines that perform this function.

If data from many stations are to be accessed for a particular 
time, the time can be set using SN_STIM.  The stations to be 
selected may be defined using LC_SARE or LC_UARE, which select 
stations using the GEMPAK variable, AREA.  The LC subroutines may
be called before or after SN_STIM.  Stations within the area are 
returned using SN_SNXT.

If data for many times at a particular station are required, the
station may be selected using SN_TSTN.  The time may then be 
defined using SN_TTIM.  Alternatively, times may be returned using
SN_TNXT.

All GEMPAK files contain information about the station in station
headers.  The station header names, contents, and the data types
returned from the SN library are:

        STID    Station identifier            CHARACTER*4
        STNM    Station number                INTEGER
        SLAT    Station latitude              REAL
        SLON    Station longitude             REAL
        SELV    Station elevation in meters   REAL
        STAT    State                         CHARACTER*2
        COUN    Country                       CHARACTER*2
	STD2	Extended station ID	      CHARACTER*4

Only SLAT and SLON are required for sounding files.  The other
header variables are optional.

The subroutines SN_FTIM and SN_FSTN can be used to find a time 
and station in a data set.  They will execute faster than the 
subroutines above, but can only be used with files where the times 
are in rows and the stations are in columns (or vice versa).  They were
designed to be used in real-time data ingest applications and should
not be used for normal applications which use general sounding
files.

Some examples of subroutine sequences for accessing the data follow.

A sequence of subroutines to retrieve sounding data for many 
stations at one time is:
 
        Initialize GEMPAK                       (IN_BDTA)

	Open the file				(SN_OPNF)
	Define the time				(SN_STIM)
	Define the area search			(LC_SARE)
	Loop:
	   Get the next station			(SN_SNXT)
	   Read the data			(SN_RDAT)
	End loop
	Close the file				(SN_CLOS)

A sequence of subroutines to retrieve sounding data for many times
at one station is:

	Open the sounding file			(SN_OPNF)
	Get times in file                       (SN_GTIM)
	Get times to use                        (TI_FIND)
	Set the station				(SN_TSTN)
	Loop:
	   Get the next time			(SN_TTIM)
	   Read the data			(SN_RDAT)
	End loop
	Close the file				(SN_CLOS)

