Simple Fortran Examples

By Dr. Steve Gao

1. Write to a text (ASCII) file

2. Read a text (ASCII) file to a 1-D array and write a text file

3. Read and write SAC files

4. Read a SAC file and some header values (e.g., event locations)

5. Executing Linux system commands inside Fortran

6. Write and execute a SAC program in fortran

7. An example of the use of subroutines

8. Smooth a SAC file

9. The use of the function amin1

10. Get the average of an array

11. Converting earthquake time into decimal year

12. Number of quakes per day

13. Number of quakes per day using arrays to speed up the processing

14. Real-life research: Spatial distribution of seismic b_values

15. Counting quakes in a circle using the subroutine distazsub.f

16. Counting numbers in fixed ranges.
Data used in the program (save it as data.dat).

17. Reading info from a list of SAC-files.
The Makefile

18. Using the ran4 function in Numerical Recipes.
The Makefile