U.S. Department of the Interior

U.S. Geological Survey

Report Series 2015–1229

csa2sac—A Program for Computing Discharge from 

Continuous Slope-Area Stage Data

By Stephen M. Wiele
U.S. Department of the Interior

SALLY JEWELL, Secretary

U.S. Geological Survey

Suzette M. Kimball, Acting Director

U.S. Geological Survey, Reston, Virginia: 2015 

For more information on the USGS—the Federal source for science about the Earth,

its natural and living resources, natural hazards, and the environment—visit

http://www.usgs.gov/ or call 1–888–ASK–USGS (1–888–275–8747). 

For an overview of USGS information products, including maps, imagery, and publications,

visit http://www.usgs.gov/pubprod/.

Any use of trade, firm, or product names is for descriptive purposes only and does not imply

endorsement by the U.S. Government.

Although this information product, for the most part, is in the public domain, it also may

contain copyrighted materials as noted in the text. Permission to reproduce copyrighted items

must be secured from the copyright owner.

Suggested citation:

Wiele, S.M., 2015, csa2sac—A program for computing discharge from Continuous Slope-Area stage data: 

U.S. Geological Survey Open-File Report 2015–1229, 4 p., http://dx.doi.org/10.3133/ofr20151229. 

ISSN 2331-1258 (online)
iii

Contents

Introduction................................................................................................................................................................. 1

Purpose and Scope .................................................................................................................................................... 2

csa2sac Input.............................................................................................................................................................. 2

csa2sac Output........................................................................................................................................................... 2

References Cited........................................................................................................................................................ 3

Glossary ..................................................................................................................................................................... 4

Appendixes............................................................................[Available online at http://dx.doi.org/10.3133/20151229] 

Appendix 1. csa2sac program code.......................................................................................csa2sac.cpp.txt

Appendix 2. Sample control file..................................................................................................... csa2sac.in 

Appendix 3. Sample SAC input file used as template for csa2sac....................................... SACtemplate.txt

Appendix 4. Sample stage data input file ...................................................................................stagedata.txt

csa2sac—A Program for Computing Discharge from 

Continuous Slope-Area Stage Data

By Stephen M. Wiele

Introduction

Continuous Slope-Area (CSA) gages were developed by the Arizona Water Science Center to 

enable the estimation of hydrographs when direct measurements of discharge cannot be made (Smith 

and others, 2010). CSA gages extend standard U.S. Geological Survey (USGS) methods for determining 

peak discharges to mid and high flows over a hydrograph computed at regular intervals with indirect 

measurement methods (Benson and Dalrymple, 1967; Dalrymple and Benson, 1967). CSA gages 

combine continuous stage records at two or more (typically three or four) cross sections with crosssection surveys and estimates of channel roughness to compute discharge over a range of flows. With 

standard indirect methods of determining peak discharge, water-surface elevation in the study reach at 

the peak flow is estimated from surveys of debris associated with the peak-flow water line. With CSA 

gages, stages are continuously measured at the cross sections, at regular and synchronized intervals 

(typically 5 minutes) over a flow event, and discharge can be calculated at each interval. 

Calculation of discharge using indirect methods has been automated with the slope-area 

computation (SAC) program (Fulford, 1994). SAC is a widely used program within the USGS; it is 

easily run and displays output in a clear and convenient format, which includes flags that alert the user 

to shortcomings in the calculation. Use of SAC has been facilitated by SACGUI (Bradley, 2012; 

SACGUI uses a version of SAC called SAC7), a user interface that directly reads and displays survey 

data, allows for specification of water-surface slope and channel roughness, writes the input file for 

SAC7, runs SAC7, and displays SAC7 output. 

csa2sac is a program (appendix 1) that repeatedly runs SAC7 using stage data and a SAC7 input 

template file to compute the discharge at CSA gages. It is written in the C programming language, and 

is compatible with 64-bit Windows operating systems. The program reads a SAC7 input file and a file 

containing stage-data time series. It writes a new version of the SAC7 input file with the stage data for 

one time step, runs SAC7, then extracts computed discharges from the SAC7 output file and collates the 

discharges and stages to a separate file. It repeats these steps for each time interval in the stage file to 

produce a discharge time series from the stage data. csa2sac has been tested with two, three, four, and 

six cross sections and found to operate successfully. By running SAC7, csa2sac maintains consistency 

and comparability of both discharges calculated from CSA gages and of standard USGS methods for 

computing discharges indirectly. Brown and Metcalfe (2014) have made available alternative software 

for producing CSA discharges. 

In addition to csa2sac, the SAC7 program is required. It is the same as the original SAC 

program, except that it is compiled for 64-bit Windows operating systems and has a slightly different 

command line input. It is available online (http://water.usgs.gov/software/SAC/) as part of the SACGUI 

installation program. The program name, “SAC7.exe,” is coded into csa2sac, and must not be changed. 
2

Purpose and Scope

This report documents a program useful for computing discharges with CSA data. Readers 

unfamiliar with CSA gages are referred to Smith and others (2010) and Wiele and others (in press). 

Readers unfamiliar with slope-area indirect methods of computing discharge are referred to Dalrymple 

and Benson (1967) and Benson and Dalrymple (1967).

csa2sac Input

Three input files are required to run csa2sac: a csa2sac control file, a SAC input template file, 

and a file with stage data. Sample files are available online as appendixes in plain text format.

csa2sac control file—This file has a fixed name (csa2sac.in) that cannot be changed by the user. It 

specifies input file names, the SAC output directory, and the number of cross sections. An annotated 

example file with explanations of the input is in appendix 2. csa2sac only uses the first character 

string in each line, so directory or file names cannot have spaces, but notes can be added to the right 

of the first character string as long as no carriage returns are inserted before the end of the line. 

SAC template file—This is a standard input file for SAC7, but with additional format restrictions. An 

example is in appendix 3, and it has been thoroughly documented by Fulford (1994). The name of 

this file is specified in csa2sac.in.

The SAC input file has some rigid formatting requirements that must be followed for SAC7 to run 

properly. For all but one line in the template file, csa2sac simply reads the line and rewrites it in the 

new SAC7 input file. The exception is the HP (or hydraulic properties) record, which specifies the 

stage. There is one HP record for each cross section. The HP record also has a cross section 

identifier (SECID). The SECID must match the SECID specified for the XS (or cross-section) 

record, which specifies the distance between cross sections. SAC7 is flexible in the text used for 

SECID, but csa2sac is restricted to “X” followed by the cross section number to form the SECID

(for example, X1, X2). The SECID used for the XS record must be in the same format. Note also 

that the SAC manual shows “4” in column 4 in the HP record. This is a carryover from the WSPRO

(Water-Surface Profile) input format, from which SAC is derived, and is not used in SAC. Column 4 

should be left blank in the HP record for csa2sac. 

Stage data—Stage data from the pressure transducers is read from this file. The name of the file is 

specified in csa2sac.in. An example showing the format is in appendix 4. Note that the time must be 

converted to a Julian date in the input file to be read by csa2sac. Spreadsheets such as Excel can be 

used to convert times to Julian dates in the input file, and back to calendar dates and times in the 

output file. When saving a spreadsheet file for the stage input file the format should be plain text.

csa2sac Output

csa2sac writes the discharge time series to a comma delimited (csv) file with the fixed name 

“q.csv.” SAC7 computes ∑ i n−1

1 (where n is the number of cross sections) discharges for various 

combinations of cross sections, and they are all printed to the output file for each time step. The stages 

are also printed. If a file with the name “q.csv” already exists in the same directory, csa2sac will 

overwrite it if it is closed, or stop running if it is open in other software. If other parameters that are 

printed in SAC7 are of interest, such as cross-sectional area or Froude number, a similar approach could 

be used to modify csa2sac to read them in the SAC7 output file and write them to the csa2sac output 

file.
3

csa2sac also writes the input file for SAC7. Both the SAC7 input and output files are written to a 

subdirectory specified in csa2sac.in (q.csv is written to the top directory). These files can be examined if 

formatting problems arise, and the output files contain useful information, such as warning flags 

concerning the discharge calculation. Note that SAC7 will not overwrite existing files, so if csa2sac is 

rerun the previous output files will have to be deleted or a different subdirectory must be specified in 

csa2sac.in.

References Cited 

Benson, M.A., and Dalrymple, T., 1967, General field and office procedures for indirect discharge 

measurements: U.S. Geological Survey Techniques of Water-Resources Investigations, book 3, chap. 

A1, 30 p., available at http://pubs.er.usgs.gov/publication/twri03A1. 

Bradley, D.N., 2012, Slope-area computation program graphical user interface 1.0—A preprocessing 

and post processing tool for estimating peak flood discharge using the slope-area method: U.S. 

Geological Survey Fact Sheet 2012–3112, 4p. 

Brown, S. and Metcalfe, R.A, 2014, The slope-area method for estimating continuous discharge: 

Ontario Ministry of Natural Resources Aquatic Research Series 2014–03, 13p. 

Chow, V.T., 1959, Open-channel hydraulics: New York, McGraw-Hill, 680 p. 

Dalrymple, T., and Benson, M.A., 1967, Measurement of peak discharge by the slope-area method: U.S. 

Geological Survey Techniques of Water-Resources Investigations, book 3, chap. A2, 12 p., available 

at http://pubs.usgs.gov/twri/twri3-a2/. 

Fulford, J.M., 1994, User’s guide to SAC, a computer program for computing discharge by slope-area 

method: U.S. Geological Survey Open-File Report 94–360, 31 p. 

Smith, C.F., Cordova, J.T., and Wiele, S.M., 2010, The continuous slope-area method for computing 

event hydrographs: U.S. Geological Survey Scientific Investigations Report 2010–5241, 37 p., 

available at http://pubs.usgs.gov/sir/2010/5241/. 

Wiele, S.M., Heaton, J.W., Bunch, C.E., Gardner, D.F., Smith, C.F., in press, Continuous slope-area 

discharge records in Maricopa County, Arizona, 2004–2012: U.S. Geological Survey Scientific 

Investigations Report 2015–5172. 
4

Glossary

csa2sac.exe Executable file that runs the csa2sac program.

csa2sac.in Control file that specifies input file names, output directory for SAC7, and number of 

directories.

HP Record in the SAC7 input file that specifies stage. One HP record is required for each cross 

section.

SAC USGS program that computes discharge using the slope-area indirect method. 

SAC7 SAC program compiled for 64-bit Windows operating systems. SAC7 comes with SACGUI. 

SACGUI Graphical user interface for SAC7. 

SAC template file SAC7 input file that is reproduced by csa2sac with stage from the stage input file 

specified in the HP records. 

Stage input file Time and stage from the CSA stage records.

SECID Parameter specified in the HP and XS records in the SAC7 input file. csa2sac requires that “X” 

be used for the SECID. 

X Letter used for the secid by csa2sac.

XS Record in the SAC7 input file that specifies distance from the first cross section. The XS record 

also has the SECID, which must match the SECID for the HP record for the same cross section.