-
Notifications
You must be signed in to change notification settings - Fork 94
/
CMTSOLUTION_to_AkiRichards.c
74 lines (63 loc) · 2.27 KB
/
CMTSOLUTION_to_AkiRichards.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*---------------------------------------------------------------------------
*
* Copyright (c) 2000-2004 by Onur TAN
* See COPYING file for copying and redistribution conditions.
*
* 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; version 2 of the License.
*
* 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.
*
* Contact info: Onur TAN,
* Istanbul Technical University, Faculty of Mines
* Department of Geophysics, Maslak, Istanbul-TURKEY
* www.geop.itu.edu.tr/~onur
* tano@itu.edu.tr
*--------------------------------------------------------------------------*/
/* cmt2aki.c : Converts Harvard-CMT moment moment tensor elements to Aki&Richard 1980 convention
by Onur TAN
ITU, Dept. of Geophysics, Istanbul, Turkey,10Jan2004
*/
// Modified by Dimitri Komatitsch, University of Pau, France, September 2007
/* Harvard CMTSOLUTION format is for instance
Mrr: -7.600000e+27
Mtt: 7.700000e+27
Mpp: -2.000000e+26
Mrt: -2.500000e+28
Mrp: 4.000000e+26
Mtp: -2.500000e+27
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main ( int argc, char* argv[] )
{
float Mrr, Mtt, Mpp, Mrt, Mrp, Mtp;
float Mxx, Myy, Mzz, Mxy, Mxz, Myz;
if ( argc != 7 ) {
printf("\nHRV-CMT - Aki&Richards1980 Moment Tensor Element Converter (by Onur TAN)\n");
printf("Usage : cmt2aki Mrr Mtt Mpp Mrt Mrp Mtp\n") ;
printf("Input Harvard CMTSOLUTION: Mrr Mtt Mpp Mrt Mrp Mtp\n") ;
printf("Output Aki&Richards1980: Mxx Myy Mzz Mxy Mxz Myz \n\n");
exit(1);
}
Mrr = atof ( argv[1] );
Mtt = atof ( argv[2] );
Mpp = atof ( argv[3] );
Mrt = atof ( argv[4] );
Mrp = atof ( argv[5] );
Mtp = atof ( argv[6] );
Mxx = Mtt ;
Myy = Mpp ;
Mzz = Mrr ;
Mxy = Mtp * -1. ;
Mxz = Mrt ;
Myz = Mrp * -1. ;
printf("Output Aki&Richards1980: Mxx Myy Mzz Mxy Mxz Myz \n");
printf("%9.5f %9.5f %9.5f %9.5f %9.5f %9.5f\n",Mxx, Myy, Mzz, Mxy, Mxz, Myz);
}