[cig-commits] r14890 - seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process
tan2 at geodynamics.org
tan2 at geodynamics.org
Wed May 6 11:29:03 PDT 2009
Author: tan2
Date: 2009-05-06 11:29:03 -0700 (Wed, 06 May 2009)
New Revision: 14890
Modified:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c
Log:
Add license and usage
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c 2009-05-06 18:21:21 UTC (rev 14889)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/UTILS/seis_process/asc2sac.c 2009-05-06 18:29:03 UTC (rev 14890)
@@ -1,4 +1,22 @@
-/* License
+/*
+ * asc2sac.c by Eh Tan
+ *
+ * Copyright (C) 2009, California Institute of Technology.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
*/
#include <stdio.h>
@@ -20,23 +38,30 @@
FILE *f;
if(argc < 4) {
- fprintf(stderr, "%s ascii-file npts sac-file\n", argv[0]);
+ fprintf(stderr,
+ "Converting evenly spaced time series ASCII file to SAC binary\n"
+ "usage: %s ascii-file npts sac-file\n\n"
+ "ascii-file: name of the input file. The file must have two columns,\n"
+ " 1st column must be evenly spaced.\n"
+ "npts: number of lines in the input file.\n"
+ "sac-file: name of the output file.\n",
+ argv[0]);
exit(1);
}
str = argv[2];
errno = 0;
+ endptr = str;
npts = strtol(str, &endptr, 10);
/* Check for various possible errors */
- if ((errno == ERANGE && (npts == INT_MAX || npts == INT_MIN))
- || (errno != 0 && npts <= 0)) {
- perror("strtol");
- exit(EXIT_FAILURE);
+ if (errno || (*endptr != 0)) {
+ fprintf(stderr, "Error when converting '%s' to integer\n", str);
+ exit(-1);
}
- if (endptr == str) {
- fprintf(stderr, "No npts were found\n");
+ if (npts <= 0) {
+ fprintf(stderr, "npts must be positive\n");
exit(EXIT_FAILURE);
}
More information about the CIG-COMMITS
mailing list