/
velesm.c
24945 lines (21948 loc) · 675 KB
/
velesm.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* velestc2.f -- translated by f2c (version 20181026).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
/* Common Block Declarations */
struct {
integer nvar, nvareff, kvar, nsta, ksta, legs, lip, neqs, nshot, nsinv,
nshcor, nshfix, icount;
} dimen_;
#define dimen_1 dimen_
struct {
real zmin, zmininput;
integer ittmax;
real delmin, veladj, swtfac, xythet;
integer invertratio, iresolcalc;
real zadj, vthet, othet, zthet, stathet, rmsmin, dmax__;
integer ifixsolution;
} param_;
#define param_1 param_
struct {
integer icnvout, istaout, ismpout, irayout, idrvout, ialeout, idspout,
irflout, irfrout, iresout;
} outputfiles_;
#define outputfiles_1 outputfiles_
struct {
real zshift;
} corr_;
#define corr_1 corr_
struct {
integer icoordsystem, itrial;
real ztrial;
integer ised, isingle, itopo, iturbo, lowveloclay;
logical single_turbo__;
integer ielev[650], iuseelev, iusestacorr;
} coordsyst_;
#define coordsyst_1 coordsyst_
struct {
integer nmod, nsp, nltot, nplay[100], laysum[100];
} modela_;
#define modela_1 modela_
struct {
real v[100], vsq[100], h__[100], thk[100];
integer jl;
real tkj, delta;
} layer_;
#define layer_1 layer_
struct {
real vp[200] /* was [2][100] */, hp[200] /* was [2][100] */,
vdamp[200] /* was [2][100] */, thkp[200] /* was [2][100] */,
vpvs;
integer ireflector, lmax;
char reflchar[1];
} layvel_;
#define layvel_1 layvel_
struct {
real ptcor[650], stcor[650], d__[11700000] /* was [650][3][6000] */;
integer model[1300];
real x[1950] /* was [650][3] */;
integer map1[650], map2[650];
} statn_;
#define statn_1 statn_
struct {
real xla[650], xlo[650];
} stltln_;
#define stltln_1 stltln_
struct {
real pt[3900000] /* was [650][6000] */;
integer kpwt[3900000] /* was [650][6000] */, istm[3900000] /*
was [650][6000] */;
real w[3900000] /* was [650][6000] */;
integer iphase[3900000] /* was [650][6000] */;
real sphase[3900000] /* was [650][6000] */;
integer knobs[6000];
real depthsofinput[6000], tcalc[650];
integer iain[650], nobswithw0;
real amx[650], prx[650];
integer idelta[650];
char prmk[1300] /* was [650][2] */;
integer nactualsta[650], nstaeff;
} obb_;
#define obb_1 obb_
struct {
real tctime[3900000] /* was [650][6000] */;
} extra_;
#define extra_1 extra_
struct {
char smn[15600000] /* was [650][6000] */, stn[2600], blank[4], blank0[4];
} charc_;
#define charc_1 charc_
struct {
integer iyr[6000], imo[6000], iday[6000], ihr[6000], imin[6000];
real e[24000] /* was [4][6000] */, emag[6000];
integer ifx[6000];
real xmagni[650];
integer nmag;
real xmagnitude, sdxmagnitude;
char regionname[32];
integer nreg, isconstrain[3], iconstrain[6000];
} event_;
#define event_1 event_
struct {
integer igap[6000];
} gap_;
#define gap_1 gap_
struct {
real rht[49598], res[3900000] /* was [650][6000] */, rms[6000], b[
49598], s[49598], avres[6000], steplen;
char smpline[80];
} a4_;
#define a4_1 a4_
struct {
real scale[7];
} fix1_;
#define fix1_1 fix1_
struct {
real g[615015200];
} gmatrix_;
#define gmatrix_1 gmatrix_
struct {
real gcopy[2975880] /* was [60][49598] */;
} gsave_;
#define gsave_1 gsave_
struct {
real dtdv[100], dtdr[3];
} dttx_;
#define dttx_1 dttx_
struct {
real gg2[720] /* was [180][4] */, ggt[720] /* was [4][180] */,
ggg[720] /* was [4][180] */, gtg[16] /* was [4][4] */,
ggti[16] /* was [4][4] */, drm[32400] /* was [180][180] */;
} dataresol_;
#define dataresol_1 dataresol_
struct {
real rc[16] /* was [4][4] */, rs[16] /* was [4][4] */, sv[4], covc[
16] /* was [4][4] */, covs[4], ale[6000], r3[9] /* was [3][3]
*/, gg[10000] /* was [100][100] */;
} goodness_;
#define goodness_1 goodness_
struct {
integer irefrlayer[100], ihypoclayer[100], noheadwave;
real refraylen[100], avhraylen, avvraylen, hitlay[300] /* was [100][
3] */;
integer irefllayer[100];
real sterr, direrr, refrerr, reflerr;
} hitl_;
#define hitl_1 hitl_
struct {
real avrefrres, avotheres, avreflres, abrefrres, abotheres, abreflres;
integer nrrefrres, nrotheres, nrreflres;
real stnazires[5200] /* was [650][8] */;
} residuals_;
#define residuals_1 residuals_
struct {
integer ibackups;
real davar1, xmsqrs1;
} a3_;
#define a3_1 a3_
struct {
real spread;
} quality_;
#define quality_1 quality_
struct {
char modelfilename[80], stationfilename[80], seismofilename[80],
scratchfilename[80];
} files_;
#define files_1 files_
struct {
char phasefile[80], shotfile[80], topo1file[80], topo2file[80],
regnamfile[80], regkoordfile[80];
} infiles_;
#define infiles_1 infiles_
struct {
char velfile[80], cnvfile[80], rayfile[80], outfile[80], smpfile[80],
stafile[80], drvfile[80], alefile[80], dsprfile[80], rflfile[80],
rfrfile[80], resfile[80];
} outfiles_;
#define outfiles_1 outfiles_
struct {
char fm[80];
integer iabort, nitt;
char headerline[240];
} form_;
#define form_1 form_
struct {
real aa, bb, bc, olat, olon;
} corect_;
#define corect_1 corect_
struct {
real sint, cost, rotate;
} coords_;
#define coords_1 coords_
struct {
doublereal rearth, ellip, rlatc, rad;
} origi_;
#define origi_1 origi_
struct {
real olat, olon;
doublereal rearth, ellip, rlatc, rad;
real aa, bb, bc, sint, cost, rotate;
integer icoordsystem;
} geo_coorsystem__;
#define geo_coorsystem__1 geo_coorsystem__
struct {
integer indfe[730], lt50[111], lt25[421];
char irname[24300];
real xnrlon[14400];
} regioncom_;
#define regioncom_1 regioncom_
/* Table of constant values */
static integer c__1 = 1;
static integer c__9 = 9;
static integer c__0 = 0;
static integer c__2 = 2;
static integer c__100 = 100;
static integer c__3 = 3;
static integer c__180 = 180;
static integer c__4 = 4;
static integer c__6000 = 6000;
static integer c__50 = 50;
static integer c__650 = 650;
static integer c_n1 = -1;
static real c_b1799 = 360.f;
static real c_b2408 = 1.f;
static complex c_b3026 = {1.f,0.f};
static real c_b3049 = -1.f;
/* Subroutine */ int velest_(char *bo, ftnlen bo_len)
{
/* Format strings */
static char fmt_59[] = "(\002# \002,i3,\002 rms value: \002,10f5.2)";
/* System generated locals */
integer i__1, i__2;
real r__1;
icilist ici__1;
olist o__1;
cllist cl__1;
alist al__1;
/* Builtin functions */
integer s_wsfi(icilist *), do_fio(integer *, char *, ftnlen), e_wsfi(void)
, s_wsfe(cilist *), e_wsfe(void), s_wsle(cilist *), e_wsle(void),
s_wsli(icilist *), do_lio(integer *, integer *, char *, ftnlen),
e_wsli(void), f_open(olist *), f_clos(cllist *);
/* Subroutine */ int s_stop(char *, ftnlen);
integer f_rew(alist *);
/* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
/* Local variables */
static integer iresflag;
extern /* Subroutine */ int cputimer_(real *), matrtran_(real *, integer *
, integer *, real *);
static real cpmintot;
extern /* Subroutine */ int matrmult_(real *, integer *, integer *, real *
, integer *, integer *, real *, integer *, integer *);
static integer i__, j, k, l;
static real d1, d2;
extern /* Subroutine */ int timeclear_(integer *, integer *, integer *,
integer *, integer *, real *, integer *), magnitude_(integer *,
integer *);
static integer istopflag;
extern /* Subroutine */ int inputdata_(integer *, char *, ftnlen),
rmsdatvar_(char *, ftnlen), openerror_(char *, char *, char *,
ftnlen, ftnlen, ftnlen);
static integer ii;
extern /* Subroutine */ int traveltime_(integer *, integer *, integer *,
char *, ftnlen), resolcovar_(real *, char *, ftnlen), inputparam_(
char *, ftnlen), sdc_(real *, real *, real *, real *, integer *),
statislout_(char *, ftnlen);
static integer ier;
extern /* Subroutine */ int nittoutput_(real *, char *, ftnlen),
adjustmodel_(real *, char *, ftnlen);
static integer i4enabletest;
static real damp, xlat, xlon;
extern /* Subroutine */ int finalstaresi_(char *, ftnlen);
static char cline[80];
extern /* Subroutine */ int setupmatrixg_(integer *, integer *), dampg_(
void);
static char ctime[20];
static real gtg_v__[16];
static integer itime, nittc;
extern /* Subroutine */ int checksolution_(integer *, logical *, char *,
ftnlen), finalhypocout_(char *, ftnlen), backup_(char *, ftnlen),
ludecp_(real *, real *, integer *, real *, real *, integer *);
static real ggti_v__[16];
extern integer juliam_(integer *, integer *, integer *, integer *,
integer *);
static real cpusec;
static logical better;
extern /* Subroutine */ int region_(integer *, real *, real *, char *,
integer *, char *, char *, ftnlen, ftnlen, ftnlen),
statisticsout_(char *, ftnlen), luelmp_(real *, real *, integer *,
real *), storeg_(integer *, integer *), fixunt_(real *, integer *
, integer *, integer *, integer *, real *, real *, integer *,
integer *, integer *), setunt_(integer *, integer *, integer *,
integer *, real *, real *, real *, real *, real *, real *),
steplengthcalc_(char *, ftnlen), steplengthdamp_(real *),
actualstations_(char *, ftnlen), adlineb_(char *, ftnlen),
singularvalues_(integer *, char *, ftnlen), detnofunknowns_(char *
, ftnlen);
static integer iminold;
extern /* Subroutine */ int matrinv_(integer *, real *, real *);
/* Fortran I/O blocks */
static icilist io___2 = { 0, form_1.headerline, 0, "(1x,'>>> Start of pr"
"ogram VELEST at ',a20, ' <<<')", 80, 1 };
static cilist io___3 = { 0, 6, 0, "(1x,'>>> Start of program VELEST at '"
",a20, ' <<<')", 0 };
static cilist io___4 = { 0, 6, 0, 0, 0 };
static icilist io___5 = { 0, form_1.headerline+80, 0, 0, 80, 1 };
static icilist io___6 = { 0, form_1.headerline+160, 0, 0, 80, 1 };
static cilist io___10 = { 0, 6, 0, "(x,'>>> End of program VELEST at '"
",a20, ' <<<',' [ CPU-sec : ',f7.1,']')", 0 };
static cilist io___15 = { 0, 6, 0, 0, 0 };
static cilist io___16 = { 0, 6, 0, "(' knobs(i)=',i4,' nobswithw0=',i4, "
" ' nvar=',i2)", 0 };
static cilist io___17 = { 0, 6, 0, 0, 0 };
static cilist io___19 = { 0, 6, 0, 0, 0 };
static cilist io___21 = { 0, 6, 0, "(1x,' finished Iteration #',i3,' at"
"', 3x,a20,5x,'CPU-sec = ',f7.1)", 0 };
static cilist io___26 = { 0, 6, 0, "(' WARNING: error in ludecp ier="
"',i5)", 0 };
static cilist io___28 = { 0, 6, 0, 0, 0 };
static cilist io___29 = { 0, 6, 0, 0, 0 };
static cilist io___30 = { 0, 6, 0, "(1x,' finished Iteration #',i3,' at"
"', 3x,a20,5x,'CPU-sec = ',f7.1)", 0 };
static cilist io___31 = { 0, 6, 0, "(' WARNING: error in ludecp ier="
"',i5)", 0 };
static cilist io___36 = { 0, 75, 0, "(2x,'ALE',3f10.4,' .1')", 0 };
static cilist io___37 = { 0, 76, 0, "(2x,'DSP',3f10.4,' .1')", 0 };
static cilist io___41 = { 0, 6, 0, "(1x,'>>> End of program VELEST at "
"',a20, ' <<<',' [ CPU-sec : ',f7.1,']')", 0 };
static cilist io___42 = { 0, 6, 0, "(1x,'GAP = ',i3,' NITT = ',i2, "
" ' D-Spread =',f5.2)", 0 };
static cilist io___43 = { 0, 6, 0, 0, 0 };
/* seisan changes: */
/* delaz renamed to delaz_velest, does not seem to be used */
/* version 3.3 E.Kissling, Institute of Geophysics, ETH Zurich */
/* 21. August 1998 */
/* this version is running as: */
/* - velest.f for SUN-Unix */
/* - velestUNIXhp.f for HP-Unix */
/* the program is based on the version 3.0 HRM,UK,EK,and W.Ellsworth */
/* of 28.oct93, and on version 3.1 EK 21April95. */
/* (see PhD thesis by U.Kradolfer 1989, and by H.R. Maurer 1993 */
/* at Institute of Gephysics, ETH Zurich, Switzerland) */
/* ********************************************************************* */
/* This version of VELEST can be used to simultaneously invert a large */
/* number of earthquake travel time data for hypocentral and velocity */
/* model (P and S velocities) parameters. Alternatively (isingle=1) it */
/* may also be used as a single event location program. */
/* This version may read from input data file in the converted (*.cnv) */
/* format (ised=0), in a velest-archive type (*arcvel) format (ised=1), */
/* and in the new SED (Swiss Seismological Service) format (ised=2). */
/* VELEST optionally writes output data files in converted and summary */
/* card format and in singleevent mode writes a location file for */
/* archive purposes (print output file). */
/* EK addition to 3.0: */
/* 9.nov93 version 3.01 added subr. inputarcvel (ised=1) */
/* 10.nov93 modified subr. inputparam for model file */
/* 10.nov93 modified " " for print ouput in */
/* single event location mode */
/* 15.nov93 modified in subr. traveltime no calls to */
/* routines rejectobs and reviveobs */
/* 16. nov93 modified in subr. gapcalc to avoid division */
/* zero by zero for call to atan2 */
/* 23. nov93 modified subr inputcnv to recognize end of file */
/* 28. nov93 testing singleevent and multievent mode and */
/* corrections for print output in subr. inputparam */
/* 30. nov93 corrected error in inputparam for isingle and */
/* no of eqs .ne.0: neqs and legs MUST be one */
/* for isingle=1 */
/* implemented dez 1994 EK: read rotate angle of coordinate system */
/* as in earlier versions */
/* subr. inputparam read neqs,nshots,rotate */
/* also dez94 EK: if ifx(i)=0 normally */
/* =1 to inhibit adjustement of (rotated) */
/* y coordinate (see subr. MATRIX) */
/* (i.e. dtdr(2)=0.0 if ifx(i)=1) */
/* EK version 3.3 as of 21August1998: implemented and improved display of */
/* P and S phase usage and station delays */
/* EK still to be implemented: flat Earth approximation */
/* EK */
/* *vel.out file for STATIS written in subr. STATISLOUT */
/* ------------------------------------------------------------------------------ */
/* -----START OF SOURCE-CODE OF PROGRAM VELEST (MAIN PROGRAM) ------------------- */
/* ------------------------------------------------------------------------------ */
/* file VELESTCOMMON.FOR Version ETH-19SEP91 */
/* ****************************************** */
/* common-blocks of program VELEST * by Urs Kradolfer */
/* ****************************************** */
/* ----------------------------------------------------------------------------- */
/* IN THIS SECTION YOU CAN CHANGE THE ARRAY-SIZES: */
/* parameter(ieq=800) ! number of earthquakes (Simultaneous mode) */
/* s parameter(ieq=1) ! number of earthquakes (single event mode ONLY) */
/* number of earthquakes (Simultaneous mod */
/* ----------------------------------------------------------------------------- */
/* max. number of shots (for simultaneous m */
/* max. number of velocity models */
/* max. number of layers per velocity mode */
/* max. number of stations in stationlist */
/* max. number of observations per ev */
/* Control-parameters: */
/* Model-parameters: */
/* Station-parameters: */
/* lmax added 5.4.91 */
/* to be verified !!! (hrm */
/* ccc character*1 cns,cew */
/* 89 character*4 smn,stn,blank,blank0 */
/* 89 data blank,blank0 /' ','0 '/ */
/* Event-parameters: */
/* cc & , effdeltaz(ieq) */
/* 'Normal-equations-parameters': */
/* max. ieq events */
/* Statistics-parameters: */
/* Files: */
/* Various other parameters: */
/* ************** end of VELESTCOMMON.FOR ******************************* */
/* integer errx,erry,errz */
/* -------------------------------------------- */
/* reset internal cpu-timer: */
/* call CPUTIMER(cpusec) */
/* test to AVOID runs of velest with compilation-option NOi4 */
i4enabletest = 1234567890;
/* end of this 'mini-test' */
/* save report of this VELEST-run (write it ev. to file16 in subr. INPUTPARAM */
/* call DATETIMEX(ctime) ! get date&time from system */
s_wsfi(&io___2);
do_fio(&c__1, "--", (ftnlen)2);
e_wsfi();
s_wsfe(&io___3);
do_fio(&c__1, "--", (ftnlen)2);
e_wsfe();
s_wsle(&io___4);
e_wsle();
s_wsli(&io___5);
do_lio(&c__9, &c__1, "::::::::::::::::::::::::::::::::::::::", (ftnlen)38)
;
e_wsli();
s_wsli(&io___6);
do_lio(&c__9, &c__1, " V E L E S T - Version : January 3, 1995", (ftnlen)
41);
e_wsli();
/* reset... */
form_1.nitt = 0;
/* number of iterations made */
nittc = 0;
/* " " for wich CPU is calculated */
dimen_1.nvar = 0;
/* number of unknowns to solve for */
istopflag = 0;
/* input control-parameters, model and stations */
inputparam_(bo, bo_len);
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "~~~ input parameters read.", (ftnlen)26);
e_wsli();
}
adlineb_(bo, bo_len);
/* if a file containing all the raypaths (ray-points) of all events */
/* is desired, open the file (unit=13): */
if (outputfiles_1.irayout == 1) {
o__1.oerr = 0;
o__1.ounit = 13;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.rayfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
if (outputfiles_1.idrvout == 1) {
o__1.oerr = 0;
o__1.ounit = 21;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.drvfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* file07 - final hypocenters and travel times ( *.CNV format, for next it.) */
/* file11 - summary cards of final hypocenters (for plotting) */
if (outputfiles_1.icnvout == 1) {
o__1.oerr = 0;
o__1.ounit = 7;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.cnvfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
if (outputfiles_1.ismpout == 1) {
o__1.oerr = 0;
o__1.ounit = 11;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.smpfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
if (coordsyst_1.isingle != 0) {
o__1.oerr = 0;
o__1.ounit = 2;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.velfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* statisL-compatible out */
if (outputfiles_1.ialeout == 1) {
o__1.oerr = 0;
o__1.ounit = 75;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.alefile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* x,y, ALE of all events */
if (outputfiles_1.idspout == 1) {
o__1.oerr = 0;
o__1.ounit = 76;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.dsprfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* x,y, DSPR of all event */
if (outputfiles_1.irflout == 1) {
o__1.oerr = 0;
o__1.ounit = 77;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.rflfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* x,y, resid. of reflect */
if (outputfiles_1.irfrout == 1) {
o__1.oerr = 0;
o__1.ounit = 78;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.rfrfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* x,y, resid. of refract */
if (outputfiles_1.iresout == 1) {
o__1.oerr = 0;
o__1.ounit = 79;
o__1.ofnmlen = 80;
o__1.ofnm = outfiles_1.resfile;
o__1.orl = 0;
o__1.osta = "unknown";
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);
}
/* dist, residual of ray */
k = 0;
/* cc call getsymbol('zirvax') ! not used in this version */
L1080:
/* START OF THE LOOP OVER O N E E V E N T FOR SINGL */
if (k == -1) {
/* means: end of input-file detected !!! */
cl__1.cerr = 0;
cl__1.cunit = 2;
cl__1.csta = 0;
f_clos(&cl__1);
/* ek */
/* no smp-file for single_event_mode since smp only in SED special format */
/* use *.cnv file for plotting etc. */
/* ek */
if (outputfiles_1.ismpout == 1 && coordsyst_1.isingle == 1) {
cl__1.cerr = 0;
cl__1.cunit = 11;
cl__1.csta = 0;
f_clos(&cl__1);
}
/* call DATETIMEX(ctime) ! get date&time from system */
/* call CPUTIMER(cpusec) */
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = "(x,'>>> End of program VELEST at ',a20, "
" ' <<<',' [ CPU-sec : ',f7.1,']')";
s_wsfi(&ici__1);
do_fio(&c__1, "------", (ftnlen)6);
do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
e_wsfi();
adlineb_(bo, bo_len);
}
s_wsfe(&io___10);
do_fio(&c__1, "------", (ftnlen)6);
do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
e_wsfe();
s_stop("...end...(VELEST was running in SINGLE-EVENT-OPTION)", (
ftnlen)52);
}
/* ---------------------------------------------------------------------------- */
/* do forward problem first: */
form_1.nitt = 0;
/* do scaling of damping-factors (and determine ICOUNT): */
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "~~~ set units for first iteration ...", (ftnlen)
37);
e_wsli();
}
adlineb_(bo, bo_len);
/* 1 --> so icount will not be 0 !!! */
setunt_(&c__1, ¶m_1.invertratio, &dimen_1.nsinv, &dimen_1.icount, &
param_1.xythet, ¶m_1.stathet, ¶m_1.othet, ¶m_1.vthet,
¶m_1.zthet, fix1_1.scale);
/* determine nr of unknowns NVAR & nr of equations LIP to be solved : */
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "~~~ determine number of unknowns ...", (ftnlen)
36);
e_wsli();
}
adlineb_(bo, bo_len);
detnofunknowns_(bo, bo_len);
/* reset G-matrix and RHT-vector : */
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "~~~ reset G and RHT ...", (ftnlen)23);
e_wsli();
}
adlineb_(bo, bo_len);
i__1 = dimen_1.kvar;
for (j = 1; j <= i__1; ++j) {
gmatrix_1.g[j - 1] = 0.f;
}
i__1 = dimen_1.nvar;
for (k = 1; k <= i__1; ++k) {
a4_1.rht[k - 1] = 0.f;
}
/* for each event do: reset avres&rms, input of the data, */
/* raytracing and accumulate normal equations */
/* ( = setup of matrix G and vector RHT ) : */
if (outputfiles_1.irayout == 1) {
al__1.aerr = 0;
al__1.aunit = 13;
f_rew(&al__1);
}
/* rewind file (if desired) with raypat */
if (outputfiles_1.idrvout == 1) {
al__1.aerr = 0;
al__1.aunit = 21;
f_rew(&al__1);
}
/* rewind file (if desired) with raypat */
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "~~~ input data, raytracing, setup G ...", (
ftnlen)39);
e_wsli();
}
adlineb_(bo, bo_len);
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = "(/////)";
s_wsfi(&ici__1);
e_wsfi();
adlineb_(bo, bo_len);
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = "(' I N P U T - D A T A ',/)";
s_wsfi(&ici__1);
e_wsfi();
if (modela_1.nsp == 2) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = "(1x,' eq origin-time latitude longitude '"
", 'depth x y z mag ifxOBStot o"
"bsP obsS')";
s_wsfi(&ici__1);
e_wsfi();
adlineb_(bo, bo_len);
} else {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = "(1x,' eq origin-time latitude longitude '"
", 'depth x y z mag if"
"xOBS')";
s_wsfi(&ici__1);
e_wsfi();
adlineb_(bo, bo_len);
}
}
i__1 = dimen_1.legs;
for (i__ = 1; i__ <= i__1; ++i__) {
a4_1.avres[i__ - 1] = 0.f;
a4_1.rms[i__ - 1] = 0.f;
/* it's the starting: input trial hypocenter and phase-data */
inputdata_(&i__, bo, bo_len);
k = obb_1.knobs[i__ - 1];
if (k == -1) {
goto L1080;
/* means: end of input-file (data) detected */
}
/* for each arrival do raytracing, residual-calc. and setup G & RHT : */
i__2 = k;
for (l = 1; l <= i__2; ++l) {
traveltime_(&i__, &l, &iresflag, bo, bo_len);
setupmatrixg_(&i__, &l);
}
if (coordsyst_1.isingle != 0) {
if (obb_1.knobs[i__ - 1] - obb_1.nobswithw0 < dimen_1.nvar) {
form_1.iabort = 1;
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "knobs(i)-nobswithw0 < nvar !!!", (
ftnlen)30);
e_wsli();
adlineb_(bo, bo_len);
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = "(' knobs(i)=',i4,' nobswithw0=',i4, "
" ' nvar=',i2)";
s_wsfi(&ici__1);
do_fio(&c__1, (char *)&obb_1.knobs[i__ - 1], (ftnlen)
sizeof(integer));
do_fio(&c__1, (char *)&obb_1.nobswithw0, (ftnlen)sizeof(
integer));
do_fio(&c__1, (char *)&dimen_1.nvar, (ftnlen)sizeof(
integer));
e_wsfi();
ici__1.icierr = 0;
ici__1.icirnum = 1;
ici__1.icirlen = bo_len;
ici__1.iciunit = bo;
ici__1.icifmt = 0;
s_wsli(&ici__1);
do_lio(&c__9, &c__1, "Event cannot be located!!!", (
ftnlen)26);
e_wsli();
adlineb_(bo, bo_len);
}
s_wsle(&io___15);
do_lio(&c__9, &c__1, "knobs(i)-nobswithw0 < nvar !!!", (
ftnlen)30);
e_wsle();
s_wsfe(&io___16);
do_fio(&c__1, (char *)&obb_1.knobs[i__ - 1], (ftnlen)sizeof(
integer));
do_fio(&c__1, (char *)&obb_1.nobswithw0, (ftnlen)sizeof(
integer));
do_fio(&c__1, (char *)&dimen_1.nvar, (ftnlen)sizeof(integer));
e_wsfe();
s_wsle(&io___17);
do_lio(&c__9, &c__1, "Event cannot be located!!!", (ftnlen)26)
;
e_wsle();
goto L98989;
}
if (! coordsyst_1.single_turbo__) {
ici__1.icierr = 0;
ici__1.icirnum = 1;