forked from NOAA-SWPC/IPE-grid-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapxntrpb4lf.f
More file actions
1779 lines (1648 loc) · 69.2 KB
/
apxntrpb4lf.f
File metadata and controls
1779 lines (1648 loc) · 69.2 KB
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
SUBROUTINE APXMKA (MSGUN, EPOCH, GPLAT,GPLON,GPALT,NLAT,NLON,NALT,
+ WK,LWK, IST)
C Lunux specific settings: see IRLF
C This contains ENTRYs that determine quantities related to Apex
C coordinates. They are designed to speed up coordinate determination
C by substituting interpolation from previously calculated tables
C for direct calculation. They also permit calculating quantities
C involving gradients of Apex coordinates, such as base vectors in
C the Modified-Apex and Quasi-Dipole systems. Options allow table
C creation, storage, and read-back in addition to interpolation.
C
C Tables (arrays) must be prepared prior to coordinate determination.
C Tables may be created for one date and held only in memory by calling
C
C APXMKA - make magnetic arrays.
C
C Or, they may be created and written, then read back later by
C
C APXWRA - make and write arrays
C APXRDA - read stored arrays.
C
C Tables may be created for multiple times (e.g., the DGRF dates)
C and written to a file using APXWRA. However, tables are held in
C memory for only one time due to the potential to exceed memory
C capacity. Thus, when reading back multiples times, APXRDA
C interpolates/extrapolates to a single time.
C
C Alternatively, If APXWRA is called to make and write tables for one
C time only, then it is not necessary to call APXRDA because tables
C have already been initialized for that time.
C
C Creation of global lookup tables can be time consuming, thus, it
C is expected that this is done rarely; it might be considered an
C installation step. Once the tables are established, programs may
C reference them by calling APXRDA. In this case, the grid coordinates
C (originally specified during the table creation) may be ascertained
C by calling
C
C APXGGC - get grid coordinates.
C
C After the tables have been loaded in memory for a given date, it
C is possible to interpolate in space to determinine various magnetic
C parameters using the following calls:
C
C APXALL - get Apex coordinates (radius, lat, lon).
C APXMALL - get Modified Apex coordinates, Quasi-Dipole
C coordinates and associated base vectors.
C APXQ2G - convert quasi-dipole to geodetic coordinates.
C
C Details for each ENTRY introduced above are provided below.
C Following the ENTRY summaries are comments describing EXTERNALS,
C INSTALLATION SPECIFICS for different computers, and a HISTORY.
C
C REFERENCE:
C Richmond, A. D., Ionospheric Electrodynamics Using Magnetic Apex
C Coordinates, J. Geomag. Geoelectr., 47, 191-212, 1995.
C
C ALGORITHM:
C When arrays are created, APXMKA calls subroutine MAKEXYZV, which
C in turn calls subroutine APEX at each grid point to get the apex
C radius A, the apex longitude PHIA, and the magnetic potential
C VMP. The cosine (CLP) and sine (SLP) of the quasi-dipole
C latitude are computed from A. From these can be computed
C preliminary quantites defined as
C
C x = cos(quasi-dipole latitude)*cos(apex longitude)
C y = cos(quasi-dipole latitude)*sin(apex longitude)
C z = sin(quasi-dipole latitude)
C v = (VMP/VP)*((RE+ALT)/RE)**2
C
C where VP is the magnitude of the magnetic potential of the
C geomagnetic dipole at a radius of RE; ALT is altitude; and RE is
C the mean Earth radius. Note that all of these quantities vary
C smoothly across the apex poles, unlike apex latitude or
C quasi-dipole latitude, so that they can be linearly interpolated
C near these poles. Corresponding values of x,y,z,v for a dipole
C field on a spherical Earth are computed analytically and
C subtracted from the above quantities, and the results are put
C into the 3D arrays X,Y,Z,V. When APXALL or APXMALL is called,
C trilinear interpolations (in latitude, longitude, and inverse
C altitude) are carried out between the grid points. Gradients are
C calculated for APXMALL in order to determine the base vectors.
C Analytic formulas appropriate for a dipole field on a spherical
C Earth are used to determine the previously removed dipole
C components of x,y,z,v, and their gradients and these are added
C back to the interpolated values obtained for the non-dipole
C components. Finally, the apex-based coordinates and their base
C vectors are calculated from x,y,z,v and their gradients.
C
C------------------------------------------------------------------------------
C
C ENTRY APXMKA and APXWRA:
C These create gridded arrays of quantities that can later be
C linearly interpolated to any desired geographic point within
C their range by APXALL, APXMALL, and APXQ2G. The spatial extent
C and resolution of the arrays in latitude, longitude, and altitude
C can be tailored for the application at hand. In one extreme,
C very high interpolation accuracy can be achieved by creating a
C 2x2x2 array with very small spatial increments surrounding the
C point of interest. (However, since vector quantities are obtained
C by taking differences of the quantities at adjacent points,
C computer roundoff errors will limit the benefits of making the
C increments too small.) In another extreme, a global array from
C the ground to an altitude of several Earth radii can be created.
C (In this case, the spatial resolution is limited by the need to
C maintain reasonable array sizes.) For most purposes, we have
C found it adequate to use a global grid with dimensions 91,151,6
C (latitude,longitude,altitude) and altitude from ground to 1274 km
C as created by GGRID with NVERT = 30 (see file test.f).
C
C WARNING: execution time to create these look-up tables can be
C substantial. It is dependent on the grid dimensions and the
C number of Epochs to be computed. For eight epochs and dimensions
C (91,151,6), it took 76 minutes on a Sun SPARCstation IPX and the
C resulting file is 15.8 Mbytes.
C
C Use APXMKA to create the interpolation tables for a single time
C without writing them. Otherwise, use APXWRA create the tables
C and save them in a file.
C
C CALL APXMKA (MSGUN, EPOCH, GPLAT,GPLON,GPALT,NLAT,NLON,NALT,
C + WK,LWK, IST)
C
C CALL APXWRA (MSGUN, FILNAM,IUN, EPOCH,NEPOCH,
C + GPLAT,GPLON,GPALT,NLAT,NLON,NALT, WK,LWK, IST)
C
C INPUTS:
C MSGUN = Fortran unit number to write diagnostic messages.
C EPOCH = Time formatted as UT year and fraction; e.g., 1990.0
C is 0 UT 1 Jan 1990. For APXMKA EPOCH is single valued;
C for APXWRA EPOCH contains NEPOCH values.
C GPLAT,GPLON,GPALT = Grid point latitudes, longitudes, and
C altitudes. NLAT values in GPLAT must be in the range
C -90. to +90. degrees North. NLON values in GPLON
C must be in the range -270. to 270. degrees East. NALT
C values in GPALT are km MSL. Each array must be in
C ascending numerical order but they may have arbitrary
C spacing (as desired for model grid resolution).
C Subroutine GGRID can be used to set up these arrays.
C NLAT,NLON,NALT = Number of latitudes, longitudes and altitudes
C are the single dimensions of the arrays GPLAT,GPLON,
C and GPALT. Subroutine GGRID can be used to select
C appropriate values. In general, increasing the number
C of grid points, increases the model resolution. While
C array values at the grid points are exact, values at
C locations between grid points are estimated by linear
C interpolation. One can increase the grid resolution to
C the point of degraded accuracy very close to the poles
C of quantities involving east-west gradients, viz.,
C B(1), G, H, W, Bhat(1), D1(1), D2(1), D3, E1, E2, E3,
C F1(2), and F2(2). This is evident with dimensions
C 301x501x15 for a global grid, 0-1000 km.
C WK = Work array is used internally, i.e., there is no need
C to access the contents. WK should not be altered
C between initialization (by APXMKA, APXWRA or APXRDA)
C and use (by APXGGC, APXALL, APXMALL, or APXQ2G).
C LWK = Dimension of WK >= NLAT*NLON*NALT*5 + NLAT+NLON+NALT
C
C Additional INPUTS for APXWRA only:
C FILNAM = file name where arrays are stored.
C IUN = Fortran unit number to be associated with FILNAM.
C NEPOCH = Number of times in EPOCH.
C
C RETURNS:
C IST = Return status: = 0 okay
C > 0 failed
C
C Declarations for APXMKA formal arguments:
C DIMENSION GPLAT(NLAT), GPLON(NLON), GPALT(NALT), WK(LWK)
C
C Additional declarations for APXWRA formal arguments:
C DIMENSION EPOCH(NEPOCH)
C CHARACTER*(*) FILNAM
C
C------------------------------------------------------------------------------
C
C ENTRY APXRDA:
C Read back tables (previously created by calling APXWRA) in
C preparation for magnetic coordinate determination (using APXALL,
C APXMALL, APXQ2G). If multiple dates were stored, interpolate
C in time.
C
C CALL APXRDA (MSGUN, FILNAM,IUN, DATE, WK,LWK, IST)
C
C INPUTS:
C MSGUN = Fortran unit number to write diagnostic messages.
C FILNAM = file name where arrays are stored.
C IUN = Fortran unit number to be associated with FILNAM.
C DATE = Time formatted as UT year and fraction; e.g., 1990.0
C is 0 UT 1 Jan 1990.
C WK,LWK = Same as APXMKA
C
C RETURNS:
C IST = Return status: = 0 okay
C = -1 non-fatal date problem
C > 0 failed
C
C Declarations for APXRDA formal arguments:
C CHARACTER*(*) FILNAM
C DIMENSION WK(LWK)
C
C------------------------------------------------------------------------------
C
C ENTRY APXGGC:
C Obtain grid coordinates from tables read back using APXRDA.
C
C CALL APXGGC (MSGUN, WK,LWK, GPLAT,GPLON,GPALT,NLAT,NLON,NALT,
C + IST)
C
C INPUTS:
C MSGUN = Fortran unit number to write diagnostic messages.
C WK,LWK = Same as APXMKA
C
C RETURNS:
C GPLAT,GPLON,GPALT = Grid point latitudes, longitudes, and
C altitudes. Units are degrees and kilometers.
C NLAT,NLON,NALT = Number of latitudes, longitudes and altitudes.
C IST = Return status, where IST=0 implies okay.
C
C Declarations for APXGGC formal arguments:
C DIMENSION GPLAT(NLAT), GPLON(NLON), GPALT(NALT), WK(LWK)
C
C
C------------------------------------------------------------------------------
C
C
C ENTRY APXALL:
C Determine Apex coordinates by interpolation from precalculated
C arrays. First call APXMKA, APXWRA, or APXRDA to load look-up
C tables in memory.
C
C CALL APXALL (GLAT,GLON,ALT, WK, A,ALAT,ALON, IST)
C
C INPUTS:
C GLAT = Geographic (geodetic) latitude, degrees, must be within
C the grid domain (GPLAT(1) <= GLAT <= GPLAT(NLAT)).
C GLON = Geographic (geodetic) longitude, degrees, must be within
C one revolution of the grid domain:
C GPLON(1) <= GLON-360.,GLON, or GLON+360. <= GPLON(NLON))
C ALT = Altitude, km
C WK = same as entry APXMKA
C RETURNS:
C A = Apex radius, normalized by Req
C ALAT = Apex latitude, degrees
C ALON = Apex longitude, degrees
C IST = Return status: okay (0); or failure (1).
C
C Dimensions of non-scalar arguments to APXALL:
C WK(LWK)
C
C
C------------------------------------------------------------------------------
C
C ENTRY APXMALL:
C Compute Modified Apex coordinates, quasi-dipole coordinates,
C base vectors and other parameters by interpolation from
C precalculated arrays. First call APXMKA, APXWRA, or APXRDA
C to load look-up tables in memory.
C
C CALL APXMALL (GLAT,GLON,ALT,HR, WK,
C + B,BHAT,BMAG,SI,
C + ALON,
C + XLATM,VMP,W,D,BE3,SIM,D1,D2,D3,E1,E2,E3,
C + XLATQD,F,F1,F2 , IST)
C
C Reference: Richmond, A. D., Ionospheric Electrodynamics Using
C Magnetic Apex Coordinates, J. Geomag. Geoelectr., 47, 191-212, 1995.
C
C INPUTS:
C GLAT = Geographic (geodetic) latitude, degrees, must be within
C the grid domain (GPLAT(1) <= GLAT <= GPLAT(NLAT)).
C GLON = Geographic (geodetic) longitude, degrees, must be within
C one revolution of the grid domain:
C GPLON(1) <= GLON-360.,GLON, or GLON+360. <= GPLON(NLON))
C ALT = Altitude, km
C HR = Reference altitude, km (used only for Modified Apex coords)
C WK = same as entry APXMKA
C RETURNS:
C B = magnetic field components (east, north, up), in nT
C BHAT = components (east, north, up) of unit vector along
C geomagnetic field direction
C BMAG = magnitude of magnetic field, in nT
C SI = sin(I)
C ALON = apex longitude = modified apex longitude = quasi-dipole
C longitude, degrees
C XLATM = Modified Apex latitude, degrees
C VMP = magnetic potential, in T.m
C W = W of reference above, in km**2 /nT (i.e., 10**15 m**2 /T)
C D = D of reference above
C BE3 = B_e3 of reference above (= Bmag/D), in nT
C SIM = sin(I_m) described in reference above
C D1,D2,D3,E1,E2,E3 = components (east, north, up) of base vectors
C described in reference above
C XLATQD = quasi-dipole latitude, degrees
C F = F described in reference above for quasi-dipole
C coordinates
C F1,F2 = components (east, north) of base vectors described in
C reference above for quasi-dipole coordinates
C IST = Return status: okay (0); or failure (1).
C
C Dimensions of non-scalar arguments to APXMALL:
C GPLAT(NLAT),GPLON(NLON),GPALT(NALT),WK(LWK),
C B(3),BHAT(3),D1(3),D2(3),D3(3), E1(3),E2(3),E3(3), F1(2),F2(2)
C
C
C------------------------------------------------------------------------------
C
C ENTRY APXQ2G:
C Convert from quasi-dipole to geodetic coordinates, APXQ2G
C (input magnetic, output geodetic) is the functional inverse
C of APXALL or APXMALL (input geodetic, output magnetic). First
C call APXMKA, APXWRA, or APXRDA to load look-up tables in memory.
C
C CALL APXQ2G (QDLAT,QDLON,ALT, WK, GDLAT,GDLON, IST)
C
C INPUTS:
C QDLAT = quasi-dipole latitude in degrees
C QDLON = quasi-dipole longitude in degrees
C ALT = altitude in km
C WK = same as entry APXMKA
C RETURNS:
C GDLAT = geodetic latitude in degrees
C GDLON = geodetic longitude in degrees
C IST = Return status: = 0 okay
C = -1 non-fatal, results are not as
C close as PRECISE
C > 0 failure
C
C Dimensions of non-scalar arguments to APXQ2G:
C WK(LWK)
C
C
C------------------------------------------------------------------------------
C
C EXTERNALS:
C apex.f - APEX, etc. source code
C magfld.f - COFRM, DYPOL, FELDG are the DGRF/IGRF.
C magloctm.f, subsol.f and cossza.f - are not externals, but they
C are related, computing magnetic local time, the sub-
C solar point, and the cosine of the solar zenith angle.
C test.f - also not an external, rather it is an example driver
C program demonstrating various call sequences. It
C includes subroutine GGRID.
C
C INSTALLATION SPECIFICS:
C The only (known) machine dependency is parameter IRLF described
C below.
C Compiler default is usually to initialize memory to 0. If this
C is not true, an error trap involving KGMA may not work.
C
C HISTORY:
C Originally coded 940824 by A. D. Richmond, NCAR. Components of
C routines in the package came from previous work by Vincent
C Wickwar (COFRM, FELDG in magfld.f).
C
C Modified Sep 95 (Roy Barnes): Changes were made with the
C objective to allow the user to completely control definition of
C the interpolation grid. While doing this the order of the
C ENTRYs in the first subroutine and arguments lists were
C changed: APXMKA, APXWRA, APXRDA (formerly GETARR) and the other
C ENTRYs now include a work array (WK) which holds arrays X,Y,Z,V,
C GPLAT,GPLON and GPALT. Subroutine SETLIM was removed and the
C grid creation algorithm based on NVERT originally integral to
C GETARR and SETLIM has been extracted, but still available as
C an example (see GGRID in file test.f). Subroutine TSTDIM has a
C different role, so it is now CKGP (check grid points).
C MAKEXYZV was also changed to accomodate explicit grid point
C arrays instead of computed values from an index, minimum and
C delta. Only one format is written now, so that is is possible
C to concatinate files for different epochs. This required
C changing delta time logic from fixed 5 yr epochs to computed
C differences which may vary. Also, the ties to DGRF/IGRF dates
C have been removed.
C
C Modified Sep 96 (Roy Barnes): Corrected bug in APXQ2G longitude
C iteration. The latitude iteration is now constrained to not
C step beyond the (partial global) interpolation grid. NITER was
C increased from 9 to 14 and code to determine cos(lambda') (CLP)
C was revised by Art Richmond to reduce truncation errors near
C the geographic poles.
C
C Modified Sep 97: Corrected comments, definition of COLAT.
C
C Modified Dec 98: Change GLON input to try +/-360 values
C before rejecting when out of defined grid (GDLON) range;
C affects INTRP
C
C Modified Feb-Mar 99: (1) Corrected a typo (bad variable name)
C in diagnostic print in INTRP: GLO -> GLON. This error was
C probably introduced Dec 98, so no-one had access to the
C bad copy and, therefore, no announcement is needed. (2) Also
C modified APXMALL and APXQ2G: When very close to a geographic
C pole, gradients are recalculated after stepping away; in this
C situation, the latitude input to INTRP was changed from GLAT
C to GLATX. This is affects gradients when within 0.1 degrees
C of a pole (defined as the larger of GLATLIM, 89.9 deg, or the
C second largest grid point). (3) Changed MAKEXYZV to make X,Y,Z,
C V constant for all longitudes (at each alt) when poleward of
C POLA; POLA was added to /APXCON/. (4) Replaced definition of
C DYLON in APXQ2G. (5) Reduced NITER to 10 from 14. Changes 3-5
C fix a problem where APXQ2G calculations were failing to satisify
C PRECISE within NITER iterations at the pole. (6) Replace
C XYZ2APX with revised trigonometry to avoid a truncation problem
C at the magnetic equator. Most changes were devised by Art
C Richmond and installed by Roy B.
C
C May 2000: Relaxed acceptable input longitude check in CKGP
C to be +/- 270 degrees. Also updated IGRF coefficients in
C magfld.f; now DGRF epochs are 1900, 1905, ... 1995 and IGRF
C is for 2000-2005.
C
C Questions about this version should be directed to Roy Barnes
C NCAR (email: bozo@ucar.edu phone: 303/497-1230).
C
C------------------------------------------------------------------------------
PARAMETER (XMISS=-32767. , GLATLIM=89.9 , PRECISE=7.6E-11,
+ DATDMX=1. , DATIMX=2.5 , IRLF=4 )
C XMISS = value used to fill returned variables when requested
C point is outside array boundaries
C GLATLIM = Extreme polar latitude allowed before changing east-west
C gradient calculation to avoid possible underflow at
C poles. GLATLIM is superseded when the second to last
C grid point value is closer to a pole.
C PRECISE = (angular distance)**2 (radians**2) of precision of
C transform from quasi-dipole to geodetic coordinates.
C 7.6E-11 corresponds to an accuracy of 0.0005 degree.
C IRLF = Record length factor required to convert the computed
C length of direct access records from words to those
C units appropriate to this computer. IRLF is 1 when
C RECL units are words, otherwise it is a function of
C the computer word length; e.g.,
C IRLF = 1 on a DEC (32-bit words, RECL units are words)
C IRLF = 4 on a PC (32-bit words, RECL units are bytes)
C IRLF = 4 on a Sun (32-bit words, RECL units are bytes)
C IRLF = 8 on a Cray (64-bit words, RECL units are bytes)
C DATDMX = maximum time difference (years) allowed between the
C requested date and the single epoch in arrays.
C DATIMX = maximum time difference (years) allowed between the
C requested date and the closest epoch in the stored
C arrays (apropos multiple stored dates).
C Formal argument declarations
DIMENSION GPLAT(*),GPLON(*),GPALT(*), EPOCH(*), WK(*),
+ GRADX(3), GRADY(3), GRADZ(3), GRADV(3),
+ GRCLM(3), CLMGRP(3), RGRLP(3),
+ B(3),BHAT(3), D1(3),D2(3),D3(3), E1(3),E2(3),E3(3),
+ F1(2),F2(2)
CHARACTER*(*) FILNAM
C Local declarations
CHARACTER CALNM*7, CMP*10, EDG*5
SAVE KGMA, GLALMN,GLALMX, NLA,NLO,NAL, LBX,LBY,LBZ,LBV,LLA,LLO,LAL
DATA KGMA /0/
C Common APXDIPL is assigned in MAKEXYZV but computed in DYPOL
C COLAT = geocentric colatitude (degrees) of north geomagnetic pole
C ELON = geocentric east longitude (degrees) of north geomagnetic
C pole
C VP = magnetic potential at 1 RE, south geomagnetic pole
C CTP = cos(colat*dtor)
C STP = sin(colat*dtor)
COMMON /APXDIPL/ COLAT,ELON,VP,CTP,STP
C Common APXCON is assigned here
C RTOD, DTOR = radians to degrees (180/pi) and inverse
C RE, REQ = 6371.2, 6378.160 (Mean and equatorial Earth radius)
C MSGU = MSGUN to be passed to subroutines
C POLA = Pole angle (deg); when the geographic latitude is
C poleward of POLA, X,Y,Z,V are forced to be constant.
C for all longitudes at each altitude
COMMON /APXCON/ RTOD,DTOR,RE,REQ,MSGU,POLA
CALNM = 'APXMKA'
LCN = 6
KGMA = 1
MSGU = MSGUN
NEPOK = 1
IF (NLAT .LT. 2 .OR. NLON .LT. 2 .OR. NALT .LT. 2) GO TO 9100
NLA = NLAT
NLO = NLON
NAL = NALT
GO TO 40
ENTRY APXGGC (MSGUN,WK,LWK, GPLAT,GPLON,GPALT,NLAR,NLOR,NALR,IST)
C Sep 95 R. Barnes
CALNM = 'APXGGC'
LCN = 6
MSGU = MSGUN
IF (KGMA .LT. 1) GO TO 9300
J = LLA
DO 10 I=1,NLA
GPLAT(I) = WK(J)
10 J = J + 1
DO 20 I=1,NLO
GPLON(I) = WK(J)
20 J = J + 1
DO 30 I=1,NAL
GPALT(I) = WK(J)
30 J = J + 1
NLAR = NLA
NLOR = NLO
NALR = NAL
IST = 0
RETURN
ENTRY APXWRA (MSGUN, FILNAM,IUN, EPOCH,NEPOCH,
+ GPLAT,GPLON,GPALT,NLAT,NLON,NALT, WK,LWK, IST)
C Sep 95 R. Barnes
CALNM = 'APXWRA'
LCN = 6
KGMA = 2
MSGU = MSGUN
NEPOK = NEPOCH
IF (NLAT .LT. 2 .OR. NLON .LT. 2 .OR. NALT .LT. 2) GO TO 9100
NLA = NLAT
NLO = NLON
NAL = NALT
GO TO 40
ENTRY APXRDA (MSGUN, FILNAM,IUN, DATE, WK,LWK, IST)
C Sep 95 R. Barnes
CALNM = 'APXRDA'
LCN = 6
KGMA = 3
C Open the read-back file with a temporary record length, get
C the grid dimensions from the first values, then close it, (so
C it can be reopened later with the proper LDR):
LDR = 7*IRLF
OPEN (IUN,FILE=FILNAM,ACCESS='direct',RECL=LDR,STATUS='old',
+ IOSTAT=IST)
MSGU = MSGUN
IF (IST .NE. 0) GO TO 9110
READ (IUN,REC=1,IOSTAT=IST) YEAR,COLAT,ELON,VP,NLA,NLO,NAL
IF (IST .NE. 0) GO TO 9120
CLOSE (IUN)
40 RE = 6371.2
REQ = 6378.160
RTOD = 45./ATAN(1.)
DTOR = 1./RTOD
POLA = 90. - SQRT (PRECISE) * RTOD
LFN = 0
IF (KGMA .EQ. 1) GO TO 51
DO 50 I=1,LEN(FILNAM)
IF (FILNAM(I:I) .EQ. ' ') GO TO 51
50 LFN = LFN + 1
51 CONTINUE
C Save grid dimensions, establish direct access rec length, and
C determine indices into the work array. WK contains arrays
C X,Y,Z,V,temp,GPLAT,GPLON,GPALT where X thru tmp are dimensioned
C (NLAT,NLON,NALT); tmp is scratch space used during read back.
NGP = NLA*NLO*NAL
NGM1= NGP - 1
LDR = NGP * IRLF
LBX = 1
LBY = LBX + NGP
LBZ = LBY + NGP
LBV = LBZ + NGP
LBT = LBV + NGP
LLA = LBT + NGP
LLO = LLA + NLA
LAL = LLO + NLO
LEG = LAL + NAL-1
IF (LWK .LT. LEG) GO TO 9130
IF (KGMA .EQ. 3) GO TO 200
C Make and optionally write interpolation arrays for NEPOK times
IF (KGMA .EQ. 2) THEN
OPEN (IUN,FILE=FILNAM,ACCESS='direct',RECL=LDR,STATUS='new',
+ IOSTAT=IST)
IF (IST .NE. 0) GO TO 9115
ENDIF
CALL CKGP (CALNM(:LCN),MSGUN,NLAT,NLON,NALT,GPLAT,GPLON,GPALT,IST)
IF (IST .NE. 0) RETURN
I = LLA - 1
DO 60 J=1,NLAT
I = I + 1
60 WK(I) = GPLAT(J)
DO 70 J=1,NLON
I = I + 1
70 WK(I) = GPLON(J)
DO 80 J=1,NALT
I = I + 1
80 WK(I) = GPALT(J)
IF (NEPOK .LT. 1) GO TO 9140
J = 1
DO 100 I=1,NEPOK
CALL MAKEXYZV (EPOCH(I),NLAT,NLON,NALT,GPLAT,GPLON,GPALT,
+ WK(LBX),WK(LBY),WK(LBZ),WK(LBV))
IF (KGMA .EQ. 1) GO TO 100
WRITE (IUN,REC=J) EPOCH(I),COLAT,ELON,VP,NLAT,NLON,NALT
WRITE (IUN,REC=J+1) (WK(K),K=LLA,LEG)
WRITE (IUN,REC=J+2) (WK(K),K=LBX,LBX+NGM1)
WRITE (IUN,REC=J+3) (WK(K),K=LBY,LBY+NGM1)
WRITE (IUN,REC=J+4) (WK(K),K=LBZ,LBZ+NGM1)
WRITE (IUN,REC=J+5) (WK(K),K=LBV,LBV+NGM1)
100 J = J + 6
IF (KGMA .EQ. 2) CLOSE (IUN)
IST = 0
GO TO 300
C Read back interpolation arrays. When arrays for multiple times
C are available, interpolate using the pair bounding the desired
C time (DATE). Make an initial pass only to identify closest
C available times and issue any diagnostics, then the second pass
C to read the stored arrays (GPLAT,GPLON,GPALT,X,Y,Z,V) and do
C the linear interpolation/extrapolation.
200 OPEN (IUN,FILE=FILNAM,ACCESS='direct',RECL=LDR,STATUS='old',
+ IOSTAT=IST)
IF (IST .NE. 0) GO TO 9110
READ (IUN,REC=1,IOSTAT=IST) TB
IF (IST .NE. 0) GO TO 9120
I2 = 1
TL = TB
IL = 1
I = 1
210 I = I + 6
READ (IUN,REC=I,IOSTAT=JST) T
C JST .NE. 0 is assumed to mean read beyond last record
IF (JST .NE. 0) GO TO 220
TO = TL
TL = T
IL = I
IF (DATE .GT. TL) GO TO 210
220 I1 = IL - 6
IST = 0
IF (TL .EQ. TB) THEN
DATD = ABS (DATE-TB)
IF (DATD .GT. DATDMX) THEN
WRITE (MSGU,9150) CALNM(1:LCN),DATE,DATD,TB
IF (TB .EQ. 0.) WRITE (MSGU,9155) FILNAM(1:LFN)
IST = -1
ENDIF
I1 = 1
I2 = 0
ELSE IF (DATE .LT. TB) THEN
WRITE (MSGU,9160) CALNM(1:LCN),DATE,TB,FILNAM(1:LFN)
IST = -1
ELSE IF (DATE .GT. TL) THEN
WRITE (MSGU,9170) CALNM(1:LCN),DATE,TL,FILNAM(1:LFN)
IST = -1
ELSE
DATD = AMIN1 (DATE-TO,TL-DATE)
IF (DATD .GT. DATIMX) THEN
WRITE (MSGU,9180) CALNM(1:LCN),DATE,TB,TL,FILNAM(1:LFN),DATD
IST = -1
ENDIF
ENDIF
READ (IUN,REC=I1) YEAR1,COLAT,ELON,VP,NLAI,NLOI,NALI
TI = YEAR1
IF (NLAI.NE.NLA .OR. NLOI.NE.NLO .OR. NALI.NE.NAL) GO TO 9190
READ (IUN,REC=I1+1) (WK(I),I=LLA,LEG)
READ (IUN,REC=I1+2) (WK(I),I=LBX,LBX+NGM1)
READ (IUN,REC=I1+3) (WK(I),I=LBY,LBY+NGM1)
READ (IUN,REC=I1+4) (WK(I),I=LBZ,LBZ+NGM1)
READ (IUN,REC=I1+5) (WK(I),I=LBV,LBV+NGM1)
IF (I2 .EQ. 1) THEN
READ (IUN,REC=I1+6) YEAR2,COLA2,ELON2,VP2,NLAI,NLOI,NALI
TI = YEAR2
IF (NLAI.NE.NLA .OR. NLOI.NE.NLO .OR. NALI.NE.NAL) GO TO 9190
LE = LBT + NLA+NLO+NAL - 1
READ (IUN,REC=I1+7) (WK(I),I=LBT,LE)
J = LLA
DO 230 I=LBT,LE
IF (WK(J) .NE. WK(I)) GO TO 9200
230 J = J + 1
FRAC = (DATE-YEAR1) / (YEAR2-YEAR1)
OMF = 1. - FRAC
LE = LBT + NGM1
READ (IUN,REC=I1+8) (WK(I),I=LBT,LE)
J = LBX
DO 240 I=LBT,LE
WK(J) = OMF*WK(J) + FRAC*WK(I)
240 J = J + 1
READ (IUN,REC=I1+9) (WK(I),I=LBT,LE)
DO 250 I=LBT,LE
WK(J) = OMF*WK(J) + FRAC*WK(I)
250 J = J + 1
READ (IUN,REC=I1+10) (WK(I),I=LBT,LE)
DO 260 I=LBT,LE
WK(J) = OMF*WK(J) + FRAC*WK(I)
260 J = J + 1
READ (IUN,REC=I1+11) (WK(I),I=LBT,LE)
DO 270 I=LBT,LE
WK(J) = OMF*WK(J) + FRAC*WK(I)
270 J = J + 1
COLAT = OMF*COLAT + FRAC*COLA2
ELON = OMF*ELON + FRAC*ELON2
VP = OMF*VP + FRAC*VP2
ENDIF
CTP = COS (COLAT*DTOR)
STP = SIN (COLAT*DTOR)
YEAR = DATE
CLOSE (IUN)
C Establish for this grid polar latitude limits beyond which east-west
C gradients are computed differently to avoid potential underflow
300 GLALMX = AMAX1 ( GLATLIM,WK(LLA+NLA-2))
GLALMN = AMIN1 (-GLATLIM,WK(LLA+1))
RETURN
C*******************************************************************************
ENTRY APXMALL (GLAT,GLO ,ALT,HR, WK, !Inputs
+ B,BHAT,BMAG,SI, !Mag Fld
+ ALON, !Apx Lon
+ XLATM,VMP,W,D,BE3,SIM,D1,D2,D3,E1,E2,E3, !Mod Apx
+ XLATQD,F,F1,F2 , IST) !Qsi-Dpl
C 940822 A. D. Richmond, Sep 95 R. Barnes
C Test to see if WK has been initialized
CALNM = 'APXMALL'
LCN = 7
IF (KGMA .LT. 1) GO TO 9300
C Alias geodetic longitude input in case INTRP adjusts it by +/-360
GLON = GLO
CALL INTRP (GLAT,GLON,ALT, WK(LBX),WK(LBY),WK(LBZ),WK(LBV),
+ NLA,NLO,NAL, WK(LLA),WK(LLO),WK(LAL),
+ FX,FY,FZ,FV,
+ DFXDTH,DFYDTH,DFZDTH,DFVDTH,DFXDLN,DFYDLN,DFZDLN,
+ DFVDLN,DFXDH,DFYDH,DFZDH,DFVDH, CALNM(1:LCN),IST)
IF (IST .NE. 0) THEN
CALL SETMISS (XMISS, XLATM,ALON,VMP,B,BMAG,BE3,SIM,SI,F,D,W,
+ BHAT,D1,D2,D3,E1,E2,E3,F1,F2)
RETURN
ENDIF
CALL ADPL (GLAT,GLON,CTH,STH,FX,FY,FZ,FV,
+ DFXDTH,DFYDTH,DFZDTH,DFVDTH,DFXDLN,DFYDLN,DFZDLN,DFVDLN)
CALL GRADXYZV (ALT,CTH,STH,
+ DFXDTH,DFYDTH,DFZDTH,DFVDTH,DFXDLN,DFYDLN,DFZDLN,DFVDLN,
+ DFXDH,DFYDH,DFZDH,DFVDH,GRADX,GRADY,GRADZ,GRADV)
IF (GLAT .GT. GLALMX .OR. GLAT .LT. GLALMN) THEN
C If the point is very close to either the North or South
C geographic pole, recompute the east-west gradients after
C stepping a small distance from the pole.
GLATX = GLALMX
IF (GLAT .LT. 0.) GLATX = GLALMN
C990225 CALL INTRP (GLAT ,GLON,ALT, WK(LBX),WK(LBY),WK(LBZ),WK(LBV),
CALL INTRP (GLATX,GLON,ALT, WK(LBX),WK(LBY),WK(LBZ),WK(LBV),
+ NLA,NLO,NAL, WK(LLA),WK(LLO),WK(LAL),
+ FXDUM,FYDUM,FZDUM,FVDUM,
+ DMXDTH,DMYDTH,DMZDTH,DMVDTH,DFXDLN,DFYDLN,DFZDLN,
+ DFVDLN,DMXDH,DMYDH,DMZDH,DMVDH, CALNM(1:LCN),IST)
CALL ADPL (GLATX,GLON,CTH,STH,FXDUM,FYDUM,FZDUM,FVDUM, DMXDTH,
+ DMYDTH,DMZDTH,DMVDTH,DFXDLN,DFYDLN,DFZDLN,DFVDLN)
CALL GRAPXYZV (ALT,CTH,STH, DFXDLN,
+ DFYDLN,DFZDLN,DFVDLN,GRADX,GRADY,GRADZ,GRADV)
ENDIF
CALL GRADLPV (HR,ALT,FX,FY,FZ,FV,GRADX,GRADY,GRADZ,GRADV,
+ XLATM,ALON,VMP,GRCLM,CLMGRP,XLATQD,RGRLP,B,CLM,R3_2)
CALL BASVEC (HR,XLATM,GRCLM,CLMGRP,RGRLP,B,CLM,R3_2,
+ BMAG,SIM,SI,F,D,W,BHAT,D1,D2,D3,E1,E2,E3,F1,F2)
BE3 = BMAG/D
IST = 0
RETURN
C*******************************************************************************
ENTRY APXALL (GLAT,GLO ,ALT, WK, A,ALAT,ALON, IST)
C 940802 A. D. Richmond, Sep 95 R. Barnes
C Test to see if WK has been initialized
CALNM = 'APXALL'
LCN = 6
IF (KGMA .LT. 1) GO TO 9300
C Alias geodetic longitude input in case INTRPSC adjusts it by +/-360
GLON = GLO
CALL INTRPSC (GLAT,GLON,ALT, WK(LBX),WK(LBY),WK(LBZ),
+ NLA,NLO,NAL, WK(LLA),WK(LLO),WK(LAL),
+ FX,FY,FZ, CALNM(1:LCN), IST)
IF (IST .NE. 0) GO TO 600
CALL ADPLSC (GLAT,GLON,FX,FY,FZ)
CALL XYZ2APX (ALT,FX,FY,FZ,A,ALAT,ALON,IST)
IF (IST .EQ. 0) GO TO 601
600 A = XMISS
ALAT = XMISS
ALON = XMISS
601 CONTINUE
RETURN
C*******************************************************************************
ENTRY APXQ2G (QDLAT,QDLON,ALT, WK, GDLAT,GDLON, IST)
C 940819 A. D. Richmond, Sep 95 R. Barnes, Sep 96 mod A. D. Richmond
C Input guessed geodetic coordinates (YLAT,YLON) to INTRP and
C compare the returned magnetic coordinates to those desired.
C If the guess is not sufficiently close (PRECISE), make another
C guess by moving in the direction of the gradient of a quantity
C (DIST2) that approximates the squared angular distance between
C the returned and desired magnetic coordinates.
C Test to see if WK has been initialized
CALNM = 'APXQ2G'
LCN = 6
IF (KGMA .LT. 1) GO TO 9300
C Determine quasi-cartesian coordinates on a unit sphere of the
C desired magnetic lat,lon in quasi-dipole coordinates.
X0 = COS (QDLAT*DTOR) * COS (QDLON*DTOR)
Y0 = COS (QDLAT*DTOR) * SIN (QDLON*DTOR)
Z0 = SIN (QDLAT*DTOR)
C Initial guess: use centered dipole, convert to geocentric coords
CALL GM2GC (QDLAT,QDLON,YLAT,YLON)
C Iterate until (angular distance)**2 (units: radians) is within
C PRECISE of location (QDLAT,QDLON) on a unit sphere.
NITER = 50
DO 1000 ITER=1,NITER
CALL INTRP (YLAT,YLON,ALT, WK(LBX),WK(LBY),WK(LBZ),WK(LBV),
+ NLA,NLO,NAL, WK(LLA),WK(LLO),WK(LAL),
+ FX,FY,FZ,FV,
+ DFXDTH,DFYDTH,DFZDTH,DFVDTH,DFXDLN,DFYDLN,DFZDLN,
+ DFVDLN,DFXDH,DFYDH,DFZDH,DFVDH, CALNM(1:LCN),IST)
IF (IST .NE. 0) GO TO 9400
CALL ADPL (YLAT,YLON,CTH,STH,FX,FY,FZ,FV,
+ DFXDTH,DFYDTH,DFZDTH,DFVDTH,DFXDLN,DFYDLN,DFZDLN,DFVDLN)
DISTLON = COS(YLAT*DTOR)
IF (YLAT .GT. GLALMX .OR. YLAT .LT. GLALMN) THEN
GLATX = GLALMX
IF (YLAT.LT.0.) GLATX = GLALMN
DISTLON = COS (GLATX*DTOR)
C990225 CALL INTRP (YLAT ,YLON,ALT, WK(LBX),WK(LBY),WK(LBZ),WK(LBV),
CALL INTRP (GLATX,YLON,ALT, WK(LBX),WK(LBY),WK(LBZ),WK(LBV),
+ NLA,NLO,NAL, WK(LLA),WK(LLO),WK(LAL),
+ FXDUM,FYDUM,FZDUM,FVDUM,
+ DMXDTH,DMYDTH,DMZDTH,DMVDTH,DFXDLN,DFYDLN,DFZDLN,
+ DFVDLN,DMXDH,DMYDH,DMZDH,DMVDH, CALNM(1:LCN),IST)
CALL ADPL (GLATX,YLON,CTH,STH,FXDUM,FYDUM,FZDUM,FVDUM,
+ DMXDTH,DMYDTH,DMZDTH,DMVDTH,DFXDLN,DFYDLN,DFZDLN,DFVDLN)
ENDIF
C At this point, FX,FY,FZ are approximate quasi-cartesian
C coordinates on a unit sphere for the quasi-dipole coordinates
C corresponding to the geodetic coordinates YLAT, YLON.
C Normalize the vector length of (FX,FY,FZ) to unity using XNORM
C so that the resultant vector can be directly compared with the
C target vector (X0,Y0,Z0).
XNORM = SQRT(FX*FX + FY*FY + FZ*FZ)
XDIF = FX/XNORM - X0
YDIF = FY/XNORM - Y0
ZDIF = FZ/XNORM - Z0
C DIST2 = square of distance between normalized (FX,FY,FZ) and
C X0,Y0,Z0.
DIST2 = XDIF*XDIF + YDIF*YDIF + ZDIF*ZDIF
IF (DIST2 .LE. PRECISE) GO TO 1001
C HGRD2* = one-half of east or north gradient of DIST2 on unit sphere.
HGRD2E = (XDIF*DFXDLN + YDIF*DFYDLN + ZDIF*DFZDLN)/DISTLON
HGRD2N = -(XDIF*DFXDTH + YDIF*DFYDTH + ZDIF*DFZDTH)
HGRD2 = SQRT(HGRD2E*HGRD2E + HGRD2N*HGRD2N)
C ANGDIST = magnitude of angular distance to be moved for new guess
C of YLAT, YLON.
ANGDIST = DIST2/HGRD2
C Following spherical trigonometry moves YLAT, YLON to new location,
C in direction of grad(DIST2), by amount ANGDIST.
CAL = -HGRD2N/HGRD2
SAL = -HGRD2E/HGRD2
COSLM = COS(YLAT*DTOR)
SLM = SIN(YLAT*DTOR)
CAD = COS(ANGDIST)
SAD = SIN(ANGDIST)
SLP = SLM*CAD + COSLM*SAD*CAL
C Old code (below) introduced truncation errors near geographic poles
C SLP = AMIN1 (SLP,SGLAN) ; sglan = sin(wk(lla+nla-1))*dtor)
C SLP = AMAX1 (SLP,SGLAS) ; sglas = sin(wk(lla)) *dtor)
C CLP = SQRT(1. - SLP*SLP)
C YLAT = ASIN(SLP)*RTOD
CLM2 = COSLM*COSLM
SLM2 = SLM*SLM
SAD2 = SAD*SAD
CAL2 = CAL*CAL
CLP2 = CLM2 + SLM2*SAD2 - 2.*SLM*CAD*COSLM*SAD*CAL -CLM2*SAD2*CAL2
CLP = SQRT (AMAX1(0.,CLP2))
YLAT = ATAN2(SLP,CLP)*RTOD
C Restrict latitude iterations to stay within the interpolation grid
C limits, but let INTRP find any longitude exceedence. This is only
C an issue when the interpolation grid does not cover the entire
C magnetic pole region.
YLAT = AMIN1(YLAT,WK(LLA+NLA-1))
YLAT = AMAX1(YLAT,WK(LLA))
DYLON = ATAN2 (SAD*SAL,CAD*COSLM-SAD*SLM*CAL)*RTOD
C Old formula (replaced Mar 99) had truncation problem near poles
C DYLON = ATAN2 (CLP*SAD*SAL,CAD-SLM*SLP)*RTOD
YLON = YLON + DYLON
IF (YLON .GT. WK(LLO+NLO-1)) YLON = YLON - 360.
IF (YLON .LT. WK(LLO) ) YLON = YLON + 360.
1000 CONTINUE
WRITE (MSGU,'(''APXQ2G: Warning'',I3,'' iterations only reduced th
+e angular difference to'',/,8X,F8.5,'' degrees ('',F8.5,'' degrees
+ is the test criterion)'')') NITER, SQRT(DIST2 )*RTOD ,
+ SQRT(PRECISE)*RTOD
EDG = ' '
IF (YLAT .EQ. WK(LLA+NLA-1)) EDG = 'north'
IF (YLAT .EQ. WK(LLA)) EDG = 'south'
IF (EDG .NE. ' ') WRITE (MSGU,'('' Coordinates are on the '
+',A,'' edge of the interpolation grid and'',/,'' latitude i
+s constrained to stay within grid limits when iterating.'')') EDG
IST = -1
GO TO 1010
1001 IST = 0
1010 GDLAT = YLAT
GDLON = YLON
RETURN
C*******************************************************************************
C Error Trap diagnostics
9100 WRITE (MSGU,'(A,'': NLAT,NLON or NALT < 2 '',3I8)')
+ CALNM(1:LCN), NLAT,NLON,NALT
IST = 1
RETURN
9110 WRITE (MSGU,'(A,'': Trouble opening old file "'',A,''"'')')
+ CALNM(1:LCN), FILNAM(1:LFN)
RETURN
9115 WRITE (MSGU,'(A,'': Trouble opening new file "'',A,''"'')')
+ CALNM(1:LCN), FILNAM(1:LFN)
RETURN
9120 WRITE (MSGU,'(A,'': Trouble reading first record of '',A)')
+ CALNM(1:LCN), FILNAM(1:LFN)
RETURN
9130 WRITE (MSGU,'(A,'': LWK is too small; LWK must be at least'',I5,''
+ but LWK ='',I5)') CALNM(1:LCN), LEG, LWK
IST = 1
RETURN
9140 WRITE (MSGU,'(A,'': NEPOCH must be positive; NEPOCH ='',I8)')
+ CALNM(1:LCN), NEPOK
IST = 1
RETURN
9150 FORMAT (A,': DATE (',F7.2,') differs by',F5.2,' years from the sto
+red EPOCH (',F7.2,')')
9155 FORMAT (' A stored date = 0. implies "',A,'" is incorrectly
+ formatted')
9160 FORMAT (A,': DATE (',F7.2,') is extrapolated before first EPOCH ('
+,F7.2,') in "',A,'"')
9170 FORMAT (A,': DATE (',F7.2,') is extrapolated after last EPOCH (',F
+7.2,') in "',A,'"')
9180 FORMAT (A,': DATE (',F7.2,') minimum difference from the nearest s
+tored ',/,' EPOCHs (',F7.2,', ',F7.2,') in "',A,'"',/,'
+ is',F6.2,' years')
9190 WRITE (MSGU,'(A,'': Dimensions (lat,lon,alt) read from "'',A,''" f
+or EPOCH '',F7.2,/,'' (''I5,'','',I5,'','',I5,'') do not ma
+tch ('',I5,'','',I5,'','',I5,'') from the'',/,'' first EPOC
+H read ('',F7.2,'')'')') CALNM(1:LCN), FILNAM(1:LFN), TI ,
+ NLAI,NLOI,NALI, NLA,NLO,NAL, TB
IST = 1
RETURN
9200 CMP = 'latitudes'
LC = 9
I1 = LLA - 1
IT = LBT - 1
N = NLA
IF (I .LT. LLO) GO TO 9201
CMP = 'longitudes'
LC = 10
I1 = I1 + NLA
IT = IT + NLA
N = NLO