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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
|
PROGRAM HTDP
**************************************************************
* NAME: HTDP (Horizontal Time-Dependent Positioning)
*
* WRITTEN BY: Richard Snay, Chris Pearson, Jarir Saleh,
* and Michael Dennis
*
* PURPOSE: Transform coordinates across time
* and between reference frames
*
**************************************************************
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
character HTDP_version*8
character Version_date*20
CHARACTER OPTION*1
character cont*5
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /VERSION/ HTDP_version
C You must change HTDP version and date here, if necessary
HTDP_version = '3.3.0'
Version_date = 'January 15, 2021'
*** Introduce variables for file id's
LUIN = 5
* interactive input
LUOUT = 6
* interactive output
I1 = 11
* input of velocity grid in GETVEL
* input of earthquake parameters in GETEQ
* input of blue-book BFILE in DLACE, VELOC, UPDATE and TRFPOS
* input of blue-book GFILE in UPDATE
I2 = 12
* output of predicted displacements in DLACE
* output of predicted velocities in VELOC
* output of updated blue-book BFILE in UPDATE
* output of updated blue-book GFILE in UPDATE
* output of updated coordinates in UPDATE
I3 = 13
* output of point-velocity records in VELOC
I4 = 14
* storage of reference latitude & longitude & region
I5 = 15
* storage of earthquake parameters
C OPEN(I5, FILE='TEMPQK' , ACCESS = 'DIRECT', RECL = 72,
C 1 FORM='UNFORMATTED')
I6 = 16
* output of transformed blue-book BFILE in TRFPOS
*** Obtain parameters defining crustal motion model
CALL MODEL
*** Initialize transformation parameters between reference frames
CALL SETTP
*** Initialize conversion table between reference frame identifiers
CALL SETRF
WRITE(LUOUT,5) HTDP_version, Version_date
5 FORMAT(
1 '********************************************************'/
1 ' HTDP (Horizontal Time-Dependent Positioning) '/
1 ' SOFTWARE VERSION: ', a8 /
1 ' VERSION DATE: ', a20 /)
WRITE(LUOUT,501)
501 FORMAT(
1 ' AUTHORS: Richard Snay, Chris Pearson, Jarir Saleh, '/
1 ' and Michael Dennis '//
1 ' Web: https://geodesy.noaa.gov/TOOLS/Htdp/Htdp.shtml '/
1 ' Email: ngs.cors.htdp@noaa.gov '/
1 '********************************************************'/)
WRITE(LUOUT,10)
10 FORMAT(
1 ' This software incorporates numerical models that',/
3 ' characterize continuous crustal motion as well as ',/
3 ' the episodic motion associated with earthquakes.'/)
WRITE(LUOUT,11)
11 FORMAT(
5 ' The User Guide contains additional information and a set'/
5 ' of exercises to familiarize users with the software.'/
5 ' Hit ENTER or RETURN to continue. ')
read(luin, '(a5)',err=51,iostat=ios) cont
if (ios /= 0) goto 51
25 WRITE(LUOUT,26)
26 FORMAT('********************************************************'/
1 ' MAIN MENU:',/
6 ' 0... Exit software.',/
7 ' 1... Estimate horizontal displacements between two dates.'/
8 ' 2... Estimate horizontal velocities.'/
9 ' 3... Transform observations to a specified reference '
& ,'frame and/or date.'/
& ' 4... Transform positions between reference frames '
& ,'and/or dates.'/
& ' 5... Transform velocities between reference frames. ')
30 READ(LUIN,35,err=52,iostat=ios) OPTION
if (ios /= 0) goto 52
35 FORMAT(A1)
IF(OPTION .EQ. '0') THEN
GO TO 50
ELSEIF(OPTION .EQ. '1') THEN
CALL DPLACE
ELSEIF(OPTION .EQ. '2') THEN
CALL VELOC
ELSEIF(OPTION .EQ. '3') THEN
CALL UPDATE(HTDP_version)
elseif(option .eq. '4') then
call TRFPOS
elseif(option .eq. '5') then
call TRFVEL
ELSE
WRITE(LUOUT,40)
40 FORMAT(' Improper entry--select again ')
GO TO 30
ENDIF
GO TO 25
50 CONTINUE
stop
C CLOSE(I5, STATUS = 'DELETE')
51 write (*,'(/)')
write (*,*) 'You did not hit enter : ios = ',ios
write (*,*) "ABNORMAL TERMINATION"
STOP
52 write (*,'(/)')
write (*,*) 'Problem with reading OPTION: ios = ',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
STOP
END
*****************************************************************************
SUBROUTINE MODEL
*** Obtain parameters defining crustal motion model
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /TIMREF/ ITREF
A = 6.378137D06
F = 1.D0 / 298.257222101D0
E2 = 0.6694380022903146D-2
AF = A / (1.D0 -F)
EPS = F*(2.D0 - F) / ((1.D0 -F)**2)
PI = 4.D0 * DATAN(1.D0)
RHOSEC = (180.D0 * 3600.D0) / PI
TWOPI = PI + PI
C*** Set default reference epoch to Jan. 1, 2010
IYRREF = 2010
IMOREF = 1
IDYREF = 1
CALL IYMDMJ (IYRREF, IMOREF, IDYREF, MJD)
ITREF = MJD * 24 * 60
CALL GETBDY
RETURN
END
*******************************************************************
SUBROUTINE GETBDY
*** Obtain coordinates for vertices that form the polygons
*** that correspond to the boundaries for the regions.
*** Region 1 is the San Andreas fault in central California
*** Region 2 is southern California
*** Region 3 is northern California
*** Region 4 is the Pacific Northwest
*** Region 5 is western CONUS
*** Region 6 is CONUS
*** Region 7 is St. Elias, Alaska
*** Region 8 is south-central Alaska
*** Region 9 is southeast Alaska
*** Region 10 is All Mainland Alaska
* Placeholder regions inserted to make compatible with new initbd.f
* that contains tectonic plates added in December 2020 (v3.3.0).
*** Region 11 is a placeholder region
*** Region 12 is a placeholder region
*** Region 13 is a placeholder region
*** Region 14 is the North America plate
*** Region 15 is the Caribbean plate
*** Region 16 is the Pacific plate
*** Region 17 is the Juan de Fuca plate
*** Region 18 is the Cocos plate
*** Region 19 is the Mariana plate
*** Region 20 is the Philippine Sea plate
* Plates added in December 2020 (v3.3.0).
*** Region 21 is the South America plate
*** Region 22 is the Nazca plate
*** Region 23 is the Panama plate
*** Region 24 is the North Andes plate
*** Region 25 is the Africa plate
*** Region 26 is the Eurasia plate
*** Region 27 is the Rivera plate
*** Region 28 is the Galapagos plate
*** Region 29 is the Tonga plate
*** Region 30 is the Niuafo'ou plate
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NMREGN = 30)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /BNDRY/ X(7000), Y(7000), NPOINT(40)
IEND = NPOINT(NMREGN + 1) - 1
DO 10 J = 1, IEND
X(J) = (X(J) * 3600.D0)/RHOSEC
Y(J) = (Y(J) * 3600.D0)/RHOSEC
10 CONTINUE
RETURN
END
*******************************************************************
SUBROUTINE GETREG(X0,YKEEP,JREGN)
*** Determine the region containing a given point.
IMPLICIT DOUBLE PRECISION(A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NMREGN = 30)
COMMON /BNDRY/ X(7000), Y(7000), NPOINT(40)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /CONST/ A, F, E2, EPS, AF, PI, TWOPI, RHOSEC
Y0 = TWOPI - YKEEP
IF (Y0 .lt. 0.d0) Y0 = Y0 + TWOPI
IR = 0
1 IR = IR + 1
IF(IR .GT. NMREGN) THEN
JREGN = 0
RETURN
ENDIF
IBEGIN = NPOINT(IR)
NUMVER = NPOINT(IR + 1) - IBEGIN
CALL POLYIN(X0,Y0,X(IBEGIN),Y(IBEGIN), NUMVER, NTEST)
IF(NTEST .EQ. 0) GO TO 1
JREGN = IR
RETURN
END
********************************************************
SUBROUTINE POLYIN (X0,Y0,X,Y,N,NPC)
* This version of subroutine is from TRANS4D v0.3.1 and replaces
* version in HTDP v3.2.9.
C SUBROUTINE TO DETERMINE IF A POINT AT (X0,Y0) IS INSIDE OR
C OUTSIDE OF A CLOSED FIGURE DESCRIBED BY A SEQUENCE OF CONNECTED
C STRAIGHT LINE SEGMENTS WITH VERTICES AT X, Y.
C
C INPUT -
C X0, Y0 COORDINATES OF A POINT TO BE TESTED
C Y0 corresponds to longitude and must be a number
C between 0.0 and 2*PI
C X, Y ARRAYS CONTAINING THE VERTICES, IN ORDER, OF A
C CLOSED FIGURE DESCRIBED BY STRAIGHT LINE SEGMNENTS.
C FOR EACH 'I', THE STRAIGHT LINE FROM (XI),Y(I)) TO
C TO (X(I+1),Y(I+1)), IS AN EDGE OF THE FIGURE.
C N DIMENSION OF X AND Y, NUMBER OF VERTICES, AND NUMBER
C OF STRAIGHT LINE SEGMENTS IN FIGURE.
C OUTPUT -
C NPC NPC=0 WHEN X0,Y0 IS OUTSIDE OF FIGURE DESCRIBED
C BY X,Y
C NPC=1 WHEN X0,Y0 IS INSIDE FIGURE
C NPC=2 WHEN X0,Y0 IS ON BORDER OF FIGURE
C METHOD -
C A COUNT IS MADE OF THE NUMBER OF TIMES THE LINE FROM (X0,Y0) TO
C (X0,+ INFINITY) CROSSES THE BORDER OF THE FIGURE. IF THE COUNT
C IS ODD, THE POINT IS INSIDE; IF THE COUNT IS EVEN THE POINT
C IS OUTSIDE.
C LIMITATIONS -
C NONE. THE PROGRAM LOGIC IS VALID FOR ALL CLOSED FIGURES,
C NO MATTER HOW COMPLEX.
C ACCURACY -
C MAINTAINS FULL ACCURACY OF INPUT COORDINATES.
C
IMPLICIT INTEGER*4 (I-N)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
DIMENSION X(N),Y(N)
IS=0
NPC=0
C
C FIND STARTING POINT WHERE X(I).NE.X0
IP=0
10 IP=IP+1
IF(X(IP)-X0) 15,12,16
12 IF(IP.LE.N) GO TO 10
WRITE(LUOUT,6001)
6001 FORMAT('0 POLYGON INPUT ERROR - ALL POINTS ON LINE X = X0')
STOP
15 IL=-1
GO TO 20
16 IL=1
20 XL=X(IP)
YL=Y(IP)
C
C SET UP SEARCH LOOP
C
IP1=IP+1
IPN=IP+N
DO 100 II=IP1,IPN
I=II
IF(I.GT.N) I=I-N
IF(IL) 30,50,40
30 IF(X(I)-X0) 90,32,34
32 IS=-1
GO TO 60
34 IL=1
GO TO 80
40 IF(X(I)-X0) 42,44,90
42 IL=-1
GO TO 80
44 IS=1
GO TO 60
50 IF(X(I)-X0) 52,55,54
52 IL=-1
IF(IS) 90,140,80
54 IL=1
IF(IS) 80,140,90
55 IF(Y(I)-Y0) 57,120,58
57 IF(YL-Y0) 90,120,120
58 IF(YL-Y0) 120,120,90
C
60 IL=0
IF(Y(I)-Y0) 90,120,90
80 IF(YL-Y0+(Y(I)-YL)*(X0-XL)/(X(I)-XL)) 90,120,85
85 NPC=NPC+1
90 XL=X(I)
YL=Y(I)
100 CONTINUE
NPC=MOD(NPC,2)
RETURN
120 NPC=2
RETURN
140 WRITE(LUOUT,6002)
6002 FORMAT('0 POLYGON LOGIC ERROR - PROGRAM SHOULD NOT REACH THIS',
. ' POINT')
RETURN
END
*****************************************************************
SUBROUTINE RADR8T (YLAT,VN,VE,VNR,VER)
C Convert horizontal velocities from mm/yr to rad/yr
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
CALL RADII (YLAT,RADMER,RADPAR)
c write (*,*) "From RADR8T",RADMER,RADPAR
VNR = VN / (1000.D0 * RADMER)
VER = VE / (1000.D0 * RADPAR)
c write (*,*) "From RADR8T",VNR,VER
RETURN
END
*****************************************************************
SUBROUTINE COMVEL(YLAT,YLON,JREGN,VN,VE,VU)
C
C Compute the NAD_83(CORS96) velocity at a point in mm/yr !Not anymore since 09/12/2014
!Now the velocity refer to ITRF2008
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NUMGRD = 10)
parameter (NMREGN = 30)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /FILES/ LUIN, LUOUT, I1,I2,I3,I4,I5,I6
COMMON /VGRID/ B(210000)
DIMENSION WEI(2,2), VEL(2,2,3)
c WRITE (6, 1001) JREGN
c1001 FORMAT( 'JREGN = ', I6)
IF(JREGN .GT. NUMGRD .AND. JREGN .LE. NMREGN) THEN
*** Use tectonic plate model to compute velocity relative
*** to ITRF2008
IPLATE = JREGN - NUMGRD
*** Subtract the number of placeholder regions
IPLATE = IPLATE - 3
ELON = - YLON
HT = 0.D0
CALL TOXYZ(YLAT, ELON, HT, X, Y, Z)
CALL PLATVL(IPLATE, X, Y, Z, VX, VY, VZ)
VX = VX * 1000.D0
VY = VY * 1000.D0
VZ = VZ * 1000.D0
*** Convert ITRF2008 velocity to NAD_83(CORS96) velocity
c CALL VTRANF(X, Y, Z, VX, VY, VZ, 15, 1) !No Do not. Leave the velocity in ITRF2008
CALL TOVNEU(YLAT, ELON, VX, VY, VZ, VN, VE, VU)
ELSEIF(JREGN .GE. 1 .AND. JREGN .LE. NUMGRD) THEN
C*** Get indices for the lower left hand corner of the grid
C*** and get the weights for the four corners
CALL GRDWEI (YLON, YLAT, JREGN, I, J, WEI)
c write (*,*) 'HHHHHHHHHHHHHHHHHHHHHHHHH',JREGN,WEI
c write (*,*) 'HHHHHHHHHHHHHHHHHHHHHHHHH',i,j
C*** Get the velocity vectors at the four corners
CALL GRDVEC (JREGN, I, J, VEL, B)
VN = WEI(1,1) * VEL(1,1,1) + WEI(1,2) * VEL(1,2,1)
* + WEI(2,1) * VEL(2,1,1) + WEI(2,2) * VEL(2,2,1)
VE = WEI(1,1) * VEL(1,1,2) + WEI(1,2) * VEL(1,2,2)
* + WEI(2,1) * VEL(2,1,2) + WEI(2,2) * VEL(2,2,2)
VU = WEI(1,1) * VEL(1,1,3) + WEI(1,2) * VEL(1,2,3)
* + WEI(2,1) * VEL(2,1,3) + WEI(2,2) * VEL(2,2,3)
c write (*,*) 'From COMVEL ',VN,VE,VU
c write (*,*) 'From COMVEL ',I,J
C*** If the point in one of the four Alaskan regions,
C*** then set its vertical velocity to 0.0
IF(JREGN .GE. 7 .AND. JREGN .LE. 10) THEN
VU = 0.D0
ENDIF
C*** If the point is in one of the first ten regions, then
c*** the velocity grids contain the ITRF2008 velocity.
c*** Hence, the following code transforms this ITRF2008 velocity
c*** to the corresponding NAD 83 (CORS96) velocity.
C
c IF(JREGN .LE. NUMGRD) THEN !Starting09/12/2014, the velocities
c ELON = - YLON !coming out of this routine are in ITRF2008
c HT = 0.D0
c CALL TOXYZ(YLAT, ELON, HT, X, Y, Z)
c CALL TOVXYZ(YLAT, ELON, VN, VE, VU, VX, VY, VZ)
c CALL VTRANF( X, Y, Z, VX, VY, VZ, 15, 1)
c CALL TOVNEU(YLAT, ELON, VX, VY, VZ, VN, VE, VU)
c ENDIF
ELSE
WRITE(LUOUT,100) JREGN
100 FORMAT(' Improper region identifier ',I4,'in COMVEL.')
STOP
ENDIF
RETURN
END
****************************************
SUBROUTINE PLATVL(IPLATE, X, Y, Z, VX, VY, VZ)
*** Compute the ITRF2008 velocity at point on plate = IPLATE
*** with coordinates X, Y, Z (in meters)
*** The resulting velocities--VX, VY, and VZ--will be in meters/yr
*** References:
*** Altamimi et al. 2012 = JGR (Paper on ITRF2008 plate motion).
*** Altamimi et al. 2017. "ITRF2014 plate motion model." Geophys. J. Int, 209.
*** Bird 2003. "An updated digital model of plate boundaries." Geochem. Geophys. Geosyst., 4(3), 1027
*** DeMets et al. 2010. "Geologically current plate motions." Geophys. J. Int., 181.
*** Kreemer et al. 2014. "A geodetic plate motion and global strain rate model." Geochem. Geophys. Geosyst., 15.
*** Mora-Páez et al. 2018. "Crustal deformation in the northern Andes – A new GPS velocity field." J. S. Amer. Earth Sci, 2018.
*** Snay 2003 = SALIS, Vol 63, No 1 (Paper on Frames for Pacific).
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
PARAMETER (NUMPLATE = 17)
DIMENSION WX(NUMPLATE), WY(NUMPLATE), WZ(NUMPLATE)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
*** All plate boundaries are from Bird 2003 with minor topological corrections.
*** IPLATE = 1 --> North America (from Altamimi et al. 2012)
*** 2 --> Caribbean (from Altamimi et al. 2012)
*** 3 --> Pacific (from Altamimi et al. 2012)
*** 4 --> Juan de Fuca (from DeMets et al. 2010)
*** 5 --> Cocos (from DeMets et al. 2010)
*** 6 --> Mariana (from Snay 2003)
*** 7 --> Philippine Sea (from DeMets et al. 2010)
*** New plates added in December 2020 (v3.3.0):
*** 8 --> South America (from Altamimi et al. 2017)
*** 9 --> Nazca (from Altamimi et al. 2017)
*** 10 --> Panama (from Kreemer et al. 2014)
*** 11 --> North Andes (from Mora-Paez, 2018)
*** 12 --> Africa (from Altamimi et al. 2017)
*** 13 --> Eurasia (from Altamimi et al. 2017)
*** 14 --> Rivera (from DeMets et al. 2010)
*** 15 --> Galapagos (from Bird 2003)
*** 16 --> Tonga (from Kreemer et al. 2014)
*** 17 --> Niuafo'ou (from Bird 2003)
* Plate rotation rates in radians per year. Existing plates (1-7) have ITRF2008 rates
* (except for plate 6, the Mariana plate referenced to ITRF2000). The new plates added
* in December 2020 have ITRF2014 rates (plates 8 thorugh 17).
DATA WX / 0.170D-9, 0.238D-9, -1.993D-9, 6.626D-9, -10.390D-9,
& -0.097D-9, -0.841D-9, -1.309D-9, -1.614D-9, 2.088D-9,
& -1.964D-9, 0.480D-9, -0.412D-9, -21.933D-9, 14.273D-9,
& 137.841D-9, -57.324D-9 /
DATA WY /-3.209D-9, -5.275D-9, 5.023D-9, 11.708D-9, -14.954D-9,
& 0.509D-9, 3.989D-9, -1.459D-9,-7.486D-9, -23.037D-9,
& -1.518D-9, -2.977D-9, -2.574D-9, -70.432D-9, 94.440D-9,
& 10.447D-9, -5.814D-9 /
DATA WZ /-0.485D-9, 3.219D-9,-10.501D-9, -10.615D-9, 9.148D-9,
& -1.682D-9, -10.626D-9, -0.679D-9, 7.869D-9, 6.729D-9,
& 0.400D-9, 3.554D-9, 3.733D-9, 27.071D-9, 4.520D-9,
& 68.458D-9, -3.722D-9 /
IF (IPLATE .LE. 0 .OR. IPLATE .GT. NUMPLATE) THEN
WRITE (LUOUT, 1) IPLATE
1 FORMAT(' Improper plate ID in PLATVL = ', I6)
STOP
ENDIF
VX = -WZ(IPLATE) * Y + WY(IPLATE) * Z
VY = WZ(IPLATE) * X - WX(IPLATE) * Z
VZ = -WY(IPLATE) * X + WX(IPLATE) * Y
*** The parameters--WX, WY, and WZ--refer to ITRF2000
*** for the Mariana Plate (Snay, 2003). Hence,
*** for this plate, VX, VY, and VZ, correspond to ITRF2000.
*** The following code converts these to ITRF2008 velocities for
*** this plate.
IF (IPLATE .EQ. 6) THEN
VX = VX*1000.d0
VY = VY*1000.d0
VZ = VZ*1000.d0
CALL VTRANF(X, Y, Z, VX, VY, VZ, 11, 15)
VX = VX/1000.d0
VY = VY/1000.d0
VZ = VZ/1000.d0
*** The rotation rates for plates added in Dec 2020 refer to ITRF2014
*** (plates 8 through 17). The following code converts the rates to
*** ITRF2008 velocities for these plates.
ELSEIF (IPLATE .GE. 8) THEN
VX = VX*1000.d0
VY = VY*1000.d0
VZ = VZ*1000.d0
CALL VTRANF(X, Y, Z, VX, VY, VZ, 16, 15)
VX = VX/1000.d0
VY = VY/1000.d0
VZ = VZ/1000.d0
*** The following translations rates are added per Altamimi et al. (2012)
*** for the other six plates referenced to ITRF2008.
ELSE
VX = 0.00041d0 + VX
VY = 0.00022d0 + VY
VZ = 0.00041d0 + VZ
ENDIF
RETURN
END
**********************************************************************
SUBROUTINE PVPRNT(LATD,LATM,SLAT,LOND,LONM,SLON,VN,VE,VU)
*** Print out a point-velocity (PV) record
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /FILES/ LUIN,LUOUT,I1,I2,I3,I4,I5, I6
LATS = IDINT(SLAT*100.D0 + 0.5D0)
LONS = IDINT(SLON*100.D0 + 0.5D0)
IVN = IDINT( VN*100.D0 + 0.5D0)
IVE = IDINT( VE*100.D0 + 0.5D0)
IVU = IDINT( VU*100.D0 + 0.5D0)
JVN = 300
JVE = 300
JVU = 500
WRITE(I3,10) LATD,LATM,LATS,LOND,LONM,LONS,
1 IVN,JVN,IVE,JVE,IVU,JVU
10 FORMAT('PV',I3,I2.2,I4.4,'N',I3,I2.2,I4.4,'W',6I6)
RETURN
END
****************************************************************************
SUBROUTINE DSDA(LOCISN, LOCJSN, MIN1, MIN2, DS, DA)
** Compute change in distance and change in azimuth.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
HTF = 0.0D0
HTT = 0.0D0
READ(I4,REC=LOCISN,err=50,iostat=ios) YLATF,YLONF,VNF,VEF,VUF
if (ios /= 0) goto 50
READ(I4,REC=LOCJSN,err=51,iostat=ios) YLATT,YLONT,VNT,VET,VUT
if (ios /= 0) goto 51
CALL COMPSN(YLATF1,YLONF1,HTF1,YLATF,YLONF,HTF,
1 MIN1, VNF, VEF, VUF)
CALL COMPSN(YLATF2,YLONF2,HTF2,YLATF,YLONF,HTF,
1 MIN2, VNF, VEF, VUF)
CALL COMPSN(YLATT1,YLONT1,HTT1,YLATT,YLONT,HTT,
1 MIN1, VNT, VET, VUT)
CALL COMPSN(YLATT2,YLONT2,HTT2,YLATT,YLONT,HTT,
1 MIN2, VNT, VET, VUT)
CALL HELINV(YLATF1,YLONF1,YLATT1,YLONT1,FAZ1,BAZ1,S1)
CALL HELINV(YLATF2,YLONF2,YLATT2,YLONT2,FAZ2,BAZ2,S2)
DS = S2 - S1
DA = FAZ2 - FAZ1
RETURN
50 write (*,'(/)')
write (*,*) "wrong input for the 1st reading in DSDA:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
51 write (*,'(/)')
write (*,*) "wrong input for the 2nd reading in DSDA:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*********************************************************************
SUBROUTINE HELINV(GLAT1,GLON1,GLAT2,GLON2,FAZ,BAZ,S)
C
C *** SOLUTION OF THE GEODETIC INVERSE PROBLEM AFTER T.VINCENTY.
C *** MODIFIED RAINSFORD WITH HELMERT ELLIPTICAL TERMS.
C *** EFFECTIVE IN ANY AZIMUTH AND AT ANY DISTANCE SHORT OF ANTIPODAL.
C *** STANDPOINT/FOREPOINT MUST NOT BE THE GEOGRAPHIC POLE .
C
C INPUT
C GLAT1 = Latitude of from point (radians, positive north)
C GLON1 = Longitude of from point (radians, positive west)
C GLAT2 = Latitude of to point (radians, positive north)
C GLON2 = Longitude of to point (radians, positive west)
C
C OUTPUT
C FAZ = Foward azimuth (radians, clockwise from north)
C BAZ = Back azimuth (radians, clockwise from north)
C S = Distance (meters)
C
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON/CONST/A,F,EPS2,EPS,AF,PI,TWOPI,RHOSEC
DATA TOL/0.5D-14/
R = 1.0D0-F
TU1 = R*DSIN(GLAT1)/DCOS(GLAT1)
TU2 = R*DSIN(GLAT2)/DCOS(GLAT2)
CU1 = 1.0D0/DSQRT(TU1*TU1+1.0D0)
SU1 = CU1*TU1
CU2 = 1.0D0/DSQRT(TU2*TU2+1.0D0)
S = CU1*CU2
BAZ = S*TU2
FAZ = BAZ*TU1
X = GLON1-GLON2
100 SX = DSIN(X)
CX = DCOS(X)
TU1 = CU2*SX
TU2 = SU1*CU2*CX-BAZ
SY = DSQRT(TU1*TU1+TU2*TU2)
CY = S*CX+FAZ
Y = DATAN2(SY,CY)
SA = S*SX/SY
C2A = -SA*SA+1.0D0
CZ = FAZ+FAZ
IF(C2A .GT. 0.0D0)CZ = -CZ/C2A+CY
E = CZ*CZ*2.0D0-1.0D0
C = ((-3.0D0*C2A+4.0D0)*F+4.0D0)*C2A*F/16.0D0
D = X
X = ((E*CY*C+CZ)*SY*C+Y)*SA
X = (1.0D0-C)*X*F+GLON1-GLON2
IF(DABS(D-X) .GT. TOL)GO TO 100
FAZ = DATAN2(-TU1,TU2)
BAZ = DATAN2(CU1*SX,BAZ*CX-SU1*CU2)
FAZ = FAZ + PI
BAZ = BAZ + PI
IF(FAZ .LT. 0.0D0)FAZ = FAZ+TWOPI
IF(BAZ .LT. 0.0D0)BAZ = BAZ+TWOPI
IF(FAZ .GT. TWOPI)FAZ = FAZ - TWOPI
IF(BAZ .GT. TWOPI)BAZ = BAZ - TWOPI
X = DSQRT((1.0D0/R/R-1.0D0)*C2A+1.0D0)+1.0D0
X = (X-2.0D0)/X
C = 1.0D0-X
C = (X*X/4.0D0+1.0D0)/C
D = (0.375D0*X*X-1.0D0)*X
X = E*CY
S = 1.0D0-E-E
S = ((((SY*SY*4.0D0-3.0D0)*S*CZ*D/6.0D0-X)*D/4.0D0+CZ)*SY*D+Y)
1 *C*A*R
RETURN
END
*************************************************************************
c SUBROUTINE TODMSA(val,id,im,s)
*** convert position radians to deg,min,sec
*** range is [-twopi to +twopi]
c implicit double precision(a-h,o-z)
c IMPLICIT INTEGER*4 (I-N)
c common/CONST/A,F,E2,EP2,AF,PI,TWOPI,RHOSEC
c 1 if(val.gt.twopi) then
c val=val-twopi
c go to 1
c endif
c 2 if(val.lt.-twopi) then
c val=val+twopi
c go to 2
c endif
c if(val.lt.0.d0) then
c isign=-1
c else
c isign=+1
c endif
c s=dabs(val*RHOSEC/3600.D0)
c id=idint(s)
c s=(s-id)*60.d0
c im=idint(s)
c s=(s-im)*60.d0
*** account for rounding error
c is=idnint(s*1.d5)
c if(is.ge.6000000) then
c s=0.d0
c im=im+1
c endif
c if(im.ge.60) then
c im=0
c id=id+1
c endif
c id = isign*id
c im = isign*im
c s = isign*s
c return
c end
*********************************************************
SUBROUTINE TRFDAT(CARD,DATE,IREC12,IYEAR1,IYEAR2,MINS)
C Convert blue-book date to time in minutes
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
CHARACTER CARD*80
CHARACTER DATE*6
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
IF (IREC12 .EQ. 0) THEN
WRITE (LUOUT, 5)
5 FORMAT(' ABORT: The blue-book needs a valid *12* record.')
STOP
ENDIF
READ (DATE, 10,err=50,iostat=ios) IYEAR, MONTH, IDAY
if (ios /= 0) goto 50
10 FORMAT (3I2)
IF ( IYEAR1 .LE. (1900 + IYEAR) .AND.
1 (1900 + IYEAR) .LE. IYEAR2) THEN
IYEAR = 1900 + IYEAR
ELSEIF ( IYEAR1 .LE. (2000 + IYEAR) .AND.
1 (2000 + IYEAR) .LE. IYEAR2) THEN
IYEAR = 2000 + IYEAR
ELSEIF ( IYEAR1 .LE. (1800 + IYEAR) .AND.
1 (1800 + IYEAR) .LE. IYEAR2) THEN
IYEAR = 1800 + IYEAR
ELSE
WRITE (LUOUT, 20) CARD
20 FORMAT(' ABORT: The following record has a date'/
1 ' which is inconsistent with the *12* record'/
1 3x, A80)
ENDIF
IF (IYEAR .LE. 1906) THEN
WRITE (LUOUT, 30)
30 FORMAT(' ***WARNING***'/
1 ' The blue-book file contains an observation that'/
1 ' predates 1906. The TDP model may not be valid'/
1 ' and the computed corrections may be erroneous.')
ENDIF
IF (IDAY .EQ. 0) IDAY = 15
IF (MONTH .EQ. 0) THEN
MONTH = 7
IDAY = 1
ENDIF
C CALL TOTIME(IYEAR,MONTH,IDAY, MINS)
CALL IYMDMJ(IYEAR,MONTH,IDAY, MJD)
MINS = MJD * 24 * 60
RETURN
50 write (*,'(/)')
write (*,*) 'wrong IYEAR, IMONTH, IDAY:ios =',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*********************************************************
SUBROUTINE TNFDAT(DATE,MINS)
C Convert blue-book date to time in years
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
character DATE*8
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
READ(DATE,10) IYEAR,MONTH,IDAY
10 FORMAT(I4,I2,I2)
IF(IYEAR .LE. 1906) THEN
WRITE(LUOUT,20)
20 FORMAT(' ***WARNING***'/
1 ' The blue-book file contains an observation that'/
2 ' predates 1906. The TDP model is not valid and the'/
3 ' computed correction may be erroneous.')
ENDIF
IF(IDAY .EQ. 0) IDAY = 15
IF(MONTH .EQ. 0) THEN
MONTH = 7
IDAY = 1
ENDIF
C CALL TOTIME(IYEAR,MONTH,IDAY,MINS)
CALL IYMDMJ(IYEAR,MONTH,IDAY,MJD)
MINS = MJD * 24 * 60
RETURN
END
***************************************************************
C SUBROUTINE GETTIM(MONTH, IDAY, IYEAR, DATE, MINS, TEST)
C
*** Read month-day-year and convert to decimal years
*** and Julian time in minutes
*** MONTH input - number from 1 to 12
*** IDAY input - number from 1 to 31
*** IYEAR input - must be after 1906
*** DATE output - corresponding time in decimal years
*** MINS output - corresponding julian time in minutes
*** TEST output - if (true) then there is an error
C
C IMPLICIT DOUBLE PRECISION (A-H,O-Z)
C IMPLICIT INTEGER*4 (I-N)
C LOGICAL TEST
C COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
C READ(LUIN,*) MONTH,IDAY,IYEAR
C IF(IYEAR .le. 1906) THEN
C WRITE(LUOUT,10)
C 10 FORMAT(' The model is not valid for dates prior ',
C 1 'to 1906.'/)
C TEST = .TRUE.
C RETURN
C ENDIF
C IF(MONTH .le. 0 .or. MONTH .gt. 12) THEN
C WRITE(LUOUT,20)
C 20 FORMAT(' Improper month specified.'/)
C TEST = .TRUE.
C RETURN
C ENDIF
C IF(IDAY .le. 0 .or. IDAY .gt. 31) THEN
C WRITE(LUOUT,30)
C 30 FORMAT(' Improper day specified.'/)
C TEST = .TRUE.
C RETURN
C ENDIF
C CALL TOTIME(IYEAR, MONTH, IDAY, MINS)
C CALL TOTIME(IYEAR, 1, 1, MIN00)
C DATE = DBLE(IYEAR) + DBLE(MINS - MIN00)/525600.D0
C TEST = .FALSE.
C RETURN
C END
C************************************************************************
SUBROUTINE TOXYZ(glat,glon,eht,x,y,z)
*** compute x,y,z
*** ref p.17 geometric geodesy notes vol 1, osu, rapp
implicit double precision(a-h,o-z)
common/CONST/ a,f,e2,ep2,af,pi,twopi,rhosec
slat=dsin(glat)
clat=dcos(glat)
w=dsqrt(1.d0-e2*slat*slat)
en=a/w
x=(en+eht)*clat*dcos(glon)
y=(en+eht)*clat*dsin(glon)
z=(en*(1.d0-e2)+eht)*slat
return
end
C************************************************************************
logical function FRMXYZ(x,y,z,glat,glon,eht)
*** convert x,y,z into geodetic lat, lon, and ellip. ht
*** ref: eq a.4b, p. 132, appendix a, osu #370
*** ref: geom geod notes gs 658, rapp
implicit double precision(a-h,o-z)
parameter(maxint=10,tol=1.d-13)
common/CONST/ a,f,e2,ep2,af,pi,twopi,rhosec
ae2=a*e2
*** compute initial estimate of reduced latitude (eht=0)
p=dsqrt(x*x+y*y)
icount=0
tgla=z/p/(1.d0-e2)
*** iterate to convergence, or to max # iterations
1 if(icount.le.maxint) then
tglax=tgla
tgla=z/(p-(ae2/dsqrt(1.d0+(1.d0-e2)*tgla*tgla)))
icount=icount+1
if(dabs(tgla-tglax).gt.tol) go to 1
*** convergence achieved
frmxyz=.true.
glat=datan(tgla)
slat=dsin(glat)
clat=dcos(glat)
glon=datan2(y,x)
w=dsqrt(1.d0-e2*slat*slat)
en=a/w
if(dabs(glat).le.0.7854d0) then
eht=p/clat-en
else
eht=z/slat-en+e2*en
endif
glon=datan2(y,x)
*** too many iterations
else
frmxyz=.false.
glat=0.d0
glon=0.d0
eht=0.d0
endif
return
end
*********************************************************************
SUBROUTINE RADII(YLAT,RADMER,RADPAR)
C
C Computes the radius of curvature in the meridian
C and the radius of curvature in a parallel of latitude
C
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COSLAT = DCOS(YLAT)
DENOM = DSQRT(1.D0 + EPS*COSLAT*COSLAT)
RADMER = AF/(DENOM**3)
RADPAR = AF*COSLAT/DENOM
RETURN
END
*********************************************************************
SUBROUTINE GETGRD(NAMEG,MINLAT,MAXLAT,ILAT,MINLON,MAXLON,ILON)
*** Interactively obtain specifications for a grid.
IMPLICIT INTEGER*4 (I-N)
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
CHARACTER NAMEG*10
WRITE(LUOUT,200)
200 FORMAT(' Enter name for grid (10 character max). ')
READ(LUIN,210,err=50,iostat=ios) NAMEG
if (ios /= 0) goto 50
210 FORMAT(A10)
WRITE(LUOUT,220)
220 FORMAT(' Enter minimum latitude for grid in deg-min-sec'/
1 ' in free format (integer values only). ')
READ(LUIN,*,err=51,iostat=ios) ID1, IM1, IS1
if (ios /= 0) goto 51
WRITE(LUOUT,230)
230 FORMAT(' Enter maximum latitude in same format. ')
READ(LUIN,*,err=52,iostat=ios) ID2, IM2, IS2
if (ios /= 0) goto 52
WRITE(LUOUT,240)
240 FORMAT(' Enter latitude increment in seconds ',
1 ' (integer value). ')
READ(LUIN,*,err=53,iostat=ios) ILAT
if (ios /= 0) goto 53
WRITE(LUOUT,250)
250 FORMAT(' Enter minimum longitude with positive being west. ')
READ(LUIN,*,err=54,iostat=ios) JD1, JM1, JS1
if (ios /= 0) goto 54
WRITE(LUOUT,260)
260 FORMAT(' Enter maximum longitude. ')
READ(LUIN,*,err=55,iostat=ios) JD2, JM2, JS2
if (ios /= 0) goto 55
WRITE(LUOUT,270)
270 FORMAT(' Enter longitude increment in seconds ',
1 ' (integer value). ')
READ(LUIN,*,err=56,iostat=ios) ILON
if (ios /= 0) goto 56
MINLAT = 3600*ID1 + 60*IM1 + IS1
MAXLAT = 3600*ID2 + 60*IM2 + IS2
MINLON = 3600*JD1 + 60*JM1 + JS1
MAXLON = 3600*JD2 + 60*JM2 + JS2
RETURN
50 write (*,'(/)')
write (*,*) "Wrong grid name in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
51 write (*,'(/)')
write (*,*) "Wrong min lat in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
52 write (*,'(/)')
write (*,*) "Wrong max lat in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
53 write (*,'(/)')
write (*,*) "Wrong ILAT in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
54 write (*,'(/)')
write (*,*) "Wrong min lon in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
55 write (*,'(/)')
write (*,*) "Wrong max lon in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
56 write (*,'(/)')
write (*,*) "Wrong ILON in GETGRD:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*********************************************************************
SUBROUTINE GETLYN(NAMEG,XLAT,XLON,FAZ,BAZ,XMIN,XMAX,XINC)
*** Interactively obtain the specifications for a line.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /FILES/ LUIN,LUOUT,I1,I2,I3,I4,I5,I6
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
CHARACTER NAMEG*10
WRITE(LUOUT,100)
100 FORMAT(' Enter name for line (10 character max.) ')
READ(LUIN,110,err=50,iostat=ios) NAMEG
if (ios /= 0) goto 50
110 FORMAT(A10)
WRITE(LUOUT,120)
120 Format(' Specify the latitude for the origin of the line'/
1 ' in deg-min-sec in free format. For example'/
2 ' 35 17 28.3'/
3 ' Positive is north. ')
READ(LUIN,*,err=51,iostat=ios) LATD,LATM,SLAT
if (ios /= 0) goto 51
XLAT = (DBLE(3600*LATD + 60*LATM)+SLAT)/RHOSEC
WRITE(LUOUT,130)
130 FORMAT(' Specify the longitude for the origin of the line'/
1 ' in free format with west being positive. ')
READ(LUIN,*,err=52,iostat=ios) LOND,LONM,SLON
if (ios /= 0) goto 52
XLON = (DBLE(3600*LOND+60*LONM)+SLON)/RHOSEC
WRITE(LUOUT,140)
140 FORMAT(' Specify the orientation of the line clockwise from'/
1 ' north in decimal degrees, eg., 43.7. ')
READ(LUIN,*,err=53,iostat=ios) FAZ
if (ios /= 0) goto 53
FAZ = 3600.D0*FAZ/RHOSEC
BAZ = FAZ + PI
IF(BAZ .GT. TWOPI) BAZ = BAZ - TWOPI
WRITE(LUOUT,150)
150 FORMAT(' Specify minimum and maximum distance from origin in'/
1 ' meters, eg., -40000. 30000. '/
2 ' NOTE: negative distance corresponds to distance in'/
3 ' the opposite direction. ')
READ(LUIN,*,err=54,iostat=ios) XMIN,XMAX
if (ios /= 0) goto 54
WRITE(LUOUT,160)
160 FORMAT(' Specify distance increment in meters. ')
READ(LUIN,*,err=55,iostat=ios) XINC
if (ios /= 0) goto 55
RETURN
50 write (*,'(/)')
write (*,*) 'Wrong name of line in GETLYN: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
51 write (*,'(/)')
write (*,*) 'Wrong LATD,LATM,SLAT in GETLYN: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
52 write (*,'(/)')
write (*,*) 'Wrong LOND,LONM,SLON in GETLYN: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
53 write (*,'(/)')
write (*,*) 'Wrong FAZ in GETLYN: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
54 write (*,'(/)')
write (*,*) 'Wrong min and max D in GETLYN: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
55 write (*,'(/)')
write (*,*) 'Wrong increment in GETLYN: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*******************************************************************
SUBROUTINE DIRCT1(GLAT1,GLON1,GLAT2,GLON2,FAZ,BAZ,S)
C
C *** SOLUTION OF THE GEODETIC DIRECT PROBLEM AFTER T.VINCENTY
C *** MODIFIED RAINSFORD'S METHOD WITH HELMERT'S ELLIPTICAL TERMS
C *** EFFECTIVE IN ANY AZIMUTH AND AT ANY DISTANCE SHORT OF ANTIPODAL
C
C *** A IS THE SEMI-MAJOR AXIS OF THE REFERENCE ELLIPSOID
C *** FINV IS THE FLATTENING OF THE REFERENCE ELLIPSOID
C *** LATITUDES AND LONGITUDES IN RADIANS POSITIVE NORTH AND EAST
C *** AZIMUTHS IN RADIANS CLOCKWISE FROM NORTH
C *** GEODESIC DISTANCE S ASSUMED IN UNITS OF SEMI-MAJOR AXIS A
C
C *** PROGRAMMED FOR CDC-6600 BY LCDR L.PFEIFER NGS ROCKVILLE MD 20FEB75
C *** MODIFIED FOR SYSTEM 360 BY JOHN G GERGEN NGS ROCKVILLE MD 750608
C
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /CONST/ A,FINV,E2,EPI,AF,PI,TWOPI,RHOSEC
DATA EPS/0.5D-13/
R=1.D0-FINV
TU=R*DSIN(GLAT1)/DCOS(GLAT1)
SF=DSIN(FAZ)
CF=DCOS(FAZ)
BAZ=0.D0
IF(CF.NE.0.D0) BAZ=DATAN2(TU,CF)*2.D0
CU=1.D0/DSQRT(TU*TU+1.D0)
SU=TU*CU
SA=CU*SF
C2A=-SA*SA+1.D0
X=DSQRT((1.D0/R/R-1.D0)*C2A+1.D0)+1.D0
X=(X-2.D0)/X
C=1.D0-X
C=(X*X/4.D0+1.D0)/C
D=(0.375D0*X*X-1.D0)*X
TU=S/R/A/C
Y=TU
100 SY=DSIN(Y)
CY=DCOS(Y)
CZ=DCOS(BAZ+Y)
E=CZ*CZ*2.D0-1.D0
C=Y
X=E*CY
Y=E+E-1.D0
Y=(((SY*SY*4.D0-3.D0)*Y*CZ*D/6.D0+X)*D/4.D0-CZ)*SY*D+TU
IF(DABS(Y-C).GT.EPS)GO TO 100
BAZ=CU*CY*CF-SU*SY
C=R*DSQRT(SA*SA+BAZ*BAZ)
D=SU*CY+CU*SY*CF
GLAT2=DATAN2(D,C)
C=CU*CY-SU*SY*CF
X=DATAN2(SY*SF,C)
C=((-3.D0*C2A+4.D0)*FINV+4.D0)*C2A*FINV/16.D0
D=((E*CY*C+CZ)*SY*C+Y)*SA
GLON2=GLON1+X-(1.D0-C)*D*FINV
IF (GLON2.GE.TWOPI) GLON2=GLON2-TWOPI
IF(GLON2.LT.0.D0) GLON2=GLON2+TWOPI
BAZ=DATAN2(SA,BAZ)+PI
IF (BAZ.GE.TWOPI) BAZ=BAZ-TWOPI
IF (BAZ.LT.0.D0) BAZ=BAZ+TWOPI
RETURN
END
***********************************************************
SUBROUTINE TOCHAR(ORIG,CHAR14)
*** Convert double precision real number to character*14
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
CHARACTER CHAR14*14
ORIG = ORIG*10000.D0
WRITE(CHAR14,10) ORIG
10 FORMAT(F14.0)
RETURN
END
*********************************************************
SUBROUTINE DDXYZ(ISN, JSN, MIN1, MIN2,
1 DDX, DDY, DDZ)
** Compute change in DX,DY,DZ-vector from time MIN1 to MIN2.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
character PIDs*6
parameter (nbbdim = 10000)
COMMON /ARRAYS/ HT(nbbdim), LOC(nbbdim),PIDs(nbbdim)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
READ(I4,REC=LOC(ISN),err=50,iostat=ios) GLATI,GLONI,VNI,VEI,VUI
if (ios /= 0) goto 50
READ(I4,REC=LOC(JSN),err=51,iostat=ios) GLATJ,GLONJ,VNJ,VEJ,VUJ
if (ios /= 0) goto 51
CALL COMPSN(YLATI1,YLONI1,HTI1,GLATI,GLONI,HT(ISN),
1 MIN1,VNI, VEI, VUI)
CALL COMPSN(YLATI2,YLONI2,HTI2,GLATI,GLONI,HT(ISN),
1 MIN2, VNI, VEI, VUI)
CALL COMPSN(YLATJ1,YLONJ1,HTJ1,GLATJ,GLONJ,HT(JSN),
1 MIN1, VNJ, VEJ, VUJ)
CALL COMPSN(YLATJ2,YLONJ2,HTJ2,GLATJ,GLONJ,HT(JSN),
1 MIN2, VNJ, VEJ, VUJ)
XLONI1 = -YLONI1
XLONI2 = -YLONI2
XLONJ1 = -YLONJ1
XLONJ2 = -YLONJ2
CALL TOXYZ(YLATI1,XLONI1,HTI1,XI1,YI1,ZI1)
CALL TOXYZ(YLATI2,XLONI2,HTI2,XI2,YI2,ZI2)
CALL TOXYZ(YLATJ1,XLONJ1,HTJ1,XJ1,YJ1,ZJ1)
CALL TOXYZ(YLATJ2,XLONJ2,HTJ2,XJ2,YJ2,ZJ2)
DDX = (XJ2 - XI2) - (XJ1 - XI1)
DDY = (YJ2 - YI2) - (YJ1 - YI1)
DDZ = (ZJ2 - ZI2) - (ZJ1 - ZI1)
RETURN
50 write (*,'(/)')
write (*,*) "Failed in 1st read statement in DDXYZ:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
51 write (*,'(/)')
write (*,*) "Failed in 2nd read statement in DDXYZ:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*************************************************************
SUBROUTINE DISLOC (YLAT,YLON,STRIKE,HL,EQLAT,EQLON,
& SS,DS,DIP,DEPTH,WIDTH,DNORTH,DWEST,DUP)
*** Compute 3-dimensional earthquake displacement at point
*** using dislocation theory
*
* INPUT:
* YLAT = Latitude in radians (positive north)
* YLON = Longitude in radians (positive west)
* STRIKE = strike in radians clockwise from north such
* that the direction of dip is pi/2 radians
* counterclockwise from the direction of strike
* HL = Half-length in meters
* EQLAT = Latitude in radians of midpoint of the
* rectangle's upper edge (positive north)
* EQLON = Longitude in radians of midpoint of the
* rectangle's upper edge (positive west)
* SS = strike slip in meters (positive = right lateral)
* DS = dip slip in meters (positive = normal faulting)
* DIP = dip in radians
* DEPTH = Vertical depth of rectangle's upper edge
* in meters
* WIDTH = width of rectangle in meters
*
* OUTPUT:
* DNORTH = northward displacement in radians
* DWEST = westward displacement in radians
* DUP = upward displacement in meters
**************
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
*** Compute radii of curvature at fault center
CALL RADII (EQLAT, RMER, RPAR)
*** Compute planar coordinates in meters
DLAT = (YLAT - EQLAT) * RMER
DLON = (YLON - EQLON) * RPAR
COSSTR = DCOS(STRIKE)
SINSTR = DSIN(STRIKE)
X1 = COSSTR*DLAT - SINSTR*DLON
X2 = SINSTR*DLAT + COSSTR*DLON
*** Compute displacements in fault-oriented coordinates
CALL OKADA(X1,X2,HL,DEPTH,WIDTH,DIP,U1SS,U2SS,
& U3SS,U1DS,U2DS,U3DS)
U1 = U1SS*SS + U1DS*DS
U2 = U2SS*SS + U2DS*DS
DUP = U3SS*SS + U3DS*DS
*** Convert horizontal displacements to radians
*** in north-west coordinate system
DNORTH = ( COSSTR*U1 + SINSTR*U2) / RMER
DWEST = (-SINSTR*U1 + COSSTR*U2) / RPAR
RETURN
END
****************************************************
SUBROUTINE OKADA(X1,X2,XL,DU,W,DIP,
1 U1SS,U2SS,U3SS,U1DS,U2DS,U3DS)
************************************************************
* This subroutine computes displacements at the point X1,X2
* on the Earth's surface due to 1.0 meter of right-lateral
* strike slip (SS) and 1.0 meter of normal dip slip (DS)
* along a rectangular fault.
*
* The rectangular fault dips in the direction of the positive
* X2-axis. The rectangle's strike parallels the X1-axis.
* With the X3-axis directed upward out of the Earth, the X1-,
* X2-, and X3-axes form a right-handed system.
*
* The equations of dislocation theory are employed whereby
* Earth is represented an a homogeneous, isotropic half-space
* with a Poisson ratio of PNU.
*
* REFERENCE: Okada, Y., Surface deformation due to shear and
* tensile faults in a half-space, Bulletin of the
* Seismological Society of America, vol. 75, pp. 1135-1154 (1985)
*
* The X3 = 0 plane corresponds to the Earth's surface. The plane's
* origin is located directly above the midpoint of the rectangle's
* upper edge.
*
* INPUT:
* X1,X2 - Location in meters
* XL - Rectangle's half-length in meters
* DU - Vertical depth to rectangle's upper edge in meters
* (always positive or zero)
* W - Rectangle's width in meters
* DIP - Rectangle's dip in radians (always between 0 and PI/2
*
* OUTPUT
* U1SS - Displacement in X1-direction due to 1.0 meters
* of right-lateral strike slip
* U2SS - Displacement in X2-direction due to 1.0 meters
* of right-lateral strike slip
* U3SS - Displacement in X3-direction due to 1.0 meters
* of right-lateral strike slip
* U1DS - Displacement in X1-direction due to 1.0 meters
* of normal dip slip
* U2DS - Displacement in X2-direction due to 1.0 meters
* of normal dip slip
* U3DS - Displacement in X3-direction due to 1.0 meters
* of normal dip slip
*******************************************************************
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
LOGICAL VERT
PI = 3.141593D0
TWOPI = PI + PI
PNU = 0.25D0
RATIO = 1.D0 - 2.D0*PNU
IF(DABS(PI/2.D0 - DIP) .LT. .01D0)THEN
DIPK = -PI/2.D0
VERT = .TRUE.
ELSE
DIPK = -DIP
VERT = .FALSE.
ENDIF
SDIP = DSIN(DIPK)
CDIP = DCOS(DIPK)
P = X2*CDIP + DU*SDIP
Q = X2*SDIP - DU*CDIP
PSI = X1 + XL
ETA = P
CALL OKADAW(PSI,ETA,Q,SDIP,CDIP,RATIO,TWOPI,
1 VERT,U1SS,U2SS,U3SS,U1DS,U2DS,U3DS)
PSI = X1 + XL
ETA = P - W
CALL OKADAW(PSI,ETA,Q,SDIP,CDIP,RATIO,TWOPI,
1 VERT,C1SS,C2SS,C3SS,C1DS,C2DS,C3DS)
U1SS = U1SS - C1SS
U2SS = U2SS - C2SS
U3SS = U3SS - C3SS
U1DS = U1DS - C1DS
U2DS = U2DS - C2DS
U3DS = U3DS - C3DS
PSI = X1 - XL
ETA = P
CALL OKADAW(PSI,ETA,Q,SDIP,CDIP,RATIO,TWOPI,
1 VERT,C1SS,C2SS,C3SS,C1DS,C2DS,C3DS)
U1SS = U1SS - C1SS
U2SS = U2SS - C2SS
U3SS = U3SS - C3SS
U1DS = U1DS - C1DS
U2DS = U2DS - C2DS
U3DS = U3DS - C3DS
PSI = X1 - XL
ETA = P - W
CALL OKADAW(PSI,ETA,Q,SDIP,CDIP,RATIO,TWOPI,
1 VERT,C1SS,C2SS,C3SS,C1DS,C2DS,C3DS)
U1SS = U1SS + C1SS
U2SS = U2SS + C2SS
U3SS = U3SS + C3SS
U1DS = U1DS + C1DS
U2DS = U2DS + C2DS
U3DS = U3DS + C3DS
RETURN
END
C********1*********2*********3*********4*********5*********6*********7**
SUBROUTINE OKADAW(PSI,ETA,Q,SDIP,CDIP,RATIO,TWOPI,VERT,U1SS,U2SS,
& U3SS,U1DS,U2DS,U3DS)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
LOGICAL VERT
YBAR = ETA*CDIP + Q*SDIP
DBAR = ETA*SDIP - Q*CDIP
R = DSQRT(PSI*PSI + ETA*ETA + Q*Q)
X = DSQRT(PSI*PSI + Q*Q)
IF(DABS(Q) .LE. 0.1d0) THEN
TERM = 0.D0
ELSE
TERM = DATAN(PSI*ETA/(Q*R))
ENDIF
IF(VERT) THEN
F5 = -RATIO*PSI*SDIP/(R + DBAR)
F4 = -RATIO*Q/(R + DBAR)
F3 = 0.5D0*RATIO*(ETA/(R + DBAR) + YBAR*Q/
& ((R + DBAR)*(R + DBAR)) - DLOG(R + ETA))
F1 = -0.5D0*RATIO*PSI*Q/((R + DBAR)*(R + DBAR))
ELSE
IF(DABS(PSI) .LE. 0.1D0) then
F5 = 0.d0
ELSE
F5 = 2.D0*RATIO*DATAN((ETA*(X+Q*CDIP)+X*(R+X)*SDIP)/
& (PSI*(R+X)*CDIP))/CDIP
ENDIF
F4 = RATIO*(DLOG(R+DBAR)-SDIP*DLOG(R+ETA))/CDIP
F3 = RATIO*(YBAR/(CDIP*(R+DBAR)) - DLOG(R+ETA)) + SDIP*F4/CDIP
F1 = -RATIO*(PSI/(CDIP*(R+DBAR))) - SDIP*F5/CDIP
ENDIF
F2 = -RATIO*DLOG(R+ETA) - F3
U1SS = -(PSI*Q/(R*(R+ETA)) + TERM + F1*SDIP)/TWOPI
U2SS = -(YBAR*Q/(R*(R+ETA)) + Q*CDIP/(R+ETA) + F2*SDIP)/TWOPI
U3SS = -(DBAR*Q/(R*(R+ETA)) + Q*SDIP/(R+ETA) + F4*SDIP)/TWOPI
U1DS = -(Q/R - F3*SDIP*CDIP)/TWOPI
* Following part of subroutine modified based on changes provided by
* Jarir Saleh on 11/19/2020 to avoid floating point exceptions when a
* point is located on the extension of a fault plane.
* Two conditional statements added to avoid floating point exception
* using variables TERM1 and TERM2:
TERM1 = YBAR*Q
IF (ABS(TERM1) < 1D-3) THEN
U2DS1 = 0.D0
ELSE
U2DS1 = -YBAR*Q/R/(R+PSI)/TWOPI
ENDIF
U2DS2 = -CDIP*TERM/TWOPI
U2DS3 = F1*SDIP*CDIP/TWOPI
U2DS = U2DS1 + U2DS2 + U2DS3
TERM2 = DBAR*Q
IF (ABS(TERM2) < 1D-3) THEN
U3DS1 = 0.D0
ELSE
U3DS1 = -DBAR*Q/R/(R+PSI)/TWOPI
ENDIF
U3DS2 = -SDIP*TERM/TWOPI
U3DS3 = F5*SDIP*CDIP/TWOPI
U3DS = U3DS1 + U3DS2 + U3DS3
* End of changes provided by Jarir
RETURN
END
C********1*********2*********3*********4*********5*********6*********7**
SUBROUTINE GRDWEI (YLON, YLAT, JREGN, I, J, WEI)
C
C********1*********2*********3*********4*********5*********6*********7**
C
C NAME: GRDWEI
C VERSION: 9302.01 (YYMM.DD)
C WRITTEN BY: MR. C. RANDOLPH PHILIPP
C PURPOSE: THIS SUBROUTINE RETURNS THE INDICES OF THE LOWER-LEFT
C HAND CORNER OF THE GRID CELL CONTAINING THE POINT
C AND COMPUTES NORMALIZED WEIGHTS FOR
C BI-LINEAR INTERPOLATION OVER A PLANE
C
C INPUT PARAMETERS FROM ARGUMENT LIST:
C ------------------------------------
C YLON LONGITUDE OF POINT IN RADIANS, POSITIVE WEST
C YLAT LATITUDE OF POINT IN RADIANS, POSITIVE NORTH
C JREGN ID OF GEOGRAPHIC REGION CONTAINING POINT
C
C OUTPUT PARAMETERS FROM ARGUMENT LIST:
C -------------------------------------
C I, J THE COORDINATES OF LOWER LEFT CORNER OF THE GRID
C CONTAINING THE ABOVE POSITION
C WEI A TWO BY TWO ARRAY CONTAINING THE NORMALIZED WEIGHTS
C FOR THE CORNER VECTORS
C
C GLOBAL VARIABLES AND CONSTANTS:
C -------------------------------
C NONE
C
C THIS MODULE CALLED BY: COMVEL
C
C THIS MODULE CALLS: NONE
C
C INCLUDE FILES USED: NONE
C
C COMMON BLOCKS USED: /CDGRID/, /CONST/
C
C REFERENCES: SEE RICHARD SNAY
C
C COMMENTS:
C
C********1*********2*********3*********4*********5*********6*********7**
C MOFICATION HISTORY:
C::9302.11, CRP, ORIGINAL CREATION FOR DYNAP
C::9511.09, RAS, MODIFIED FOR HTDP
C::9712.05, RAS, MODIFIED TO ACCOUNT FOR MULTIPLE GRIDS
C********1*********2*********3*********4*********5*********6*********7**
C**** COMPUTES THE WEIGHTS FOR AN ELEMENT IN A GRID
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NUMGRD = 10)
DIMENSION WEI(2,2)
COMMON /CDGRID/ GRDLX(NUMGRD), GRDUX(NUMGRD),
1 GRDLY(NUMGRD), GRDUY(NUMGRD),
1 ICNTX(NUMGRD), ICNTY(NUMGRD), NBASE(NUMGRD)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
C*** Convert input coordinates to degrees
POSX = (TWOPI - YLON) * 180.D0 / PI
POSY = YLAT * 180.D0 / PI
C*** Obtain indices for the lower-left corner of the cell
C*** containing the point
STEPX = (GRDUX(JREGN) - GRDLX(JREGN)) / ICNTX(JREGN)
STEPY = (GRDUY(JREGN) - GRDLY(JREGN)) / ICNTY(JREGN)
I = IDINT((POSX - GRDLX(JREGN))/STEPX) + 1
J = IDINT((POSY - GRDLY(JREGN))/STEPY) + 1
c write(6,1001) JREGN, I, J
c1001 format(1x, 'jregn = ', I5 /
c 1 1x, ' i = ', I5 /
c 1 1x, ' j = ', I5)
C*** Compute the limits of the grid cell
GRLX = GRDLX(JREGN) + (I - 1) * STEPX
GRUX = GRLX + STEPX
GRLY = GRDLY(JREGN) + (J - 1) * STEPY
GRUY = GRLY + STEPY
C*** Compute the normalized weights for the point
DENOM = (GRUX - GRLX) * (GRUY - GRLY)
WEI(1,1) = (GRUX - POSX) * (GRUY - POSY) / DENOM
WEI(2,1) = (POSX - GRLX) * (GRUY - POSY) / DENOM
WEI(1,2) = (GRUX - POSX) * (POSY - GRLY) / DENOM
WEI(2,2) = (POSX - GRLX) * (POSY - GRLY) / DENOM
RETURN
END
C*********************************************************************
C
SUBROUTINE GRDVEC (JREGN, I, J, VEL, B)
C
C********1*********2*********3*********4*********5*********6*********7**
C
C NAME: GRDVEC
C VERSION: 9302.01 (YYMM.DD)
C WRITTEN BY: MR. C. RANDOLPH PHILIPP
C PURPOSE: THIS SUBROUTINE RETRIEVES THE APPROXIMATE VALUES OF THE
C GRID NODE VELOCITIES FOR GRID (I,J)
C
C INPUT PARAMETERS FROM ARGUMENT LIST:
C ------------------------------------
C JREGN ID OF GEOGRAPHIC REGION CORRESPONDING TO GRID
C I, J THE COORDINATES OF LOWER LEFT CORNER OF THE GRID
C CONTAINING THE ABOVE POSITION
C B THE ARRAY CONTAINING ALL THE APPROXIMATE VALUES
C FOR THE ADJUSTMENT
C
C OUTPUT PARAMETERS FROM ARGUMENT LIST:
C -------------------------------------
C VEL A TWO BY TWO ARRAY CONTAINING THE VELOCITY VECTORS
C FOR THE CORNERS OF THE GRID
C
C GLOBAL VARIABLES AND CONSTANTS:
C -------------------------------
C NONE
C
C THIS MODULE CALLED BY: COMVEL
C
C THIS MODULE CALLS: NONE
C
C INCLUDE FILES USED: NONE
C
C COMMON BLOCKS USED: NONE
C
C REFERENCES: SEE RICHARD SNAY
C
C COMMENTS:
C
C********1*********2*********3*********4*********5*********6*********7**
C MOFICATION HISTORY:
C::9302.11, CRP, ORIGINAL CREATION FOR DYNAP
C::9712.05, RAS, MODIFIED FOR HTDP (version 2.2)
C********1*********2*********3*********4*********5*********6*********7**
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
DIMENSION VEL(2,2,3), B(*)
DO 30 II = 0,1
DO 20 IJ = 0,1
DO 10 IVEC = 1, 3
INDEX = IUNGRD(JREGN, I + II, J + IJ, IVEC)
VEL(II + 1, IJ + 1, IVEC) = B(INDEX)
10 CONTINUE
20 CONTINUE
30 CONTINUE
RETURN
END
C***************************************************
SUBROUTINE RDEG (INPUT,VAL,CNEG)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
CHARACTER INPUT*10
CHARACTER CNEG*1
INTEGER DEG, MIN, ISEC
DO 10 I = 1, 9
IF (INPUT(I:I).EQ.' ') THEN
INPUT(I:I) = '0'
ENDIF
10 CONTINUE
READ (INPUT,20) DEG, MIN, ISEC
20 FORMAT(I3,I2,I4)
SEC = ISEC/100.D0
VAL = (DEG + (MIN/60.D0) + (SEC/3600.D0) )
IF (INPUT(10:10).EQ.CNEG) THEN
VAL = -VAL
ENDIF
RETURN
END
C***************************************************
INTEGER FUNCTION IUNGRD(IREGN, I, J, IVEC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NUMGRD = 10)
COMMON /CDGRID/ GRDLX(NUMGRD), GRDUX(NUMGRD),
1 GRDLY(NUMGRD), GRDUY(NUMGRD),
1 ICNTX(NUMGRD), ICNTY(NUMGRD), NBASE(NUMGRD)
IUNGRD = NBASE(IREGN) +
1 3 * ((J - 1) * (ICNTX(IREGN) + 1) + (I - 1)) + IVEC
RETURN
END
C*********************************************************
C
SUBROUTINE TOMNT( IYR, IMON, IDAY, IHR, IMN, MINS )
*** This subroutine is not called; apparently replaced by IYMDMJ.
C
C********1*********2*********3*********4*********5*********6*********7**
C
C NAME: TOMNT (ORIGINALLY IYMDMJ)
C VERSION: 9004.17
C WRITTEN BY: M. SCHENEWERK
C PURPOSE: CONVERT DATE TO MODIFIED JULIAN DATE PLUS UT
C
C INPUT PARAMETERS FROM THE ARGUEMENT LIST:
C -----------------------------------------
C IDAY DAY
C IMON MONTH
C IYR YEAR
C
C OUTPUT PARAMETERS FROM ARGUEMENT LIST:
C --------------------------------------
C MINS MODIFIED JULIAN DATE IN MINUTES
C
C
C LOCAL VARIABLES AND CONSTANTS:
C ------------------------------
C A TEMPORARY STORAGE
C B TEMPORARY STORAGE
C C TEMPORARY STORAGE
C D TEMPORARY STORAGE
C IMOP TEMPORARY STORAGE
C IYRP TEMPORARY STORAGE
C
C GLOBAL VARIABLES AND CONSTANTS:
C ------------------------------
C
C
C THIS MODULE CALLED BY: GENERAL USE
C
C THIS MODULE CALLS: DINT
C
C INCLUDE FILES USED:
C
C COMMON BLOCKS USED:
C
C REFERENCES: DUFFETT-SMITH, PETER 1982, 'PRACTICAL
C ASTRONOMY WITH YOUR CALCULATOR', 2ND
C EDITION, CAMBRIDGE UNIVERSITY PRESS,
C NEW YORK, P.9
C
C COMMENTS: THIS SUBROUTINE REQUIRES THE FULL YEAR,
C I.E. 1992 RATHER THAN 92.
C
C********1*********2*********3*********4*********5*********6*********7**
C::LAST MODIFICATION
C::8909.06, MSS, DOC STANDARD IMPLIMENTED
C::9004.17, MSS, CHANGE ORDER YY MM DD
C********1*********2*********3*********4*********5*********6*********7**
C
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
C
INTEGER*4 A, B, C, D
IYRP = IYR
C
C........ 0.0 EXPLICIT INITIALIZATION
C
IF( IMON .LT. 3 ) THEN
IYRP= IYRP - 1
IMOP= IMON + 12
ELSE
IMOP= IMON
END IF
C
C........ 1.0 CALCULATION
C
*** Following 4 lines edited in v3.3.0 to address compiler issue with
*** real to integer conversion.
C A= IYRP*0.01D0
C B= 2 - A + DINT( A*0.25D0 )
C C= 365.25D0*IYRP
C D= 30.6001D0*(IMOP + 1)
A = IDINT(DBLE(IYRP)*0.01D0)
B = 2 - A + IDINT(DBLE(A)*0.25D0)
C = IDINT(365.25D0*DBLE(IYRP))
D = IDINT(30.6001D0*(DBLE(IMOP + 1)))
MINS = (B + C + D + IDAY - 679006) * (24 * 60)
& + (60 * IHR) + IMN
RETURN
END
*****************************************************
SUBROUTINE TOVNEU(GLAT,GLON,VX,VY,VZ,VN,VE,VU)
*** Convert velocities from vx,vy,vz to vn,ve,vu
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
SLAT = DSIN(GLAT)
CLAT = DCOS(GLAT)
SLON = DSIN(GLON)
CLON = DCOS(GLON)
VN = -SLAT*CLON*VX - SLAT*SLON*VY + CLAT*VZ
VE = -SLON*VX + CLON*VY
VU = CLAT*CLON*VX + CLAT*SLON*VY + SLAT*VZ
RETURN
END
***************************************************
SUBROUTINE TOVXYZ(GLAT,GLON,VN,VE,VU,VX,VY,VZ)
*** Convert velocities from vn,ve,vu to vx,vy,vz
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
SLAT = DSIN(GLAT)
CLAT = DCOS(GLAT)
SLON = DSIN(GLON)
CLON = DCOS(GLON)
VX = -SLAT*CLON*VN - SLON*VE + CLAT*CLON*VU
VY = -SLAT*SLON*VN + CLON*VE + CLAT*SLON*VU
VZ = CLAT*VN + SLAT*VU
RETURN
END
*****************************************************
SUBROUTINE DPLACE
*** Predict displacements between two dates.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (numref = 16)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
CHARACTER CARD*80
CHARACTER record*120
CHARACTER NAMEF*80, NAME*80, NAMEBB*80, NAMEIF*80
CHARACTER NAME24*24
CHARACTER BLAB*17
CHARACTER NAMEG*10
CHARACTER TYPE*4
CHARACTER OPTION*1,JN*1,JW*1, VOPT*1
CHARACTER LATDIR*1, LONDIR*1
CHARACTER ANSWER*1
character frame1*24
LOGICAL TEST
BLAB = 'OUTSIDE OF REGION'
WRITE(LUOUT,10)
10 FORMAT(
1 ' Displacements will be predicted from time T1 to time T2.')
WRITE(LUOUT,* ) ' Please enter T1 '
20 CALL GETMDY(MONTH1,IDAY1,IYEAR1,DATE1,MIN1,TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter T1? (y/n)'
read (luin,21,err=600,iostat=ios) ANSWER
if (ios /= 0) goto 600
21 format( A1 )
IF (ANSWER .eq. 'y' .or. ANSWER .eq. 'Y') GO TO 20
RETURN
ENDIF
WRITE(LUOUT,*) ' Please enter T2 '
35 CALL GETMDY(MONTH2,IDAY2,IYEAR2,DATE2,MIN2,TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter T2? (y/n) '
read(luin,21,err=600,iostat=ios) ANSWER
if (ios /= 0) goto 600
if (ANSWER .eq. 'y' .or. ANSWER .eq. 'Y') GO TO 35
RETURN
ENDIF
WRITE(LUOUT,45)
45 FORMAT(
1 ' Please enter the name for the file to contain'/
2 ' the predicted displacements. ')
READ(LUIN,50,err=601,iostat=ios) NAMEF
if (ios /= 0) goto 601
50 FORMAT(A80)
OPEN(I2,FILE=NAMEF,STATUS='UNKNOWN')
CALL HEADER
*** Choosing reference frame for displacements
56 WRITE(LUOUT,55)
55 FORMAT(' ************************************************'/
1 ' Select the reference frame to be used for specifying'/
2 ' positions and displacements. '/)
call MENU1(iopt, frame1)
IF(IOPT .GE. 1 .AND . IOPT .LE. numref) THEN
WRITE(I2,57) frame1
57 FORMAT(' DISPLACEMENTS IN METERS RELATIVE TO ', a24)
ELSE
WRITE(LUOUT,70)
70 FORMAT(' Improper selection--try again. ')
GO TO 56
ENDIF
WRITE(I2,71) MONTH1,IDAY1,IYEAR1,MONTH2,IDAY2,IYEAR2,
1 DATE1, DATE2
71 FORMAT (
1 ' FROM ',I2.2,'-',I2.2,'-',I4,' TO ',
2 I2.2,'-',I2.2,'-',I4,' (month-day-year)'/
2 ' FROM ',F8.3, ' TO ',F8.3, ' (decimal years)'//
3 'NAME OF SITE LATITUDE LONGITUDE ',
4 ' NORTH EAST UP ')
WRITE(LUOUT,80) !Remove label 75 (v3.3.0)
80 FORMAT(' ********************************'/
1 ' Displacements will be predicted at each point whose',/
2 ' horizontal position is specified.',/
4 ' Please indicate how you wish to supply positions.'/ )
85 WRITE(LUOUT,86)
86 FORMAT(
5 ' 0. No more points. Return to main menu.'/
6 ' 1. Individual points entered interactively.'/
7 ' 2. Points on a specified grid.'/
8 ' 3. The *80* records in a specified blue-book file.'/
9 ' 4. Points on a specified line. ' /
1 ' 5. Batch file of delimited records of form: ' /
2 ' LAT,LON,TEXT ' /
4 ' LAT = latitude in degrees (positive north/DBL PREC)' /
5 ' LON = longitude in degrees (positive west/DBL PREC)' /
7 ' TEXT = Descriptive text (CHARACTER*24) ' /
8 ' Example: ' /
9 ' 40.731671553,112.212671753,SALT AIR '/)
READ(LUIN,'(A1)',err=602,iostat=ios) OPTION
if (ios /= 0) goto 602
IF(OPTION .EQ. '0') THEN
GO TO 510
ELSEIF(OPTION .EQ. '1') THEN
CALL GETPNT(LATD,LATM,SLAT,LATDIR,LOND,LONM,SLON,
1 LONDIR,NAME24, X,Y,Z,YLAT,YLON,EHT)
ELON = -YLON
call GETVLY(YLAT,ELON,VX,VY,VZ,VN,VE,VU,VOPT,210)
if (vopt .eq. '0') then
call PREDV( ylat, ylon, eht, date1, iopt,
1 jregn, vn, ve, vu)
if (jregn .eq. 0) then
write(luout, 140)
go to 85
endif
endif
call NEWCOR(ylat, ylon, eht, min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
140 FORMAT(' ****************************************'/
1 ' A displacement can not be predicted because'/
1 ' the point is outside of the modeled region.'/
2 ' For additional displacements, please indicate how'/
3 ' you wish to supply the horizontal coordinates.'/)
WRITE(LUOUT,150) DN, DE,DU
150 FORMAT(' *****************************************'/
1 ' Northward displacement = ',F7.3,' meters'/
1 ' Eastward displacement = ',F7.3,' meters'/
1 ' Upward displacement = ',F7.3,' meters'/
1 ' *****************************************'//
2 ' For additional displacements, please indicate how'/
3 ' you wish to supply the horizontal coordinates.'/)
WRITE(I2,160) NAME24,LATD,LATM,SLAT,LATDIR,
1 LOND,LONM,SLON,LONDIR,DN,DE,DU
160 FORMAT(A24,1X,I2,1X,I2,1X,F8.5,1X,A1,2X,
1 I3,1X,I2,1X,F8.5,1X,A1,1X,3F8.3)
ELSEIF(OPTION .EQ. '2') THEN
CALL GETGRD(NAMEG,MINLAT,MAXLAT,IDS,MINLON,MAXLON,JDS)
I = -1
280 I = I + 1
LAT = MINLAT + I*IDS
IF(LAT .GT. MAXLAT) GO TO 296
XLAT = DBLE(LAT)/RHOSEC
CALL TODMSS(XLAT,LATD,LATM,SLAT,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
J = -1
290 J = J + 1
YLAT = XLAT
LON = MINLON + J*JDS
IF(LON .GT. MAXLON) GO TO 280
YLON = DBLE(LON)/RHOSEC
CALL TODMSS(YLON,LOND,LONM,SLON,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
EHT = 0.D0
call PREDV(ylat,ylon, eht, date1, iopt,
1 jregn, vn, ve, vu)
IF(JREGN .eq. 0) THEN
WRITE(I2,291)NAMEG,I,J,LATD,LATM,SLAT,LATDIR,LOND,
1 LOND,LONM,SLON,LONDIR,BLAB
291 FORMAT(A10,2I4, 7X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,
1 1X,I2,1X,F8.5,1X,A1,1X,A17)
ELSE
call NEWCOR( ylat, ylon, eht, min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
WRITE(I2,295)NAMEG,I,J,LATD,LATM,SLAT,LATDIR,
1 LOND,LONM,SLON,LONDIR,DN,DE,DU
295 FORMAT(A10,2I4, 7X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,
1 1X,F8.5,1X,A1,1X,3F8.3)
ENDIF
GO TO 290
296 WRITE(LUOUT,297)
297 FORMAT(' ***********************************'/
1 ' Displacements have been calculated for the specified'/
2 ' grid. If you wish to calculate additional displacements,'/
3 ' please indicate how you will supply the coordinates.'/)
ELSEIF(OPTION .EQ. '3') THEN
VOPT = '0'
WRITE(LUOUT,300)
300 FORMAT(' Enter name of blue-book file ')
READ(LUIN,310,err=603,iostat=ios) NAMEBB
if (ios /= 0) goto 603
310 FORMAT(A80)
OPEN(I1,FILE=NAMEBB,STATUS='OLD')
320 READ(I1,330,END=350,err=604,iostat=ios) CARD
if (ios /= 0) goto 604
330 FORMAT(A80)
TYPE = CARD(7:10)
IF(TYPE .EQ. '*80*') THEN
READ(CARD,340,err=605,iostat=ios) NAME,LATD,LATM,SLAT,JN,
1 LOND,LONM,SLON,JW
if (ios /= 0) goto 605
340 FORMAT(BZ,14X,A30,I2,I2,F7.5,A1,I3,I2,F7.5,A1)
NAME24 = NAME(1:24)
C IF(JN.EQ.'S' .OR. JW.EQ.'E')GO TO 320
YLAT =(DBLE((LATD*60+LATM)*60)+SLAT)/RHOSEC
IF (JN .eq. 'S') YLAT = -YLAT
YLON =(DBLE((LOND*60+LONM)*60)+SLON)/RHOSEC
IF (JW .eq. 'E') YLON = -YLON
EHT = 0.D0
call PREDV( ylat, ylon, eht, date1, iopt,
1 jregn, vn, ve, vu)
IF(JREGN .EQ. 0) THEN
WRITE(I2,345)NAME24,LATD,LATM,SLAT,JN,LOND,LONM,SLON,
1 JW,BLAB
345 FORMAT(A24,1X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,1X,
1 F8.5,1X,A1,1X,A17)
ELSE
call NEWCOR( ylat, ylon, eht, min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
WRITE(I2,160)NAME24,LATD,LATM,SLAT,JN,LOND,LONM,SLON,
1 JW,DN,DE,DU
ENDIF
ENDIF
GO TO 320
350 CLOSE(I1,STATUS='KEEP')
WRITE(LUOUT,360)
360 FORMAT(' ************************************'/
1 ' Displacements have been calculated for the specified'/
2 ' blue-book file. If you wish to calculate additional'/
3 ' displacements, please indicate how you will supply'/
4 ' the horizontal coordinates.'/)
ELSEIF(OPTION .EQ. '4') THEN
VOPT = '0'
CALL GETLYN(NAMEG,XLAT,XLON,FAZ,BAZ,XMIN,XMAX,XINC)
XLON = TWOPI - XLON
I = -1
400 I = I + 1
S = XMIN + I*XINC
IF(S .GT. XMAX) GO TO 430
IF(S .LT. 0.0D0) THEN
S1 = -S
AZ = BAZ
ELSE
S1 = S
AZ = FAZ
ENDIF
CALL DIRCT1(XLAT,XLON,YLAT,YLON,AZ,AZ1,S1)
YLON = TWOPI - YLON
CALL TODMSS(YLAT,LATD,LATM,SLAT,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
CALL TODMSS(YLON,LOND,LONM,SLON,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
EHT = 0.D0
call PREDV( ylat, ylon, eht, date1, iopt,
1 jregn, vn, ve, vu)
IF(JREGN .eq. 0) THEN
WRITE(I2,405)NAMEG,I,LATD,LATM,SLAT,LATDIR,
1 LOND,LONM,SLON,LONDIR, BLAB
405 FORMAT(A10,I4,11X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,1X,
1 F8.5,1X,A1,1X,A17)
ELSE
call NEWCOR( ylat, ylon, eht, min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
WRITE(I2,410)NAMEG,I,LATD,LATM,SLAT,LATDIR,LOND,LONM,
1 SLON,LONDIR,DN,DE,DU
410 FORMAT(A10,I4,11X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,
1 1X,F8.5,1X,A1,1X,3F8.3)
ENDIF
GO TO 400
430 WRITE(LUOUT,440)
440 FORMAT(' ***************************************'/
1 ' Displacements have been calculated for the specified'/
2 ' line. If you wish to calculate additional displacements,'/
3 ' please indicate how you will supply the coordinates.'/)
ELSEIF(OPTION .EQ. '5') THEN
VOPT = '0'
EHT = 0.0D0
write(luout,450)
450 format(' Enter name of batch file ')
read(luin, 451,err=606,iostat=ios) NAMEIF
if (ios /= 0) goto 606
451 format(A80)
open(I1,FILE=NAMEIF,STATUS='OLD')
LINE = 0 !Inititalize line number of input file.
455 read(I1,'(a)',END=460,err=607,iostat=ios) record
if (ios /= 0) goto 607
call interprate_latlon_record (record,XLAT,XLON,name24)
LINE = LINE + 1 !Increment line number of input file.
*** If latitude magnitudes > 90 degrees or longitude magnitude > 360 degrees,
*** write error message and terminate program (added for v3.3.0).
IF ((DABS(XLAT) .GT. 90).OR.(DABS(XLON) .GT. 360)) THEN
WRITE(*,*)'***********************************************'
WRITE(*,*)'Invalid latitude or longitude in input file'
WRITE(*,4551)'on line', LINE, ':'
WRITE(*,4552) XLAT, XLON, name24
WRITE(*,*)'Please check your input file and try again.'
WRITE(*,*)'***********************************************'
4551 FORMAT (1X, A, I8, A/)
4552 FORMAT (1X, 2F17.10, 2X, A/)
STOP
ENDIF
YLAT = (XLAT*3600.D0)/RHOSEC
YLON = (XLON*3600.D0)/RHOSEC
CALL TODMSS(YLAT,LATD,LATM,SLAT,ISIGN)
IF (ISIGN .EQ. 1) THEN
JN = 'N'
ELSE
JN = 'S'
ENDIF
CALL TODMSS(YLON, LOND,LONM,SLON,ISIGN)
IF (ISIGN .EQ. 1) THEN
JW = 'W'
ELSE
JW = 'E'
ENDIF
CALL PREDV(YLAT,YLON,EHT,DATE1,IOPT,
1 JREGN,VN,VE,VU)
IF (JREGN .EQ. 0) THEN
Write(I2,345) NAME24,LATD,LATM,SLAT, JN,
1 LOND,LONM,SLON,JW, BLAB
ELSE
CALL NEWCOR (YLAT, YLON, EHT, MIN1, MIN2,
1 YLATT, YLONT, EHTNEW, DN,DE,DU,VN,VE,VU)
WRITE(I2, 160) NAME24, LATD, LATM, SLAT, JN,
1 LOND, LONM, SLON, JW, DN, DE , DU
ENDIF
GO TO 455
460 CLOSE(I1, STATUS = 'KEEP')
write(LUOUT, 470)
470 format(' ******************************************'/
1 ' Displacements have been calculated for the specified'/
1 ' file. If you wish to calculate additional displacements,'/
1 ' please indicate how you will supply the horizontal '/
1 ' coordinates.'/)
ELSE
WRITE(LUOUT,500)
500 FORMAT(' Improper entry--select again. ')
ENDIF
GO TO 85
510 CONTINUE
CLOSE(I2, STATUS = 'KEEP')
RETURN
600 write (*,'(/)')
write (*,*) 'Wrong answer in DPLACE: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
601 write (*,'(/)')
write (*,*) 'Wrong file name in DPLACE: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
602 write (*,'(/)')
write (*,*) 'Wrong OPTION in DPLACE: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
603 write (*,'(/)')
write (*,*) 'Wrong bbname in DPLACE: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
604 write (*,'(/)')
write (*,*) 'Wrong CARD from bbfile in DPLACE:ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
605 write (*,'(/)')
write (*,*) 'Wrong CARD80 from bbfile in DPLACE:ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
606 write (*,'(/)')
write (*,*) 'Wrong batch file name in DPLACE:ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
607 write (*,'(/)')
write (*,*) 'Wrong record from batch in DPLACE:ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
********************************************************************
SUBROUTINE VELOC
*** Compute velocities at specified locations
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (numref = 16)
parameter (nrsrch = 0)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
CHARACTER CARD*80
CHARACTER NAMEF*80,NAME*80,NAMEBB*80,PVFILE*80
CHARACTER NAME24*24
CHARACTER BLAB*17
CHARACTER NAMEG*10
CHARACTER TYPE*4
CHARACTER OPTION*1,JN*1,JW*1,PVOUT*1
CHARACTER LATDIR*1, LONDIR*1
character frame1*24
character record*120
*** Commented out following temporary code (v3.3.0).
*** temporary code to plot results ****************
C character TEMPNA*8 !Added string length to match string below.
C
C TEMPNA = ' '
C DUMMY = 0.0D0
*** end of temporary code *************************
BLAB = 'OUTSIDE OF REGION'
WRITE(LUOUT,10)
10 FORMAT(' Please enter name for the file to contain the'/
1 ' predicted velocities. ')
READ(LUIN,20,err=700,iostat=ios) NAMEF
if (ios /= 0) goto 700
20 FORMAT(A80)
OPEN(I2,FILE=NAMEF,STATUS='UNKNOWN')
CALL HEADER
if (nrsrch .eq. 1) then
WRITE(LUOUT,21)
21 FORMAT(
1 ' Do you want to create a file of point-velocity (PV)'/
1 ' records for use with the DYNAPG software (y/n)? ')
READ(LUIN,'(A1)',err=701,iostat=ios) PVOUT
if (ios /= 0) goto 701
IF(PVOUT .EQ. 'Y' .OR. PVOUT .EQ. 'y') THEN
PVOUT = 'Y'
WRITE(LUOUT,22)
22 FORMAT(' Enter name for the file that is to contain'/
1 ' the PV records. ')
READ(LUIN,'(A80)',err=702,iostat=ios) PVFILE
if (ios /= 0) goto 702
OPEN(I3,FILE = PVFILE, STATUS = 'UNKNOWN')
ENDIF
else
PVOUT = 'N'
endif
*** Choosing reference system for velocities
1000 WRITE(LUOUT,1001)
1001 FORMAT(' **************************************************'/
1 ' Select the reference frame to be used for specifying'/
2 ' positions and velocities. '/
c 6 ' 0...Positions in NAD 83 and velocities relative to'/
c 6 ' a specified point having a specified velocity.')
6 )
call MENU1(iopt, frame1)
if (iopt .ge. 1 .and. iopt .le. numref) then
WRITE(I2,1002) frame1
1002 FORMAT('VELOCITIES IN MM/YR RELATIVE TO ', a24 )
RVN = 0.0D0
RVE = 0.0D0
RVU = 0.0D0
ELSEIF(IOPT .EQ. 0) THEN
WRITE(LUOUT,1010)
CALL GETPNT(LATD,LATM,SLAT,LATDIR,LOND,LONM,SLON,
1 LONDIR, NAME24, X,Y,Z,YLAT,YLON,EHT)
CALL GETREG(YLAT,YLON,JREGN)
IF(JREGN .EQ. 0 ) THEN
WRITE(LUOUT,1008)
1008 FORMAT(' **********************************'/
1 ' Point is not in modeled region and it can not'/
1 ' be used as the reference location.'/)
GO TO 1000
ENDIF
WRITE(I2,1009)
1009 FORMAT('VELOCITIES IN MM/YR IN A REFERENCE FRAME FOR ',
1 'WHICH THE FIRST POINT LISTED'/
2 'BELOW HAS THE VELOCITY AS LISTED'//
4 '**************REFERENCE SITE')
1010 FORMAT(' For the reference point...'/)
WRITE(LUOUT,1030)
1030 FORMAT(' Enter northward velocity of reference location'/
1 ' in mm/yr. ')
READ(LUIN,*,err=703,iostat=ios) SVN
if (ios /= 0) goto 703
WRITE(LUOUT,1040)
1040 FORMAT(' Enter eastward velocity of reference location'/
1 ' in mm/yr. ')
READ(LUIN,*,err=703,iostat=ios) SVE
if (ios /= 0) goto 703
WRITE(LUOUT,1050)
1050 FORMAT(' Enter upward velocity of the reference location'/
1 ' in mm/yr. ')
READ(LUIN,*,err=703,iostat=ios) SVU
if (ios /= 0) goto 703
CALL COMVEL(YLAT,YLON,JREGN,VN,VE,VU)
RVN = SVN - VN
RVE = SVE - VE
RVU = SVU - VU
GLON = -YLON
CALL TOVXYZ(YLAT,GLON,SVN,SVE,SVU,SVX,SVY,SVZ)
WRITE(I2,1060) NAME24,LATD,LATM,SLAT,LATDIR,SVN,LOND,LONM,
1 SLON,LONDIR,SVE,EHT,SVU,X,SVX,Y,SVY,Z,SVZ
1060 FORMAT(/A24,/
1'LATITUDE = ',2I3,F9.5,1X,A1,' NORTH VELOCITY =',F7.2,' mm/yr'/
2'LONGITUDE = ',2I3,F9.5,1X,A1,' EAST VELOCITY =',F7.2,' mm/yr'/
3'ELLIPS. HT. = ',F10.3,' m', 6X,'UP VELOCITY =',F7.2,' mm/yr'/
4'X =',F13.3,' m',14X, 'X VELOCITY =',F7.2,' mm/yr'/
5'Y =',F13.3,' m',14X, 'Y VELOCITY =',F7.2,' mm/yr'/
6'Z =',F13.3,' m',14X, 'Z VELOCITY =',F7.2,' mm/yr')
WRITE(I2,1070)
1070 FORMAT('******************************')
ELSE
write(luout, 1080)
1080 format(' Improper selection -- try again. ')
GO TO 1000
ENDIF
*** Choosing input format for locations where velocities are to be predicted
WRITE(LUOUT,30)
30 FORMAT(' ************************************************'/
1 ' Velocities will be predicted at each point whose'/
2 ' horizontal position is specified. Please indicate'/
4 ' how you wish to supply positions.'/)
40 WRITE(LUOUT,50)
50 FORMAT(
1 ' 0... No more points. Return to main menu.'/
2 ' 1... Individual points entered interactively.'/
3 ' 2... Points on a specified grid.'/
4 ' 3... The *80* records in a specified blue-book file.'/
5 ' 4... Points on a specified line. '/
6 ' 5... Batch file of delimited records of form: '/
7 ' LAT,LON,TEXT '/
8 ' LAT = latitude in degrees (positive north/DBL PREC) '/
9 ' LON = longitude in degrees (positive west/DBL PREC) '/
1 ' TEXT = Descriptive text (CHARACTER*24) '/
1 ' Example: '/
2 ' 40.731671553,112.212671753,SALT AIR '/)
READ(LUIN,60,err=704,iostat=ios) OPTION
if (ios /= 0) goto 704
60 FORMAT(A1)
IF(OPTION .EQ. '0') THEN
GO TO 610
ELSEIF(OPTION .EQ. '1') THEN
CALL GETPNT(LATD,LATM,SLAT,LATDIR,LOND,LONM,SLON,
1 LONDIR, NAME24, X,Y,Z,YLAT,YLON,EHT)
CALL GTOVEL(YLAT,YLON,EHT,RVN,RVE,RVU,
1 VN,VE,VU,VX,VY,VZ,JREGN,IOPT)
IF(JREGN .eq. 0 ) THEN
WRITE(LUOUT,80)
80 FORMAT(' *************************************'/
1 ' A velocity can not be predicted because'/
1 ' the point is outside of the modeled region.'/
2 ' For additional velocities, please indicate how'/
3 ' you wish to supply the horizontal coordinates.'/)
ELSE
WRITE(LUOUT,90) VN, VE, VU, VX, VY, VZ
90 FORMAT(' **************************************'/
1 ' Northward velocity = ',F6.2,' mm/yr'/
1 ' Eastward velocity = ',F6.2,' mm/yr'/
1 ' Upward velocity = ',F6.2,' mm/yr'//
1 ' X-dim. velocity = ',F6.2,' mm/yr'/
1 ' Y-dim. velocity = ',F6.2,' mm/yr'/
1 ' Z-dim. velocity = ',F6.2,' mm/yr'/
1 ' **************************************'//
2 ' For additional velocities, please indicate how'/
3 ' you wish to specify the horizontal coordinates.'/)
WRITE(I2,1060)NAME24,LATD,LATM,SLAT,LATDIR,VN,LOND,LONM,
1 SLON, LONDIR, VE, EHT,VU,X,VX,Y,VY,Z,VZ
100 FORMAT(A24,1X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,1X,F8.5,
1 1X,A1,1X,3F8.2)
IF(PVOUT .EQ. 'Y') THEN
CALL PVPRNT(LATD,LATM,SLAT,LOND,LONM,SLON,VN,VE,VU)
ENDIF
ENDIF
ELSEIF(OPTION .EQ. '2') THEN
EHT = 0.D0
WRITE(I2,105)
105 FORMAT(
1 'NAME OF SITE',14X,'LATITUDE LONGITUDE ',
2 ' NORTH EAST UP'/)
106 FORMAT(
1 'NAME OF LINE', 6X,'LATITUDE LONGITUDE ',
2 ' NORTH EAST UP'/)
CALL GETGRD(NAMEG,MINLAT,MAXLAT,IDS,MINLON,MAXLON,JDS)
I = -1
110 I = I + 1
LAT = MINLAT + I*IDS
IF(LAT .GT. MAXLAT) GO TO 150
XLAT = DBLE(LAT)/RHOSEC
CALL TODMSS(XLAT,LATD,LATM,SLAT,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
J = -1
120 J = J + 1
YLAT = XLAT
LON = MINLON + J*JDS
IF(LON .GT. MAXLON) GO TO 110
YLON = DBLE(LON)/RHOSEC
CALL TODMSS(YLON,LOND,LONM,SLON,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
CALL GTOVEL(YLAT,YLON,EHT,RVN,RVE,RVU,
1 VN,VE,VU,VX,VY,VZ,JREGN,IOPT)
IF(JREGN .EQ. 0 ) THEN
WRITE(I2,125)NAMEG,I,J,LATD,LATM,SLAT,LATDIR,LOND,LONM,
1 SLON,LONDIR,BLAB
125 FORMAT(A10,2I4, 7X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,
1 1X,F8.5,1X,A1, 1X,A17)
ELSE
*** Commented out following temporary code (v3.3.0).
*** temporary code to plot results
C ZLAT = DBLE(LATD) + DBLE(LATM)/60.D0 + SLAT/3600.D0
C ZLON = DBLE(LOND) + DBLE(LONM)/60.D0 + SLON/3600.D0
C ZLON = 360.D0 - ZLON
C TOTVEL = DSQRT(VN*VN + VE*VE)
C
*** code to create vectors to be plotted
C IF (TOTVEL .GE. 5.0D0 .AND. TOTVEL .LE. 50.D0) THEN
C TVE = VE/10.D0
C TVN = VN/10.D0
C WRITE(I2,129) ZLON,ZLAT,TVE,TVN,DUMMY,DUMMY,DUMMY,
C 1 TEMPNA
C 129 FORMAT(F10.6, 2x, F9.6, 2X, 5(F7.2, 2x), A8)
C ENDIF
C
*** code to create contour plots
C WRITE(I2,129) ZLON, ZLAT, TOTVEL
C 129 FORMAT(F6.2, 1X, F6.2, 1X, F5.1)
*** end of temporary code
*** beginning of original code
WRITE(I2,130)NAMEG,I,J,LATD,LATM,SLAT,LATDIR,
1 LOND,LONM,SLON,LONDIR,VN,VE,VU
130 FORMAT(A10,2I4, 7X,I2,1X,I2,1X,F8.5,1X,A1,2X,
1 I3,1X,I2,1X,F8.5,1X,A1,1X,3F8.2)
*** end of original code
IF(PVOUT .EQ. 'Y') THEN
CALL PVPRNT(LATD,LATM,SLAT,LOND,LONM,SLON,VN,VE,VU)
ENDIF
ENDIF
GO TO 120
150 WRITE(LUOUT,160)
160 FORMAT(' **********************************************'/
1 ' Velocities have been calculated for the specified grid.'/
2 ' If you wish to calculate additional velocities, please'/
3 ' indicate how you will specify positional coordinates.'/)
ELSEIF(OPTION .EQ. '3') THEN
EHT = 0.D0
WRITE(I2,105)
WRITE(LUOUT,200)
200 FORMAT(' Enter name of blue-book file. ')
READ(LUIN,210,err=705,iostat=ios) NAMEBB
if (ios /= 0) goto 705
210 FORMAT(A80)
OPEN(I1,FILE=NAMEBB,STATUS='OLD')
220 READ(I1,230,END=250,err=706,iostat=ios) CARD
if (ios /= 0) goto 706
230 FORMAT(A80)
TYPE = CARD(7:10)
IF(TYPE .EQ. '*80*') THEN
READ(CARD,240,err=707,iostat=ios)NAME,LATD,LATM,SLAT,JN,
1 LOND,LONM,SLON,JW
if (ios /= 0) goto 707
240 FORMAT(BZ,14X,A30,I2,I2,F7.5,A1,I3,I2,F7.5,A1)
NAME24 = NAME(1:24)
YLAT =(DBLE((LATD*60+LATM)*60)+SLAT)/RHOSEC
YLON =(DBLE((LOND*60+LONM)*60)+SLON)/RHOSEC
if (jn .eq. 'S') ylat = -ylat
if (jw .eq. 'E') ylon = -ylon
CALL GTOVEL(YLAT,YLON,EHT,RVN,RVE,RVU,
1 VN,VE,VU,VX,VY,VZ,JREGN,IOPT)
IF(JREGN .EQ. 0 ) THEN
WRITE(I2,245)NAME24,LATD,LATM,SLAT,JN,LOND,LONM,
1 SLON,JW,BLAB
245 FORMAT(A24,1X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,
1 1X,F8.5,1X,A1,1X,A17)
ELSE
WRITE(I2,100)NAME24,LATD,LATM,SLAT,JN,LOND,LONM,
1 SLON,JW,VN,VE,VU
IF(PVOUT .EQ. 'Y') THEN
CALL PVPRNT(LATD,LATM,SLAT,LOND,LONM,SLON,VN,VE,VU)
ENDIF
ENDIF
ENDIF
GO TO 220
250 CLOSE(I1,STATUS='KEEP')
WRITE(LUOUT,260)
260 FORMAT(' ****************************************'/
1 ' Velocities have been calculated for the specified '/
2 ' blue-book file. If you wish to calculate additional'/
3 ' velocities, please indicate how you will supply the'/
4 ' horizontal coordinates.'/)
ELSEIF(OPTION .EQ. '4') THEN
EHT = 0.D0
WRITE(I2,106)
CALL GETLYN(NAMEG,XLAT,XLON,FAZ,BAZ,XMIN,XMAX,XINC)
XLON = TWOPI - XLON
I = -1
300 I= I+1
S = XMIN + I*XINC
IF(S .GT. XMAX) GO TO 330
IF(S .LT. 0.0D0) THEN
S1 = -S
AZ = BAZ
ELSE
S1 = S
AZ = FAZ
ENDIF
CALL DIRCT1(XLAT,XLON,YLAT,YLON,AZ,AZ1,S1)
YLON = TWOPI - YLON
CALL TODMSS(YLAT,LATD,LATM,SLAT,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
CALL TODMSS(YLON,LOND,LONM,SLON,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
CALL GTOVEL(YLAT,YLON,EHT,RVN,RVE,RVU,
1 VN,VE,VU,VX,VY,VZ,JREGN,IOPT)
IF(JREGN .EQ. 0 ) THEN
WRITE(I2,305)NAMEG,I,LATD,LATM,SLAT,LATDIR,LOND,LONM,
1 SLON,LONDIR,BLAB
305 FORMAT(A10,I4,3X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,
1 I2,1X,F8.5,1X,A1,1X,A17)
ELSE
WRITE(I2,310)NAMEG,I,LATD,LATM,SLAT,LATDIR,LOND,LONM,SLON,
1 LONDIR,VN,VE,VU
310 FORMAT(A10,I4,3X,I2,1X,I2,1X,F8.5,1X,A1,2X,I3,1X,I2,1X,
1 F8.5,1X,A1,1X,3F8.2)
IF(PVOUT .EQ. 'Y') THEN
CALL PVPRNT(LATD,LATM,SLAT,LOND,LONM,SLON,VN,VE,VU)
ENDIF
ENDIF
GO TO 300
330 WRITE(LUOUT,340)
340 FORMAT(' ***********************************************'/
1 ' Velocities have been calculated for the specified line.'/
2 ' If you wish to calculate additional velocities, please'/
3 ' indicate how you will specify positional coordinates.'/)
ELSEIF(OPTION .EQ. '5') THEN
EHT = 0.0D0
WRITE(I2, 105)
WRITE(LUOUT,400)
400 FORMAT(' Enter name of input file. ')
READ(LUIN,410,err=708,iostat=ios) NAMEBB
if (ios /= 0) goto 708
410 FORMAT(A80)
OPEN(I1,FILE=NAMEBB,STATUS='OLD')
LINE = 0 !Inititalize line number of input file.
420 READ(I1,'(a)',END=450,err=709,iostat=ios) record
call interprate_latlon_record (record,XLAT,XLON,NAME24)
if (ios /= 0) goto 709
LINE = LINE + 1 !Increment line number of input file.
*** If latitude magnitudes > 90 degrees or longitude magnitude > 360 degrees,
*** write error message and terminate program (added for v3.3.0).
IF ((DABS(XLAT) .GT. 90).OR.(DABS(XLON) .GT. 360)) THEN
WRITE(*,*)'***********************************************'
WRITE(*,*)'Invalid latitude or longitude in input file'
WRITE(*,4201)'on line', LINE, ':'
WRITE(*,4202) XLAT, XLON, name24
WRITE(*,*)'Please check your input file and try again.'
WRITE(*,*)'***********************************************'
4201 FORMAT (1X, A, I8, A/)
4202 FORMAT (1X, 2F17.10, 2X, A/)
STOP
ENDIF
YLAT = (XLAT*3600.D0)/RHOSEC
YLON = XLON*3600.d0/RHOSEC
CALL TODMSS(YLAT, LATD, LATM, SLAT, ISIGN)
IF (ISIGN .eq. 1) then
JN = 'N'
Else
JN = 'S'
endif
call TODMSS(YLON, LOND, LONM, SLON, ISIGN)
IF (ISIGN .eq. 1) then
JW = 'W'
else
JW = 'E'
endif
CALL GTOVEL(YLAT,YLON,EHT,RVN,RVE, RVU,
1 VN,VE,VU,VX,VY,VZ,JREGN,IOPT)
IF (JREGN .eq. 0) then
write(I2,245)NAME24,LATD,LATM,SLAT,JN,
1 LOND,LONM,SLON,JW,BLAB
ELSE
write(I2,100)NAME24,LATD,LATM,SLAT,JN,
1 LOND,LONM,SLON,JW,VN,VE,VU
IF(PVOUT .EQ. 'Y') then
call PVPRNT(LATD,LATM,SLAT,LOND,LONM,SLON,VN,VE,VU)
ENDIF
ENDIF
GO TO 420
450 CLOSE(I1, STATUS = 'KEEP')
write(LUOUT, 460)
460 format(' ********************************'/
1 ' Velocities have been calculated for the specified'/
2 ' file. if you wish to calculate additional velocities, '/
3 ' please indicate how you will supply the coordinates.'/)
ELSE
WRITE(LUOUT,600)
600 FORMAT(' Improper entry--select again. ')
ENDIF
GO TO 40
610 CONTINUE
CLOSE(I2, STATUS = 'KEEP')
IF( PVOUT .EQ. 'Y') CLOSE(I3, STATUS = 'KEEP')
RETURN
700 write (*,'(/)')
write (*,*) 'Failed to read file name: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
701 write (*,'(/)')
write (*,*) 'Failed to read answer: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
702 write (*,'(/)')
write (*,*) 'Failed to read file name: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
703 write (*,'(/)')
write (*,*) 'Failed to read velocity: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
704 write (*,'(/)')
write (*,*) 'Failed to read OPTION: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
705 write (*,'(/)')
write (*,*) 'Failed to read name of bbfile: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
706 write (*,'(/)')
write (*,*) 'Failed to read card from bbfile: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
707 write (*,'(/)')
write (*,*) 'Failed to read card80 from bbfile: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
708 write (*,'(/)')
write (*,*) 'Failed to read file name: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
709 write (*,'(/)')
write (*,*) 'Failed to read bbfile: ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
**************************************************************************
SUBROUTINE GTOVEL(YLAT,YLON,EHT,RVN,RVE,RVU,
1 VN,VE,VU,VX,VY,VZ,JREGN,IOPT)
*** Compute velocity in appropriate reference frame for point with
*** latitude YLAT (radians), longitude YLON (radians, positive west)
*** and ellipsoid height EHT (meters) in this reference frame.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
logical Is_iopt_NAD83
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
Is_iopt_NAD83 = (IOPT == 1)
*** Get reference latitude RLAT and reference longitude RLON in NAD 83
c IF(IOPT .EQ. 0 .OR. IOPT .EQ. 1) THEN !Not NAD83 anymore
IF(IOPT .EQ. 15) THEN
RLAT = YLAT
*** Added conditional statement to get rid of out-of-region error when
*** YLON is negative for reference frame (v3.3.0):
IF(YLON .GE. 0.D0) THEN
RLON = YLON
ELSE
RLON = YLON + TWOPI
ENDIF
ELSE
ELON = -YLON
CALL TOXYZ(YLAT,ELON,EHT,X,Y,Z)
DATE = 2010.0d0
c CALL XTONAD(X,Y,Z,RLAT,RLON,EHTNAD,DATE,IOPT) !Removed on 09/12/2014. The velocity grids are not converted to NAD83 anymore.
CALL XTO08 (X,Y,Z,RLAT,RLON,EHT08,DATE,IOPT) !They are in ITRF2008
ENDIF
*** Get velocity in NAD 83 !Not anymore since 09/12/2014. Now it is in ITRF2008
CALL GETREG(RLAT,RLON,JREGN)
IF (JREGN .EQ. 0) RETURN
CALL COMVEL(RLAT,RLON,JREGN,VN,VE,VU)
VN = VN + RVN
VE = VE + RVE
VU = VU + RVU
ELON = -YLON
CALL TOVXYZ(YLAT,ELON,VN,VE,VU,VX,VY,VZ)
*** Convert velocity into another reference frame if needed
c IF(IOPT .NE. 0 .AND. IOPT .NE. 1) THEN !Commented out on 09/12/2014
IF(IOPT .NE. 15) THEN
IF(Is_iopt_NAD83) THEN
c CALL VTRANF(X,Y,Z,VX,VY,VZ, 1, IOPT) !No longer NAD83
CALL VTRANF(X,Y,Z,VX,VY,VZ, 15, IOPT) !No longer NAD83
else
CALL VTRANF_IERS(X,Y,Z,VX,VY,VZ, 15, IOPT) !Now ITRF2008
endif
CALL TOVNEU(YLAT, ELON, VX, VY, VZ, VN, VE, VU)
ENDIF
RETURN
END
****************************************************************************
SUBROUTINE XTO08 (X,Y,Z,RLAT,WLON,EHT08,DATE,IOPT)
*** Converts X,Y,Z in specified datum to latitude and
*** longitude (in radians) and height (meters) in ITRF2008
*** datum with longitude positive west.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
LOGICAL FRMXYZ
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
*** Convert to cartesian coordinates in ITRF2008
c if (iopt .eq. 0 .or. iopt .eq. 1) then
if (iopt .eq. 15) then
x2 = x
y2 = y
z2 = z
elseif (iopt .eq. 1) then
call toit94(x,y,z,x1,y1,z1,date,iopt)
call frit94(x1,y1,z1,x2,y2,z2,date,15)
else
call toit94_iers(x,y,z,x1,y1,z1,date,iopt)
call frit94_iers(x1,y1,z1,x2,y2,z2,date,15)
endif
***Convert to geodetic coordinates
IF(.NOT.FRMXYZ(X2,Y2,Z2,RLAT,ELON,EHT08))STOP 666
WLON = -ELON
100 IF(WLON .LT. 0.D0) THEN
WLON = WLON + TWOPI
GO TO 100
ENDIF
c write (*,*) "FROM XT08 ",RLAT*180.d0/pi,WLON*180.d0/pi,EHT08
RETURN
END
****************************************************************************
SUBROUTINE XTONAD (X,Y,Z,RLAT,WLON,EHTNAD,DATE,IOPT)
*** Converts X,Y,Z in specified datum to latitude and
*** longitude (in radians) and height (meters) in NAD 83
*** datum with longitude positive west.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
LOGICAL FRMXYZ
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
*** Convert to cartesian coordinates in NAD 83
if (iopt .eq. 0 .or. iopt .eq. 1) then
x2 = x
y2 = y
z2 = z
else
call toit94(x,y,z,x1,y1,z1,date,iopt)
jopt = 1
call frit94(x1,y1,z1,x2,y2,z2,date,jopt)
endif
***Convert to geodetic coordinates
IF(.NOT.FRMXYZ(X2,Y2,Z2,RLAT,ELON,EHTNAD))STOP 666
WLON = -ELON
100 IF(WLON .LT. 0.D0) THEN
WLON = WLON + TWOPI
GO TO 100
ENDIF
RETURN
END
******************************************************
subroutine TRFPOS
*** Transform position between reference frames
implicit double precision (a-h,o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
parameter (nbbdim = 10000)
parameter (rad2deg = 180.d0/3.14159265358979d0)
character card*80,namebb*80,nameif*80,name24*80
character record*120
character NAMEF*80
character frame1*24, frame2*24
character jn*1,jw*1,LATDIR*1,LONDIR*1
character option*1, answer*1, vopt*1
character PID*6,PIDs*6
character HTDP_version*8
LOGICAL FRMXYZ
LOGICAL TEST
LOGICAL Is_inp_NAD83,Is_out_NAD83
LOGICAL Is_inp_NAD83PAC,Is_out_NAD83PAC
LOGICAL Is_inp_NAD83MAR,Is_out_NAD83MAR
COMMON /CONST/ A, F, E2, EPS, AF, PI, TWOPI, RHOSEC
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /ARRAYS/ HT(nbbdim), LOC(nbbdim),PIDs(nbbdim)
COMMON /VERSION/ HTDP_version
write(luout,80)
80 format(
1 ' Please enter the name for the file to contain'/
2 ' the transformed positions. ')
read(luin,'(A80)',err=600,iostat=ios) namef
if (ios /= 0) goto 600
open(i2, file = namef, status = 'unknown')
CALL HEADER
95 write(luout,100)
100 format (' *******************************************'/
1 ' Enter the reference frame of the input positions')
call MENU1(iopt1, frame1)
if (iopt1 .lt. 1 .or. iopt1 .gt. numref) then
write(luout,*) ' Improper selection -- try again. '
go to 95
endif
Is_inp_NAD83 = (iopt1 == 1 .and. frame1(1:3) /= "WGS")
Is_inp_NAD83PAC = (iopt1 == 12)
Is_inp_NAD83MAR = (iopt1 == 13)
105 write(luout,110)
110 format (/' Enter the reference frame for the output positions')
call MENU1(iopt2, frame2)
if (iopt2 .lt. 1 .or. iopt2 .gt. numref) then
write(luout,*) ' Improper selection -- try again. '
go to 105
endif
Is_out_NAD83 = (iopt2 == 1 .and. frame2(1:3) /= "WGS") !Changed from frame1 in v3.3.0.
Is_out_NAD83PAC = (iopt2 == 12)
Is_out_NAD83MAR = (iopt2 == 13)
write(luout,120)
120 format (/
1 ' Enter the reference date of the input positions.')
121 CALL GETMDY(MONTH1, IDAY1, IYEAR1, DATE1, MIN1, TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter the date? (y/n)'
read(luin, '(A1)',err=601,iostat=ios) ANSWER
if (ios /= 0) goto 601
if(ANSWER .eq. 'y' .or. ANSWER .eq. 'Y')GO TO 121
RETURN
ENDIF
write(luout,130)
130 format(/
1 ' Enter the reference date for the output positions. ')
131 CALL GETMDY(MONTH2, IDAY2, IYEAR2, DATE2, MIN2, TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter the date? (y/n)'
read(luin, '(A1)',err=601,iostat=ios) ANSWER
if (ios /= 0) goto 601
if(ANSWER .eq. 'Y' .or. ANSWER .eq. 'y') GO TO 131
RETURN
ENDIF
write(i2, 150) frame1, month1, iday1, iyear1, date1,
1 frame2, month2, iday2, iyear2, date2
150 format(' TRANSFORMING POSITIONS FROM ',A24,' (EPOCH = ',
1 I2.2,'-',I2.2,'-',I4,' (',F9.4,'))'/26X,
1 'TO ', A24, ' (EPOCH = ',I2.2,'-',I2.2,'-',I4,' (',F9.4,'))'/)
c 1 13X,'INPUT COORDINATES OUTPUT COORDINATES',
c 1 4x, 'INPUT VELOCITY' /)
160 write(luout, 170)
170 format (/' ***************************************'/
1 ' Coordinates will be transformed at each specified point.'/
1 ' Please indicate how you wish to supply positions.'/
1 ' 0... No more points. Return to main menu.'/
1 ' 1... Individual points entered interactively.'/
1 ' 2... The *80* records in a specified blue-book file. '/
1 ' 3... Transform positions contained in batch file '/
1 ' of delimited records of the form: '/
1 ' LAT,LON,EHT,TEXT' /
1 ' LAT = latitude in degrees (positive north/DBL PREC)'/
1 ' LON = longitude in degrees (positive west/DBL PREC)'/
1 ' EHT = ellipsoid height in meters (DBL PREC)'/
1 ' TEXT = Descriptive text (CHARACTER*24) '/
1 ' Example: '/
1 ' 40.731671553,112.212671753,34.241,SALT AIR '/
1 ' 4... Transform positions contained in batch file '/
1 ' of delimited records of the form: '/
1 ' X, Y, Z,TEXT' /
1 ' X, Y, Z are Cartesian coordinates of the station'/
1 ' TEXT = Descriptive text (CHARACTER*24) '/
1 ' Example: '/
1 ' -86682.104,-5394026.861,3391189.647,SALT AIR '/
1 ' Necessary velocities predicted by HTDP '/
1 ' 5... Transform positions using velocities contained in a '/
1 ' batch file of delimited records of the form: '/
1 ' X, Y, Z, Vx, Vy, Vz, TEXT' /
1 ' X, Y, Z are Cartesian coordinates of the station'/
1 ' Vx,Vy,Vz are Cartesian velocities in m/year '/
1 ' TEXT = Descriptive text (CHARACTER*24) '/
1 ' Example: '/
1'-86682.104,-5394026.861,3391189.647,-0.012,-0.001,-0.001,SALT'/)
read(luin,'(a1)',err=602,iostat=ios) option
if (ios /= 0) goto 602
c write (*,*) "Starting to look at options"
if (option .eq. '0') then
go to 500
elseif (option .eq. '1') then
vxsave = 0.d0
vysave = 0.d0
vzsave = 0.d0
vnsave = 0.d0
vesave = 0.d0
vusave = 0.d0
180 call GETPNT(latd, latm, slat, LATDIR, lond, lonm, slon,
1 LONDIR, name24, x, y, z, ylat, ylon, eht)
C Added by JS on 09/10/2014
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TOIT94(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94(x1, y1, z1, x2, y2, z2, date1, iopt2)
else
call TOIT94_IERS(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94_IERS(x1, y1, z1, x2, y2, z2, date1, iopt2)
endif
if (min1 .ne. min2) then !i.e., if the input and output dates are different
if(.not.FRMXYZ(x2,y2,z2,ylat1,elon1,eht1)) STOP 666
ylon1 = -elon1
if(ylon1 .lt. 0.d0) ylon1 = ylon1 + twopi
c write (*,*) ylon1*180.d0/pi,ylat1*180.d0/pi,eht1
call GETVLY(ylat1,elon1,vx,vy,vz,vn,ve,vu,vopt,210)
c write (*,*) vx,vy,vz,vn,ve,vu
if (vopt .eq. '0') then
call PREDV(ylat1,ylon1,eht1,date1,iopt1,jregn,vn,ve,vu)
c write (*,*) jregn,vn,ve,vu
if (jregn .eq. 0) then
write(luout, 200)
200 format(/' ****************************************'/
1 ' These coordinates can not be transformed to a different'/
1 ' date because the point is outside of the modeled region.'/)
go to 220
else
call TOVXYZ( ylat1, elon1, vn, ve, vu, vx, vy, vz)
c write (*,*) vx,vy,vz,vn,ve,vu
endif
endif
vxsave = vx
vysave = vy
vzsave = vz
vnsave = vn
vesave = ve
vusave = vu
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF( x, y, z, vx, vy, vz, iopt1, iopt2)
else
call VTRANF_IERS( x, y, z, vx, vy, vz, iopt1, iopt2)
endif
call TOVNEU( ylat1, elon1, vx, vy, vz, vn, ve, vu)
c write (*,*) "Passed TOVNEU",vn, ve, vu
call NEWCOR( ylat1, ylon1, eht1, min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
c write (*,*) "Passed NEWCOR",vn, ve, vu
call TOXYZ(ylatt,-ylont, ehtnew, xt, yt, zt)
c write (*,*) "Passed TOXYZ"
else
xt = x2
yt = y2
zt = z2
if(.not.(FRMXYZ(xt,yt,zt,ylatt,elont,ehtnew))) STOP 666
ylont = -elont
if(ylont .lt. 0.0d0) ylont = ylont + twopi
c write (*,*) ylont*180.d0/pi,ylatt*180.d0/pi,ehtnew
endif
call PRNTTP(x, y, z, xt, yt, zt, ylat, ylatt,
1 ylon, ylont, eht, ehtnew, name24, 1,
2 vxsave, vysave, vzsave, vnsave, vesave, vusave)
220 write(luout,*) ' Transform more positions? (y/n) '
read(luin,'(a1)',err=601,iostat=ios) answer
if (ios /= 0) goto 601
if(answer .eq. 'Y' .or. answer .eq. 'y') go to 180
close (i2, status = 'keep')
elseif (option .eq. '2') then !Blue book input and output
vxsave = 0.d0
vysave = 0.d0
vzsave = 0.d0
vnsave = 0.d0
vesave = 0.d0
vusave = 0.d0
write(luout, 300)
300 format(/
1 ' Enter name of the blue-book file: ')
read(luin, '(a)',err=603,iostat=ios) namebb
if (ios /= 0) goto 603
open (i1, file = namebb, status = 'old')
*** Obtaining the ellipsoid heights from the blue book file
do i = 1, nbbdim
ht(i) = 0.d0
enddo
302 read (i1, '(a80)', end = 309,err=604,iostat=ios) card
if (ios /= 0) goto 604
if (card(7:10) .eq. '*80*') then
c read (card, 303) isn, eht
c 303 format (bz, 10x, i4, t70, f6.2)
read (card, 303,err=605,iostat=ios) PID,isn,eht
if (ios /= 0) goto 605
303 format (a6,4x,i4, t70, f6.2)
if (ht(isn) .eq. 0.d0) ht(isn) = eht
PIDs(isn) = PID
elseif (card(7:10) .eq. '*86*') then
if (card(46:52) .ne. ' ') then
read (card, 304,err=606,iostat=ios) isn, eht
if (ios /= 0) goto 606
304 format (bz, 10x, i4, t46, f7.3)
ht(isn) = eht
else
read (card, 305,err=606,iostat=ios) isn, oht, ght
if (ios /= 0) goto 606
305 format (bz, 10x, i4, t17, f7.3, t36, f7.3)
ht(isn) = oht + ght
endif
endif
go to 302
309 rewind i1
c open (i6,file='transformed_'//namebb)
C write some comments in the transformed files
call extract_name (namebb,iii)
*** Commented out due to unused label (v3.3.0).
*1309 format (/'The file, transformed_',a,
* & ', contains the transformed input file.'/)
write (i2,1310) HTDP_version
1310 format (' ***CAUTION: This file was processed using HTDP',
& ' version ',a8, '***')
write (i2,1311) frame2
1311 format (' ***CAUTION: Coordinates in this file are in ',
& a24, '***')
WRITE (i2, 1312) MONTH2, IDAY2, IYEAR2, DATE2
1312 FORMAT(' ***CAUTION: Coordinates in this file have been ',
* 'updated to ',I2,'-',I2.2,'-',I4, '=(',F8.3,') ***'/)
*** Reread blue book file to get latitudes and longitudes
*** and to perform transformations
*** and to write transformed lat and lon to the *80* records of the output bfile
*** and to write transformed ellip. h to the *86* records of the output bfile
310 read(i1, '(a80)', end = 390,err=604,iostat=ios) card
if (ios /= 0) goto 604
if (card(7:10) .eq. '*80*') then
read(card,320,err=605,iostat=ios) isn,name24(1:30),latd,
& latm,slat,jn,lond, lonm, slon, jw
if (ios /= 0) goto 605
320 format(10x, i4, a30, i2, i2, f7.5, a1,
& i3, i2, f7.5, a1)
*** Commented out due to unused label (v3.3.0).
* 321 format(i2, i2, f7.5, a1,3x, i3, i2, f7.5, a1)
ylat = (dble((latd*60 + latm)*60) + slat) / rhosec
ylon = (dble((lond*60 + lonm)*60) + slon) / rhosec
if (jn .eq. 'S') ylat = -ylat
if (jw .eq. 'E') ylon = -ylon
eht = ht(isn)
call TOXYZ(ylat, -ylon, eht, x, y, z)
C Modified in 09/15/2014 by JS to accommodate the IERS 96-97 trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TOIT94(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94(x1, y1, z1, x2, y2, z2, date1, iopt2)
else
call TOIT94_IERS(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94_IERS(x1, y1, z1, x2, y2, z2, date1, iopt2)
endif
C End changes
if (min1 .ne. min2) then
if(.not.FRMXYZ(x2,y2,z2,ylat1,elon1,eht1)) STOP 666
ylon1 = -elon1
if (ylon1 .lt. 0.0d0) ylon1 = ylon1 + twopi
call PREDV(ylat1, ylon1, eht1, date1, iopt1,
1 jregn, vn, ve, vu)
if (jregn .eq. 0) then
write(i2, 330) name24
330 format (/ 1x,a,
1 ' is outside of the modeled region.'/)
go to 310
else
call TOVXYZ(ylat1,elon1,vn,ve,vu,vx,vy,vz)
vxsave = vx
vysave = vy
vzsave = vz
vnsave = vn
vesave = ve
vusave = vu
C Modified on 09/15/2014 by JS to accomodate the IERS trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF(x,y,z,vx,vy,vz,iopt1,iopt2)
else
call VTRANF_IERS( x, y, z, vx, vy, vz, iopt1, iopt2)
endif
C End changes
call TOVNEU(ylat1,elon1,vx,vy,vz,vn,ve,vu)
call NEWCOR(ylat1,ylon1,eht1,min1,min2,
1 ylatt,ylont,ehtnew,dn,de,dui,vn,ve,vu)
call TOXYZ(ylatt,-ylont,ehtnew,xt,yt,zt)
endif
else
xt = x2
yt = y2
zt = z2
if(.not.FRMXYZ(xt,yt,zt,ylatt,elont,ehtnew))STOP 666
ylont = -elont
if (ylont .lt. 0.0d0) ylont = ylont + twopi
endif
c call PRNTTP(x,y,z, xt,yt, zt, ylat, ylatt,
c 1 ylon, ylont, eht, ehtnew, name24, 0,
c 1 vxsave, vysave, vzsave, vnsave, vesave, vusave)
C Now write output *80* records to the output bfile
call TODMSS (ylatt,latdeg,latmin,seclat,isign)
latsec = nint(100000*seclat)
latdir = 'N'
if (isign .eq. -1) latdir = 'S'
call TODMSS (ylont,londeg,lonmin,seclon,isign)
lonsec = nint(100000*seclon)
londir = 'W'
if (isign .eq. -1) londir = 'E'
write (card(45:46),'(i2)') latdeg
write (card(47:48),'(i2)') latmin
write (card(49:55),'(i7)') latsec
do i=45,55
if (card(i:i) == ' ') card(i:i) = '0'
enddo
write (card(56:56),'(a1)') latdir
write (card(57:59),'(i3)') londeg
write (card(60:61),'(i2)') lonmin
write (card(62:68),'(i7)') lonsec
do i=57,68
if (card(i:i) == ' ') card(i:i) = '0'
enddo
write (card(69:69),'(a1)') londir
write (i2,'(a)') card
c write (*,'(a)') card
C Now write output *86* records
elseif (card(8:9) == '86') then
c write (*,'(a)') card
write (card(46:52),'(i7)') nint(ehtnew*1000)
write (i2,'(a)') card
c write(*, '(a80)') card
else
write (i2,'(a)') card
endif
go to 310
390 close (i1, status = 'keep')
c close (i6, status = 'keep')
close (i2, status = 'keep')
elseif (option .eq. '3') then
vxsave = 0.d0
vysave = 0.d0
vzsave = 0.d0
vnsave = 0.d0
vesave = 0.d0
vusave = 0.d0
write (luout, 400)
400 format (' Enter name of input file: ')
read (luin,'(a)',err=608,iostat=ios) nameif
if (ios /= 0) goto 608
open (i1, file = nameif, status = 'old')
C open (i6,file='transformed_'//nameif)
C write some comments in the transformed files
call extract_name (nameif,iii)
write (i2,1310) HTDP_version
write (i2,1311) frame2
WRITE (I2, 1312) MONTH2, IDAY2, IYEAR2, DATE2
LINE = 0 !Inititalize line number of input file.
410 read (i1,'(a)',end=450,err=607,iostat=ios) record
if (ios /= 0) goto 607
call interprate_XYZ_record (record,xlat,xlon,eht,name24)
LINE = LINE + 1 !Increment line number of input file.
*** If latitude magnitudes > 90 degrees or longitude magnitude > 360 degrees,
*** write error message and terminate program (added for v3.3.0).
IF ((DABS(xlat) .GT. 90).OR.(DABS(xlon) .GT. 360)) THEN
WRITE(*,*)'***********************************************'
WRITE(*,*)'Invalid latitude or longitude in input file'
WRITE(*,4101)'on line', LINE, ':'
WRITE(*,4102) xlat, xlon, eht, name24
WRITE(*,*)'Please check your input file and try again.'
WRITE(*,*)'***********************************************'
4101 FORMAT (1X, A, I8, A/)
4102 FORMAT (1X, 2F17.10, F11.3, 2X, A)
STOP
ENDIF
ylat = (xlat*3600.d0) / rhosec
ylon = (xlon*3600.d0) / rhosec
elon = -ylon
call TOXYZ(ylat, elon, eht, x, y, z)
C Modified in 09/15/2014 by JS to accommodate the IERS 96-97 trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TOIT94 (x,y,z,x1,y1,z1,date1,iopt1)
call FRIT94 (x1,y1,z1,x2,y2,z2,date1,iopt2)
else
call TOIT94_IERS(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94_IERS(x1, y1, z1, x2, y2, z2, date1, iopt2)
endif
C End changes
if (min1 .ne. min2) then
if(.not.FRMXYZ(x2,y2,z2,ylat1,elon1,eht1)) STOP 666
ylon1 = -elon1
if (ylon1 .lt. 0.d0) ylon1 = ylon1 + twopi
call PREDV (ylat1, ylon1, eht1, date1, iopt1, jregn,
1 vn, ve, vu)
if (jregn .eq. 0) then
write(i2, 330) name24
go to 410
else
call TOVXYZ(ylat1,elon1,vn,ve,vu,vx,vy,vz)
vxsave = vx
vysave = vy
vzsave = vz
vnsave = vn
vesave = ve
vusave = vu
C Modified on 09/15/2014 by JS to accomodate the IERS trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF(x,y,z,vx,vy,vz,iopt1,iopt2)
else
call VTRANF_IERS( x, y, z, vx, vy, vz, iopt1, iopt2)
endif
C End changes
call TOVNEU(ylat1, elon1,vx,vy,vz,vn,ve,vu)
call NEWCOR (ylat1, ylon1, eht1, min1, min2,
1 ylatt,ylont,ehtnew,dn,de,du,vn,ve,vu)
call TOXYZ(ylatt,-ylont,ehtnew,xt,yt,zt)
endif
else
xt = x2
yt = y2
zt = z2
if(.not.FRMXYZ(xt,yt,zt,ylatt,elont,ehtnew)) STOP 666
ylont = -elont
if (ylont .lt. 0.d0) ylont = ylont + twopi
endif
c call PRNTTP(x,y,z,xt,yt,zt,ylat,ylatt,ylon,ylont,eht,ehtnew,
c 1 name24,0,vxsave,vysave,vzsave,vnsave,vesave,vusave)
outlat = ylatt*rad2deg
outlon = ylont*rad2deg
call extract_name (name24,iii)
write (i2,449) outlat,outlon,ehtnew,name24(1:iii)
c write (i6,449) outlat,outlon,ehtnew,trim(name24)
449 format (2f16.10,f10.3,4x,a)
go to 410
450 close(i1, status = 'keep')
c close(i6, status = 'keep')
close(i2, status = 'keep')
elseif (option .eq. '4') then
vxsave = 0.d0
vysave = 0.d0
vzsave = 0.d0
vnsave = 0.d0
vesave = 0.d0
vusave = 0.d0
write (luout, 4001)
4001 format (' Enter name of input file: ')
read (luin, '(a)',err=600,iostat=ios) nameif
if (ios /= 0) goto 600
open (i1, file = nameif, status = 'old')
c open (i6,file='transformed_'//nameif)
C write some comments in the transformed files
call extract_name (nameif,iii)
411 read (i1,'(a)',end=451,err=607,iostat=ios) record
if (ios /= 0) goto 607
call interprate_XYZ_record (record,x,y,z,name24)
if(.not.FRMXYZ(x,y,z,ylat,elon,eht)) STOP 666
ylon = -elon
if (ylon .lt. 0.d0) ylon = ylon + twopi
C Modified in 09/15/2014 by JS to accommodate the IERS 96-97 trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TOIT94 (x,y,z,x1,y1,z1,date1,iopt1)
call FRIT94 (x1,y1,z1,x2,y2,z2,date1,iopt2)
else
call TOIT94_IERS(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94_IERS(x1, y1, z1, x2, y2, z2, date1, iopt2)
endif
C End changes
if (min1 .ne. min2) then
if(.not.FRMXYZ(x2,y2,z2,ylat1,elon1,eht1)) STOP 666
ylon1 = -elon1
if (ylon1 .lt. 0.d0) ylon1 = ylon1 + twopi
call PREDV (ylat1,ylon1,eht1,date1,iopt1,jregn,vn,ve,vu)
if (jregn .eq. 0) then
write(i2, 330) name24
go to 411
else
call TOVXYZ(ylat1,elon1,vn,ve,vu,vx,vy,vz)
vxsave = vx
vysave = vy
vzsave = vz
vnsave = vn
vesave = ve
vusave = vu
write (*,*) vn,ve,vu
write (*,*) vx,vy,vz
C Modified on 09/15/2014 by JS to accomodate the IERS trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF(x,y,z,vx,vy,vz,iopt1,iopt2)
else
call VTRANF_IERS( x, y, z, vx, vy, vz, iopt1, iopt2)
endif
C End changes
call TOVNEU(ylat1, elon1,vx,vy,vz,vn,ve,vu)
write (*,*) vn,ve,vu
call NEWCOR (ylat1, ylon1, eht1, min1, min2,
1 ylatt,ylont,ehtnew,dn,de,du,vn,ve,vu)
call TOXYZ(ylatt,-ylont,ehtnew,xt,yt,zt)
endif
else
xt = x2
yt = y2
zt = z2
if(.not.FRMXYZ(xt,yt,zt,ylatt,elont,ehtnew)) STOP 666
ylont = -elont
if (ylont .lt. 0.d0) ylont = ylont + twopi
endif
c call PRNTTP(x,y,z,xt,yt,zt,ylat,ylatt,ylon,ylont,eht,ehtnew,
c 1 name24,0,vxsave,vysave,vzsave,vnsave,vesave,vusave)
call extract_name (name24,iii)
write (i2,1449) xt,yt,zt,name24(1:iii)
c write (i6,1449) xt,yt,zt,trim(name24)
1449 format (3f20.3,4x,a)
go to 411
451 close(i1, status = 'keep')
close(i2, status = 'keep')
elseif (option .eq. '5') then
vxsave = 0.d0
vysave = 0.d0
vzsave = 0.d0
vnsave = 0.d0
vesave = 0.d0
vusave = 0.d0
write (luout, 5001)
5001 format (' Enter name of input file: ')
read (luin, '(a)',err=600,iostat=ios) nameif
if (ios /= 0) goto 600
open (i1, file = nameif, status = 'old')
c open (i6,file='transformed_'//nameif)
C write some comments in the transformed files
call extract_name (nameif,iii)
511 read (i1,'(a)',end=551,err=607,iostat=ios) record
if (ios /= 0) goto 607
call interprate_XYZVxVyVz_record (record,x,y,z,Vx,Vy,Vz,name24)
c write (*,*) X,Y,Z
c write (*,*) Vx,Vy,Vz
if(.not.FRMXYZ(x,y,z,ylat,elon,eht)) STOP 666
ylon = -elon
if (ylon .lt. 0.d0) ylon = ylon + twopi
C Modified in 09/15/2014 by JS to accommodate the IERS 96-97 trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TOIT94 (x,y,z,x1,y1,z1,date1,iopt1)
call FRIT94 (x1,y1,z1,x2,y2,z2,date1,iopt2)
else
call TOIT94_IERS(x, y, z, x1, y1, z1, date1, iopt1)
call FRIT94_IERS(x1, y1, z1, x2, y2, z2, date1, iopt2)
endif
C End changes on 09/15/2014
if (min1 .ne. min2) then
if(.not.FRMXYZ(x2,y2,z2,ylat1,elon1,eht1)) STOP 666
ylon1 = -elon1
if (ylon1 .lt. 0.d0) ylon1 = ylon1 + twopi
c call PREDV (ylat1,ylon1,eht1,date1,iopt1,jregn,vn,ve,vu)
c if (jregn .eq. 0) then
c write(i2, 330) name24
c go to 411
c else
c call TOVXYZ(ylat1,elon1,vn,ve,vu,vx,vy,vz)
call TOVNEU(ylat1,elon1,vx,vy,vz,vn,ve,vu)
vxsave = vx
vysave = vy
vzsave = vz
vnsave = vn
vesave = ve
vusave = vu
c write (*,*) vn,ve,vu
C Modified on 09/15/2014 by JS to accomodate the IERS trans. par.
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF(x,y,z,vx,vy,vz,iopt1,iopt2)
else
call VTRANF_IERS( x, y, z, vx, vy, vz, iopt1, iopt2)
endif
C End changes
call TOVNEU(ylat1, elon1,vx,vy,vz,vn,ve,vu)
call NEWCOR (ylat1, ylon1, eht1, min1, min2,
1 ylatt,ylont,ehtnew,dn,de,du,vn,ve,vu)
call TOXYZ(ylatt,-ylont,ehtnew,xt,yt,zt)
c endif
else
xt = x2
yt = y2
zt = z2
if(.not.FRMXYZ(xt,yt,zt,ylatt,elont,ehtnew)) STOP 666
ylont = -elont
if (ylont .lt. 0.d0) ylont = ylont + twopi
endif
c call PRNTTP(x,y,z,xt,yt,zt,ylat,ylatt,ylon,ylont,eht,ehtnew,
c 1 name24,0,vxsave,vysave,vzsave,vnsave,vesave,vusave)
call extract_name (name24,iii)
write (i2,1449) xt,yt,zt,name24(1:iii)
c write (i6,1449) xt,yt,zt,trim(name24)
go to 511
551 close(i1, status = 'keep')
close(i2, status = 'keep')
else
write(luout,*) ' Improper selection -- try again. '
go to 160
endif
500 continue
c close(i2, status = 'keep')
return
600 write (*,'(/)')
write (*,*) "Wrong output file name in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
601 write (*,'(/)')
write (*,*) "Wrong answer in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
602 write (*,'(/)')
write (*,*) "Wrong option in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
603 write (*,'(/)')
write (*,*) "Wrong bbname in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
604 write (*,'(/)')
write (*,*) "Wrong card in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
605 write (*,'(/)')
write (*,*) "Failed to read 80 record in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
606 write (*,'(/)')
write (*,*) "Failed to read 86 record in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
607 write (*,*) "Failed reading input file in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
608 write (*,'(/)')
write (*,*) "Wrong input file name in TRFPOS: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
end
C*******************************************8*****************************************************
subroutine PRNTTP(x, y, z, x1, y1, z1, ylat,
1 ylatt, ylon, ylont, eht, ehtnew, name24, iprint,
2 vx, vy, vz, vn, ve, vu )
** Print updated and/or transformed parameters
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
CHARACTER NAME24*24
CHARACTER LATDIR*1, LONDIR*1, LATDR*1, LONDR*1
CALL TODMSS(YLATT,LATDN,LATMN,SLATN,ISIGN)
LATDIR = 'N'
if (isign .eq. -1) LATDIR = 'S'
CALL TODMSS(YLONT,LONDN,LONMN,SLONN,ISIGN)
LONDIR = 'W'
if (isign .eq. -1) LONDIR = 'E'
if (iprint .eq. 1) then
WRITE(LUOUT,1065)LATDN,LATMN,SLATN,LATDIR,LONDN,LONMN,
1 SLONN,LONDIR, EHTNEW, X1,Y1,Z1
1065 FORMAT(' ****************************************'/
1 ' New latitude = ',I3,1X,I2,1X,F8.5,1X,A1 /
2 ' New longitude = ',I3,1x,I2,1X,F8.5,1X,A1 /
2 ' New Ellip. Ht. = ', F12.3 ,' meters' /
3 ' New X = ',F12.3 ,' meters' /
4 ' New Y = ',F12.3 ,' meters' /
5 ' New Z = ',F12.3 ,' meters' /
3 ' ****************************************'/)
endif
call TODMSS(ylat,latd,latm,slat,isign)
latdr = 'N'
if(isign .eq. -1) latdr = 'S'
call TODMSS(ylon, lond,lonm,slon,isign)
londr = 'W'
if(isign .eq. -1) londr = 'E'
WRITE(I2,1070)NAME24,
1 LATD,LATM,SLAT,latdr,LATDN,LATMN,SLATN,latdir,vn,
1 LOND,LONM,SLON,londr,LONDN,LONMN,SLONN,londir,ve,
1 EHT, EHTNEW, vu, X, X1, vx,
1 Y, Y1, vy, Z, Z1, vz
1070 FORMAT(1X,A24,/
1 2X, 'LATITUDE ',2(2X,I3,1X,I2.2,1X,F8.5,1X,A1,2X),
1 2X, f8.2, ' mm/yr north' /
1 2X, 'LONGITUDE ',2(2X,I3,1X,I2.2,1X,F8.5,1X,A1,2X),
1 2X, f8.2, ' mm/yr east' /
1 2X, 'ELLIP. HT.',2(6X,F14.3),' m ',
1 f8.2, ' mm/yr up' /
1 2X, 'X ',2(6X,F14.3),' m ', f8.2, ' mm/yr' /
1 2X, 'Y ',2(6X,F14.3),' m ', f8.2, ' mm/yr' /
1 2X, 'Z ',2(6X,F14.3),' m ', f8.2, ' mm/yr'/ )
RETURN
END
**********************************************************
subroutine SETTP
*** Specify transformation parameters from ITRF94
*** to other reference frames
**************************************
C Important note:
C The parameters in common block tranpa are computed using the IGS convention ITRF96 <> ITRF97.
C The parameters in common block tranpa1 are computed using the IERS convention ITRF96 = ITRF97.
C The latter parameters were added to HTDP in 09/2014. They will be used to transform between
C ITRF systems. They will not be used if the transformation involves NAD83 or WGS84 (original/transit).
C However, the NAD 83 Pacific frames use the IERS convention ITRF96 = ITRF97.
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /const/ a, f, e2, eps, af, pi, twopi, rhosec
common /tranpa/ tx(numref), ty(numref), tz(numref),
& dtx(numref), dty(numref), dtz(numref),
& rx(numref), ry(numref), rz(numref),
& drx(numref), dry(numref), drz(numref),
& scale(numref), dscale(numref), refepc(numref)
common /tranpa1/ tx1(numref), ty1(numref), tz1(numref),
& dtx1(numref), dty1(numref), dtz1(numref),
& rx1(numref), ry1(numref), rz1(numref),
& drx1(numref), dry1(numref), drz1(numref),
& scale1(numref), dscale1(numref), refepc1(numref)
C Parameters computed with the IGS convention ITRF96 <> ITRF97
*** From ITRF94 to NAD 83
tx(1) = 0.9910d0
ty(1) = -1.9072d0
tz(1) = -0.5129d0
dtx(1) = 0.d0
dty(1) = 0.d0
dtz(1) = 0.d0
rx(1) = 1.25033d-7
ry(1) = 0.46785d-7
rz(1) = 0.56529d-7
drx(1) = 0.00258d-7
dry(1) = -0.03599d-7
drz(1) = -0.00153d-7
scale(1) = 0.d0
dscale(1) = 0.0d0
refepc(1) = 1997.0d0
*** From ITRF94 to ITRF88
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx(2) = 0.018d0
ty(2) = 0.000d0
tz(2) = -0.092d0
dtx(2) = 0.0d0
dty(2) = 0.0d0
dtz(2) = 0.0d0
rx(2) = -0.0001d0 / rhosec
ry(2) = 0.0d0
rz(2) = 0.0d0
drx(2) = 0.0d0
dry(2) = 0.0d0
drz(2) = 0.0d0
scale(2) = 0.749d-8 !Previous scale = 0.74d-8 (prior to v3.3.0)
dscale(2) = 0.0d0
refepc(2) = 1988.0d0
*** From ITRF94 to ITRF89
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx(3) = 0.023d0
ty(3) = 0.036d0
tz(3) = -0.068d0
dtx(3) = 0.0d0
dty(3) = 0.0d0
dtz(3) = 0.0d0
rx(3) = 0.0d0
ry(3) = 0.0d0
rz(3) = 0.0d0
drx(3) = 0.0d0
dry(3) = 0.0d0
drz(3) = 0.0d0
scale(3) = 0.439d-8 !Previous scale = 0.43d-8 (prior to v3.3.0)
dscale(3) = 0.0d0
refepc(3) = 1988.0d0
*** From ITRF94 to ITRF90
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx(4) = 0.018d0
ty(4) = 0.012d0
tz(4) = -0.030d0
dtx(4) = 0.0d0
dty(4) = 0.0d0
dtz(4) = 0.0d0
rx(4) = 0.0d0
ry(4) = 0.0d0
rz(4) = 0.0d0
drx(4) = 0.0d0
dry(4) = 0.0d0
drz(4) = 0.0d0
scale(4) = 0.099d-8 !Previous scale = 0.09d-8 (prior to v3.3.0)
dscale(4) = 0.0d0
refepc(4) = 1988.0d0
*** From ITRF94 to ITRF91
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx(5) = 0.020d0
ty(5) = 0.016d0
tz(5) = -0.014d0
dtx(5) = 0.0d0
dty(5) = 0.0d0
dtz(5) = 0.0d0
rx(5) = 0.0d0
ry(5) = 0.0d0
rz(5) = 0.0d0
drx(5) = 0.0d0
dry(5) = 0.0d0
drz(5) = 0.0d0
scale(5) = 0.069d-8 !Previous scale = 0.06d-8 (prior to v3.3.0)
dscale(5) = 0.0d0
refepc(5) = 1988.0d0
*** From ITRF94 to ITRF92
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx(6) = 0.008d0
ty(6) = 0.002d0
tz(6) = -0.008d0
dtx(6) = 0.0d0
dty(6) = 0.0d0
dtz(6) = 0.0d0
rx(6) = 0.0d0
ry(6) = 0.0d0
rz(6) = 0.0d0
drx(6) = 0.0d0
dry(6) = 0.0d0
drz(6) = 0.0d0
scale(6) = -0.071d-8 !Previous scale = -0.08d-8 (prior to v3.3.0)
dscale(6) = 0.0d0
refepc(6) = 1988.0d0
*** From ITRF94 to ITRF93
*** Update scale in v3.3.0 to match current value published by IERS
*** (https://itrf.ign.fr/trans_para.php). Supersedes scale in file
*** "ITRF94.TX" at ftp://itrf-ftp.ign.fr/pub/itrf/itrf94/.
*** Previous link under “Other transformation parameters” at
*** https://itrf.ign.fr/ITRF_solutions/94/ITRF94.php?page=2 currently
*** does not work (as of 1/15/2021).
*** This update also affects the scale for transformations from ITRF94
*** to all earlier ITRFs.
*** Note that this transformation is not published in IERS TN20 (1996).
tx(7) = 0.006d0
ty(7) = -0.005d0
tz(7) = -0.015d0
dtx(7) = -0.0029d0
dty(7) = 0.0004d0
dtz(7) = 0.0008d0
rx(7) = 0.00039d0 / rhosec
ry(7) = -0.00080d0 / rhosec
rz(7) = 0.00096d0 / rhosec
drx(7) = 0.00011d0 / rhosec
dry(7) = 0.00019d0 / rhosec
drz(7) = -0.00005d0 / rhosec
scale(7) = 0.049d-8 !Previous scale = 0.040d-8 (prior to v3.3.0)
dscale(7) = 0.0d0
refepc(7) = 1988.0d0
*** From ITRF94 to ITRF96
tx(8) = 0.d0
ty(8) = 0.d0
tz(8) = 0.d0
dtx(8) = 0.d0
dty(8) = 0.d0
dtz(8) = 0.d0
rx(8) = 0.d0
ry(8) = 0.d0
rz(8) = 0.d0
drx(8) = 0.d0
dry(8) = 0.d0
drz(8) = 0.d0
scale(8) = 0.d0
dscale(8) = 0.0d0
refepc(8) = 1996.0d0
*** From ITRF94 to ITRF97 (also IGS97), based on IGS adopted values
*** According to IGS: ITRF97 <> ITRF96 = ITRF94
tx(9) = 0.00207d0
ty(9) = 0.00021d0
tz(9) = -0.00995d0
dtx(9) = -0.00069d0
dty(9) = 0.00010d0
dtz(9) = -0.00186d0
rx(9) = -0.00012467d0 / rhosec
ry(9) = 0.00022355d0 / rhosec
rz(9) = 0.00006065d0 / rhosec
drx(9) = -0.00001347d0 / rhosec
dry(9) = 0.00001514d0 / rhosec
drz(9) = -0.00000027d0 / rhosec
scale(9) = 0.93496d-9
dscale(9) = 0.19201d-9
refepc(9) = 1997.0d0
*** From ITRF94 to WGS 72 (composition of ITRF94 -> NAD_83 -> WGS_72)
tx(10) = 0.9910d0
ty(10) = -1.9072d0
tz(10) = -0.5129d0 - 4.5d0
dtx(10) = 0.d0
dty(10) = 0.d0
dtz(10) = 0.d0
rx(10) = 1.25033d-7
ry(10) = 0.46785d-7
rz(10) = 0.56529d-7 + 26.85868d-7
drx(10) = 0.00258d-7
dry(10) = -0.03599d-7
drz(10) = -0.00153d-7
scale(10) = 0.d0 - 0.2263d-6
dscale(10) = 0.0d0
refepc(10) = 1997.0d0
*** From ITRF94 to ITRF2000 (also IGS00 and IGb00)
*** assumes that ITRF94 = ITRF96 and
*** uses IGS values for ITRF96 -> ITRF97
*** and IERS values for ITRF97 -> ITRF2000
tx(11) = -0.00463d0
ty(11) = -0.00589d0
tz(11) = 0.00855d0
dtx(11) = -0.00069d0
dty(11) = 0.00070d0
dtz(11) = -0.00046d0
rx(11) = -0.00012467d0 / rhosec
ry(11) = 0.00022355d0 / rhosec
rz(11) = 0.00006065d0 / rhosec
drx(11) = -0.00001347d0 / rhosec
dry(11) = 0.00001514d0 / rhosec
drz(11) = 0.00001973d0 / rhosec
scale(11) = -0.61504d-9
dscale(11) = 0.18201d-9
refepc(11) = 1997.0d0
*** From ITRF94 to PACP00
*** use PA/ITRF2000 rotation rates from Beavan et al., (2002)
tx(12) = 0.9056d0
ty(12) = -2.0200d0
tz(12) = -0.5516d0
dtx(12) = -0.00069d0
dty(12) = 0.00070d0
dtz(12) = -0.00046d0
rx(12) = 0.027616d0 / rhosec
ry(12) = 0.013692d0 / rhosec
rz(12) = 0.002773d0 / rhosec
drx(12) = -0.000397d0 / rhosec
dry(12) = 0.001022d0 / rhosec
drz(12) = -0.002166d0 / rhosec
scale(12) = -0.61504d-9
dscale(12) = 0.18201d-9
refepc(12) = 1997.0d0
*** From ITRF94 to MARP00
*** Use velocity of GUAM
tx(13) = 0.9056d0
ty(13) = -2.0200d0
tz(13) = -0.5516d0
dtx(13) = -0.00069d0
dty(13) = 0.00070d0
dtz(13) = -0.00046d0
rx(13) = 0.028847d0 / rhosec
ry(13) = 0.010644d0 / rhosec
rz(13) = 0.008989d0 / rhosec
drx(13) = -0.000033d0 / rhosec
dry(13) = 0.000120d0 / rhosec
drz(13) = -0.000327d0 / rhosec
scale(13) = -0.61504d-9
dscale(13) = 0.18201d-9
refepc(13) = 1997.00d0
*** From ITRF94 to ITRF2005 (also IGS05)
*** assumes that ITRF94 = ITRF96
*** uses IGS values for ITRF96 -> ITRF97
*** uses IERS values for ITRF97 -> ITRF2000
*** uses IERS values for ITRF2000 -> ITRF2005
tx(14) = -0.00533d0
ty(14) = -0.00479d0
tz(14) = 0.00895d0
dtx(14) = -0.00049d0
dty(14) = 0.00060d0
dtz(14) = 0.00134d0
rx(14) = -0.00012467d0 / rhosec
ry(14) = 0.00022355d0 / rhosec
rz(14) = 0.00006065d0 / rhosec
drx(14) = -0.00001347d0 / rhosec
dry(14) = 0.00001514d0 / rhosec
drz(14) = 0.00001973d0 / rhosec
scale(14) = -0.77504d-9
dscale(14) = 0.10201d-9
refepc(14) = 1997.0d0
*** From ITRF94 to ITRF2008 (also IGS08 and IGb08)
*** assumes that ITRF94 = ITRF96
*** uses IGS values for ITRF96 -> ITRF97
*** uses IERS values for ITRF97 -> ITRF2000
*** uses IERS values for ITRF2000-> ITRF2005
*** uses IERS values for ITRF2005 -> ITRF2008
tx(15) = -0.00243d0
ty(15) = -0.00389d0
tz(15) = 0.01365d0
dtx(15) = -0.00079d0
dty(15) = 0.00060d0
dtz(15) = 0.00134d0
rx(15) = -0.00012467d0 / rhosec
ry(15) = 0.00022355d0 / rhosec
rz(15) = 0.00006065d0 / rhosec
drx(15) = -0.00001347d0 / rhosec
dry(15) = 0.00001514d0 / rhosec
drz(15) = 0.00001973d0 / rhosec
scale(15) = -1.71504d-9
dscale(15) = 0.10201d-9
refepc(15) = 1997.0d0
*** From ITRF94 to ITRF2014 (also IGS14 and IGb14)
*** assumes that ITRF94 = ITRF96
*** uses IGS values for ITRF96 -> ITRF97
*** uses IERS values for ITRF97 -> ITRF2000
*** uses IERS values for ITRF2000-> ITRF2005
*** uses IERS values for ITRF2005 -> ITRF2008
*** uses IERS values for ITRF2008 -> ITRF2014
tx(16) = -0.01430d0
ty(16) = 0.00201d0
tz(16) = 0.02867d0
dtx(16) = -0.00079d0
dty(16) = 0.00060d0
dtz(16) = 0.00144d0
rx(16) = -0.00029978d0 / rhosec
ry(16) = 0.00042037d0 / rhosec
rz(16) = 0.00031714d0 / rhosec
drx(16) = -0.00001347d0 / rhosec
dry(16) = 0.00001514d0 / rhosec
drz(16) = 0.00001973d0 / rhosec
scale(16) = -0.36891d-9
dscale(16) = 0.07201d-9
refepc(16) = 2010.0d0
C*************************************************************************************************************************
C Parameters computed with the IERS convention ITRF96 = ITRF97
*** From ITRF94 to NAD 83
tx1(1) = 0.9910d0
ty1(1) = -1.9072d0
tz1(1) = -0.5129d0
dtx1(1) = 0.d0
dty1(1) = 0.d0
dtz1(1) = 0.d0
rx1(1) = 1.25033d-7
ry1(1) = 0.46785d-7
rz1(1) = 0.56529d-7
drx1(1) = 0.00258d-7
dry1(1) = -0.03599d-7
drz1(1) = -0.00153d-7
scale(1) = 0.d0
dscale1(1) = 0.0d0
refepc1(1) = 1997.0d0
*** From ITRF94 to ITRF88
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx1(2) = 0.018d0
ty1(2) = 0.000d0
tz1(2) = -0.092d0
dtx1(2) = 0.0d0
dty1(2) = 0.0d0
dtz1(2) = 0.0d0
rx1(2) = -0.0001d0 / rhosec
ry1(2) = 0.0d0
rz1(2) = 0.0d0
drx1(2) = 0.0d0
dry1(2) = 0.0d0
drz1(2) = 0.0d0
scale1(2) = 0.749d-8 !Previous scale = 0.74d-8 (prior to v3.3.0)
dscale1(2) = 0.0d0
refepc1(2) = 1988.0d0
*** From ITRF94 to ITRF89
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx1(3) = 0.023d0
ty1(3) = 0.036d0
tz1(3) = -0.068d0
dtx1(3) = 0.0d0
dty1(3) = 0.0d0
dtz1(3) = 0.0d0
rx1(3) = 0.0d0
ry1(3) = 0.0d0
rz1(3) = 0.0d0
drx1(3) = 0.0d0
dry1(3) = 0.0d0
drz1(3) = 0.0d0
scale1(3) = 0.439d-8 !Previous scale = 0.43d-8 (prior to v3.3.0)
dscale1(3) = 0.0d0
refepc1(3) = 1988.0d0
*** From ITRF94 to ITRF90
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx1(4) = 0.018d0
ty1(4) = 0.012d0
tz1(4) = -0.030d0
dtx1(4) = 0.0d0
dty1(4) = 0.0d0
dtz1(4) = 0.0d0
rx1(4) = 0.0d0
ry1(4) = 0.0d0
rz1(4) = 0.0d0
drx1(4) = 0.0d0
dry1(4) = 0.0d0
drz1(4) = 0.0d0
scale1(4) = 0.099d-8 !Previous scale = 0.09d-8 (prior to v3.3.0)
dscale1(4) = 0.0d0
refepc1(4) = 1988.0d0
*** From ITRF94 to ITRF91
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx1(5) = 0.020d0
ty1(5) = 0.016d0
tz1(5) = -0.014d0
dtx1(5) = 0.0d0
dty1(5) = 0.0d0
dtz1(5) = 0.0d0
rx1(5) = 0.0d0
ry1(5) = 0.0d0
rz1(5) = 0.0d0
drx1(5) = 0.0d0
dry1(5) = 0.0d0
drz1(5) = 0.0d0
scale1(5) = 0.069d-8 !Previous scale = 0.06d-8 (prior to v3.3.0)
dscale1(5) = 0.0d0
refepc1(5) = 1988.0d0
*** From ITRF94 to ITRF92
*** Update scale in v3.3.0 due to ITRF94 to ITRF93 transformation update.
tx1(6) = 0.008d0
ty1(6) = 0.002d0
tz1(6) = -0.008d0
dtx1(6) = 0.0d0
dty1(6) = 0.0d0
dtz1(6) = 0.0d0
rx1(6) = 0.0d0
ry1(6) = 0.0d0
rz1(6) = 0.0d0
drx1(6) = 0.0d0
dry1(6) = 0.0d0
drz1(6) = 0.0d0
scale1(6) = -0.071d-8 !Previous scale = -0.08d-8 (prior to v3.3.0)
dscale1(6) = 0.0d0
refepc1(6) = 1988.0d0
*** From ITRF94 to ITRF93
*** Update scale in v3.3.0 to match current value published by IERS
*** (https://itrf.ign.fr/trans_para.php). Supersedes scale in file
*** "ITRF94.TX" at ftp://itrf-ftp.ign.fr/pub/itrf/itrf94/.
*** Previous link under “Other transformation parameters” at
*** https://itrf.ign.fr/ITRF_solutions/94/ITRF94.php?page=2 currently
*** does not work (as of 1/15/2021).
*** This update also affects the scale for transformations from ITRF94
*** to all earlier ITRFs.
*** Note that this transformation is not published in IERS TN20 (1996).
tx1(7) = 0.006d0
ty1(7) = -0.005d0
tz1(7) = -0.015d0
dtx1(7) = -0.0029d0
dty1(7) = 0.0004d0
dtz1(7) = 0.0008d0
rx1(7) = 0.00039d0 / rhosec
ry1(7) = -0.00080d0 / rhosec
rz1(7) = 0.00096d0 / rhosec
drx1(7) = 0.00011d0 / rhosec
dry1(7) = 0.00019d0 / rhosec
drz1(7) = -0.00005d0 / rhosec
scale1(7) = 0.049d-8 !Previous scale = 0.04d-8 (prior to v3.3.0)
dscale1(7) = 0.0d0
refepc1(7) = 1988.0d0
*** From ITRF94 to ITRF96
*** According to IERS: ITRF97 = ITRF96 = ITRF94
tx1(8) = 0.d0
ty1(8) = 0.d0
tz1(8) = 0.d0
dtx1(8) = 0.d0
dty1(8) = 0.d0
dtz1(8) = 0.d0
rx1(8) = 0.d0
ry1(8) = 0.d0
rz1(8) = 0.d0
drx1(8) = 0.d0
dry1(8) = 0.d0
drz1(8) = 0.d0
scale1(8) = 0.d0
dscale1(8) = 0.0d0
refepc1(8) = 1996.0d0
*** From ITRF94 to ITRF97 (also IGS97), based on IERS adopted values
*** According to IERS: ITRF97 = ITRF96 = ITRF94
tx1(9) = 0.0d0
ty1(9) = 0.0d0
tz1(9) = 0.0d0
dtx1(9) = 0.0d0
dty1(9) = 0.0d0
dtz1(9) = 0.0d0
rx1(9) = 0.0d0
ry1(9) = 0.0d0
rz1(9) = 0.0d0
drx1(9) = 0.0d0
dry1(9) = 0.0d0
drz1(9) = 0.0d0
scale1(9) = 0.d0
dscale1(9) = 0.d0
refepc1(9) = 2000.0d0
*** From ITRF94 to WGS 72 (composition of ITRF94 -> NAD_83 -> WGS_72)
tx1(10) = 0.9910d0
ty1(10) = -1.9072d0
tz1(10) = -.5129d0 - 4.5d0
dtx1(10) = 0.d0
dty1(10) = 0.d0
dtz1(10) = 0.d0
rx1(10) = 1.25033d-7
ry1(10) = 0.46785d-7
rz1(10) = 0.56529d-7 + 26.85868d-7
drx1(10) = 0.00258d-7
dry1(10) = -.03599d-7
drz1(10) = -.00153d-7
scale1(10) = 0.d0 - 0.2263d-6
dscale1(10) = 0.0d0
refepc1(10) = 1997.0d0
*** From ITRF94 to ITRF2000 (also IGS00 and IGb00)
*** assumes that ITRF94 = ITRF96 and
*** uses IERS convention ITRF96 = ITRF97
*** and IERS values for ITRF97 -> ITRF2000
tx1(11) = -0.00670d0
ty1(11) = -0.00430d0
tz1(11) = 0.02270d0
dtx1(11) = 0.00000d0
dty1(11) = 0.00060d0
dtz1(11) = 0.00140d0
rx1(11) = 0.0d0 / rhosec
ry1(11) = 0.0d0 / rhosec
rz1(11) = 0.00006000d0 / rhosec
drx1(11) = 0.0d0 / rhosec
dry1(11) = 0.0d0 / rhosec
drz1(11) = 0.00002000d0 / rhosec
scale1(11) = -1.58000d-9
dscale1(11) = -0.01000d-9
refepc1(11) = 2000.0d0
*** From ITRF94 to PACP00
*** use PA/ITRF2000 rotation rates from Beavan et al., (2002)
tx1(12) = 0.9035d0
ty1(12) = -2.0202d0
tz1(12) = -0.5417d0
dtx1(12) = 0.0d0
dty1(12) = 0.00060d0
dtz1(12) = 0.0014d0
rx1(12) = 0.027741d0 / rhosec
ry1(12) = 0.013469d0 / rhosec
rz1(12) = 0.002712d0 / rhosec
drx1(12) = -0.000384d0 / rhosec
dry1(12) = 0.001007d0 / rhosec
drz1(12) = -0.002166d0 / rhosec
scale1(12) = -1.55000d-9
dscale1(12) = -0.010000d-9
refepc1(12) = 1997.0d0
*** From ITRF94 to MARP00
*** Use velocity of GUAM
tx1(13) = 0.9035d0
ty1(13) = -2.0202d0
tz1(13) = -0.5417d0
dtx1(13) = -0.00000d0
dty1(13) = 0.00060d0
dtz1(13) = 0.00140d0
rx1(13) = 0.028971d0 / rhosec
ry1(13) = 0.01042d0 / rhosec
rz1(13) = 0.008928d0 / rhosec
drx1(13) = -0.00002d0 / rhosec
dry1(13) = 0.000105d0 / rhosec
drz1(13) = -0.000327d0 / rhosec
scale1(13) = -1.55000d-9
dscale1(13) = -0.01000d-9
refepc1(13) = 1997.00d0
*** From ITRF94 to ITRF2005 (also IGS05)
*** assumes that ITRF94 = ITRF96
*** uses IERS convention ITRF96 = ITRF97
*** uses IERS values for ITRF97 -> ITRF2000
*** uses IERS values for ITRF2000 -> ITRF2005
tx1(14) = -0.00680d0
ty1(14) = -0.00350d0
tz1(14) = 0.0285d0
dtx1(14) = 0.00020d0
dty1(14) = 0.00050d0
dtz1(14) = 0.00320d0
rx1(14) = 0.0d0 / rhosec
ry1(14) = 0.0d0 / rhosec
rz1(14) = 0.00006000d0 / rhosec
drx1(14) = 0.0d0 / rhosec
dry1(14) = 0.0d0 / rhosec
drz1(14) = 0.00002000d0 / rhosec
scale1(14) = -1.98000d-9
dscale1(14) = -0.09000d-9
refepc1(14) = 2000.0d0
*** From ITRF94 to ITRF2008 (also IGS08 and IGb08)
*** assumes that ITRF94 = ITRF96
*** uses IERS convention ITRF96 = ITRF97
*** uses IERS values for ITRF97 -> ITRF2000
*** uses IERS values for ITRF2000 -> ITRF2005
*** uses IERS values for ITRF2005 -> ITRF2008
tx1(15) = -0.00480d0
ty1(15) = -0.00260d0
tz1(15) = 0.03320d0
dtx1(15) = -0.00010d0
dty1(15) = 0.00050d0
dtz1(15) = 0.00320d0
rx1(15) = 0.0d0 / rhosec
ry1(15) = 0.0d0 / rhosec
rz1(15) = 0.00006000d0 / rhosec
drx1(15) = -0.0d0 / rhosec
dry1(15) = 0.0d0 / rhosec
drz1(15) = 0.00002000d0 / rhosec
scale1(15) = -2.92d-9
dscale1(15) = -0.09d-9
refepc1(15) = 2000.0d0
*** From ITRF94 to ITRF2014 (also IGS14 and IGb14)
*** assumes that ITRF94 = ITRF96
*** uses IERS convention ITRF96 = ITRF97
*** uses IERS values for ITRF97 -> ITRF2000
*** uses IERS values for ITRF2000 -> ITRF2005
*** uses IERS values for ITRF2005 -> ITRF2008
*** uses IERS values for ITRF2008 -> ITRF2014
tx1(16) = -0.00740d0
ty1(16) = 0.00050d0
tz1(16) = 0.06280d0
dtx1(16) = -0.00010d0
dty1(16) = 0.00050d0
dtz1(16) = 0.00330d0
rx1(16) = 0.0d0 / rhosec
ry1(16) = 0.0d0 / rhosec
rz1(16) = 0.00026000d0 / rhosec
drx1(16) = 0.0d0 / rhosec
dry1(16) = 0.0d0 / rhosec
drz1(16) = 0.00002000d0 / rhosec
scale1(16) = -3.80d-9
dscale1(16) = -0.12d-9
refepc1(16) = 2010.0d0
return
end
*************************************************************
subroutine frit94(x1, y1, z1, x2, y2, z2, date, jopt)
*** Converts ITRF94 cartesian coordinates to cartesian
*** coordinates in the specified reference frame for the
*** given date
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
*** (x1, y1, z1) --> input ITRF94 coordiates (meters)
*** (x2, y2, z2) --> output coordinates (meters)
*** date --> time (decimal years) to which the input & output
*** coordinates correspond
*** jopt --> input specifier of output reference frame
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /tranpa/ tx(numref), ty(numref), tz(numref),
& dtx(numref), dty(numref), dtz(numref),
& rx(numref), ry(numref), rz(numref),
& drx(numref), dry(numref), drz(numref),
& scale(numref), dscale(numref), refepc(numref)
if (jopt .eq. 0) then
iopt = 1
else
iopt = jopt
endif
dtime = date - refepc(iopt)
tranx = tx(iopt) + dtx(iopt)*dtime
trany = ty(iopt) + dty(iopt)*dtime
tranz = tz(iopt) + dtz(iopt)*dtime
rotnx = rx(iopt) + drx(iopt)*dtime
rotny = ry(iopt) + dry(iopt)*dtime
rotnz = rz(iopt) + drz(iopt)*dtime
ds = 1.d0 + scale(iopt) + dscale(iopt)*dtime
x2 = tranx + ds*x1 + rotnz*y1 - rotny*z1
y2 = trany - rotnz*x1 + ds*y1 + rotnx*z1
z2 = tranz + rotny*x1 - rotnx*y1 + ds*z1
c write (*,*) "FROM TIIT94 ",dtime
c write (*,*) "FROM TIIT94 ",tx(iopt),ty(iopt),tz(iopt)
c write (*,*) "FROM TIIT94 ",dtx(iopt),dty(iopt),dtz(iopt)
c write (*,*) "FROM TIIT94 ",rx(iopt),ry(iopt),rz(iopt)
c write (*,*) "FROM TIIT94 ",drx(iopt),dry(iopt),drz(iopt)
c write (*,*) "FROM TIIT94 ",scale(iopt),dscale(iopt)
c write (*,*) "FROM TIIT94 ",x2,y2,z2
return
end
*************************************************************************************
subroutine frit94_IERS (x1, y1, z1, x2, y2, z2, date, jopt)
*** Converts ITRF94 cartesian coordinates to cartesian
*** coordinates in the specified reference frame for the
*** given date
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
*** (x1, y1, z1) --> input ITRF94 coordiates (meters)
*** (x2, y2, z2) --> output coordinates (meters)
*** date --> time (decimal years) to which the input & output
*** coordinates correspond
*** jopt --> input specifier of output reference frame
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /tranpa1/ tx1(numref), ty1(numref), tz1(numref),
& dtx1(numref), dty1(numref), dtz1(numref),
& rx1(numref), ry1(numref), rz1(numref),
& drx1(numref), dry1(numref), drz1(numref),
& scale1(numref), dscale1(numref), refepc1(numref)
if (jopt .eq. 0) then
iopt = 1
else
iopt = jopt
endif
dtime = date - refepc1(iopt)
tranx = tx1(iopt) + dtx1(iopt)*dtime
trany = ty1(iopt) + dty1(iopt)*dtime
tranz = tz1(iopt) + dtz1(iopt)*dtime
rotnx = rx1(iopt) + drx1(iopt)*dtime
rotny = ry1(iopt) + dry1(iopt)*dtime
rotnz = rz1(iopt) + drz1(iopt)*dtime
ds = 1.d0 + scale1(iopt) + dscale1(iopt)*dtime
x2 = tranx + ds*x1 + rotnz*y1 - rotny*z1
y2 = trany - rotnz*x1 + ds*y1 + rotnx*z1
z2 = tranz + rotny*x1 - rotnx*y1 + ds*z1
c write (*,*) "FROM TIIT94_IERS ",dtime
c write (*,*) "FROM TIIT94_IERS ",tx1(iopt),ty1(iopt),tz1(iopt)
c write (*,*) "FROM TIIT94_IERS ",dtx1(iopt),dty1(iopt),dtz1(iopt)
c write (*,*) "FROM TIIT94_IERS ",rx1(iopt),ry1(iopt),rz1(iopt)
c write (*,*) "FROM TIIT94_IERS ",drx1(iopt),dry1(iopt),drz1(iopt)
c write (*,*) "FROM TIIT94_IERS ",scale1(iopt),dscale1(iopt)
c write (*,*) "FROM TIIT94_IERS ",x2,y2,z2
return
end
***********************************************************
subroutine toit94(x1, y1, z1, x2, y2, z2, date, jopt)
*** Converts cartesian coordinates in a specified reference
*** to ITRF94 cartesian coordinates for the given date
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
*** (x1, y1, z1) --> input coordiates (meters)
*** (x2, y2, z2) --> output ITRF94 coordinates (meters)
*** date --> time (decimal years) to which the input & output
*** coordinates correspond
*** jopt --> input specifier of input reference frame
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /tranpa/ tx(numref), ty(numref), tz(numref),
& dtx(numref), dty(numref), dtz(numref),
& rx(numref), ry(numref), rz(numref),
& drx(numref), dry(numref), drz(numref),
& scale(numref), dscale(numref), refepc(numref)
if (jopt .eq. 0) then
iopt = 1
else
iopt = jopt
endif
dtime = date - refepc(iopt)
tranx = -(tx(iopt) + dtx(iopt)*dtime)
trany = -(ty(iopt) + dty(iopt)*dtime)
tranz = -(tz(iopt) + dtz(iopt)*dtime)
rotnx = -(rx(iopt) + drx(iopt)*dtime)
rotny = -(ry(iopt) + dry(iopt)*dtime)
rotnz = -(rz(iopt) + drz(iopt)*dtime)
ds = 1.d0 - (scale(iopt) + dscale(iopt)*dtime)
x2 = tranx + ds*x1 + rotnz*y1 - rotny*z1
y2 = trany - rotnz*x1 + ds*y1 + rotnx*z1
z2 = tranz + rotny*x1 - rotnx*y1 + ds*z1
c write (*,*) "TO TIIT94 ",dtime
c write (*,*) "TO TIIT94 ",tx(iopt),ty(iopt),tz(iopt)
c write (*,*) "TO TIIT94 ",dtx(iopt),dty(iopt),dtz(iopt)
c write (*,*) "TO TIIT94 ",rx(iopt),ry(iopt),rz(iopt)
c write (*,*) "TO TIIT94 ",drx(iopt),dry(iopt),drz(iopt)
c write (*,*) "TO TIIT94 ",scale(iopt),dscale(iopt)
c write (*,*) "TO TIIT94 ",x2,y2,z2
return
end
*****************************************************************
subroutine toit94_IERS(x1, y1, z1, x2, y2, z2, date, jopt)
*** Converts cartesian coordinates in a specified reference
*** to ITRF94 cartesian coordinates for the given date
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
*** (x1, y1, z1) --> input coordiates (meters)
*** (x2, y2, z2) --> output ITRF94 coordinates (meters)
*** date --> time (decimal years) to which the input & output
*** coordinates correspond
*** jopt --> input specifier of input reference frame
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /tranpa1/ tx1(numref), ty1(numref), tz1(numref),
& dtx1(numref), dty1(numref), dtz1(numref),
& rx1(numref), ry1(numref), rz1(numref),
& drx1(numref), dry1(numref), drz1(numref),
& scale1(numref), dscale1(numref), refepc1(numref)
if (jopt .eq. 0) then
iopt = 1
else
iopt = jopt
endif
dtime = date - refepc1(iopt)
tranx = -(tx1(iopt) + dtx1(iopt)*dtime)
trany = -(ty1(iopt) + dty1(iopt)*dtime)
tranz = -(tz1(iopt) + dtz1(iopt)*dtime)
rotnx = -(rx1(iopt) + drx1(iopt)*dtime)
rotny = -(ry1(iopt) + dry1(iopt)*dtime)
rotnz = -(rz1(iopt) + drz1(iopt)*dtime)
ds = 1.d0 - (scale1(iopt) + dscale1(iopt)*dtime)
x2 = tranx + ds*x1 + rotnz*y1 - rotny*z1
y2 = trany - rotnz*x1 + ds*y1 + rotnx*z1
z2 = tranz + rotny*x1 - rotnx*y1 + ds*z1
c write (*,*) "TO TIIT94_IERS ",dtime
c write (*,*) "TO TIIT94_IERS ",tx1(iopt),ty1(iopt),tz1(iopt)
c write (*,*) "TO TIIT94_IERS ",dtx1(iopt),dty1(iopt),dtz1(iopt)
c write (*,*) "TO TIIT94_IERS ",rx1(iopt),ry1(iopt),rz1(iopt)
c write (*,*) "TO TIIT94_IERS ",drx1(iopt),dry1(iopt),drz1(iopt)
c write (*,*) "TO TIIT94_IERS ",scale1(iopt),dscale1(iopt)
c write (*,*) "TO TIIT94_IERS ",x2,y2,z2
return
end
*****************************************************************
subroutine MENU1(kopt, mframe)
** Write out options for reference frames
implicit integer*4 (i-n)
character mframe*24, nframe*24
dimension nframe(24)
dimension iframe(24)
common /files/ luin, luout, i1, i2, i3, i4, i5, i6
iframe(1) = 1
nframe(1) = 'NAD_83(2011/CORS96/2007)'
iframe(2) = 12
nframe(2) = 'NAD_83(PA11/PACP00) '
iframe(3) = 13
nframe(3) = 'NAD_83(MA11/MARP00) '
iframe(4) = 10
nframe(4) = 'WGS_72 '
iframe(5) = 1
nframe(5) = 'WGS_84(original) '
c iframe(6) = 6 (This was incorrect in all versions of HTDP)
iframe(6) = 5
nframe(6) = 'WGS_84(G730) '
iframe(7) = 8
nframe(7) = 'WGS_84(G873) '
iframe(8) = 11
nframe(8) = 'WGS_84(G1150) '
iframe(9) = 15
nframe(9) = 'WGS_84(G1674) '
c iframe(10)= 4
c nframe(10)= 'PNEOS_90 or NEOS_90 '
iframe(10)= 15
nframe(10)= 'WGS_84(G1762) '
iframe(11)= 5
nframe(11)= 'SIO/MIT_92 '
iframe(12)= 2
nframe(12)= 'ITRF88 '
iframe(13)= 3
nframe(13)= 'ITRF89 '
iframe(14)= 4
nframe(14)= 'ITRF90 '
iframe(15)= 5
nframe(15)= 'ITRF91 '
iframe(16)= 6
nframe(16)= 'ITRF92 '
iframe(17)= 7
nframe(17)= 'ITRF93 '
iframe(18)= 8
nframe(18)= 'ITRF94 '
iframe(19)= 8
nframe(19)= 'ITRF96 '
iframe(20)= 9
nframe(20)= 'ITRF97 or IGS97 '
iframe(21)= 11
nframe(21)= 'ITRF2000 or IGS00/IGb00 '
iframe(22)= 14
nframe(22)= 'ITRF2005 or IGS05 '
iframe(23)= 15
nframe(23)= 'ITRF2008 or IGS08/IGb08 '
iframe(24)= 16
nframe(24)= 'ITRF2014 or IGS14/IGb14 '
write(luout, 100)
100 format(
1' 1...NAD_83(2011/CORS96/2007) (North American plate fixed) '/
1' 2...NAD_83(PA11/PACP00) (Pacific plate fixed) '/
1' 3...NAD_83(MA11/MARP00) (Mariana plate fixed) '/
1' '/
c 1' 4...WGS_72 '/
1' 5...WGS_84(original) (NAD_83(2011) used) 15...ITRF91 '/
1' 6...WGS_84(G730) (ITRF91 used) 16...ITRF92 '/
1' 7...WGS_84(G873) (ITRF94 used) 17...ITRF93 '/
1' 8...WGS_84(G1150) (ITRF2000 used) 18...ITRF94 '/
1' 9...WGS_84(G1674) (ITRF2008 used) 19...ITRF96 '/
c 1' 10...PNEOS_90 or NEOS_90 (ITRF90 used) 20...ITRF97 or IGS97'/
1' 10...WGS_84(G1762) (IGb08 used) 20...ITRF97 or IGS97'/
1' 11...SIO/MIT_92 (ITRF91 used) 21...ITRF2000 or IGS00/IGb00'/
1' 12...ITRF88 22...ITRF2005 or IGS05 '/
1' 13...ITRF89 23...ITRF2008 or IGS08/IGb08'/
1' 14...ITRF90 or (PNEOS90/NEOS90) 24...ITRF2014 or IGS14/IGb14'/)
c 1' 14...ITRF90 '/ )
read (luin, *,err=50,iostat=ios) iopt
if (ios /= 0) goto 50
if ( 1 .le. iopt .and. iopt .le. 24) then
mframe = nframe(iopt)
kopt = iframe(iopt)
else
mframe = ' '
kopt = iopt
endif
return
50 write (*,*) 'Failed to read option in MENU1:ios=',ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
end
***************************************************************
SUBROUTINE UPDATE(HTDP_version)
** Update positions and/or observations to a specified date.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (numref = 16)
parameter (nbbdim = 10000)
CHARACTER OLDBB*80, NEWBB*80, NAMEIF*80
CHARACTER NAME24*24
CHARACTER OPT*1, ANSWER*1, BBTYPE*1, VOPT*1
CHARACTER LATDIR*1, LONDIR*1, LATDR*1, LONDR*1
character frame1*24, frame2*24
character HTDP_version*8
LOGICAL TEST
LOGICAL Is_iopt_NAD83
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
WRITE(LUOUT,20)
20 FORMAT(' ********************************************'/
1 ' Please enter the time to which the updated'/
1 ' positions and/or observations are to correspond:')
15 CALL GETMDY(MONTH2,IDAY2,IYEAR2,DATE2,MIN2,TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter the time? (y/n)'
read (luin, '(A1)',err=500,iostat=ios) ANSWER
if (ios /= 0) goto 500
if (ANSWER .eq. 'y' .or. ANSWER .eq. 'Y') GO TO 15
RETURN
ENDIF
** Choosing reference frame for positions
35 WRITE(LUOUT,30)
30 FORMAT(' **************************************************'/
1 ' Specify the reference frame of the input positions:'/)
call MENU1( iopt, frame1)
IF(IOPT .LT. 1 .OR. IOPT .GT. numref) THEN
WRITE(LUOUT,40)
40 FORMAT(' Improper selection--try again. ')
GO TO 35
ENDIF
Is_iopt_NAD83 = (iopt == 1)
999 WRITE(LUOUT,1000)
1000 FORMAT(' ******************************'/
1 ' Select option:'/
2 ' 0...No more updates. Return to main menu.'/
3 ' 1...Update positions for individual points',
4 ' entered interactively.'/
5 ' 2...Update positions for blue book stations.'/
6 ' 3...Update values for blue book observations.'/
7 ' 4...Update both the positions for blue book',
8 ' stations'/
9 ' and the values for blue book',
9 ' observations.'/
9 ' 5...Update positions for multiple points contained'/
9 ' in a file in Lat-Lon-Ht format:'/
9 ' LAT,LON,EHT,TEXT'/
9 ' LAT = latitude in degrees (positive north)'/
9 ' LON = longitude in degrees (positive west)'/
9 ' EHT = ellipsoid height in meters'/
9 ' TEXT = Descriptive text (up to 24 characters)'/
9 ' Example:'/
9 ' 40.731671553,112.212671753,34.241,SALT AIR'/)
READ(LUIN,'(A1)',err=501,iostat=ios) OPT
if (ios /= 0) goto 501
IF(OPT .eq. '0') THEN
RETURN
ELSEIF(OPT .eq. '1') THEN
WRITE(LUOUT,1020)
1020 FORMAT(' ************************************'/
1 ' Enter the time',
2 ' to which the input positions will correspond: ')
1025 CALL GETMDY(MONTH1,IDAY1,IYEAR1,DATE1,MIN1,TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter the time? (y/n)'
read(luin,'(A1)',err=500,iostat=ios) ANSWER
if (ios /= 0) goto 500
if(ANSWER .eq. 'Y' .or. ANSWER .eq. 'y') GO TO 1025
RETURN
ENDIF
WRITE(LUOUT,1030)
1030 FORMAT(' ENTER file to save updated positions. ')
READ(LUIN,'(A80)',err=502,iostat=ios) NEWBB
if (ios /= 0) goto 502
OPEN(I2,FILE=NEWBB,STATUS='UNKNOWN')
CALL HEADER
WRITE(I2,1031) frame1
1031 FORMAT(' UPDATED POSITIONS IN ', a24)
WRITE(I2,1040) MONTH1,IDAY1,IYEAR1,MONTH2,IDAY2,IYEAR2,
1 DATE1, DATE2
1040 FORMAT(' FROM ',I2,'-',I2.2,'-',I4,
1 ' TO ',I2,'-',I2.2,'-',I4,' (month-day-year)'/
1 ' FROM ',F8.3, ' TO ',F8.3, ' (decimal years)'//
2 16X,'OLD COORDINATE NEW COORDINATE',
3 4X,'VELOCITY DISPLACEMENT',/)
1050 CALL GETPNT(LATD,LATM,SLAT,LATDIR,LOND,LONM,SLON,
1 LONDIR, NAME24, X,Y,Z,YLAT,YLON,EHT)
ELON = -YLON
call GETVLY(YLAT,ELON,VX,VY,VZ,VN,VE,VU,VOPT,210)
IF ( VOPT .EQ. '0') then
call PREDV( ylat, ylon, eht, date1, iopt,
1 jregn, vn, ve, vu)
IF(JREGN .eq. 0) THEN
WRITE(LUOUT,1060)
1060 FORMAT(' **************************************'/
1 ' Can not update the position of this point'/
2 ' because it is outside of the modeled region.'/)
GO TO 1075
ELSE
call TOVXYZ(ylat,elon,vn,ve,vu,vx,vy,vz)
ENDIF
ENDIF
call NEWCOR(ylat,ylon,eht,min1,min2,
1 ylatt,ylont,ehtnew,dn,de,du,vn,ve,vu)
CALL TODMSS(YLATT,LATDN,LATMN,SLATN,ISIGN)
LATDR = 'N'
IF (ISIGN .eq. -1) LATDR = 'S'
CALL TODMSS(YLONT,LONDN,LONMN,SLONN,ISIGN)
LONDR = 'W'
IF (ISIGN .eq. -1) LONDR = 'E'
ELONT = -YLONT
CALL TOXYZ(YLATT,ELONT,EHTNEW,X1,Y1,Z1)
DX = X1 - X
DY = Y1 - Y
DZ = Z1 - Z
WRITE(LUOUT,1065)LATDN,LATMN,SLATN,LATDR,LONDN,LONMN,SLONN,
1 LONDR, EHTNEW, X1,Y1,Z1
1065 FORMAT(' ****************************************'/
1 ' Updated latitude = ',I3,I3,1X,F8.5,1X,A1 /
2 ' Updated longitude = ',I3,I3,1X,F8.5,1X,A1 /
2 ' Updated Ellip. Ht. = ', F12.3 ,' meters' /
3 ' Updated X = ',F12.3 ,' meters' /
4 ' Updated Y = ',F12.3 ,' meters' /
5 ' Updated Z = ',F12.3 ,' meters' /
3 ' ****************************************'/)
WRITE(I2,1070)NAME24,
1 LATD,LATM,SLAT,LATDIR,LATDN,LATMN,SLATN,LATDR,vn,DN,
1 LOND,LONM,SLON,LONDIR,LONDN,LONMN,SLONN,LONDR,ve,DE,
1 EHT, EHTNEW, vu,DU, X, X1, vx,DX,
1 Y, Y1, vy,DY, Z, Z1, vz,DZ
1070 FORMAT(1X,A24,/
1 1X, 'LATITUDE ',2(2X,I3,I3.2,1X,F8.5,1X,A1),
1 F8.2, ' mm/yr', f8.3, ' m north'/
1 1X, 'LONGITUDE ',2(2X,I3,I3.2,1X,F8.5,1x,A1),
1 f8.2, ' mm/yr',f8.3,' m east'/
1 1X, 'ELLIP. HT.',2(6X,F13.3),
1 f8.2, ' mm/yr',F8.3,' m up'/
1 1X, 'X ',2(6X,F13.3),
1 f8.2, ' mm/yr',F8.3,' m '/
1 1X, 'Y ',2(6X,F13.3),
1 f8.2, ' mm/yr',f8.3, ' m'/
1 1X, 'Z ',2(6X,F13.3),
1 f8.2, ' mm/yr',F8.3,' m'/)
1075 WRITE(LUOUT,1080)
1080 FORMAT(' Update more positions? (y/n) ')
READ(LUIN,'(A1)',err=500,iostat=ios) ANSWER
if (ios /= 0) goto 500
IF(ANSWER .eq. 'Y' .or. ANSWER .eq. 'y') GO TO 1050
CLOSE(I2,STATUS='KEEP')
RETURN
*** Updating a blue book
ELSEIF(OPT .eq. '2' .or. OPT .eq. '3' .or. OPT .eq. '4') THEN
if (nbbdim .eq. 10000) then
90 WRITE(LUOUT,91)
91 FORMAT(
1 ' Identify type of blue book:'/
2 ' 1...Standard (4-digit SSN)'/
3 ' 2...Non-standard (5-digit SSN) ')
READ(LUIN,'(A1)',err=503,iostat=ios) BBTYPE
if (ios /= 0) goto 503
IF(BBTYPE .NE. '1' .AND. BBTYPE .NE. '2') GO TO 90
else
BBTYPE = '1'
endif
WRITE(LUOUT,100)
100 FORMAT(' Enter name of the blue book file to be updated.'/)
READ(LUIN,110,err=502,iostat=ios) OLDBB
if (ios /= 0) goto 502
110 FORMAT(A80)
WRITE(LUOUT,120)
120 FORMAT(' Enter name for the new blue book file that is to '/
1 'contain the updated information.'/)
READ(LUIN,110,err=502,iostat=ios) NEWBB
if (ios /= 0) goto 502
OPEN(I1,FILE = OLDBB , STATUS = 'OLD')
OPEN(I4, ACCESS = 'DIRECT', RECL = 40,
1 FORM = 'UNFORMATTED', STATUS = 'SCRATCH')
IF(OPT .eq. '2' .or. OPT .eq. '4') THEN
WRITE(LUOUT,122)
122 FORMAT(' *********************************************'/
1 ' Enter the time',
1 ' to which the input positions correspond:'/)
123 CALL GETMDY(MONTH1,IDAY1,IYEAR1,DATE1,MIN1,TEST)
IF(TEST) then
write(luout,*) ' Do you wish to re-enter the time? (y/n)'
read(luin, '(A1)',err=500,iostat=ios) ANSWER
if (ios /= 0) goto 500
IF (ANSWER .eq. 'y' .or. ANSWER .eq. 'Y') GO TO 123
RETURN
ENDIF
ENDIF
*** Retrieve geodetic positions from old blue-book file
IF(BBTYPE .EQ. '1') THEN
CALL GETPO4(IOPT, DATE1)
ELSEIF(BBTYPE .EQ. '2') THEN
CALL GETPO5(IOPT, DATE1)
ENDIF
*** Create new blue book file
OPEN(I2,FILE = NEWBB, STATUS = 'UNKNOWN')
write (i2,127) HTDP_version
127 format (' ***CAUTION: This file was processed using HTDP',
& ' version ', a8, '***')
write (i2,128) frame1
128 format (' ***CAUTION: Coordinates in this file are in ',
& a24, '***')
IF (OPT .EQ. '2' .OR. OPT .EQ. '4') THEN
WRITE(I2, 129) MONTH2, IDAY2, IYEAR2, DATE2
129 FORMAT(' ***CAUTION: Coordinates in this file have been ',
* 'updated to ',I2,'-',I2.2,'-',I4, ' = (',F8.3,') ***')
ENDIF
c IF (OPT .EQ. '3' .OR. OPT .EQ. '4') THEN
c WRITE(I2, 130) MONTH2, IDAY2, IYEAR2, DATE2
c 130 FORMAT(' ***CAUTION: Observations in this file have been ',
c * 'updated to ',I2,'-',I2.2,'-',I4, ' = (',F8.3,') ***')
c ENDIF
IF(BBTYPE .EQ. '1') THEN
CALL UPBB4(MIN1,MIN2,OPT)
ELSEIF(BBTYPE .EQ. '2') THEN
CALL UPBB5(MIN1,MIN2,OPT)
ENDIF
CLOSE(I1, STATUS = 'KEEP')
CLOSE(I2, STATUS = 'KEEP')
*** Update G-FILE
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
605 WRITE(LUOUT,610)
610 FORMAT(/' Is there a G-FILE to be updated? (y/n) ')
READ(LUIN,'(A1)',err=500,iostat=ios) ANSWER
if (ios /= 0) goto 500
IF(ANSWER .eq. 'N' .or. ANSWER .eq. 'n') THEN
CONTINUE
ELSEIF(ANSWER .eq. 'Y' .or. ANSWER .eq. 'y')THEN
WRITE(LUOUT,620)
620 FORMAT(' Enter name of old G-FILE to be updated. ')
READ(LUIN,'(A80)',err=502,iostat=ios) OLDBB
if (ios /= 0) goto 502
WRITE(LUOUT,630)
630 FORMAT(' Enter name for the new updated G-FILE. ')
READ(LUIN,'(A80)',err=502,iostat=ios) NEWBB
if (ios /= 0) goto 502
OPEN(I1,FILE=OLDBB,STATUS='OLD')
OPEN(I2,FILE=NEWBB,STATUS='UNKNOWN')
WRITE(I2,130) MONTH2, IDAY2, IYEAR2, DATE2
130 FORMAT(' ***CAUTION: Observations in this file have been ',
* 'updated to ',I2,'-',I2.2,'-',I4, ' = (',F8.3,') ***')
634 WRITE(LUOUT, 632)
632 FORMAT(/' ***************************'/
* ' Specify the reference frame for the updated'
* ' G-File vectors:'//
* ' -1...Do not transform GPS vectors.')
CALL MENU1(kopt, frame2)
IF(KOPT .LT. -1 .OR. KOPT .GT. numref) THEN
WRITE(LUOUT, 40)
GO TO 634
ELSEIF (1 .LE. KOPT .AND. KOPT .LE. numref) then
write( I2, 640) frame2
640 format( ' ***CAUTION: All GPS interstation vectors',
1 ' have been transformed to ', a24, ' ***')
write( I2, 641) HTDP_version
641 format(' ***CAUTION: Observations were transformed using'
1 ,' HTDP version ', a8, ' ***')
ENDIF
IF(BBTYPE .EQ. '1') THEN
CALL UPGFI4(DATE2, MIN2, IOPT, KOPT,
* MONTH2, IDAY2, IYEAR2)
ELSEIF(BBTYPE .EQ. '2') THEN
CALL UPGFI5(DATE2, MIN2, IOPT, KOPT,
* MONTH2, IDAY2, IYEAR2)
ENDIF
CLOSE(I1, STATUS = 'KEEP')
CLOSE(I2, STATUS = 'KEEP')
ELSE
WRITE(LUOUT,700)
GO TO 605
ENDIF
ENDIF
CLOSE(I4, STATUS = 'DELETE')
RETURN
ELSEIF (OPT .eq. '5') then
write (luout, 710)
710 format(' Enter name of input file ')
read( luin, 711,err=502,iostat=ios) NAMEIF
if (ios /= 0) goto 502
711 format( a30 )
open(I1, FILE=NAMEIF, STATUS = 'OLD')
write(luout, 1020)
720 call GETMDY(MONTH1,IDAY1,IYEAR1,DATE1,MIN1,TEST)
if(TEST) then
write(luout,*) ' Do you wish to re-enter the time? (y/n)'
read(luin, '(A1)',err=500,iostat=ios) ANSWER
if (ios /= 0) goto 500
if(ANSWER .eq. 'Y' .or. ANSWER .eq. 'y') GO TO 720
RETURN
endif
write(luout, 1030)
read(luin, '(A80)',err=502,iostat=ios)NEWBB
if (ios /= 0) goto 502
open(I2, FILE=NEWBB, STATUS='UNKNOWN')
CALL HEADER
write(I2, 1031) frame1
write(I2, 1040) MONTH1,IDAY1,IYEAR1,
1 MONTH2,IDAY2,IYEAR2,DATE1,DATE2
730 read(I1,*,END = 750,err=504,iostat=ios) XLAT, XLON, EHT, NAME24
if (ios /= 0) goto 504
YLAT = (XLAT*3600.d0) / rhosec
Ylon = (XLON*3600.d0) / rhosec
ELON = -YLON
call TODMSS(ylat,latd,latm,slat,ISIGN)
if (ISIGN .eq. 1) then
latdir = 'N'
else
latdir = 'S'
endif
call TODMSS (ylon,lond,lonm,slon,isign)
if (isign .eq. 1) then
londir = 'W'
else
londir = 'E'
endif
call PREDV(ylat,ylon,eht,date1,iopt,jregn,vn,ve,vu)
if(jregn .eq. 0) then
write(I2, 735) name24, latd,latm,slat,latdir,
1 lond,lonm,slon,londir
735 format(1x,a24,/
1 1x, 'LATITUDE ', 2x,i3,i3.2,1x,f8.5,1x,a1,3x,
1 'POINT LOCATED OUTSIDE OF MODELED REGION'/
1 1x, 'LONGITUDE ', 1x,i3,i3.2,1x,f8.5,1x,a1 /)
else
call TOVXYZ(ylat,elon,vn,ve,vu,vx,vy,vz)
call NEWCOR(ylat,ylon,eht,min1,min2,ylatt,ylont,ehtnew,
1 dn,de,du,vn,ve,vu)
call TODMSS(YLATT,latdn,latmn,slatn,isign)
latdr = 'N'
if (isign .eq. -1) latdr = 'S'
call TODMSS(ylont,londn,lonmn,slonn,isign)
londr = 'W'
if (isign .eq. -1) londr = 'E'
call TOXYZ(ylat,elon,eht,x,y,z)
elont = -ylont
call TOXYZ(ylatt,elont,ehtnew,x1,y1,z1)
dx = x1 - x
dy = y1 - y
dz = z1 - z
write(I2, 1070) NAME24, latd,latm,slat,latdir,
1 latdn,latmn,slatn,latdr,vn,dn,
1 lond,lonm,slon,londir,londn,lonmn,slonn,londr,ve,de,
1 eht,ehtnew,vu,du, x, x1,vx,dx,
1 y, y1,vy,dy, z, z1, vz,dz
endif
go to 730
750 close(I1, STATUS='KEEP')
close(I2, status = 'KEEP')
return
ELSE
WRITE(LUOUT,700)
700 FORMAT(' Improper entry !'/)
GO TO 999
ENDIF
500 write (*,'(/)')
write (*,*) "Failed to read answer in UPDATE:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
501 write (*,'(/)')
write (*,*) "Failed to read OPTION in UPDATE:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
502 write (*,'(/)')
write (*,*) "Failed to read file name in UPDATE:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
503 write (*,'(/)')
write (*,*) "Failed to read BBTYPE in UPDATE:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
504 write (*,'(/)')
write (*,*) "Failed to read input in UPDATE:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*******************************************************************
SUBROUTINE GETPO4(IOPT, DATE)
*** Retrieve geodetic coordinates from the blue book
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (nbbdim = 10000)
CHARACTER JN*1,JW*1
CHARACTER TYPE*4
CHARACTER CARD*80
CHARACTER PIDs*6
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /ARRAYS/ HT(nbbdim),LOC(nbbdim),PIDs(nbbdim)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
DO 100 I = 1, 10000
LOC(I) = 0
HT(I) = 0.D0
100 CONTINUE
JREC = 0
125 READ(I1,130,END=160,err=200,iostat=ios) CARD
if (ios /= 0) goto 200
130 FORMAT(A80)
TYPE = CARD(7:10)
IF(TYPE .EQ. '*80*') THEN
JREC = JREC + 1
READ(CARD,140,err=201,iostat=ios) ISN,LATD,LATM,SLAT,JN,LOND,
& LONM,SLON,JW,OH
if (ios /= 0) goto 201
140 FORMAT(BZ,10X,I4,T45,2I2,F7.5,A1,I3,I2,F7.5,A1,F6.2)
LOC(ISN) = JREC
C HT(ISN) = HT(ISN) + OH
IF ( HT(ISN) .EQ. 0.D0 ) HT(ISN) = OH
c write (*,*) SLAT,SLON,HT(ISN) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
YLAT = (DBLE((LATD*60+LATM)*60)+SLAT)/RHOSEC
YLON = (DBLE((LOND*60+LONM)*60)+SLON)/RHOSEC
IF(JN .EQ. 'S') YLAT = -YLAT
IF(JW .EQ. 'E') YLON = -YLON
c write (*,*) ylat,ylon !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call PREDV( ylat, ylon, ht(isn), date, iopt,
1 IDG, vn, ve, vu)
c write (*,*) 'IDG ',IDG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
IF(IDG .eq. 0) THEN
WRITE(LUOUT,150) CARD
150 FORMAT(' **WARNING** The following point is outside of ',
1 'the modeled region.'/
2 ' It will be assumed that this point has not moved.'/A80/)
ENDIF
WRITE(I4, REC = JREC) YLAT, YLON, VN, VE, VU
C ELSEIF(TYPE .eq. '*84*') THEN
C READ(CARD,155) ISN,GH
C 155 FORMAT(BZ,10X,I4,T70,F6.2)
C HT(ISN) = HT(ISN) + GH
ELSEIF(TYPE .eq. '*86*') THEN
IF(CARD(46:52) .ne. ' ') THEN
READ(CARD,156,err=202,iostat=ios) ISN, EHT
if (ios /= 0) goto 202
156 FORMAT(BZ,10X,I4,T46,F7.3)
HT(ISN) = EHT
ELSE
READ(CARD,157,err=202,iostat=ios) ISN, OHT, GHT
if (ios /= 0) goto 202
157 FORMAT(BZ,10X,I4,T17,F7.3,T36,F7.3)
HT(ISN) = OHT + GHT
ENDIF
ENDIF
GO TO 125
160 REWIND I1
RETURN
200 write (*,'(/)')
write (*,*) "Failed 1st reading in GETPO4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
201 write (*,'(/)')
write (*,*) "Failed reading *80* record in GETPO4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
202 write (*,'(/)')
write (*,*) "Failed reading *86* record in GETPO4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
******************************************************************
SUBROUTINE GETPO5(IOPT, DATE)
*** Retrieve geodetic position from blue book with 5-digit SSN
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (nbbdim = 10000)
CHARACTER JN*1,JW*1
CHARACTER TYPE*3
CHARACTER CARD*80
CHARACTER PIDs*6
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /ARRAYS/ HT(nbbdim),LOC(nbbdim),PIDs(nbbdim)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
DO 100 I = 1, 10000
LOC(I) = 0
HT(I) = 0.D0
100 CONTINUE
JREC = 0
125 READ(I1,130,END=160,err=200,iostat=ios) CARD
if (ios /= 0) goto 200
130 FORMAT(A80)
TYPE = CARD(7:9)
IF(TYPE .EQ. '*80') THEN
JREC = JREC + 1
READ(CARD,140,err=201,iostat=ios) ISN,LATD,LATM,SLAT,JN,LOND,
& LONM,SLON,JW,OH
if (ios /= 0) goto 200
140 FORMAT(BZ, 9X,I5,T45,2I2,F7.5,A1,I3,I2,F7.5,A1,F6.2)
LOC(ISN) = JREC
C HT(ISN) = HT(ISN) + OH
IF ( HT(ISN) .EQ. 0.D0 ) HT(ISN) = OH
YLAT = (DBLE((LATD*60+LATM)*60)+SLAT)/RHOSEC
YLON = (DBLE((LOND*60+LONM)*60)+SLON)/RHOSEC
IF(JN .EQ. 'S') YLAT = -YLAT
IF(JW .EQ. 'E') YLON = -YLON
call PREDV( ylat, ylon, ht(isn), date, iopt,
1 idg, vn, ve, vu)
IF(IDG .eq. 0) THEN
WRITE(LUOUT,150) CARD
150 FORMAT(' **WARNING** The following point is outside of ',
1 'the modeled region.'/
2 ' It will be assumed that this point has not moved.'/A80/)
ENDIF
WRITE(I4, REC = JREC) YLAT, YLON, VN, VE, VU
C ELSEIF(TYPE .eq. '*84') THEN
C READ(CARD,155) ISN,GH
C 155 FORMAT(BZ, 9X,I5,T70,F6.2)
C HT(ISN) = HT(ISN) + GH
ELSEIF(TYPE .eq. '*86') THEN
IF(CARD(46:52) .ne. ' ') THEN
READ(CARD,156,err=202,iostat=ios) ISN, EHT
if (ios /= 0) goto 202
156 FORMAT(BZ, 9X,I5,T46,F7.3)
HT(ISN) = EHT
ELSE
READ(CARD,157,err=202,iostat=ios) ISN, OHT, GHT
if (ios /= 0) goto 202
157 FORMAT(BZ, 9X,I5,T17,F7.3,T36,F7.3)
HT(ISN) = OHT + GHT
ENDIF
ENDIF
GO TO 125
160 REWIND I1
RETURN
200 write (*,'(/)')
write (*,*) "Failed 1st reading in GETPO4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
201 write (*,'(/)')
write (*,*) "Failed reading *80* record in GETPO4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
202 write (*,'(/)')
write (*,*) "Failed reading *86* record in GETPO4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
******************************************************************
SUBROUTINE UPBB4(MIN1,MIN2,OPT)
*** Update blue book
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (nbbdim = 10000)
CHARACTER CARD*80
CHARACTER DATE*6
CHARACTER TYPE*4
CHARACTER OPT*1,JN*1,JW*1
CHARACTER LATDIR*1, LONDIR*1
CHARACTER PIDs*6
LOGICAL TEST, TEST1
COMMON /ARRAYS/ HT(nbbdim),LOC(nbbdim) ,PIDs(nbbdim)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
C*** To update classical observations an *12* record
C*** is needed to identify the correct century, as
C*** classical observation records contain only a 2-digit year
IREC12 = 0
170 READ(I1,175,END=600,err=700,iostat=ios) CARD
if (ios /= 0) goto 700
175 FORMAT(A80)
TYPE = CARD(7:10)
IF(TYPE .EQ. '*A1*' .OR.
1 TYPE .EQ. '*AA*' .OR.
1 TYPE .EQ. '*10*' .OR.
1 TYPE .EQ. '*11*' .OR.
1 TYPE .EQ. '*13*' .OR.
1 TYPE .EQ. '*21*' .OR.
1 TYPE .EQ. '*25*' .OR.
1 TYPE .EQ. '*26*' .OR.
1 TYPE .EQ. '*27*' .OR.
1 TYPE .EQ. '*28*' .OR.
1 TYPE .EQ. '*29*' ) THEN
CONTINUE
ELSEIF(TYPE .EQ. '*31*' .OR.
1 TYPE .EQ. '*40*' .OR.
1 TYPE .EQ. '*41*' .OR.
1 TYPE .EQ. '*42*' .OR.
1 TYPE .EQ. '*45*' .OR.
1 TYPE .EQ. '*46*' .OR.
1 TYPE .EQ. '*47*' .OR.
1 TYPE .EQ. '*70*' .OR.
1 TYPE .EQ. '*81*' .OR.
1 TYPE .EQ. '*82*' .OR.
1 TYPE .EQ. '*83*' .OR.
1 TYPE .EQ. '*84*' .OR.
1 TYPE .EQ. '*85*' .OR.
1 TYPE .EQ. '*86*' .OR.
1 TYPE .EQ. '*90*') THEN
CONTINUE
ELSEIF (TYPE .EQ. '*12*') THEN
IF( CARD(11:14) .EQ. ' ' .OR.
1 CARD(17:20) .EQ. ' ') THEN
WRITE ( LUOUT, 176 )
176 FORMAT( ' ERROR: The *12* record does not contain'/
1 ' appropriate dates.')
ELSE
READ ( CARD, 177,err=701,iostat=ios) IYEAR1, IYEAR2
if (ios /= 0) goto 701
177 FORMAT ( 10X, I4, 2X, I4)
IF ( (IYEAR2 - IYEAR1) .LT. 0 .OR.
1 (IYEAR2 - IYEAR1) .GT. 99 ) THEN
WRITE (LUOUT, 178)
178 FORMAT(' ERROR: The dates in the *12* record are in'/
1 ' error. Either they span more than 99 years or '/
1 ' the end date preceedes the start date.'/
1 ' If they span more than 99 years, then the Bluebook'/
1 ' will need to divided into two or more bluebooks'/
1 ' with the observations in each spanning no more'/
1 ' than 99 years.')
ELSE
IREC12 = 1
ENDIF
ENDIF
*** Regular distance
ELSEIF(TYPE .EQ. '*50*' .OR.
1 TYPE .EQ. '*51*' .OR.
1 TYPE .EQ. '*52*') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4')THEN
READ(CARD,180,err=702,iostat=ios) ISN,DATE,JSN,OBS
if (ios /= 0) goto 702
180 FORMAT(BZ,10X,I4,T35,A6,T46,I4,T64,F9.4)
CALL CHECK(ISN,JSN,CARD,TEST)
IF(TEST) THEN
CALL TRFDAT(CARD,DATE,IREC12,IYEAR1,IYEAR2,MINO)
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
IOBS = IDNINT((OBS+DS)*10000.D0)
WRITE(CARD(64:72),190) IOBS
190 FORMAT(I9)
ENDIF
ENDIF
*** Azimuth
ELSEIF(TYPE .EQ. '*60*' .OR. TYPE .EQ. '*61*') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
READ(CARD,200,err=703,iostat=ios)ISN,DATE,JSN,IDEG,MIN,SEC
if (ios /= 0) goto 703
200 FORMAT(BZ,10X,I4,T40,A6,T51,I4,T64,I3,I2,F3.1)
CALL CHECK(ISN,JSN,CARD,TEST)
IF(TEST) THEN
CALL TRFDAT(CARD,DATE,IREC12, IYEAR1, IYEAR2, MINO)
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
OBS = (DBLE((IDEG*60+MIN)*60)+SEC)/RHOSEC
OBS = OBS + DA
IF(OBS .GE. TWOPI) THEN
OBS = OBS - TWOPI
ELSEIF(OBS .LT. 0.D0) THEN
OBS = OBS + TWOPI
ENDIF
CALL TODMSS(OBS,IDEG,MIN,SEC,ISIGN)
ISEC = IDNINT(SEC*10.D0)
WRITE(CARD(64:71),210) IDEG,MIN,ISEC
210 FORMAT(I3,I2.2,I3.3)
ENDIF
ENDIF
*** Direction observation
ELSEIF(TYPE .EQ. '*20*') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
READ(CARD,220,err=704,iostat=ios) ISN0,LIST0,DATE,JSN
if (ios /= 0) goto 704
220 FORMAT(BZ,10X,I4,I2,T40,A6,T51,I4)
CALL CHECK(ISN0,JSN,CARD,TEST)
CALL TRFDAT(CARD,DATE,IREC12, IYEAR1, IYEAR2, MINO)
IF(TEST) THEN
CALL DSDA(LOC(ISN0),LOC(JSN),MINO,MIN2,DS,DA0)
ELSE
DA0 = 0.D0
ENDIF
ENDIF
ELSEIF(TYPE .EQ. '*22*') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
READ(CARD,230,err=705,iostat=ios) ISN,LIST,JSN,IDEG,MIN,SEC
if (ios /= 0) goto 705
230 FORMAT(BZ,10X,I4,I2,T51,I4,T64,I3,I2,F4.2)
IF(LIST.NE.LIST0 .OR. ISN.NE.ISN0) THEN
WRITE(LUOUT,240) CARD
240 FORMAT(' Blue-book file has incorrect structure.'/
1 ' A *22* record disagrees with its corresponding'/
2 ' *20* record. The record reads:'/A80)
STOP
ENDIF
CALL CHECK(ISN,JSN,CARD,TEST)
IF(TEST) THEN
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
OBS=(DBLE((IDEG*60+MIN)*60)+SEC)/RHOSEC
OBS = OBS + DA - DA0
IF(OBS .GT. TWOPI) THEN
OBS = OBS - TWOPI
ELSEIF(OBS .LT. 0.D0) THEN
OBS = OBS + TWOPI
ENDIF
CALL TODMSS(OBS,IDEG,MIN,SEC,ISIGN)
ISEC = IDNINT(SEC*100.D0)
WRITE(CARD(64:72),250) IDEG,MIN,ISEC
250 FORMAT(I3.3,I2.2,I4.4)
ENDIF
ENDIF
*** Long distance
ELSEIF(TYPE .EQ. '*53*' .OR.
1 TYPE .EQ. '*54*') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
READ(CARD,260,err=706,iostat=ios) ISN,DATE,JSN,OBS
if (ios /= 0) goto 706
260 FORMAT(BZ,10X,I4,T35,A6,T46,I4,T64,F10.3)
CALL CHECK(ISN,JSN,CARD,TEST)
IF(TEST) THEN
CALL TRFDAT(CARD,DATE,IREC12, IYEAR1, IYEAR2, MINO)
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
IOBS = IDNINT((OBS + DS)*1000.D0)
WRITE(CARD(64:73),270) IOBS
270 FORMAT(I10)
ENDIF
ENDIF
*** Horizontal angle
ELSEIF(TYPE .EQ. '*30*' .OR.
1 TYPE .EQ. '*32*') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
READ(CARD,280,err=707,iostat=ios) ISN,JSN,IDEG,MIN,SEC,KSN
if (ios /= 0) goto 707
280 FORMAT(BZ,10X,I4,T51,I4,T64,I3,I2,F3.1,I4)
IF(TYPE.EQ.'*30*') THEN
DATE = CARD(40:45)
CALL TRFDAT(CARD,DATE,IREC12, IYEAR1, IYEAR2, MINO)
ENDIF
CALL CHECK(ISN,JSN,CARD,TEST)
CALL CHECK(ISN,KSN,CARD,TEST1)
IF(TEST .and. TEST1) THEN
CALL DSDA(LOC(ISN), LOC(JSN),
1 MINO, MIN2, DS, DA0)
CALL DSDA(LOC(ISN), LOC(KSN),
1 MINO, MIN2, DS, DA)
OBS=(DBLE((IDEG*60+MIN)*60)+SEC)/RHOSEC
OBS = OBS + DA - DA0
IF(OBS .GE. TWOPI) THEN
OBS = OBS - TWOPI
ELSEIF(OBS .LT. 0.D0) THEN
OBS = OBS + TWOPI
ENDIF
CALL TODMSS(OBS,IDEG,MIN,SEC,ISIGN)
ISEC = IDNINT(SEC*10.D0)
WRITE(CARD(64:71),290)IDEG,MIN,SEC
290 FORMAT(I3.3,I2.2,I3.3)
ENDIF
ENDIF
*** position record
ELSEIF(TYPE .EQ. '*80*') THEN
IF(OPT .eq. '2' .or. OPT .eq. '4') THEN
READ(CARD,300,err=708,iostat=ios) ISN,LATD,LATM,
& SLAT,JN,LOND,LONM,SLON,JW
if (ios /= 0) goto 708
300 FORMAT(BZ,10X,I4,T45,2I2,F7.5,A1,I3,I2,F7.5,A1)
YLAT = (DBLE((LATD*60+LATM)*60)+SLAT)/RHOSEC
YLON = (DBLE((LOND*60+LONM)*60)+SLON)/RHOSEC
IF(JN .EQ. 'S') YLAT = -YLAT
IF(JW .EQ. 'E') YLON = -YLON
C READ(I4, REC = LOC(ISN)) RLAT, RLON, IDG
READ(I4, REC = LOC(ISN),err=709,iostat=ios) RLAT,
& RLON, VN, VE, VU
if (ios /= 0) goto 709
call NEWCOR( ylat, ylon, ht(isn), min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
C CALL NWCORD(YLAT,YLON,HT(ISN),
C 1 RLAT,RLON,IDG,MIN1,MIN2,
C 1 YLATT,YLONT,EHTNEW,DN,DE,DU,IOPT)
CALL TODMSS(YLATT,LATDN,LATMN,SLATN,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
CALL TODMSS(YLONT,LONDN,LONMN,SLONN,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
LATS = IDNINT(SLATN*100000.D0)
LONS = IDNINT(SLONN*100000.D0)
WRITE(CARD(45:56),310) LATDN,LATMN,LATS,LATDIR
310 FORMAT(I2,I2.2,I7.7,A1)
WRITE(CARD(57:69),320) LONDN,LONMN,LONS,LONDIR
320 FORMAT(I3,I2.2,I7.7,A1)
ENDIF
*** Unrecognized blue book record
*** Associated ELSE statement with label 500 deleted in v3.3.0.
ENDIF
WRITE(I2,175) CARD
GO TO 170
600 CONTINUE
RETURN
700 write (*,'(/)')
write (*,*) "Failed to read card in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
701 write (*,'(/)')
write (*,*) "Failed to read card *12* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
702 write (*,'(/)')
write (*,*) "Failed to read *50,51,52* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
703 write (*,'(/)')
write (*,*) "Failed to read *60,61* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
704 write (*,'(/)')
write (*,*) "Failed to read *20* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
705 write (*,'(/)')
write (*,*) "Failed to read *22* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
706 write (*,'(/)')
write (*,*) "Failed to read *53,54* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
707 write (*,'(/)')
write (*,*) "Failed to read *30,32* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
708 write (*,'(/)')
write (*,*) "Failed to read *80* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
709 write (*,'(/)')
write (*,*) "Failed to read I4 of *80* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
***************************************************************
SUBROUTINE UPBB5(MIN1,MIN2,OPT)
*** Update 5-digit blue book
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (nbbdim = 10000)
CHARACTER CARD*212
CHARACTER SUBCRD*80
C CHARACTER DATE*6
CHARACTER DATE8*8
CHARACTER TYPE*3
CHARACTER OPT*1,SIGN*1,JN*1,JW*1
CHARACTER LATDIR*1,LONDIR*1
CHARACTER PIDs*6
LOGICAL TEST
COMMON /ARRAYS/ HT(nbbdim),LOC(nbbdim) ,PIDs(nbbdim)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
170 READ(I1,175,END=600,err=700,iostat=ios) CARD
if (ios /= 0) goto 700
175 FORMAT(A212)
SUBCRD = CARD(1:80)
TYPE = CARD(7:9)
IF(TYPE .EQ. '*A1' .OR.
1 TYPE .EQ. '*AA' .OR.
1 TYPE .EQ. '*10' .OR.
1 TYPE .EQ. '*11' .OR.
1 TYPE .EQ. '*12' .OR.
1 TYPE .EQ. '*13' .OR.
1 TYPE .EQ. '*21' .OR.
1 TYPE .EQ. '*25' .OR.
1 TYPE .EQ. '*26' .OR.
1 TYPE .EQ. '*27' .OR.
1 TYPE .EQ. '*28' .OR.
1 TYPE .EQ. '*29' ) THEN
CONTINUE
ELSEIF(TYPE .EQ. '*31' .OR.
1 TYPE .EQ. '*40' .OR.
1 TYPE .EQ. '*41' .OR.
1 TYPE .EQ. '*42' .OR.
1 TYPE .EQ. '*45' .OR.
1 TYPE .EQ. '*46' .OR.
1 TYPE .EQ. '*47' .OR.
1 TYPE .EQ. '*70' .OR.
1 TYPE .EQ. '*81' .OR.
1 TYPE .EQ. '*82' .OR.
1 TYPE .EQ. '*83' .OR.
1 TYPE .EQ. '*84' .OR.
1 TYPE .EQ. '*85' .OR.
1 TYPE .EQ. '*86' .OR.
1 TYPE .EQ. '*90') THEN
CONTINUE
*** Regular distance
ELSEIF(TYPE .EQ. '*50' .OR.
1 TYPE .EQ. '*51' .OR.
1 TYPE .EQ. '*52') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4')THEN
C READ(CARD,180) ISN,DATE,JSN,OBS
C 180 FORMAT(BZ, 9X,I5,T35,A6,T46,I5,T64,F9.4)
READ(CARD,180,err=702,iostat=ios) ISN,JSN,OBS,DATE8
if (ios /= 0) goto 702
180 FORMAT(BZ, 9X,I5,T46,I5,T64,F9.4,T101,A8)
CALL CHECK(ISN,JSN,SUBCRD,TEST)
IF(TEST) THEN
CALL TNFDAT(DATE8,MINO)
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
IOBS = IDNINT((OBS+DS)*10000.D0)
WRITE(CARD(64:72),190) IOBS
190 FORMAT(I9)
WRITE(CARD(174:181),191) DS
191 FORMAT(F8.4)
ENDIF
ENDIF
*** Azimuth
ELSEIF(TYPE .EQ. '*60' .OR. TYPE .EQ. '*61') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
C READ(CARD,200) ISN,DATE,JSN,IDEG,MIN,SEC
C 200 FORMAT(BZ, 9X,I5,T40,A6,T51,I5,T64,I3,I2,F3.1)
READ(CARD,200,err=703,iostat=ios) ISN,JSN,IDEG,MIN,
& SEC,DATE8
if (ios /= 0) goto 703
200 FORMAT(BZ, 9X,I5,T51,I5,T64,I3,I2,F3.1,T101,A8)
CALL CHECK(ISN,JSN,SUBCRD,TEST)
IF(TEST) THEN
CALL TNFDAT(DATE8,MINO)
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
OBS = (DBLE((IDEG*60+MIN)*60)+SEC)/RHOSEC
OBS = OBS + DA
IF(OBS .GE. TWOPI) THEN
OBS = OBS - TWOPI
ELSEIF(OBS .LT. 0.D0) THEN
OBS = OBS + TWOPI
ENDIF
CALL TODMSS(OBS,IDEG,MIN,SEC,ISIGN)
ISEC = IDNINT(SEC*10.D0)
WRITE(CARD(64:71),210) IDEG,MIN,ISEC
210 FORMAT(I3,I2.2,I3.3)
IF(DA .GE. 0.0D0) THEN
SIGN = ' '
ELSE
SIGN = '-'
ENDIF
ANGLE = DABS(DA)
CALL TODMSS(ANGLE,IDEG,MIN,SEC,ISIGN)
ISEC1 = IDINT(SEC) !Convert SEC to integer (v3.3.0)
ISEC2 = IDNINT((SEC - DBLE(ISEC1)) * 100.D0)
WRITE(CARD(152:162),211)SIGN,IDEG,MIN,ISEC1,ISEC2
211 FORMAT(A1,I3.3,I2.2,I2.2,'.',I2.2)
ENDIF
ENDIF
*** Direction observation
ELSEIF(TYPE .EQ. '*20') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
C READ(CARD,220) ISN0,LIST0,DATE,JSN
C 220 FORMAT(BZ, 9X,I5,I2,T40,A6,T51,I5)
READ(CARD,220,err=704,iostat=ios) ISN0,LIST0,JSN,DATE8
if (ios /= 0) goto 704
220 FORMAT(BZ, 9X,I5,I2,T51,I5,T101,A8)
CALL CHECK(ISN0,JSN,SUBCRD,TEST)
CALL TNFDAT(DATE8,MINO)
IF(TEST) THEN
CALL DSDA(LOC(ISN0),LOC(JSN),MINO,MIN2,DS,DA0)
ELSE
DA0 = 0.D0
ENDIF
CARD(132:142) = ' 0000000.00'
ENDIF
ELSEIF(TYPE .EQ. '*22') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
READ(CARD,230,err=705,iostat=ios) ISN,LIST,JSN,IDEG,
& MIN,SEC
if (ios /= 0) goto 705
230 FORMAT(BZ, 9X,I5,I2,T51,I5,T64,I3,I2,F4.2)
IF(LIST.NE.LIST0 .OR. ISN.NE.ISN0) THEN
WRITE(LUOUT,240) CARD
240 FORMAT(' Blue-book file has incorrect structure.'/
1 ' A *22* record disagrees with its corresponding'/
2 ' *20* record. The record reads:'/A212)
STOP
ENDIF
CALL CHECK(ISN,JSN,SUBCRD,TEST)
IF(TEST) THEN
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
ELSE
DA = 0.D0
ENDIF
OBS=(DBLE((IDEG*60+MIN)*60)+SEC)/RHOSEC
OBS = OBS + DA - DA0
IF(OBS .GT. TWOPI) THEN
OBS = OBS - TWOPI
ELSEIF(OBS .LT. 0.D0) THEN
OBS = OBS + TWOPI
ENDIF
CALL TODMSS(OBS,IDEG,MIN,SEC,ISIGN)
ISEC = IDNINT(SEC*100.D0)
WRITE(CARD(64:72),250) IDEG,MIN,ISEC
250 FORMAT(I3.3,I2.2,I4.4)
IF((DA-DA0) .GE. 0.D0) THEN
SIGN = ' '
ELSE
SIGN = '-'
ENDIF
ANGLE = DABS(DA - DA0)
CALL TODMSS(ANGLE,IDEG,MIN,SEC,ISIGN)
ISEC1 = IDINT(SEC) !Convert SEC to integer (v3.3.0)
ISEC2 = IDNINT((SEC-DBLE(ISEC1))*100.D0)
WRITE(CARD(132:142),251) SIGN,IDEG,MIN,ISEC1,ISEC2
251 FORMAT(A1,I3.3,I2.2,I2.2,'.',I2.2)
ENDIF
*** Long distance
ELSEIF(TYPE .EQ. '*53' .OR.
1 TYPE .EQ. '*54') THEN
IF(OPT .eq. '3' .or. OPT .eq. '4') THEN
C READ(CARD,260) ISN,DATE,JSN,OBS
C 260 FORMAT(BZ, 9X,I5,T35,A6,T46,I5,T64,F10.3)
READ(CARD,260,err=706,iostat=ios) ISN,JSN,OBS,DATE8
if (ios /= 0) goto 706
260 FORMAT(BZ, 9X,I5,T46,I5,T64,F10.3,T101,A8)
CALL CHECK(ISN,JSN,SUBCRD,TEST)
IF(TEST) THEN
CALL TNFDAT(DATE8,MINO)
CALL DSDA(LOC(ISN),LOC(JSN),MINO,MIN2,DS,DA)
IOBS = IDNINT((OBS + DS)*1000.D0)
WRITE(CARD(64:73),270) IOBS
270 FORMAT(I10)
CORR = IDNINT(DS*10000.D0)
WRITE(CARD(174:181),271) CORR
271 FORMAT(F8.4)
ENDIF
ENDIF
*** position record
ELSEIF(TYPE .EQ. '*80') THEN
IF(OPT .eq. '2' .or. OPT .eq. '4') THEN
READ(CARD,300,err=708,iostat=ios) ISN,LATD,LATM,
& SLAT,JN,LOND,LONM,SLON,JW
if (ios /= 0) goto 708
300 FORMAT(BZ,9X,I5,T45,2I2,F7.5,A1,I3,I2,F7.5,A1)
YLAT = (DBLE((LATD*60+LATM)*60)+SLAT)/RHOSEC
YLON = (DBLE((LOND*60+LONM)*60)+SLON)/RHOSEC
IF(JN .EQ. 'S') YLAT = -YLAT
IF(JW .EQ. 'E') YLON = -YLON
C READ(I4, REC = LOC(ISN)) RLAT, RLON, IDG
C CALL NWCORD(YLAT,YLON,HT(ISN),
C 1 RLAT,RLON,IDG,MIN1,MIN2,
C 1 YLATT,YLONT,EHTNEW,DN,DE,DU,IOPT)
READ(I4, REC = LOC(ISN),err=709,iostat=ios) RLAT, RLON,
& VN, VE, VU
if (ios /= 0) goto 709
call NEWCOR( ylat, ylon, ht(isn), min1, min2,
1 ylatt, ylont, ehtnew, dn, de, du, vn, ve, vu)
CALL TODMSS(YLATT,LATDN,LATMN,SLATN,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
CALL TODMSS(YLONT,LONDN,LONMN,SLONN,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
LATS = IDNINT(SLATN*100000.D0)
LONS = IDNINT(SLONN*100000.D0)
WRITE(CARD(45:56),310) LATDN,LATMN,LATS,LATDIR
310 FORMAT(I2,I2.2,I7.7,A1)
WRITE(CARD(57:69),320) LONDN,LONMN,LONS,LONDIR
320 FORMAT(I3,I2.2,I7.7,A1)
ENDIF
*** Unrecognized blue book record
ELSE
WRITE(LUOUT,500) TYPE
500 FORMAT(' This software does not recognize an ',A3,/
1 ' record. The record will be copied to the new'/
2 ' file without change.')
ENDIF
WRITE(I2,175) CARD
GO TO 170
600 CONTINUE
RETURN
700 write (*,'(/)')
write (*,*) "Failed to read card in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
702 write (*,'(/)')
write (*,*) "Failed to read *50,51,52* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
703 write (*,'(/)')
write (*,*) "Failed to read *60,61* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
704 write (*,'(/)')
write (*,*) "Failed to read *20* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
705 write (*,'(/)')
write (*,*) "Failed to read *22* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
706 write (*,'(/)')
write (*,*) "Failed to read *53,54* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
708 write (*,'(/)')
write (*,*) "Failed to read *80* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
709 write (*,'(/)')
write (*,*) "Failed to read I4 of *80* in UPBB4:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
***************************************************************
SUBROUTINE CHECK(ISN,JSN,CARD,TEST)
*** Check if stations have *80* records
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (nbbdim = 10000)
CHARACTER CARD*80
CHARACTER PIDs*6
LOGICAL TEST
COMMON /ARRAYS/ HT(nbbdim),LOC(nbbdim),PIDs(nbbdim)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
TEST = .TRUE.
IF(LOC(ISN) .eq. 0) THEN
WRITE(LUOUT,100) ISN, CARD
100 FORMAT(' No *80* record for SSN = ',I4/A80/)
TEST = .FALSE.
ENDIF
IF(LOC(JSN) .eq. 0) THEN
WRITE(LUOUT,100) JSN, CARD
TEST = .FALSE.
ENDIF
RETURN
END
C*************************************************
SUBROUTINE UPGFI4(DATE2, MIN2, IOPT, KOPT,
* MONTH, IDAY, IYEAR)
*** Update G-FILE of blue book
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
c CHARACTER*80 CARD
CHARACTER CARD*120
CHARACTER TYPE*1
CHARACTER NRF*2
CHARACTER ZT*2
CHARACTER CHAR14*14
LOGICAL TEST
LOGICAL Is_inp_NAD83,Is_out_NAD83,Is_out1_NAD83
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
ZT = 'ZT'
*** Obtain blue-book reference frame identifier
*** corresponding to KOPT (output frame for vectors)
IF (KOPT .NE. -1) THEN
CALL RFCON1(KOPT, NBBREF)
WRITE(NRF,10) NBBREF
10 FORMAT(I2.2)
ENDIF
90 READ(I1,100,END=200,err=300,iostat=ios) CARD
if (ios /= 0) goto 300
c 100 FORMAT(A80)
100 FORMAT(A120)
TYPE = CARD(1:1)
IF(TYPE .eq. 'A') THEN
IF (CARD(79:80) .EQ. ZT) THEN
WRITE(LUOUT, 103)
103 FORMAT(
1 ' *****************************************************'/
1 ' * ERROR: The input GFILE contains the letters, ZT, *'/
1 ' * in columns 79-80 of its A-record. This indicates *'/
1 ' * that the GPS vectors in this file have already *'/
1 ' * been updated to a common date. This software *'/
1 ' * will not further modify the GPS vectors. *'/
1 ' *****************************************************'/)
RETURN
ENDIF
WRITE(CARD(79:80),101) ZT
101 FORMAT(A2)
WRITE(CARD(4:11), 102) IYEAR, MONTH, IDAY
102 FORMAT(I4, I2.2, I2.2)
WRITE(CARD(12:19), 102) IYEAR, MONTH, IDAY
ELSEIF(TYPE .eq. 'B') THEN
READ(CARD,110,err=301,iostat=ios)IYEAR1,MONTH1,IDAY1,
1 IYEAR2,MONTH2,IDAY2,IBBREF
if (ios /= 0) goto 301
110 FORMAT(1X,I4,I2,I2,4X,I4,I2,I2,30X,I2)
C CALL TOTIME(IYEAR1,MONTH1,IDAY1,MINO1)
C CALL TOTIME(IYEAR1, 1, 1, MIN00)
C DECYR1 = DBLE(IYEAR1) + DBLE(MINO1 - MIN00)/525600.D0
C CALL TOTIME(IYEAR2,MONTH2,IDAY2,MINO2)
C CALL TOTIME(IYEAR2, 1, 1, MIN00)
C DECYR2 = DBLE(IYEAR2) + DBLE(MINO2 - MIN00)/525600.D0
CALL IYMDMJ(IYEAR1,MONTH1,IDAY1,MJD1)
MINO1 = MJD1 * 24 * 60
CALL IYMDMJ(IYEAR1, 1, 1, MJD0)
DECYR1 = DBLE(IYEAR1) + DBLE(MJD1 - MJD0)/365.D0
CALL IYMDMJ(IYEAR2,MONTH2,IDAY2, MJD2)
MINO2 = MJD2 * 24 * 60
CALL IYMDMJ(IYEAR2, 1, 1, MJD0)
DECYR2 = DBLE(IYEAR2) + DBLE(MJD2 - MJD0)/365.D0
MINO = (MINO1 + MINO2) / 2
DECYR = (DECYR1 + DECYR2) / 2.D0
CALL RFCON(IBBREF, JREF) !JREF is the current frame or frame of input
IF (KOPT .NE. -1) THEN
CARD(52:53) = NRF
ENDIF
Is_inp_NAD83 = (JREF == 1)
Is_out_NAD83 = (IOPT == 1) !IOPT is the frame of the positions
Is_out1_NAD83 = (KOPT == 1) !IOPT is the frame of the positions
ELSEIF(TYPE .eq. 'C') THEN
READ(CARD,120,err=302,iostat=ios)ISN,JSN,DX,DY,DZ
if (ios /= 0) goto 302
120 FORMAT(BZ,1X,2I4,F11.4,5X,F11.4,5X,F11.4)
CALL CHECK(ISN, JSN, CARD, TEST)
IF (TEST) THEN
CALL DDXYZ(ISN, JSN,
1 MINO, MIN2, DDX, DDY, DDZ)
*** Convert vector from JREF to IOPT frame
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TRAVEC (DX, DY, DZ, DECYR, JREF, IOPT)
else
call TRAVEC_IERS (DX, DY, DZ, DECYR, JREF, IOPT)
endif
DX = DX + DDX
DY = DY + DDY
DZ = DZ + DDZ
*** Convert GPS vector from IOPT to KOPT reference frame
IF (KOPT .NE. -1) THEN
if (Is_out_NAD83 .or. Is_out1_NAD83) then
CALL TRAVEC(DX, DY, DZ, DATE2, IOPT, KOPT)
else
CALL TRAVEC_IERS(DX, DY, DZ, DATE2, IOPT, KOPT)
endif
ELSE
if (Is_inp_NAD83 .or. Is_out_NAD83) then
CALL TRAVEC(DX, DY, DZ, DATE2, IOPT, JREF)
else
CALL TRAVEC_IERS(DX, DY, DZ, DATE2, IOPT, JREF)
endif
ENDIF
*** Rewrite GPS observational record
CALL TOCHAR(DX,CHAR14)
CARD(10:20) = CHAR14(3:13)
CALL TOCHAR(DY,CHAR14)
CARD(26:36) = CHAR14(3:13)
CALL TOCHAR(DZ,CHAR14)
CARD(42:52) = CHAR14(3:13)
ENDIF
ELSEIF(TYPE .eq. 'F') THEN
READ(CARD,140,err=303,iostat=ios)ISN,JSN,DX,DY,DZ
if (ios /= 0) goto 303
140 FORMAT(BZ,1X,2I4,F13.4,5X,F13.4,5X,F13.4)
CALL CHECK(ISN, JSN, CARD, TEST)
IF (TEST) THEN
CALL DDXYZ(ISN, JSN,
1 MINO, MIN2, DDX, DDY, DDZ)
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call TRAVEC( DX, DY, DZ, DECYR, JREF, IOPT)
else
call TRAVEC_IERS( DX, DY, DZ, DECYR, JREF, IOPT)
endif
DX = DX + DDX
DY = DY + DDY
DZ = DZ + DDZ
*** Convert GPS vector to output reference frame
IF (KOPT .NE. -1) THEN
if (Is_out_NAD83 .or. Is_out1_NAD83) then
CALL TRAVEC(DX, DY, DZ, DATE2, IOPT, KOPT)
else
CALL TRAVEC_IERS (DX, DY, DZ, DATE2, IOPT, KOPT)
endif
ELSE
if (Is_out_NAD83 .or. Is_out1_NAD83) then
CALL TRAVEC(DX, DY, DZ, DATE2, IOPT, JREF)
else
CALL TRAVEC_IERS (DX, DY, DZ, DATE2, IOPT, JREF)
endif
ENDIF
*** Rewrite GPS observational record
CALL TOCHAR(DX,CHAR14)
CARD(10:22) = CHAR14(1:13)
CALL TOCHAR(DY,CHAR14)
CARD(28:40) = CHAR14(1:13)
CALL TOCHAR(DZ,CHAR14)
CARD(46:58) = CHAR14(1:13)
ENDIF
ENDIF
WRITE(I2,100) CARD
GO TO 90
200 CONTINUE
RETURN
300 write (*,'(/)')
write (*,*) "Failed to read gfile in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
301 write (*,'(/)')
write (*,*) "Failed to read B card in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
302 write (*,'(/)')
write (*,*) "Failed to read C card in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
303 write (*,'(/)')
write (*,*) "Failed to read F card in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*********************************************************
SUBROUTINE UPGFI5(DATE2, MIN2, IOPT, KOPT,
* MONTH, IDAY, IYEAR)
*** Update G-FILE of 5-digit blue book
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
CHARACTER CARD*180
CHARACTER SUBCRD*80
CHARACTER TYPE*1
CHARACTER NRF*2
CHARACTER ZT*2
CHARACTER CHAR14*14
LOGICAL TEST
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
ZT = 'ZT'
*** Obtain blue-book reference frame identifier
*** corresponding to IOPT
IF (KOPT .NE. -1) THEN
CALL RFCON1(KOPT, NBBREF)
WRITE(NRF, 10) NBBREF
10 FORMAT(I2.2)
ENDIF
90 READ(I1,100,END=200,err=300,iostat=ios) CARD
if (ios /= 0) goto 300
100 FORMAT(A180)
TYPE = CARD(1:1)
IF (TYPE .eq. 'A') THEN
IF (CARD(79:80) .EQ. ZT) THEN
WRITE(LUOUT, 103)
103 FORMAT(
1 ' *****************************************************'/
1 ' * ERROR: The input GFILE contains the letters, ZT, *'/
1 ' * in columns 79-80 of its A-record. This indicates *'/
1 ' * that the GPS vectors in this file have already *'/
1 ' * been updated to a common date. This software *'/
1 ' * will not further modify the GPS vectors. *'/
1 ' *****************************************************'/)
RETURN
ENDIF
WRITE(CARD(79:80), 101) ZT
101 FORMAT(A2)
WRITE(CARD(4:11), 102) IYEAR, MONTH, IDAY
102 FORMAT(I4, I2.2, I2.2)
WRITE(CARD(12:19), 102) IYEAR, MONTH, IDAY
ELSEIF(TYPE .eq. 'B') THEN
READ(CARD,110,err=301,iostat=ios)IYEAR1,MONTH1,IDAY1,
1 IYEAR2,MONTH2,IDAY2,IBBREF
if (ios /= 0) goto 301
110 FORMAT(1X,I4,I2,I2,4X,I4,I2,I2,30X,I2)
C CALL TOTIME(IYEAR1,MONTH1,IDAY1,MINO1)
C CALL TOTIME(IYEAR1, 1, 1, MIN00)
C DECYR1 = DBLE(IYEAR1) + DBLE(MINO1 - MIN00)/525600.D0
C CALL TOTIME(IYEAR2,MONTH2,IDAY2,MINO2)
C CALL TOTIME(IYEAR2, 1, 1, MIN00)
CALL IYMDMJ(IYEAR1,MONTH1,IDAY1,MJD1)
MINO1 = MJD1 * 24 * 60
CALL IYMDMJ(IYEAR1, 1, 1, MJD0)
DECYR1 = DBLE(IYEAR1) + DBLE(MJD1 - MJD0)/365.D0
CALL IYMDMJ(IYEAR2, MONTH2,IDAY2, MJD2)
MINO2 = MJD2 * 24 * 60
CALL IYMDMJ(IYEAR2, 1, 1, MJD0)
DECYR2 = DBLE(IYEAR2) + DBLE(MJD2 - MJD0)/365.D0
C DECYR2 = DBLE(IYEAR2) + DBLE(MINO2 - MIN00)/525600.D0
MINO = (MINO1 + MINO2) / 2
DECYR = (DECYR1 + DECYR2) / 2.D0
CALL RFCON(IBBREF, JREF)
IF (KOPT .NE. -1) THEN
CARD(52:53) = NRF
ENDIF
ELSEIF(TYPE .eq. 'F') THEN
READ(CARD,140,err=303,iostat=ios)ISN,DX,DY,DZ,JSN
if (ios /= 0) goto 303
140 FORMAT(BZ,1X,I5,3X,F13.4,5X,F13.4,5X,F13.4,T81,I5)
SUBCRD = CARD(1:80)
CALL CHECK(ISN, JSN, SUBCRD, TEST)
IF (TEST) THEN
CALL DDXYZ(ISN, JSN,
1 MINO,MIN2,DDX, DDY, DDZ)
call TRAVEC( DX, DY, DZ, DECYR, JREF, IOPT)
DX = DX + DDX
DY = DY + DDY
DZ = DZ + DDZ
*** Convert GPS vector to outout reference frame
IF (KOPT .NE. -1) THEN
CALL TRAVEC(DX, DY, DZ, DATE2, IOPT, KOPT)
ELSE
CALL TRAVEC(DX, DY, DZ, DATE2, IOPT, JREF)
ENDIF
*** Rewrite GPS observational record
CALL TOCHAR(DX,CHAR14)
CARD(10:22) = CHAR14(1:13)
CALL TOCHAR(DY,CHAR14)
CARD(28:40) = CHAR14(1:13)
CALL TOCHAR(DZ,CHAR14)
CARD(46:58) = CHAR14(1:13)
ISHIFT = IDNINT(DDX * 10000.D0)
WRITE(CARD(115:121),150) ISHIFT
150 FORMAT(I7)
ISHIFT = IDNINT(DDY * 10000.D0)
WRITE(CARD(125:131),150) ISHIFT
ISHIFT = IDNINT(DDZ * 10000.D0)
WRITE(CARD(135:141),150) ISHIFT
ENDIF
ENDIF
WRITE(I2,100) CARD
GO TO 90
200 CONTINUE
RETURN
300 write (*,'(/)')
write (*,*) "Failed to read gfile in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
301 write (*,'(/)')
write (*,*) "Failed to read B card in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
303 write (*,'(/)')
write (*,*) "Failed to read F card in UPGFIG:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*********************************************************
SUBROUTINE TODMSS(val,id,im,s,isign)
*** convert position radians to deg,min,sec
*** range is [-twopi to +twopi]
implicit double precision(a-h,o-z)
IMPLICIT INTEGER*4 (I-N)
common/CONST/A,F,E2,EP2,AF,PI,TWOPI,RHOSEC
1 if(val.gt.twopi) then
val=val-twopi
go to 1
endif
2 if(val.lt.-twopi) then
val=val+twopi
go to 2
endif
if(val.lt.0.d0) then
isign=-1
else
isign=+1
endif
s=dabs(val*RHOSEC/3600.D0)
id=idint(s)
s=(s-id)*60.d0
im=idint(s)
s=(s-im)*60.d0
*** account for rounding error
is=idnint(s*1.d5)
if(is.ge.6000000) then
s=0.d0
im=im+1
endif
if(im.ge.60) then
im=0
id=id+1
endif
return
end
*********************************************************
SUBROUTINE SETRF
*** Specify arrays that may be used to convert
*** a reference frame identifier in the blue book
*** to a reference frame identifier in HTDP and back
IMPLICIT INTEGER*4 (I-N)
parameter ( numref = 16 )
COMMON /REFCON/ IRFCON(37), JRFCON(numref)
*** From blue book identifier to HTDP indentifier
*** WGS 72 Precise
c IRFCON(1) = 10
IRFCON(1) = 1
C HTDP no longer supports WGS 72. Hence, if a BlueBook
C file contains WGS 72 coordinates, HTDP treats these
C coordinates as if they were NAD 83(2011) coordinates.
*** WGS 84 (orig) Precise (set equal to NAD 83)
IRFCON(2) = 1
*** WGS 72 Broadcast
c IRFCON(3) = 10
IRFCON(3) = 1
C HTDP no longer supports WGS 72. Hence, if a BlueBook
C file contains WGS 72 coordinates, HTDP treats these
C coordinates as if they were NAD 83(2011)coordinates.
*** WGS 84 (orig) Broadcast (set equal to NAD 83)
IRFCON(4) = 1
*** ITRF89
IRFCON(5) = 3
*** PNEOS 90 or NEOS 91.25 (set equal to ITRF90)
IRFCON(6) = 4
*** NEOS 90 (set equal to ITRF90)
IRFCON(7) = 4
*** ITRF91
IRFCON(8) = 5
*** SIO/MIT 92.57 (set equal to ITRF91)
IRFCON(9) = 5
*** ITRF91
IRFCON(10) = 5
*** ITRF92
IRFCON(11) = 6
*** ITRF93
IRFCON(12) = 7
*** WGS 84 (G730) Precise (set equal to ITRF91)
IRFCON(13) = 5
*** WGS 84 (G730) Broadcast (set equal to ITRF91)
IRFCON(14) = 5
*** ITRF94
IRFCON(15) = 8
*** WGS 84 (G873) Precise (set equal to ITRF94)
IRFCON(16) = 8
*** WGS 84 (G873) Broadcast (set equal to ITRF94)
IRFCON(17) = 8
*** ITRF96
IRFCON(18) = 8
*** ITRF97
IRFCON(19) = 9
*** IGS97
IRFCON(20) = 9
*** ITRF2000
IRFCON(21) = 11
*** IGS00
IRFCON(22) = 11
*** WGS 84 (G1150)
IRFCON(23) = 11
*** IGb00
IRFCON(24) = 11
*** ITRF2005
IRFCON(25) = 14
*** IGS05
IRFCON(26) = 14
*** IGS08
IRFCON(27) = 15
*** IGb08
IRFCON(28) = 15
*** ITRF2008
IRFCON(29) = 15
*** WGS84 (G1674)
IRFCON(30) = 15
*** WGS84 (G1762)
IRFCON(31) = 15
*** ITRF2014
IRFCON(32) = 16
*** IGS14
IRFCON(33) = 16
*** NAD83 (2011/2007/CORS96/FBN/HARN)
IRFCON(34) = 1
*** NAD83 (PA11)
IRFCON(35) = 12
*** NAD83 (MA11)
IRFCON(36) = 13
*** IGb14
IRFCON(37) = 16
*** From HTDP identifier to blue book identifier.
*** NAD 83 (2011/2007/CORS96/...) referenced to North America plate.
c JRFCON(1) = 2
JRFCON(1) = 34
*** ITRF88 (set equal to ITRF89)
JRFCON(2) = 5
*** ITRF89
JRFCON(3) = 5
*** ITRF90 (set equal to NEOS 90)
JRFCON(4) = 7
*** ITRF91
JRFCON(5) = 8
*** ITRF92
JRFCON(6) = 11
*** ITRF93
JRFCON(7) = 12
*** ITRF96 (= ITRF94)
JRFCON(8) = 18
*** ITRF97
JRFCON(9) = 19
*** WGS 72
JRFCON(10) = 1
*** ITRF2000
JRFCON(11) = 21
*** NAD 83 (PACP00) or NAD 83 (PA11)
c JRFCON(12) = 0
c JRFCON(12) = 2
JRFCON(12) = 35
*** NAD 83 (MARP00) or NAD 83 (MA11)
c JRFCON(13) = 0
c JRFCON(13) = 2
JRFCON(13) = 36
*** ITRF2005 or IGS05
JRFCON(14) = 26
*** ITRF2008 or IGS08
JRFCON(15) = 27
*** IGb08
JRFCON(15) = 28
*** ITRF2014 or IGS14
JRFCON(16) = 33
*** IGb14
JRFCON(16) = 37
RETURN
END
***************************************************
SUBROUTINE RFCON(IBBREF, JREF)
*** Convert reference frame identifier from
*** system used in the blue-book to the
*** system used in HTDP
IMPLICIT INTEGER*4 (I-N)
parameter ( numref = 16 )
COMMON /REFCON/ IRFCON(37), JRFCON(numref)
IF (1 .LE. IBBREF .AND. IBBREF .LE. 37) THEN
JREF = IRFCON(IBBREF)
ELSE
WRITE(6, 10) IBBREF
10 FORMAT(' Improper reference frame identifier (=',
1 I4, ')' /
1 ' appearing in B-record of the G-FILE')
STOP
ENDIF
RETURN
END
*******************************************************
SUBROUTINE RFCON1(JREF, IBBREF)
*** Convert reference frame identifier from
*** system used in HTDP to the system
*** used in the blue-book
IMPLICIT INTEGER*4 (I-N)
parameter ( numref = 16 )
COMMON /REFCON/ IRFCON(37), JRFCON(numref)
IF (JREF .EQ. 0) THEN
I = 1
ELSE
I = JREF
ENDIF
IF(1. LE. I .AND. I .LE. numref) THEN
IBBREF = JRFCON(I)
IF ( IBBREF .eq. 0) THEN
write(6,5) JREF
5 format(' ERROR: The BlueBook does not recognize '/
* 'this reference frame, HTDP ID = ',I2)
stop
ENDIF
ELSE
WRITE(6, 10) JREF
10 FORMAT(' Improper reference frame identifier (=',
* I4, ')' / 'appearing in routine RFCON1')
STOP
ENDIF
RETURN
END
*****************************************************************
subroutine TRAVEC(dxi, dyi, dzi, date, jopt1, jopt2)
*** Transform GPS or other vector from one reference frame to another
*** for the given date
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
*** (dxi, dyi, dzi) --> (input) components of input vector in meters
*** --> (output) components of transformed vector in meters
*** date --> (input) time (decimal years) to which the input & output
*** vectors correspond
*** jopt1 --> (input) specifier of reference frame for input vector
*** jopt2 --> (input) specifier of reference frame for output vector
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /tranpa/ tx(numref), ty(numref), tz(numref),
& dtx(numref), dty(numref), dtz(numref),
& rx(numref), ry(numref), rz(numref),
& drx(numref), dry(numref), drz(numref),
& scale(numref), dscale(numref), refepc(numref)
*** Transform input vector to ITRF94 reference frame
if (jopt1 .eq. 0) then
iopt = 1
else
iopt = jopt1
endif
dtime = date - refepc(iopt)
rotnx = -(rx(iopt) + drx(iopt)*dtime)
rotny = -(ry(iopt) + dry(iopt)*dtime)
rotnz = -(rz(iopt) + drz(iopt)*dtime)
ds = 1.d0 - (scale(iopt) + dscale(iopt)*dtime)
dxt = + ds*dxi + rotnz*dyi - rotny*dzi
dyt = - rotnz*dxi + ds*dyi + rotnx*dzi
dzt = + rotny*dxi - rotnx*dyi + ds*dzi
*** Transform ITRF94 vector to new reference frame
if (jopt2 .eq. 0) then
iopt = 1
else
iopt = jopt2
endif
dtime = date - refepc(iopt)
rotnx = rx(iopt) + drx(iopt)*dtime
rotny = ry(iopt) + dry(iopt)*dtime
rotnz = rz(iopt) + drz(iopt)*dtime
ds = 1.d0 + scale(iopt) + dscale(iopt)*dtime
dxi = + ds*dxt + rotnz*dyt - rotny*dzt
dyi = - rotnz*dxt + ds*dyt + rotnx*dzt
dzi = + rotny*dxt - rotnx*dyt + ds*dzt
return
end
***********************************************************
subroutine TRAVEC_IERS(dxi, dyi, dzi, date, jopt1, jopt2)
*** Transform GPS or other vector from one reference frame to another
*** for the given date, using the IERS 96-97 transformation parameters
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
*** (dxi, dyi, dzi) --> (input) components of input vector in meters
*** --> (output) components of transformed vector in meters
*** date --> (input) time (decimal years) to which the input & output
*** vectors correspond
*** jopt1 --> (input) specifier of reference frame for input vector
*** jopt2 --> (input) specifier of reference frame for output vector
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
common /tranpa1/ tx1(numref), ty1(numref), tz1(numref),
& dtx1(numref), dty1(numref), dtz1(numref),
& rx1(numref), ry1(numref), rz1(numref),
& drx1(numref), dry1(numref), drz1(numref),
& scale1(numref), dscale1(numref), refepc1(numref)
*** Transform input vector to ITRF94 reference frame
if (jopt1 .eq. 0) then
iopt = 1
else
iopt = jopt1
endif
dtime = date - refepc1(iopt)
rotnx = -(rx1(iopt) + drx1(iopt)*dtime)
rotny = -(ry1(iopt) + dry1(iopt)*dtime)
rotnz = -(rz1(iopt) + drz1(iopt)*dtime)
ds = 1.d0 - (scale1(iopt) + dscale1(iopt)*dtime)
dxt = + ds*dxi + rotnz*dyi - rotny*dzi
dyt = - rotnz*dxi + ds*dyi + rotnx*dzi
dzt = + rotny*dxi - rotnx*dyi + ds*dzi
*** Transform ITRF94 vector to new reference frame
if (jopt2 .eq. 0) then
iopt = 1
else
iopt = jopt2
endif
dtime = date - refepc1(iopt)
rotnx = rx1(iopt) + drx1(iopt)*dtime
rotny = ry1(iopt) + dry1(iopt)*dtime
rotnz = rz1(iopt) + drz1(iopt)*dtime
ds = 1.d0 + scale1(iopt) + dscale1(iopt)*dtime
dxi = + ds*dxt + rotnz*dyt - rotny*dzt
dyi = - rotnz*dxt + ds*dyt + rotnx*dzt
dzi = + rotny*dxt - rotnx*dyt + ds*dzt
return
end
***********************************************************
SUBROUTINE GETPNT(LATD,LATM,SLAT,LATDIR,LOND,LONM,SLON,
1 LONDIR, NAME, X,Y,Z,XLAT,XLON,EHT)
*** Interactively obtain name and coordinates for a point.
*** Output longitude will be positive west.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
CHARACTER NAME*24
CHARACTER COPT*1,LATDIR*1,LONDIR*1
LOGICAL FRMXYZ
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
WRITE(LUOUT,100)
100 FORMAT(' Enter name for point (24 character max). ')
READ(LUIN,105,err=200,iostat=ios) NAME
if (ios /= 0) goto 200
105 FORMAT(A24)
110 WRITE(LUOUT,111)
111 FORMAT(' How do you wish to specify positional coordinates:'/
1 ' 1...geodetic latitude, longitude, ellipsoid height'/
2 ' 2...Cartesian (X,Y,Z) coordinates. ')
READ(LUIN,'(A1)',err=201,iostat=ios) COPT
if (ios /= 0) goto 201
IF(COPT .EQ. '1') THEN
WRITE(LUOUT,115)
115 FORMAT(
1 ' Enter latitude degrees-minutes-seconds in free format'/,
2 ' with north being positive. For example, 35,17,28.3 '/
2 ' For a point in the southern hemisphere, enter a minus sign'/
3 ' before each value. For example, -35,-17,-28.3')
READ(LUIN,*,err=202,iostat=ios) LATD, LATM, SLAT
if (ios /= 0) goto 202
*** START insertion of new code and comments for v3.3.0 to handle
*** incorrect input latitude and longitude.
***
*** Test whether latitude magnitude is > 90 degrees. If it is, prompt
*** for re-entry.
TEST = DBLE(ABS(LATD)) + DBLE(ABS(LATM))/60.D0
& + DABS(SLAT)/3600.D0
DO WHILE (DABS(TEST) .GT. 90.D0)
WRITE(*,*)' Latitude magnitude (degrees) =', TEST
WRITE(*,*)
& ' Magnitude cannot exceed 90. Please re-enter all values.'
READ(LUIN,*,err=202,iostat=ios) LATD, LATM, SLAT
if (ios /= 0) goto 202
TEST = DBLE(ABS(LATD)) + DBLE(ABS(LATM))/60.D0
& + DABS(SLAT)/3600.D0
END DO
*** Non-zero latitude minutes and seconds must be the same sign, and
*** if latitude degrees is non-zero, minutes and seconds must be the
*** same sign as latitude degrees. Otherwise prompt for re-entry.
IF (LATD .EQ. 0) THEN
IF (DBLE(LATM)*SLAT .LT. 0.D0) THEN
WRITE(*,*)' Minutes and seconds must be the same sign.',
& ' Please re-enter minutes and seconds.'
READ(LUIN,*,err=202,iostat=ios) LATM, SLAT
if (ios /= 0) goto 202
ENDIF
ENDIF
IF (LATD .GT. 0) THEN
IF ((LATM .LT. 0).OR.(SLAT .LT. 0.D0))
& WRITE(*,*)' Latitude degrees are positive.'
DO WHILE (LATM .LT. 0)
WRITE(*,*)
& ' Minutes must also be positive. Please re-enter minutes.'
READ(LUIN,*,err=202,iostat=ios) LATM
if (ios /= 0) goto 202
END DO
DO WHILE (SLAT .LT. 0.D0)
WRITE(*,*)
& ' Seconds must also be positive. Please re-enter seconds.'
READ(LUIN,*,err=202,iostat=ios) SLAT
if (ios /= 0) goto 202
END DO
ENDIF
IF (LATD .LT. 0) THEN
IF ((LATM .GT. 0).OR.(SLAT .GT. 0.D0))
& WRITE(*,*)' Latitude degrees are negative.'
DO WHILE (LATM .GT. 0)
WRITE(*,*)
& ' Minutes must also be negative. Please re-enter minutes.'
READ(LUIN,*,err=202,iostat=ios) LATM
if (ios /= 0) goto 202
END DO
DO WHILE (SLAT .GT. 0.D0)
WRITE(*,*)
& ' Seconds must also be negative. Please re-enter seconds.'
READ(LUIN,*,err=202,iostat=ios) SLAT
if (ios /= 0) goto 202
END DO
ENDIF
*** Test whether latitude minute or second magnitudes are >= 60.
*** If either is, prompt for re-entry.
DO WHILE (ABS(LATM) .GE. 60)
WRITE(*,*)' Minutes magnitude must be < 60.',
& ' Please re-enter latitude minutes.'
READ(LUIN,*,err=202,iostat=ios) LATM
if (ios /= 0) goto 202
END DO
DO WHILE (DABS(SLAT) .GE. 60.D0)
WRITE(*,*)' Seconds magnitude must be < 60.',
& ' Please re-enter latitude seconds.'
READ(LUIN,*,err=202,iostat=ios) SLAT
if (ios /= 0) goto 202
END DO
WRITE(LUOUT,120)
120 FORMAT(
1 ' Enter longitude degrees-minutes-seconds in free format'/,
2 ' with west being positive. To express a longitude measured'/
3 ' eastward, enter a minus sign before each value.')
READ(LUIN,*,err=203,iostat=ios) LOND, LONM, SLON
if (ios /= 0) goto 203
*** Test whether longitude magnitude is > 360 degrees. If it is, prompt
*** for re-entry.
TEST = DBLE(ABS(LOND)) + DBLE(ABS(LONM))/60.D0
& + DABS(SLON)/3600.D0
DO WHILE (DABS(TEST) .GT. 360.D0)
WRITE(*,*)' Longitude magnitude (degrees) =', TEST
WRITE(*,*)
& ' Magnitude cannot exceed 360. Please re-enter all values.'
READ(LUIN,*,err=203,iostat=ios) LOND, LONM, SLON
if (ios /= 0) goto 203
TEST = DBLE(ABS(LOND)) + DBLE(ABS(LONM))/60.D0
& + DABS(SLON)/3600.D0
END DO
*** Non-zero longitude minutes and seconds must be the same sign, and
*** if longitude degrees is non-zero, minutes and seconds must be the
*** same sign as longitude degrees. Otherwise prompt for re-entry.
IF (LOND .EQ. 0) THEN
IF (DBLE(LONM)*SLON .LT. 0.D0) THEN
WRITE(*,*)' Minutes and seconds must be the same sign.',
& ' Please re-enter minutes and seconds.'
READ(LUIN,*,err=203,iostat=ios) LONM, SLON
if (ios /= 0) goto 203
ENDIF
ENDIF
IF (LOND .GT. 0) THEN
IF ((LONM .LT. 0).OR.(SLON .LT. 0.D0))
& WRITE(*,*)' Longitude degrees are negative.'
DO WHILE (LONM .LT. 0)
WRITE(*,*)
& ' Minutes must also be positive. Please re-enter minutes.'
READ(LUIN,*,err=203,iostat=ios) LONM
if (ios /= 0) goto 203
END DO
DO WHILE (SLON .LT. 0.D0)
WRITE(*,*)
& ' Seconds must also be positive. Please re-enter seconds.'
READ(LUIN,*,err=203,iostat=ios) SLON
if (ios /= 0) goto 203
END DO
ENDIF
IF (LOND .LT. 0) THEN
IF ((LONM .GT. 0).OR.(SLON .GT. 0.D0))
& WRITE(*,*)' Longitude degrees are negative.'
DO WHILE (LONM .GT. 0)
WRITE(*,*)
& ' Minutes must also be negative. Please re-enter minutes.'
READ(LUIN,*,err=203,iostat=ios) LONM
if (ios /= 0) goto 203
END DO
DO WHILE (SLON .GT. 0.D0)
WRITE(*,*)
& ' Seconds must also be negative. Please re-enter seconds.'
READ(LUIN,*,err=203,iostat=ios) SLON
if (ios /= 0) goto 203
END DO
ENDIF
*** Test whether longitude minute or second magnitudes are >= 60.
*** If either is, prompt for re-entry.
DO WHILE (ABS(LONM) .GE. 60)
WRITE(*,*)' Minutes magnitude must be < 60.',
& ' Please re-enter longitude minutes.'
READ(LUIN,*,err=203,iostat=ios) LONM
if (ios /= 0) goto 203
END DO
DO WHILE (DABS(SLON) .GE. 60.D0)
WRITE(*,*)' Seconds magnitude must be < 60.',
& ' Please re-enter longitude seconds.'
READ(LUIN,*,err=203,iostat=ios) SLON
if (ios /= 0) goto 203
END DO
*** END insertion of new code and comments for v3.3.0 to handle
*** incorrect input latitude and longitude.
WRITE(LUOUT, 125)
125 FORMAT(
1 ' Enter ellipsoid height in meters. (Note that'/,
1 ' predicted motions are independent of this height.) ')
READ(LUIN,*,err=204,iostat=ios) EHT
if (ios /= 0) goto 204
XLAT = (DBLE((LATD*60 + LATM)*60) + SLAT)/RHOSEC
LATDIR = 'N'
IF (XLAT .lt. 0.0D0) then
LATD = - LATD
LATM = - LATM
SLAT = - SLAT
LATDIR = 'S'
ENDIF
XLON = (DBLE((LOND*60 + LONM)*60) + SLON)/RHOSEC
ELON = -XLON
CALL TOXYZ(XLAT,ELON,EHT,X,Y,Z)
LONDIR = 'W'
IF (XLON .lt. 0.0D0) then
LOND = -LOND
LONM = -LONM
SLON = -SLON
LONDIR = 'E'
ENDIF
ELSEIF(COPT .EQ. '2') THEN
WRITE(LUOUT,130)
130 FORMAT(' Enter X coordinate in meters. ')
READ(LUIN,*,err=205,iostat=ios) X
if (ios /= 0) goto 205
WRITE(LUOUT,140)
140 FORMAT(' Enter Y coordinate in meters. ')
READ(LUIN,*,err=206,iostat=ios) Y
if (ios /= 0) goto 206
WRITE(LUOUT,150)
150 FORMAT(' Enter Z coordinate in meters. ')
READ(LUIN,*,err=207,iostat=ios) Z
if (ios /= 0) goto 207
IF(.NOT.FRMXYZ(X,Y,Z,XLAT,XLON,EHT)) STOP 666
XLON = -XLON
IF(XLON .LT. 0.0D0) XLON = XLON + TWOPI
CALL TODMSS(XLAT,LATD,LATM,SLAT,ISIGN)
LATDIR = 'N'
IF (ISIGN .eq. -1) LATDIR = 'S'
CALL TODMSS(XLON,LOND,LONM,SLON,ISIGN)
LONDIR = 'W'
IF (ISIGN .eq. -1) LONDIR = 'E'
ELSE
WRITE(LUOUT,*) ' Improper response -- try again. '
GO TO 110
ENDIF
RETURN
200 write (*,'(/)')
write (*,*) "Failed to read point name: ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
201 write (*,'(/)')
write (*,*) "Failed to read Coord. form option:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
202 write (*,'(/)')
write (*,*) "Failed to read latitude:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
203 write (*,'(/)')
write (*,*) "Failed to read longitude:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
204 write (*,'(/)')
write (*,*) "Failed to read ellipsoidal height:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
205 write (*,'(/)')
write (*,*) "Failed to read the X coordinate:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
206 write (*,'(/)')
write (*,*) "Failed to read the Y coordinate:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
207 write (*,'(/)')
write (*,*) "Failed to read the Z coordinate:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
*****************************************************************
SUBROUTINE GETVLY(GLAT, GLON, VX, VY, VZ,
1 VNORTH, VEAST, VUP, VOPT, IFORM)
*** Interactively obtain velocity for a point
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
CHARACTER VOPT*1
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
200 CONTINUE
IF (IFORM .eq. 210) then
WRITE(LUOUT, 210)
210 FORMAT(' What is the velocity of this site relative to '/
1 ' the input reference frame:'/
1 ' 0...use velocity predicted by this software.'/
1 ' 1...user will specify the north-east-up'/
1 ' components of site velocity.'/
1 ' 2...user will specify the global x-y-z'/
1 ' components of site velocity.' )
else
write(luout, 211)
211 FORMAT(' How do you wish to specify the velocity: '/
1 ' 1...north-east-up components.'/
1 ' 2...global x-y-z components.' )
endif
READ(LUIN, '(A1)',err=300,iostat=ios) VOPT
if (ios /= 0) goto 300
IF (VOPT .EQ. '0') THEN
CONTINUE
ELSEIF (VOPT .EQ. '1') THEN
WRITE(LUOUT, 220)
220 FORMAT( ' Enter north-south component of velocity in mm/yr'/
1 ' with north being positive and south being negative')
READ(LUIN, *,err=301,iostat=ios) VNORTH
if (ios /= 0) goto 301
WRITE(LUOUT, 221)
221 FORMAT( ' Enter east-west component of velocity in mm/yr'/
1 ' with east being positive and west being negative')
READ(LUIN, *,err=302,iostat=ios) VEAST
if (ios /= 0) goto 302
WRITE(LUOUT, 222)
222 FORMAT( ' Enter vertical component of velocity in mm/yr'/
1 ' with up being positive and down being negative'/
1 ' or enter 0.0 if unknown.')
READ(LUIN, *,err=303,iostat=ios) VUP
if (ios /= 0) goto 303
CALL TOVXYZ( GLAT, GLON, VNORTH, VEAST, VUP, VX, VY, VZ)
ELSEIF (VOPT .EQ. '2') THEN
WRITE(LUOUT, *) ' Enter x-component of velocity in mm/yr.'
READ(LUIN, *,err=304,iostat=ios) VX
if (ios /= 0) goto 304
WRITE(LUOUT, *) ' Enter y-component of velocity in mm/yr.'
READ(LUIN, *,err=305,iostat=ios) VY
if (ios /= 0) goto 305
WRITE(LUOUT, *) ' Enter z-component of velocity in mm/yr.'
READ(LUIN, *,err=306,iostat=ios) VZ
if (ios /= 0) goto 306
CALL TOVNEU(GLAT, GLON, VX, VY, VZ, VNORTH, VEAST, VUP)
ELSE
WRITE(LUOUT, *) 'Improper response -- try again. '
GO TO 200
ENDIF
RETURN
300 write (*,'(/)')
write (*,*) "Failed to read form of velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
301 write (*,'(/)')
write (*,*) "Failed to read North velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
302 write (*,'(/)')
write (*,*) "Failed to read East velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
303 write (*,'(/)')
write (*,*) "Failed to read Up velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
304 write (*,'(/)')
write (*,*) "Failed to read X velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
305 write (*,'(/)')
write (*,*) "Failed to read Y velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
306 write (*,'(/)')
write (*,*) "Failed to read Z velocity:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
************************************************************************
SUBROUTINE COMPSN(YLATT,YLONT,HTT,YLAT,YLON,HT,
1 MIN,VN, VE, VU)
*** Compute the position of a point at specified time
*** Upon input VN, VE, and VU are in mm/yr
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NDLOC = 2195)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /TIMREF/ ITREF
COMMON /QPARM/ STRIKE(NDLOC), HL(NDLOC), EQLAT(NDLOC),
1 EQLON(NDLOC), SSLIP(NDLOC), DSLIP(NDLOC),
1 DIP(NDLOC), DEPTH(NDLOC), WIDTH(NDLOC),
1 EQLATR(50),EQLONR(50),EQRAD(50),
1 ITEQK(50),NLOC(50),NFP(50),NUMEQ
COMMON /FILES/ LUIN,LUOUT, I1, I2, I3, I4, I5, I6
** Compute the contribution due to constant velocity
DTIME = DBLE(MIN - ITREF) / 525960.D0
CALL RADR8T(YLAT,VN,VE,VNR,VER)
YLATT = YLAT + VNR*DTIME
YLONT = YLON - VER*DTIME
HTT = HT + ((VU * DTIME) /1000.D0)
c write (*,*) "FROM COMPSN ",YLATT*180.d0/pi,YLONT*180.d0/pi,
c & HTT
c write (*,*) "FROM COMPSN ",ITREF,MIN,DTIME
** Compute the contribution due to earthquakes.
** It is assumed that the components of displacement,
** DNORTH,DWEST,DUP, do not vary from one reference
** frame to another given the accuracy of dislocation
** models.
DO 10 I = 1, NUMEQ
IF(ITEQK(I) .GT. ITREF) THEN
NTIME = 1
ELSE
NTIME = 0
ENDIF
IF(MIN .LT. ITEQK(I)) NTIME = NTIME - 1
IF(NTIME .NE. 0) THEN
CALL RADII(EQLATR(I),RADMER,RADPAR)
DDLAT = (YLAT - EQLATR(I))*RADMER
DDLON = (YLON - EQLONR(I))*RADPAR
DIST = DSQRT(DDLAT*DDLAT + DDLON*DDLON)
IF(DIST .LE. EQRAD(I)) THEN
ISTART = NLOC(I)
IEND = NLOC(I) + NFP(I) - 1
DO 5 JREC = ISTART,IEND
CALL DISLOC(YLAT,YLON,STRIKE(JREC),HL(JREC),
& EQLAT(JREC),EQLON(JREC),SSLIP(JREC),
& DSLIP(JREC),DIP(JREC),DEPTH(JREC),
& WIDTH(JREC),DNORTH,DWEST,DUP)
YLATT = YLATT + NTIME*DNORTH
YLONT = YLONT + NTIME*DWEST
HTT = HTT + NTIME*DUP
5 CONTINUE
ENDIF
ENDIF
10 CONTINUE
*** Compute contribution due to postseismic deformation
CALL PSDISP(YLAT, YLON, MIN, DNORTH, DEAST, DUP)
c write (*,*) "FROM COMPSN DISP ",DNORTH, DEAST, DUP
CALL RADII (YLAT, RMER, RPAR)
YLATT = YLATT + DNORTH/RMER
YLONT = YLONT - DEAST/RPAR
HTT = HTT + DUP
RETURN
END
***************************************************************
SUBROUTINE NEWCOR(YLAT,YLON,HTOLD,MIN1,MIN2,
1 YLAT3,YLON3,HTNEW,DN,DE,DU,VN, VE, VU)
*** Predict coordinates at time MIN2 given coordinates at time MIN1.
*** Predict displacements from time MIN1 to time MIN2.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
HT = HTOLD
CALL COMPSN(YLAT1,YLON1,HT1,YLAT,YLON,HT,
1 MIN1,VN, VE, VU)
CALL COMPSN(YLAT2,YLON2,HT2,YLAT,YLON,HT,
1 MIN2, VN, VE, VU)
YLAT3 = YLAT + YLAT2 - YLAT1
YLON3 = YLON + YLON2 - YLON1
HTNEW = HT + HT2 - HT1
c write (*,*) "FROM NEWCOR ",YLAT3*180.d0/pi,YLON3*180.d0/pi,
c & HTNEW
CALL RADII(YLAT,RADMER,RADPAR)
DN = RADMER * (YLAT2 - YLAT1)
DE = -RADPAR * (YLON2 - YLON1)
DU = HT2 - HT1
c write (*,*) "FROM NEWCOR displacement ",DN,DE,DU
c write (*,*) "FROM NEWCOR ",YLAT*180.d0/pi,YLON*180.d0/pi,HT
c write (*,*) "FROM NEWCOR ",YLAT1*180.d0/pi,YLON1*180.d0/pi,HT1
c write (*,*) "FROM NEWCOR ",YLAT2*180.d0/pi,YLON2*180.d0/pi,HT2
c write (*,*) "FROM NEWCOR ",YLAT3*180.d0/pi,YLON3*180.d0/pi,HTNEW
RETURN
END
******************************************************************
subroutine PREDV (ylat,ylon,eht,date,iopt,jregn,vn,ve,vu)
** Predict velocity in iopt reference frame
** ylat input - north latitude (radians)
** ylon input - west longitude (radians)
** eht input - ellipsoid height (meters)
** date input - date (decimal years)
** iopt input - reference frame
** jregn output - deformation region
** vn output - northward velocity in mm/yr
** ve output - eastward velocity in mm/yr
** vu output - upward velocity in mm/yr
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
logical Is_iopt_NAD83
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
** Get reference latitude (RLAT) and reference longitude (RLON)
C The following 2 lines were added on 07/22/2015 after Rich found this bug
elon = -ylon
call TOXYZ(ylat, elon, eht, x, y, z)
c IF(IOPT .EQ. 0 .OR. IOPT .EQ. 1) THEN !Velocity grids are No longer in NAD83
IF(IOPT .EQ. 15) THEN !They are in ITRF2008
RLAT = YLAT
*** Added conditional statement to get rid of out-of-region error when
*** YLON is negative for reference frame (v3.3.0):
IF(YLON .GE. 0.D0) THEN
RLON = YLON
ELSE
RLON = YLON + TWOPI
ENDIF
ELSE
c elon = -ylon !Was a bug, commented out on 07222015
c call TOXYZ(ylat, elon, eht, x, y, z) !Was a bug, commented out on 07222015
c CALL XTONAD(X,Y,Z,RLAT,RLON,EHTNAD,DATE,IOPT) !No longer NAD83
CALL XTO08 (X,Y,Z,RLAT,RLON,EHTNAD,DATE,IOPT) !Positions should be in ITRF2008
ENDIF
** Get deformation region
CALL GETREG(RLAT,RLON,JREGN)
c write (*,*) JREGN
IF (JREGN .EQ. 0) THEN
VN = 0.D0
VE = 0.D0
VU = 0.D0
RETURN
ENDIF
CALL COMVEL( RLAT, RLON, JREGN, VN, VE, VU) !Those velocities are in ITRF2008
** Convert velocity to reference of iopt, if iopt != NAD83 !No, was in ITRF2008, not in NAD83 (since 09/12/2014)
Is_iopt_NAD83 = (iopt == 1)
c IF (IOPT .NE. 0 .AND. IOPT .NE. 1) THEN
IF (IOPT .NE. 15) THEN
CALL TOVXYZ( YLAT, ELON, VN, VE, VU, VX, VY, VZ)
if (Is_iopt_NAD83) then
c CALL VTRANF( X, Y, Z, VX, VY, VZ, 1, IOPT)
CALL VTRANF( X, Y, Z, VX, VY, VZ, 15, IOPT)
else
CALL VTRANF_IERS( X, Y, Z, VX, VY, VZ, 15, IOPT)
endif
CALL TOVNEU( YLAT, ELON, VX, VY, VZ, VN, VE, VU)
ENDIF
c write (*,*) "From PREDV ",VN, VE, VU
RETURN
END
****************************************************************
subroutine TRFVEL
*** Transform velocities from one reference frame to another
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
parameter (numref = 16)
character nameif*80,name24*80
character NAMEF*80
character frame1*24, frame2*24
character option*1
character vopt*1, LATDIR*1,LONDIR*1
character record*120
LOGICAL Is_inp_NAD83,Is_out_NAD83
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /CONST/ A, F, E2, EPS, AF, PI, TWOPI, RHOSEC
write( luout, 100)
100 format(
1 ' Please enter the name of the file to contain '/
1 ' the transformed velocities. ')
read( luin, '(A80)',err=600,iostat=ios) namef
if (ios /= 0) goto 600
open( i2, file = namef, status = 'unknown')
CALL HEADER
105 write( luout, 110)
110 format( /'*******************************'/
1 ' Enter the reference frame of the input velocities.')
call MENU1(iopt1, frame1)
if (iopt1 .lt. 1 .or. iopt1 .gt. numref) then
write( luout, *) ' Improper selection -- try again.'
go to 105
endif
Is_inp_NAD83 = (iopt1 == 1)
115 write( luout, 120)
120 format( /' Enter the reference frame for the output velocities.')
call MENU1(iopt2, frame2)
if (iopt2 .lt. 1 .or. iopt2 .gt. numref) then
write( luout, *) 'Improper selection -- try again.'
go to 115
endif
Is_out_NAD83 = (iopt2 == 1)
write( i2, 125) frame1, frame2
125 format( ' TRANSFORMING VELOCITIES FROM ', A24, ' TO ', a24//
1 16X, ' INPUT VELOCITIES OUTPUT VELOCITIES'/)
130 write( luout, 140)
140 format(' ************************************************'/
1 ' Velocities will be transformed at each specified point.'/
1 ' Please indicate how you wish to input points.'/
1 ' 0...No more points. Return to main menu.'/
1 ' 1...Individual points entered interactively.'/
1 ' 2...Transform velocities contained in batch file '/
1 ' of delimited records of the form: '/
1 ' LAT,LON,VN,VE,VU,TEXT ' /
1 ' LAT = latitude in degrees (positive north/DBL PREC)'/
1 ' LON = longitude in degrees (positive west/DBL PREC)'/
1 ' VN = northward velocity in mm/yr (DBL PREC) '/
1 ' VE = eastwars velocity in mm/yr (DBL PREC) '/
1 ' VU = upward velocity in mm/yr (DBL PREC) '/
1 ' TEXT = descriptive text (CHARACTER*24) '/
1 ' Example: '/
1 ' 40.731671553,112.212671753, 3.7,3.8,-2.4,SALT AIR '/)
read( luin,'(a1)',err=601,iostat=ios) option
if (ios /= 0) goto 601
if (option .eq. '0') then
go to 500
elseif (option .eq. '1') then
call GETPNT( latd, latm, slat, LATDIR, lond, lonm, slon,
1 LONDIR, name24, x, y, z, ylat, ylon, eht)
elon = - ylon
call GETVLY( ylat, elon, vx, vy, vz, vn, ve, vu, vopt, 211)
vx1 = vx
vy1 = vy
vz1 = vz
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF( x, y, z, vx1, vy1, vz1, iopt1, iopt2)
else
call VTRANF_IERS( x, y, z, vx1, vy1, vz1, iopt1, iopt2)
endif
call TOVNEU( ylat, elon, vx1, vy1, vz1, vn1, ve1, vu1)
xlat = (ylat*rhosec)/3600.d0
xlon = (ylon*rhosec)/3600.d0
call PRNTVL(vn, ve, vu, vx, vy, vz, vn1, ve1, vu1,
1 vx1, vy1, vz1, name24, 1,xlat, xlon)
go to 130
elseif (option .eq. '2') then
eht = 0.d0
write (luout, 200)
200 format(/' Enter name of input file: ')
read(luin, '(a)',err=602,iostat=ios) nameif
if (ios /= 0) goto 602
open (i1, file = nameif, status = 'old')
LINE = 0 !Inititalize line number of input file.
210 read(i1,'(a)',end = 220,err=603,iostat=ios) record
call interprate_velocity_record (record,xlat,xlon,vn,ve,vu,
& name24)
if (ios /= 0) goto 603
LINE = LINE + 1 !Increment line number of input file.
*** If latitude magnitudes > 90 degrees or longitude magnitude > 360 degrees,
*** write error message and terminate program (added for v3.3.0).
IF ((DABS(xlat) .GT. 90).OR.(DABS(xlon) .GT. 360)) THEN
WRITE(*,*)'***********************************************'
WRITE(*,*)'Invalid latitude or longitude in input file'
WRITE(*,2101)'on line', LINE, ':'
WRITE(*,2102) xlat, xlon, vn, ve, vu, name24
WRITE(*,*)'Please check your input file and try again.'
WRITE(*,*)'***********************************************'
2101 FORMAT (1X, A, I8, A/)
2102 FORMAT (1X, 2F17.10, 3F8.2, 2X, A)
STOP
ENDIF
ylat = (xlat*3600.d0) / rhosec
ylon = (xlon*3600.d0) / rhosec
elon = -ylon
call TOXYZ (ylat, elon, eht, x, y, z)
call TOVXYZ (ylat, elon, vn,ve,vu,vx,vy,vz)
vx1 = vx
vy1 = vy
vz1 = vz
if (Is_inp_NAD83 .or. Is_out_NAD83) then
call VTRANF ( x, y, z, vx1, vy1, vz1, iopt1, iopt2)
else
call VTRANF_IERS ( x, y, z, vx1, vy1, vz1, iopt1, iopt2)
endif
call TOVNEU (ylat, elon, vx1, vy1, vz1, vn1, ve1, vu1)
call PRNTVL (vn, ve,vu,vx,vy,vz,vn1,ve1,vu1,vx1,vy1,vz1,
1 name24, 0, xlat, xlon)
go to 210
220 close (i1, status = 'keep')
endif
500 continue
close (i2, status = 'keep')
return
600 write (*,'(/)')
write (*,*) "Failed to read file name in TRFVEL:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
601 write (*,'(/)')
write (*,*) "Failed to read option in TRFVEL:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
602 write (*,'(/)')
write (*,*) "Failed to read input file name in TRFVEL:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
603 write (*,'(/)')
write(*,*)"Failed to read input file format in TRFVEL:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
end
*******************************************************************
SUBROUTINE VTRANF(X,Y,Z,VX,VY,VZ, IOPT1, IOPT2)
*** Convert velocity from reference frame of IOPT1 to
*** reference frame of IOPT2.
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (numref = 16)
common /tranpa/ tx(numref), ty(numref), tz(numref),
& dtx(numref), dty(numref), dtz(numref),
& rx(numref), ry(numref), rz(numref),
& drx(numref), dry(numref), drz(numref),
& scale(numref), dscale(numref), refepc(numref)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
IF(IOPT1 .le. numref .and. IOPT2. le. numref
& .and. IOPT1 .gt. 0 .and. IOPT2 .gt. 0 ) THEN
*** Convert from mm/yr to m/yr
VX = VX /1000.d0
VY = VY / 1000.d0
VZ = VZ / 1000.d0
*** From IOPT1 to ITRF94
*** (following equations use approximations assuming
*** that rotations and scale change are small)
WX = -drx(iopt1)
WY = -dry(iopt1)
WZ = -drz(iopt1)
DS = -dscale(iopt1)
VX = VX - dtx(iopt1) + DS*X + WZ*Y - WY*Z
VY = VY - dty(iopt1) - WZ*X +DS*Y + WX*Z
VZ = VZ - dtz(iopt1) + WY*X - WX*Y + DS*Z
*** From ITRF94 to IOPT2 reference frame
*** (following equations use approximations assuming
*** that rotations and scale change are small)
WX = drx(iopt2)
WY = dry(iopt2)
WZ = drz(iopt2)
DS = dscale(iopt2)
VX = VX + dtx(iopt2) + DS*X + WZ*Y - WY*Z
VY = VY + dty(iopt2) - WZ*X + DS*Y + WX*Z
VZ = VZ + dtz(iopt2) + WY*X - WX*Y + DS*Z
*** FROM m/yr to mm/yr
VX = VX * 1000.d0
VY = VY * 1000.d0
VZ = VZ * 1000.d0
ELSE
write(luout,*) ' Improper reference frame in routine vtranf'
stop
ENDIF
c write (*,*) "Inside VTRANF ",Vx,Vy,Vz
RETURN
END
******************************************************
SUBROUTINE VTRANF_IERS(X,Y,Z,VX,VY,VZ, IOPT1, IOPT2)
*** Convert velocity from reference frame of IOPT1 to
*** reference frame of IOPT2.
****************
C Important note:
C The parameters in common block tranpa are computed using the IGS values of ITRF96==>ITRF97
C The parameters in common block tranpa1 are computed using the IERS values of ITRF96==>ITRF97
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (numref = 16)
common /tranpa1/ tx1(numref), ty1(numref), tz1(numref),
& dtx1(numref), dty1(numref), dtz1(numref),
& rx1(numref), ry1(numref), rz1(numref),
& drx1(numref), dry1(numref), drz1(numref),
& scale1(numref), dscale1(numref), refepc1(numref)
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
IF(IOPT1 .le. numref .and. IOPT2. le. numref
& .and. IOPT1 .gt. 0 .and. IOPT2 .gt. 0 ) THEN
*** Convert from mm/yr to m/yr
VX = VX /1000.d0
VY = VY / 1000.d0
VZ = VZ / 1000.d0
*** From IOPT1 to ITRF94
*** (following equations use approximations assuming
*** that rotations and scale change are small)
WX = -drx1(iopt1)
WY = -dry1(iopt1)
WZ = -drz1(iopt1)
DS = -dscale1(iopt1)
VX = VX - dtx1(iopt1) + DS*X + WZ*Y - WY*Z
VY = VY - dty1(iopt1) - WZ*X +DS*Y + WX*Z
VZ = VZ - dtz1(iopt1) + WY*X - WX*Y + DS*Z
*** From ITRF94 to IOPT2 reference frame
*** (following equations use approximations assuming
*** that rotations and scale change are small)
WX = drx1(iopt2)
WY = dry1(iopt2)
WZ = drz1(iopt2)
DS = dscale1(iopt2)
VX = VX + dtx1(iopt2) + DS*X + WZ*Y - WY*Z
VY = VY + dty1(iopt2) - WZ*X + DS*Y + WX*Z
VZ = VZ + dtz1(iopt2) + WY*X - WX*Y + DS*Z
*** FROM m/yr to mm/yr
VX = VX * 1000.d0
VY = VY * 1000.d0
VZ = VZ * 1000.d0
ELSE
write(luout,*) ' Improper reference frame in routine vtranf'
stop
ENDIF
RETURN
END
******************************************************
subroutine PRNTVL(VN, VE, VU, VX, VY, VZ, VN1, VE1, VU1,
1 VX1, VY1, VZ1, NAME24, IPRINT,XLAT,XLON)
*** Print transformed velocities
implicit double precision (a-h, o-z)
implicit integer*4 (i-n)
character name24*80
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
if (iprint .eq. 1) then
write( luout, 100) vn1, ve1, vu1, vx1, vy1, vz1
100 format(' ************************************************'/
1 ' New northward velocity = ', f8.2, ' mm/yr' /
1 ' New eastward velocity = ', f8.2, ' mm/yr'/
1 ' New upward velocity = ', f8.2, ' mm/yr'/
1 ' New x velocity = ', f8.2, ' mm/yr'/
1 ' New y velocity = ', f8.2, ' mm/yr'/
1 ' New z velocity = ', f8.2, ' mm/yr')
endif
write( i2, 200) name24, xlat, xlon,
1 vn, vn1, ve, ve1, vu, vu1,
1 vx, vx1, vy, vy1, vz, vz1
200 format(1x, a24 /
1 1x, 'latitude = ',F14.9,2x,'longitude = ',F14.9 /
1 5x, 'northward velocity ', f8.2, 6x, f8.2, ' mm/yr' /
1 5x, 'eastward velocity ', f8.2, 6x, f8.2, ' mm/yr' /
1 5x, 'upward velocity ', f8.2, 6x, f8.2, ' mm/yr' /
1 5x, 'x velocity ', f8.2, 6x, f8.2, ' mm/yr' /
1 5x, 'y velocity ', f8.2, 6x, f8.2, ' mm/yr' /
1 5x, 'z velocity ', f8.2, 6x, f8.2, ' mm/yr' /)
return
end
*******************************************************************
SUBROUTINE HEADER
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
character HTDP_version*8
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
COMMON /VERSION/ HTDP_version
WRITE(I2, 10) HTDP_version
10 FORMAT(' HTDP OUTPUT, VERSION ',a / )
RETURN
END
*********************************************
SUBROUTINE GETMDY(MONTH, IDAY, IYEAR, DATE, MINS, TEST)
*** Read month-day-year and convert to decimal years
*** and Julian time in minutes
*** MONTH output - number from 1 to 12
*** IDAY output - number from 1 to 31
*** IYEAR output - must be after 1906
*** DATE output - corresponding time in decimal years
*** MINS output - corresponding julian time in minutes
*** TEST output - if (true) then there is an error
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
DIMENSION M(12)
LOGICAL TEST
CHARACTER TOPT*1
COMMON /FILES/ LUIN, LUOUT, I1, I2, I3, I4, I5, I6
M(1) = 31
M(2) = 28
M(3) = 31
M(4) = 30
M(5) = 31
M(6) = 30
M(7) = 31
M(8) = 31
M(9) = 30
M(10) = 31
M(11) = 30
M(12) = 31
3 WRITE (LUOUT,1)
1 FORMAT (' How do you wish to enter the time?'/
1 ' 1. month-day-year in free format'/
1 ' for example, 5,12,1979'/
1 ' represents May 12, 1979'/
1 ' 2. decimal year'/
1 ' for example the entry 1979.359'/
1 ' represents UTC midnight at the begining'/
1 ' of May 12, 1979.'/)
READ (LUIN,5,err=100,iostat=ios) TOPT
if (ios /= 0) goto 100
5 format (A1)
IF (TOPT .EQ. '1') Then
write (luout,*) ' Enter month-day-year '
READ(LUIN,*,err=101,iostat=ios) MONTH,IDAY,IYEAR
if (ios /= 0) goto 101
IF(IYEAR .le. 1906) THEN
WRITE(LUOUT,10)
10 FORMAT(' The model is not valid for dates prior ',
1 'to 1906.'/)
TEST = .TRUE.
RETURN
ENDIF
IF(MONTH .le. 0 .or. MONTH .gt. 12) THEN
WRITE(LUOUT,20)
20 FORMAT(' Improper month specified.'/)
TEST = .TRUE.
RETURN
ENDIF
IF(IDAY .le. 0 .or. IDAY .gt. 31) THEN
WRITE(LUOUT,30)
30 FORMAT(' Improper day specified.'/)
TEST = .TRUE.
RETURN
ENDIF
CALL IYMDMJ(IYEAR, MONTH, IDAY, MJD)
CALL IYMDMJ(IYEAR, 1, 1, MJD0)
IYEAR1 = IYEAR + 1
CALL IYMDMJ(IYEAR1, 1, 1, MJD1)
DAY = DBLE(MJD - MJD0)
DENOM = DBLE(MJD1 - MJD0)
DATE = DBLE(IYEAR) + (DAY / DENOM)
MINS = MJD * 24 * 60
TEST = .FALSE.
RETURN
ELSEIF (TOPT .EQ. '2') then
write(luout,*) ' Enter decimal year '
READ (LUIN, *,err=102,iostat=ios) DATE
if (ios /= 0) goto 102
IF (DATE .lt. 1906.0d0) then
write (luout, 10)
TEST = .TRUE.
RETURN
ENDIF
IYEAR = IDINT(DATE) !Convert DATE to integer (v3.3.0)
CALL IYMDMJ(IYEAR, 1, 1, MJD0)
IYEAR1 = IYEAR + 1
CALL IYMDMJ(IYEAR1, 1, 1, MJD1)
LEAP = 0
IF ((MJD1 - MJD0) .eq. 366) LEAP = 1
REMDAY = (DATE - IYEAR)* (MJD1 - MJD0)
IBEGIN = 0
ITOTAL = 31
IF (REMDAY .LT. ITOTAL) then
MONTH = 1
IDAY = IDINT(REMDAY) - IBEGIN + 1 !Convert REMDAY to integer (v3.3.0)
CALL IYMDMJ(IYEAR,MONTH,IDAY,MJD)
MINS = MJD * 24 * 60
TEST = .FALSE.
RETURN
ENDIF
IBEGIN = ITOTAL
ITOTAL = ITOTAL + LEAP
DO I = 2, 12
ITOTAL = ITOTAL + M(I)
IF (REMDAY .LT. ITOTAL) then
MONTH = I
IDAY = IDINT(REMDAY) - IBEGIN + 1 !Convert REMDAY to integer (v3.3.0)
TEST = .FALSE.
CALL IYMDMJ(IYEAR,MONTH,IDAY,MJD)
MINS = MJD * 24 * 60
RETURN
ENDIF
IBEGIN = ITOTAL
ENDDO
Write(LUOUT, 60)
60 Format (' Error could not convert Decimal years to '
1 ,'month-day-year')
TEST = .TRUE.
RETURN
ELSE
write (luout, 70)
70 format (' Improper entry')
Go TO 3
ENDIF
100 write (*,'(/)')
write (*,*) "Failed to read option in GETDMY:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
101 write (*,'(/)')
write (*,*) "Wrong MDY input in GETDMY:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
102 write (*,'(/)')
write (*,*) "Wrong decimal year in GETDMY:ios=",ios
write (*,*) "ABNORMAL TERMINATION"
write (*,*) "PLEASE CHECK YOUR INPUT FILE AND TRY AGAIN"
stop
END
************************************
SUBROUTINE IYMDMJ( IYR, IMON, IDAY, MJD )
C
C********1*********2*********3*********4*********5*********6*********7**
C
C NAME: IYMDMJ
C VERSION: Sep. 17, 2010
C WRITTEN BY: R. SNAY (after M. SCHENEWERK)
C PURPOSE: CONVERT DATE TO MODIFIED JULIAN DATE
C
C INPUT PARAMETERS FROM THE ARGUEMENT LIST:
C -----------------------------------------
C IDAY DAY
C IMON MONTH
C IYR YEAR
C
C OUTPUT PARAMETERS FROM ARGUEMENT LIST:
C --------------------------------------
C MJD MODIFIED JULIAN DATE
C
C
C LOCAL VARIABLES AND CONSTANTS:
C ------------------------------
C A TEMPORARY STORAGE
C B TEMPORARY STORAGE
C C TEMPORARY STORAGE
C D TEMPORARY STORAGE
C IMOP TEMPORARY STORAGE
C IYRP TEMPORARY STORAGE
C
C GLOBAL VARIABLES AND CONSTANTS:
C ------------------------------
C
C
C THIS MODULE CALLED BY: GENERAL USE
C
C THIS MODULE CALLS: DINT
C
C INCLUDE FILES USED:
C
C COMMON BLOCKS USED:
C
C REFERENCES: DUFFETT-SMITH, PETER 1982, 'PRACTICAL
C ASTRONOMY WITH YOUR CALCULATOR', 2ND
C EDITION, CAMBRIDGE UNIVERSITY PRESS,
C NEW YORK, P.9
C
C COMMENTS: THIS SUBROUTINE REQUIRES THE FULL YEAR,
C I.E. 1992 RATHER THAN 92.
C
C********1*********2*********3*********4*********5*********6*********7**
C::LAST MODIFICATION
C::8909.06, MSS, DOC STANDARD IMPLIMENTED
C::9004.17, MSS, CHANGE ORDER YY MM DD
C********1*********2*********3*********4*********5*********6*********7**
C
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
C
INTEGER*4 A, B, C, D
IYRP = IYR
C
C........ 0.0 EXPLICIT INITIALIZATION
C
IF( IMON .LT. 3 ) THEN
IYRP= IYRP - 1
IMOP= IMON + 12
ELSE
IMOP= IMON
END IF
C
C........ 1.0 CALCULATION
C
*** Following 4 lines edited in v3.3.0 to address compiler issue with
*** real to integer conversion.
C A= IYRP*0.01D0
C B= 2 - A + DINT( A*0.25D0 )
C C= 365.25D0*IYRP
C D= 30.6001D0*(IMOP + 1)
C MJD = (B + C + D + IDAY - 679006)
C
C WRITE(*,*)'Old values:'
C WRITE(*,*)'A, B, C, D =', A, B, C, D
C WRITE(*,*)'MJD =', MJD
A = IDINT(DBLE(IYRP)*0.01D0)
B = 2 - A + IDINT(DBLE(A)*0.25D0)
C = IDINT(365.25D0*DBLE(IYRP))
D = IDINT(30.6001D0*(DBLE(IMOP + 1)))
MJD = B + C + D + IDAY - 679006
C WRITE(*,*)'New values:'
C WRITE(*,*)'A, B, C, D =', A, B, C, D
C WRITE(*,*)'MJD =', MJD
C WRITE(*,*)
RETURN
END
*****************************************************
SUBROUTINE PSDISP(YLAT, YLON, MIN, DNORTH, DEAST, DUP)
********
* Compute total postseismic displacement for all earthquakes
*
* INPUT
* YLAT latitude of point in radians, positive north
* YLON longitude of point in radians, positive west
* MIN modified julian date of reference epoch for new coordinates
* in minutes
*
* DNORTH Total northward postseismic displacement at point during
* period from ITREF to MIN in meters
* DEAST TOTAL eastward postseismic displacement
* DUP Total upward postseismic displacement
*******
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
IMPLICIT INTEGER*4 (I-N)
LOGICAL INSIDE
parameter (NUMPSG = 1)
COMMON /CONST/ A, F,E2,EPS,AF,PI,TWOPI,RHOSEC
COMMON /TIMREF/ ITREF
COMMON /PSGRID/ PSGLX(NUMPSG), PSGUX(NUMPSG),
1 PSGLY(NUMPSG), PSGUY(NUMPSG),
1 ICNTPX(NUMPSG), ICNTPY(NUMPSG), NBASEP(NUMPSG)
COMMON /PGRID/ PS(18000)
DIMENSION ITEQ(NUMPSG)
DIMENSION TAU(NUMPSG)
DIMENSION WEI(2,2)
DIMENSION AMP(2,2,3)
*** Relaxation constant (in years) for 2002 Denali earthquake
TAU(1) = 5.0D0
*** Modofied Julian Date (in minutes) for the 2002 Denali earthquake
IYEAR = 2002
IMO = 11
IDAY = 3
CALL IYMDMJ(IYEAR,IMO,IDAY, MJD)
ITEQ(1) = MJD*60*24
DNORTH = 0.0D0
DEAST = 0.0D0
DUP = 0.0D0
DO K = 1, NUMPSG
*** Check if the point is inside the grid
POSX = YLON*180.d0/PI
POSX = 360.d0 - POSX
IF (POSX .GT. 360.D0) POSX = POSX - 360.D0
POSY = YLAT*180.D0/PI
CALL GRDCHK(POSX, POSY, PSGLX(K), PSGUX(K),
1 PSGLY(K), PSGUY(K), INSIDE)
IF (INSIDE ) THEN
*** Get the indices for the lower left-hand corner of the grid
CALL PSGWEI(POSX,POSY,K,I,J,WEI)
*** Get the displacement amplitude at the four corners
CALL GRDAMP(K,I,J,AMP,PS)
ANORTH = WEI(1,1)*AMP(1,1,1) + WEI(1,2)*AMP(1,2,1)
1 + WEI(2,1)*AMP(2,1,1) + WEI(2,2)*AMP(2,2,1)
AEAST = WEI(1,1)*AMP(1,1,2) + WEI(1,2)*AMP(1,2,2)
1 + WEI(2,1)*AMP(2,1,2) + WEI(2,2)*AMP(2,2,2)
AUP = WEI(1,1)*AMP(1,1,3) + WEI(1,2)*AMP(1,2,3)
1 + WEI(2,1)*AMP(2,1,3) + WEI(2,2)*AMP(2,2,3)
c write (6, 30) anorth, aeast, aup
c 30 format (1x, 3f15.5)
*** Convert amplitudes from mm to meters
ANORTH = ANORTH / 1000.D0
AEAST = AEAST / 1000.D0
AUP = AUP / 1000.D0
IF (MIN .GT. ITEQ(K)) THEN
DTIME = DBLE(MIN - ITEQ(K))/(60.D0*24.D0*365.D0)
FACTOR = 1.D0 - DEXP(-DTIME/TAU(K))
DNORTH = DNORTH + ANORTH*FACTOR
DEAST = DEAST + AEAST*FACTOR
DUP = DUP + AUP*FACTOR
ENDIF
IF (ITREF .GT. ITEQ(K)) THEN
DTIME = DBLE(ITREF - ITEQ(K))/(60.D0*24.D0*365.D0)
FACTOR = 1.D0 - DEXP(-DTIME/TAU(K))
DNORTH = DNORTH - ANORTH*FACTOR
DEAST = DEAST - AEAST*FACTOR
DUP = DUP - AUP*FACTOR
ENDIF
ENDIF
ENDDO
RETURN
END
****************************************************
SUBROUTINE GRDCHK (POSX, POSY, GRDLX, GRDUX,
1 GRDLY, GRDUY, INSIDE)
C
C ROUTINE CHECKS IF THE POINT HAVING COORDINATES (POSX, POSY)
C IS WITHIN THE REGION SPANNED BY THE GRID
C
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
LOGICAL INSIDE
INSIDE = .TRUE.
IF (POSX .LT. GRDLX .OR. POSX .GT. GRDUX) THEN
INSIDE = .FALSE.
ENDIF
IF (POSY .LT. GRDLY .OR. POSY .GT. GRDUY) THEN
INSIDE = .FALSE.
ENDIF
RETURN
END
*******************************************************************
SUBROUTINE PSGWEI (POSX, POSY, K, I, J, WEI)
C
C********1*********2*********3*********4*********5*********6*********7**
C
C PURPOSE: THIS SUBROUTINE RETURNS THE INDICES OF THE LOWER-LEFT
C HAND CORNER OF THE GRID CELL CONTAINING THE POINT
C AND COMPUTES NORMALIZED WEIGHTS FOR
C BI-LINEAR INTERPOLATION OVER A PLANE
C
C INPUT PARAMETERS FROM ARGUMENT LIST:
C ------------------------------------
C POSX LONGITUDE OF POINT IN DEGREES, POSITIVE EAST
C POSY LATITUDE OF POINT IN DEGREES, POSITIVE NORTH
C K ID OF EARTHQUAKE GRID
C
C OUTPUT PARAMETERS FROM ARGUMENT LIST:
C -------------------------------------
C I, J THE COORDINATES OF LOWER LEFT CORNER OF THE GRID
C CONTAINING THE ABOVE POSITION
C WEI A TWO BY TWO ARRAY CONTAINING THE NORMALIZED WEIGHTS
C FOR THE CORNER VECTORS
C
C GLOBAL VARIABLES AND CONSTANTS:
C -------------------------------
C NONE
C
C THIS MODULE CALLED BY: PSDISP
C
C THIS MODULE CALLS: NONE
C
C INCLUDE FILES USED: NONE
C
C COMMON BLOCKS USED: /PSGRID/, /CONST/
C
C REFERENCES: SEE RICHARD SNAY
C
C COMMENTS:
C
C********1*********2*********3*********4*********5*********6*********7**
C MOFICATION HISTORY:
C::9302.11, CRP, ORIGINAL CREATION FOR DYNAP
C::9511.09, RAS, MODIFIED FOR HTDP
C::9712.05, RAS, MODIFIED TO ACCOUNT FOR MULTIPLE GRIDS
C********1*********2*********3*********4*********5*********6*********7**
C**** COMPUTES THE WEIGHTS FOR AN ELEMENT IN A GRID
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NUMPSG = 1)
DIMENSION WEI(2,2)
COMMON /PSGRID/ PSGLX(NUMPSG), PSGUX(NUMPSG),
1 PSGLY(NUMPSG), PSGUY(NUMPSG),
1 ICNTPX(NUMPSG), ICNTPY(NUMPSG), NBASEP(NUMPSG)
COMMON /CONST/ A,F,E2,EPS,AF,PI,TWOPI,RHOSEC
C*** Obtain indices for the lower-left corner of the cell
C*** containing the point
STEPX = (PSGUX(K) - PSGLX(K)) / ICNTPX(K)
STEPY = (PSGUY(K) - PSGLY(K)) / ICNTPY(K)
I = IDINT((POSX - PSGLX(K))/STEPX) + 1
J = IDINT((POSY - PSGLY(K))/STEPY) + 1
c write(6,1001) K, I, J
c1001 format(1x, 'quake = ', I5 /
c 1 1x, ' i = ', I5 /
c 1 1x, ' j = ', I5)
C*** Compute the limits of the grid cell
GRLX = PSGLX(K) + (I - 1) * STEPX
GRUX = GRLX + STEPX
GRLY = PSGLY(K) + (J - 1) * STEPY
GRUY = GRLY + STEPY
C*** Compute the normalized weights for the point
DENOM = (GRUX - GRLX) * (GRUY - GRLY)
WEI(1,1) = (GRUX - POSX) * (GRUY - POSY) / DENOM
WEI(2,1) = (POSX - GRLX) * (GRUY - POSY) / DENOM
WEI(1,2) = (GRUX - POSX) * (POSY - GRLY) / DENOM
WEI(2,2) = (POSX - GRLX) * (POSY - GRLY) / DENOM
RETURN
END
C*********************************************************************
SUBROUTINE GRDAMP (K, I, J, AMP, PS)
C********1*********2*********3*********4*********5*********6*********7**
C
C PURPOSE: THIS SUBROUTINE RETRIEVES THE AMPLITUDES OF THE FOUR
C GRID NODES OFGRID K WHERE I,J ARE THE INDICES OF
C THE LOWER LEFT HAND CORNER
C
C INPUT PARAMETERS FROM ARGUMENT LIST:
C ------------------------------------
C
C K ID OF EARTHQUAKE CORRESPONDING TO GRID
C I, J THE COORDINATES OF LOWER LEFT CORNER OF THE GRID
C CONTAINING THE ABOVE POSITION
C PS THE ARRAY CONTAINING ALL THE GRIDDED AMPLITUDES
C
C OUTPUT PARAMETERS FROM ARGUMENT LIST:
C -------------------------------------
C AMP A TWO BY TWO ARRAY CONTAINING THE 3D AMPLITUDES
C FOR THE CORNERS OF THE GRID
C
C GLOBAL VARIABLES AND CONSTANTS:
C -------------------------------
C NONE
C
C THIS MODULE CALLED BY: PSDISP
C
C THIS MODULE CALLS: NONE
C
C INCLUDE FILES USED: NONE
C
C COMMON BLOCKS USED: NONE
C
C REFERENCES: SEE RICHARD SNAY
C
C COMMENTS:
C
C********1*********2*********3*********4*********5*********6*********7**
C MOFICATION HISTORY:
C::2011.08.17, RAS, ORIGINAL CREATION FOR TRANS4D
C********1*********2*********3*********4*********5*********6*********7**
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
DIMENSION AMP(2,2,3), PS(*)
DO 30 II = 0,1
DO 20 IJ = 0,1
DO 10 IVEC = 1, 3
INDEX = IPSGRD(K, I + II, J + IJ, IVEC)
AMP(II + 1, IJ + 1, IVEC) = PS(INDEX)
10 CONTINUE
20 CONTINUE
30 CONTINUE
RETURN
END
C***************************************************
INTEGER FUNCTION IPSGRD(IGRID, I, J, IVEC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IMPLICIT INTEGER*4 (I-N)
parameter (NUMPSG = 1)
COMMON /PSGRID/ PSGLX(NUMPSG), PSGUX(NUMPSG),
1 PSGLY(NUMPSG), PSGUY(NUMPSG),
1 ICNTPX(NUMPSG), ICNTPY(NUMPSG), NBASEP(NUMPSG)
IPSGRD = NBASEP(IGRID) +
1 3 * ((J - 1) * (ICNTPX(IGRID) + 1) + (I - 1)) + IVEC
RETURN
END
C---------------------------------------------------------------------
subroutine extract_name (name,i)
C In f90, use trim(name) to truncate all spaces after the name.
C But "trim" were not available in f77. This is what this subroutine is for
implicit none
integer*4 i
character name*80,scratch*80
do i=80,1,-1
if (name(i:i) /= ' ') exit
enddo
scratch = name(1:i)
name = scratch
return
end
C-----------------------------------------------------------------------------------
subroutine interprate_XYZ_record (record,x,y,z,name)
implicit none
integer*4 i,length
real*8 x,y,z
character name*80,record*120,record1*120,chars*120
character xxxx*80,yyyy*80,zzzz*80
record1 = trim(adjustl(record))
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == ' ') then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get x or phi
xxxx = '0'
do i=1,length
if (chars(i:i) == '1') then
xxxx(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (xxxx,*) x
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get y or lamda
yyyy = '0'
do i=1,length
if (chars(i:i) == '1') then
yyyy(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (yyyy,*) y
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get z or h
zzzz = '0'
do i=1,length
if (chars(i:i) == '1') then
zzzz(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (zzzz,*) z
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get name
name = trim(record1)
C Done
return
end
C-----------------------------------------------------------------------------------
subroutine interprate_XYZVxVyVz_record (record,x,y,z,Vx,Vy,Vz,
& name)
implicit none
integer*4 i,length
real*8 x,y,z,Vx,Vy,Vz
character name*80,record*120,record1*120,chars*120
character xxxx*80,yyyy*80,zzzz*80
record1 = trim(adjustl(record))
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == ' ') then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get x or phi
xxxx = '0'
do i=1,length
if (chars(i:i) == '1') then
xxxx(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (xxxx,*) x
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get y or lamda
yyyy = '0'
do i=1,length
if (chars(i:i) == '1') then
yyyy(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (yyyy,*) y
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get z or h
zzzz = '0'
do i=1,length
if (chars(i:i) == '1') then
zzzz(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (zzzz,*) z
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get Vx
xxxx = '0'
do i=1,length
if (chars(i:i) == '1') then
xxxx(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (xxxx,*) Vx
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get Vy
yyyy = '0'
do i=1,length
if (chars(i:i) == '1') then
yyyy(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (yyyy,*) Vy
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get z or h
zzzz = '0'
do i=1,length
if (chars(i:i) == '1') then
zzzz(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (zzzz,*) Vz
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get name
name = trim(record1)
C Done
return
end
C-----------------------------------------------------------------------------------
subroutine interprate_latlon_record (record,x,y,name)
implicit none
integer*4 i,length
real*8 x,y
character name*24,record*120,record1*120,chars*120
character xxxx*80,yyyy*80
record1 = trim(adjustl(record))
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == ' ') then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get x or phi
xxxx = '0'
do i=1,length
if (chars(i:i) == '1') then
xxxx(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (xxxx,*) x
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get y or lamda
yyyy = '0'
do i=1,length
if (chars(i:i) == '1') then
yyyy(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (yyyy,*) y
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get name
name = trim(record1)
C Done
return
end
C-----------------------------------------------------------------------------------
subroutine interprate_velocity_record (record,x,y,vn,ve,
& vu,name)
implicit none
integer*4 i,length
real*8 x,y,vn,ve,vu
character name*80,record*120,record1*120,chars*120
character xxxx*80,yyyy*80,vnnn*80,veee*80,vuuu*80
record1 = trim(adjustl(record))
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == ' ') then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get x or phi
xxxx = '0'
do i=1,length
if (chars(i:i) == '1') then
xxxx(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1)) !adjust left then trim all trailing spaces
read (xxxx,*) x
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get y or lamda
yyyy = '0'
do i=1,length
if (chars(i:i) == '1') then
yyyy(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (yyyy,*) y
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get vn
vnnn = '0'
do i=1,length
if (chars(i:i) == '1') then
vnnn(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (vnnn,*) vn
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get ve
veee = '0'
do i=1,length
if (chars(i:i) == '1') then
veee(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (veee,*) ve
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get vu
vuuu = '0'
do i=1,length
if (chars(i:i) == '1') then
vuuu(i:i) = record1(i:i)
record1(i:i) = ' '
elseif (chars(i:i) == '0') then
exit
endif
enddo
record = trim(adjustl(record1))
read (vuuu,*) vu
if (record(1:1) == ',') then
record(1:1) = ' '
endif
record1 = adjustl(record)
length = len_trim(record1)
chars = ' '
do i=1,length
if (record1(i:i) == ' ' .or. record1(i:i) == ',' .or.
& record1(i:i) == " ") then
chars(i:i) = '0'
else
chars(i:i) = '1'
endif
enddo
C Get name
name = trim(record1)
C Done
return
end
C-----------------------------------------------------------------------
C On 5/10/2020 removed all code and comments entered on 7/22/2015 that limited use
C of HTDP to US and its territories. That functionality was disabled on 5/11/2017.
C The removed code still exists in HTDP v3.2.8 and 3.2.7, commented out to disable.
C But functions remained in those previous versions, causing numerous warnings when
C program compiled.
|