2008 NSHM Software Documentation

This page contains documentation on how to download, compile, and run the software that created the 2008 Update to the National Seismic Hazard Maps. For documentation and/or more information about the science behind this update, please read: OFR 2008-1128: Documentation for the 2008 Update of the United States National Seismic Hazard Maps.

General Comments

The code used in creating the 2008 U.S. Geological Survey Nationial Seismic Hazard Maps Update consisits of Fortran, C, and various scripts. The scientific portion of the code lives in the Fortran (*.f) files. The C code is used for input/output (I/O) routines, and the scripts are used as a convience for calling the fortran codes in the proper order. The software also relies on several ascii and binary input files. The ascii files should not pose any problems, however the binary may cause problems if you try to run the code on your own computer. Binary files are all written using the “little endian” format. This format is common for Intel processors and makes the binary format compatible with most Windows, Linux, and Mac (after the Intel switch) computers. Solaris and older Apple computers use different types of processors and may require you to swap the byte order of the binary files before you can use them. View the Wikipedia page on “Endianness” for more information about byte-order and what this may mean for you.

In addition to documentation contained below, each of the source code files (listed and described below), are fairly well-documented themselves and can provide some guidance for users. The top of most of the files also contain a “change log” that can be useful to see what specific changes have been made to the code, why they were made, and when they were made. To view this inline documentation, download the source code.

The software has been tested to compile and run using each of f95, gfortran, and ifort. Compilation flags vary slighly between compilers, but each of the fortran programs use similar flags. An example compilation command for each compiler is given below:

In this example we will compile the program “hazFXnga7c.f”. You will need to replace file references as appropriate to compile other programs on your system.

  • Using f95
    f95 -o hazFXnga7c hazFXnga7c.f iosubs.o -fast -e -ftrap=%none
  • Using ifort
    ifort -o hazFXnga7c hazFXnga7c.f iosubs.o -O -132
  • Using gfortran
    gfortran -static -O -ffixed-line-length-none -ffpe-trap= -o hazFXnga7c hazFXnga7c.f iosubs.o

Source Code Information

hazFXnga7c.f

This code for computes hazard curves from fault sources. Up to 500 faults may be listed. The code will output hazard curves for a grid of sites or for a small set of sites. The grid option is selected by making the first input-field value a 0 (zero). The grid of sites can be large, as you will see from the input files. Our grids cover either the Western US or the Central and Eastern US. User specifies the set of attenuation models and their weights in the PSHA. The attenuation model weights normally sum to 1. Output may be ASCII or binary. Choose binary if you want to combine output with that from other files.

hazgridXnga2.f

The first of two codes for computing hazard curves from gridded or background hazard. The background hazard sources are always stored in binary files. These are included with the other input files. This code is generally used for CEUS gridded-hazard runs and some WUS runs. Output may be ASCII or binary. Choose binary if you want to combine output with that from other files.

hazgridXnga3.f

The second of two codes for computing hazard curves from gridded or background hazard. This code is used for gridded hazard with a normal-slip or reverse-slip component. The difference between nga3 and nga2 is that the former explicitly defines and analyses virtual dipping faults at all distances in order to compute hanging-wall effects for two NGA relations (Campbell-Bozorgnia and Chiou-Youngs). Nga2 however, only computes hanging-wall effects for the nearest grid points (<10km from the site). There are several input files with significant percentage of dip-slip sources, including Mendomap, pugetmap, and brawmap. These input files should be run with hazgridXnga3 rather than hazgridXnga2. In practice the hazard-curve differences associated with these two codes are very slight.

hazSUBXnga.f

This is the subducting-slab hazard code. There are no NGA relations in this code, but there are some modern interface attenuation models in this code, some developed in 2005 and 2006. This code differs from hazFXnga7c in other ways, the main one being how the slab is defined. In this code an upper-fault-contour and a lower-fault-contour have to be defined. In hazFXnga7c, only the upper-fault-contour is defined, and the bottom is inferred from the fault's width and internal assumptions about fault geometry. Another difference is that only one fault or slab is allowed in hazSUBXnga.f, whereas 500 may be listed in hazFXnga7c.f. Output may be ASCII or binary. Choose binary if you want to combine output with that from other files.

hazallXL.v2.f

This code combines the hazard from the binary output files of the runs of the above 4 programs. The combined hazard may be output as hazard curves (binary or ascii), or as hazard values at a fixed annual rate or probability of exceedance. The latter option is usually output as an ascii file, and is what we use for making maps of the seismic hazard model. When interpolation is called for, log-log interpolation is performed. Log-log is more accurate than linear interpolation in most cases. However, it may produce a small low bias (1 or 2 %).

hazpoint.f

This program will output a hazard curve or set of hazard curves associated with one geographic position, given as a <latitude, longitude> coordinate pair.

hazinterp.nga.f

This program performs spatial interpolation, doubling the sampling density of hazard curves in the X- and Y- directions. Simple linear interpolation is used.

combineL.v2.f

This code combines the eastern and western hazard curve collections, to give a US hazard map at a specified PE.

combinehaz2007.f

This code also combines the eastern and western hazard curve collections, to produce a US hazard curve collection.

gethead.nga.f

This code reads the header information associated with set of binary hazard files entered on command line and writes this data to the terminal. The header information tells you details like what input file was used, what program was used, what the grid of stations is, and what Vs30 is for the run, along with other useful information. If you are unsure of the contents of a binary file output by the above hazard programs, the first thing to do is to run gethead.nga on it to get a better understanding. The wildcard convention may be used. For example:

gethead.nga WUSmap*.5hz*

dumps header information from all files that match the command line instruction.

iosubs.c

This code provides basic I/O sub-routines and is used extensively by most of the fortran programs. This code is compiled differently than all the others in that it does not produce an executable file, but rather an object file. This library file becomes a compilation dependency for most of the fortran code. To compile this utility: gcc -c -o iosubs.o iosubs.c

swapf.c

This code provides a means to swap binary file endian order. By default, all binary content is posted in “little-endian” byte order. This is compatible with many machines, however some users will need to use this code to swap the binary data. Running this code on the same binary file twice will get you back to the original (unswapped) data.