source: SH_SHM/trunk/util/traveltime.c @ 207

Revision 207, 3.1 KB checked in by marcus, 13 years ago (diff)

r124 | klaus | 2010-04-08 10:33:29 +0200 (Do, 08 Apr 2010) | 1 line

better error messages in traveltime and locdiff

  • Property svn:executable set to *
Line 
1
2/* file traveltime.c
3 *      ============
4 *
5 * version 4, 21-Nov-2005
6 *
7 * Computes travel time in seconds
8 * K. Stammler, 7-Aug-96
9 */
10
11
12/*
13 *
14 *  SeismicHandler, seismic analysis software
15 *  Copyright (C) 1996,  Klaus Stammler, Federal Institute for Geosciences
16 *                                       and Natural Resources (BGR), Germany
17 *
18 *  This program is free software; you can redistribute it and/or modify
19 *  it under the terms of the GNU General Public License as published by
20 *  the Free Software Foundation; either version 2 of the License, or
21 *  (at your option) any later version.
22 *
23 *  This program is distributed in the hope that it will be useful,
24 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 *  GNU General Public License for more details.
27 *
28 *  You should have received a copy of the GNU General Public License
29 *  along with this program; if not, write to the Free Software
30 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
31 *
32 */
33
34
35
36#include <stdio.h>
37#include <string.h>
38#include "basecnst.h"
39#ifdef BC_INC_STDLIB
40#include BC_INC_STDLIB
41#endif
42#include "sysbase.h"
43#include "ptusrdef.h"
44#include "erusrdef.h"
45#include "cpar.h"
46#include "globalparams.h"
47
48
49
50int main( int argc, char *argv[] )
51{
52        /* local variables */
53        char     *env;                       /* pointer to environment */
54        char     tablepath[cBcFileLth+1];    /* name of table directory */
55        TSyStatus status;                    /* return status */
56        char     phase[cBcLineLth+1];        /* phase name */
57        float    distance;                   /* distance in deg */
58        float    depth;                      /* depth in km */
59        float    ttime;                      /* travel time in sec */
60        TSyBoolean compute_slowness;         /* compute slowness instead of time */
61        TSyBoolean quiet;                    /* don't complain on wrong distance */
62
63        /* executable code */
64
65        pa_init( argc, argv );
66        if  (pa_pnumber() != 3)  {
67                fprintf( stderr, "Usage: %s <phase> <distance> <depth>\n",
68                        pa_progname() );
69                fprintf( stderr, "  Options:   -s   compute slowness instead of time\n" );
70                fprintf( stderr, "             -q   be quiet on errors\n" );
71                return 1;
72        } /*endif*/
73
74        GpReadParfile();
75
76        status = cBcNoError;
77
78        env = (char *)getenv( "SH_INPUTS" );
79        if  (env == NULL)  {
80                fprintf( stderr, "%s: environment SH_INPUTS not set\n", pa_progname() );
81                return 1;
82        } /*endif*/
83        strcpy( tablepath, env );
84        strcat( tablepath, "/" );
85        pt_settabledir( tablepath, &status );
86        if  (SySevere(&status))  err_writemsg( status, "", TRUE );
87
88        /* get command line parameters */
89        strcpy( phase, pa_pvalue(1) );
90        sscanf( pa_pvalue(2), "%f", &distance );
91        sscanf( pa_pvalue(3), "%f", &depth );
92        compute_slowness = pa_qspecified( "-s" );
93        quiet = pa_qspecified( "-q" );
94
95        if  (compute_slowness)  {
96                ttime = pt_slowness( phase, distance, depth, &status );
97        } else {
98                ttime = pt_travel( phase, distance, depth, &status );
99        } /*endif*/
100        if  (SySevere(&status))  {
101                ttime = 0.0;
102                if  (!quiet)
103                        err_writemsg( status, phase, FALSE );
104        } /*endif*/
105        printf( "%7.2f\n", ttime );
106
107        return 0;
108
109} /* end of main */
Note: See TracBrowser for help on using the repository browser.