Time series data can be generated in your own fortran (and C ) programs and output in SAC binary format. Many of my programs use this capability since it is useful to compare data and synthetic seismograms in the same format. It also useful to read SAC binary files to perform more specialized functions that SAC does not include.
This is accomplished by called the following IO routines available in the SAC library, "sac.a".
Here is an f77 program that constructs a gaussian time
function an outputs the result in SAC binary format.
|c ------ gauss.f program to create gaussian time function
* Create the far field time function --------------------
100 FORMAT('INPUT time width and time shift of gaussian pulse:')
101 FORMAT('INPUT DT AND NPTS WANTED:')
DO 10 I=1,NPOINT
TM=DT*(I-1) - twidth - tshift
C---------- NOW CREATE A HEADER IN SAC FORMAT.---------------------
C - Set all header fields to their default values.
C - USER ACTION: Shown below are incomplete statements used
C to define each of the SAC header fields.
C Using your own variables, complete the statements
C which define the SAC header fields that you
C want to be in the file. Delete the remaining lines.
C - The definitions for each of these variables can be found in the
C appendix to the SAC Command Reference Manual.
C - Fields which begin with an "L" are logical fields and must
C be either .TRUE. or .FALSE.
C - Fields which begin with an "N" are integer fields.
C - Fields which begin with an "I" are also integers, but can only
C be set to a limited number of values, each corresponding
C to a specific condition. See the above mentioned appendix.
C - Fields which begin with a "K" are character variables of
C length 8 unless otherwise noted.
C - All other fields are real.
C - The following fields are required:
C - WRITE THE FILE TO DISK.
200 FORMAT(1X,'SAC FILE ',A32,' HAS BEEN WRITTEN TO DISK')
calculate the gaussian function
Set up a new SAC header
Set header variables needed
use wsac1 to create an evenly spaced binary file
FFLAGS = -g
MYBIN = /yourdirectory/bin
LIB = $(SACDIR)/lib
f77 $(FFLAGS) -o $(MYBIN)/gauss gauss.f $(LIB)/sac.a
At this time (3/05/01) CERI does not have a generally available copy of the SAC library, "sac.a" or "sacio.a", that can be used in compiling fortran or C programs on SUN Solaris systems. A copy is available at /tetemeko/local/sac/lib/sac.a if you need to compile programs with SAC I/O routines.