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

Revision 16, 3.1 KB checked in by marcus, 14 years ago (diff)

r1 | svn | 2007-12-13 11:10:29 +0100 (Do, 13 Dez 2007) | 2 lines

Initial import

  • 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
47
48
49int main( int argc, char *argv[] )
50{
51        /* local variables */
52        char     *env;                       /* pointer to environment */
53        char     tablepath[cBcFileLth+1];    /* name of table directory */
54        TSyStatus status;                    /* return status */
55        char     phase[cBcLineLth+1];        /* phase name */
56        float    distance;                   /* distance in deg */
57        float    depth;                      /* depth in km */
58        float    ttime;                      /* travel time in sec */
59        TSyBoolean compute_slowness;         /* compute slowness instead of time */
60        TSyBoolean quiet;                    /* don't complain on wrong distance */
61
62        /* executable code */
63
64        pa_init( argc, argv );
65        if  (pa_pnumber() != 3)  {
66                fprintf( stderr, "Usage: %s <phase> <distance> <depth>\n",
67                        pa_progname() );
68                fprintf( stderr, "  Options:   -s   compute slowness instead of time\n" );
69                fprintf( stderr, "             -q   be quiet on errors\n" );
70                return 1;
71        } /*endif*/
72
73        status = cBcNoError;
74
75        env = (char *)getenv( "SH_INPUTS" );
76        if  (env == NULL)  {
77                fprintf( stderr, "%s: environment SH_INPUTS not set\n", pa_progname() );
78                return 1;
79        } /*endif*/
80        strcpy( tablepath, env );
81        strcat( tablepath, "/" );
82        pt_settabledir( tablepath, &status );
83        if  (SySevere(&status))  err_writemsg( status, "", TRUE );
84
85        /* get command line parameters */
86        strcpy( phase, pa_pvalue(1) );
87        sscanf( pa_pvalue(2), "%f", &distance );
88        sscanf( pa_pvalue(3), "%f", &depth );
89        compute_slowness = pa_qspecified( "-s" );
90        quiet = pa_qspecified( "-q" );
91
92        if  (compute_slowness)  {
93                ttime = pt_slowness( phase, distance, depth, &status );
94        } else {
95                ttime = pt_travel( phase, distance, depth, &status );
96        } /*endif*/
97        if  (SySevere(&status))  {
98                ttime = 0.0;
99                if  (!quiet)
100                        err_writemsg( status, phase, FALSE );
101        } /*endif*/
102        printf( "%7.2f\n", ttime );
103
104        return 0;
105
106} /* end of main */
Note: See TracBrowser for help on using the repository browser.