C     PROGRAM STAR  
C REVISED BY RODDY IN DECEMBER 1985 TO RUN MORE THAN 1 YEAR AT A TIME   
      INTEGER CORE (20000)  
      INTEGER HY1(6),HY5(6),HY7(6)  
      Character*4 ABC1,ABC2,ABC3,ABC4,ABC5,ABC6,DRCTN,AB4,EST,WST   
      CHARACTER*4 ISTA,LLSTA
      CHARACTER*2 ABK2,AWDX,AWDXX,ABYR,ABMO,AEYR,AEMO,ANHRX2,AFNB,AFNE  
      CHARACTER*1 CH(4),CM(11),NO,IC,IBK,ABK1,ARBCX,STAB,IAPL,IHD   
      CHARACTER*1 HY2(6),HY3(6),HY4(6),HY6(6),HY8(6),HY9(6),INV 
      CHARACTER*3 ERN   
      Character*5 FST   
      Character*8 ADTE(17)  
      Character*80 HREC 
      DIMENSION D(12,31),E(12,31),NC(11)
      DIMENSION WRQ(9,16,6),ISTA(9),LLSTA(7)
      DIMENSION ABC1(20),ABC2(20),ABC3(20),ABC4(20),ABC5(20),ABC6(20)   
      DIMENSION STI(9),WRJ(18),DRCTN(18),IWRS(7),STAB(8),WRS(6),WR(6)   XX  
      DIMENSION           ITAB(36),ISEA(12) 
      DIMENSION IHD(66),IAPL(9) 
      DIMENSION TWRS(7) 
      DIMENSION TMPH(7) 
      DIMENSION IWND(17),IHG(24)
      COMMON IWMOX(5,9,18,7)
      COMMON IWR(9,18,7),IUR,T,IPTR 
      COMMON TT(5)                                                      XX  
      DIMENSION D1(12),D2(12),D3(12),D4(12),D5(12),D6(12),D7(12),D8(12) 
      DIMENSION D9(12),D10(12),D11(12),D12(12),D13(12),D14(12),D15(12)  
      DIMENSION D16(12),D17(12),D18(12),D19(12),D20(12),D21(12),D22(12) 
      DIMENSION D23(12),D24(12),D25(12),D26(12),D27(12),D28(12),D29(12) 
      DIMENSION D30(12),D31(12) 
      DIMENSION E1(12),E2(12),E3(12),E4(12),E5(12),E6(12),E7(12),E8(12) 
      DIMENSION E9(12),E10(12),E11(12),E12(12),E13(12),E14(12),E15(12)  
      DIMENSION E16(12),E17(12),E18(12),E19(12),E20(12),E21(12),E22(12) 
      DIMENSION E23(12),E24(12),E25(12),E26(12),E27(12),E28(12),E29(12) 
      DIMENSION E30(12),E31(12) 
      EQUIVALENCE (D(1,1),D1(1)),(D(1,2),D2(1)),(D(1,3),D3(1)), 
     1(D(1,4),D4(1)),(D(1,5),D5(1)),(D(1,6),D6(1)),(D(1,7),D7(1)),  
     2(D(1,8),D8(1)),(D(1,9),D9(1)),(D(1,10),D10(1)),   
     3(D(1,11),D11(1)),(D(1,12),D12(1)),(D(1,13),D13(1)),   
     4(D(1,14),D14(1)),(D(1,15),D15(1)),(D(1,16),D16(1)),   
     5(D(1,17),D17(1)),(D(1,18),D18(1)),(D(1,19),D19(1)),   
     6(D(1,20),D20(1)),(D(1,21),D21(1)),(D(1,22),D22(1)),   
     7(D(1,23),D23(1)),(D(1,24),D24(1)),(D(1,25),D25(1)),   
     8(D(1,26),D26(1)),(D(1,27),D27(1)),(D(1,28),D28(1)),   
     9(D(1,29),D29(1)),(D(1,30),D30(1)),(D(1,31),D31(1))
      EQUIVALENCE (E(1,1),E1(1)),(E(1,2),E2(1)),(E(1,3),E3(1)), 
     1(E(1,4),E4(1)),(E(1,5),E5(1)),(E(1,6),E6(1)),(E(1,7),E7(1)),  
     2(E(1,8),E8(1)),(E(1,9),E9(1)),(E(1,10),E10(1)),   
     3(E(1,11),E11(1)),(E(1,12),E12(1)),(E(1,13),E13(1)),   
     4(E(1,14),E14(1)),(E(1,15),E15(1)),(E(1,16),E16(1)),   
     5(E(1,17),E17(1)),(E(1,18),E18(1)),(E(1,19),E19(1)),   
     6(E(1,20),E20(1)),(E(1,21),E21(1)),(E(1,22),E22(1)),   
     7(E(1,23),E23(1)),(E(1,24),E24(1)),(E(1,25),E25(1)),   
     8(E(1,26),E26(1)),(E(1,27),E27(1)),(E(1,28),E28(1)),   
     9(E(1,29),E29(1)),(E(1,30),E30(1)),(E(1,31),E31(1))
      OPEN(UNIT=14,TYPE='SDF',MRECL=124,BLOCK=560)  
      OPEN(UNIT=24,TYPE='SDF',MRECL=124,BLOCK=560)  
      OPEN(UNIT=15,TYPE='SDF',MRECL=124)
      OPEN(UNIT=18,TYPE='SDF',MRECL=20) 
      OPEN(UNIT=16,TYPE='SDF',MRECL=20) 
      OPEN(UNIT=28,TYPE='SDF',MRECL=20) 
      OPEN(UNIT=9,TYPE='SDF',MRECL=20)  
      DATA IHG/1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6/ 
      DATA NO/'N'/,IC/'C'/  
      DATA ITAB/1,2,2,3,3,4,4,5,5,5,6,6,7,7,8,8,9,9,9,10,10,11,11,  
     112,12,13,13,13,14,14,15,15,16,16,1,1/ 
      DATA ISEA/1,1,2,2,2,3,3,3,4,4,4,1/
      DATA INV,IBK/'*',' '/ 
      DATA ABK2 /'  '/  
      DATA ABK1 /' '/   
      DATA ARBCX /'-'/  
      DATA AB4 /'    '/,EST/'EAST'/,WST/'WEST'/, ERN /'ERN'/
      DATA STAB /'A','B','C','D','E','F','G','H'/   
      DATA DRCTN /'   N',' NNE','  NE',' ENE','   E',' ESE','  SE', 
     1' SSE','   S',' SSW','  SW',' WSW','   W',' WNW','  NW',' NNW'
     1,' AVG','CALM'/   
      DATA IAPL/'A','B','C','D','E','F','G','H','I'/
      DATA CM/'1','2','3','4','5','6','7','8','9','0','-'/  
      DATA NC/1,2,3,4,5,6,7,8,9,0,10/   
      DATA ADTE/'MO = JAN','MO = FEB','MO = MAR','MO = APR','MO = MAY', XX  
     1          'MO = JUN','MO = JUL','MO = AUG','MO = SEP','MO = OCT', XX  
     2          'MO = NOV','MO = DEC','SEA= DJF','SEA= MAM','SEA= JJA', XX  
     3          'SEA= SON',' ANNUAL '/                                  XX  
      DATA D1/-23.078, -17.357,  -7.932,   4.187,  14.798,  21.930,     001 
     2         23.173,  18.253,   8.618,  -2.830, -14.138, -21.663/     002 
      DATA D2/-22.998, -17.075,  -7.553,   4.573,  15.103,  22.068,     003 
     2         23.110,  18.003,   8.255,  -3.218, -14.460, -21.822/     004 
      DATA D3/-22.912, -16.787,  -7.172,   4.958,  15.403,  22.200,     005 
     2         23.038,  17.750,   7.892,  -3.607, -14.778, -21.973/     006 
      DATA D4/-22.812, -16.495,  -6.788,   5.342,  15.698,  22.327,     007 
     2         22.960,  17.490,   7.525,  -3.993, -15.093, -22.118/     008 
      DATA D5/-22.715, -16.198,  -6.405,   5.725,  15.990,  22.445,     009 
     2         22.877,  17.227,   7.157,  -4.380, -15.403, -22.255/     010 
      DATA D6/-22.605, -15.895,  -6.018,   6.105,  16.278,  22.558,     011 
     2         22.785,  16.957,   6.787,  -4.765, -15.701, -22.385/     012 
      DATA D7/-22.488, -15.588,  -5.632,   6.483,  16.560,  22.665,     013 
     2         22.688,  16.683,   6.415,  -5.152, -16.012, -22.508/     014 
      DATA D8/-22.363, -15.278,  -5.243,   6.860,  16.838,  22.763,     015 
     2         22.583,  16.407,   6.040,  -5.533, -16.308, -22.623/     016 
      DATA D9/-22.232, -14.963,  -4.853,   7.235,  17.112,  22.857,     017 
     2         22.473,  16.123,   5.665,  -5.915, -16.602, -22.732/     018 
      DATAD10/-22.092, -14.643,  -4.463,   7.608,  17.380,  22.943,     019 
     2         22.355,  15.837,   5.288,  -6.297, -16.888, -22.833/     020 
      DATAD11/-21.947, -14.320,  -4.070,   7.978,  17.645,  23.023,     021 
     2         22.232,  15.547,   4.910,  -6.677, -17.172, -22.925/     022 
      DATAD12/-21.792, -13.993,  -3.678,   8.348,  17.903,  23.095,     023 
     2         22.102,  15.252,   4.530,  -7.055, -17.450, -23.012/     024 
      DATAD13/-21.632, -13.662,  -3.285,   8.713,  18.158,  23.162,     025 
     2         21.965,  14.952,   4.148,  -7.430, -17.723, -23.090/     026 
      DATAD14/-21.465, -13.327,  -2.892,   9.078,  18.407,  23.220,     027 
     2         21.823,  14.650,   3.767,  -7.805, -17.990, -23.160/     028 
      DATAD15/-21.290, -12.987,  -2.497,   9.438,  18.650,  23.272,     029 
     2         21.673,  14.342,   3.383,  -8.178, -18.253, -23.222/     030 
      DATAD16/-21.108, -12.645,  -2.102,   9.797,  18.888,  23.318,     031 
     2         21.518,  14.032,   2.992,  -8.548, -18.512, -23.277/     032 
      DATAD17/-20.920, -12.300,  -1.707,  10.153,  19.122,  23.357,     033 
     2         21.358,  13.718,   2.613,  -8.918, -18.763, -23.325/     034 
      DATAD18/-20.725, -11.950,  -1.312,  10.507,  19.350,  23.388,     035 
     2         21.190,  13.400,   2.227,  -9.285, -19.010, -23.365/     036 
      DATAD19/-20.525, -11.598,  -0.917,  10.857,  19.572,  23.413,     037 
     2         21.017,  13.078,   1.840,  -9.648, -19.250, -23.397/     038 
      DATAD20/-20.317, -11.243,  -0.520,  11.203,  19.788,  23.430,     039 
     2         20.838,  12.753,   1.452, -10.012, -19.485, -23.420/     040 
      DATAD21/-20.103, -10.887,  -0.125,  11.548,  19.998,  23.442,     041 
     2         20.653,  12.425,   1.063, -10.372, -19.715, -23.437/     042 
      DATAD22/-19.882, -10.525,   0.270,  11.888,  20.203,  23.445,     043 
     2         20.463,  12.093,   0.675, -10.728, -19.938, -23.445/     044 
      DATAD23/-19.655, -10.162,   0.665,  12.227,  20.403,  23.443,     045 
     2         20.267,  11.760,   0.287, -11.083, -20.155, -23.445/     046 
      DATAD24/-19.423,  -9.797,   1.058,  12.560,  20.597,  23.433,     047 
     2         20.065,  11.422,  -0.103, -11.435, -20.367, -23.437/     048 
      DATAD25/-19.185,  -9.428,   1.453,  12.890,  20.785,  23.417,     049 
     2         19.857,  11.080,  -0.493, -11.783, -20.570, -23.422/     050 
      DATAD26/-18.940,  -9.057,   1.845,  13.218,  20.967,  23.393,     051 
     2         19.643,  10.737,  -0.882, -12.130, -20.770, -23.398/     052 
      DATAD27/-18.690,  -8.683,   2.238,  13.542,  21.143,  23.363,     053 
     2         19.425,  10.390,  -1.272, -12.473, -20.962, -23.368/     054 
      DATAD28/-18.435,  -8.308,   2.630,  13.862,  21.312,  23.325,     055 
     2         19.202,  10.042,  -1.662, -12.813, -21.147, -23.330/     056 
      DATAD29/-18.173,   0.0  ,   3.020,  14.178,  21.477,  23.282,     057 
     2         18.970,   9.688,  -2.052, -13.150, -21.327, -23.283/     058 
      DATAD30/-17.907,   0.0  ,   3.400,  14.490,  21.633,  23.232,     059 
     2         18.738,   9.335,  -2.440, -13.483, -21.498, -23.228/     060 
      DATAD31/-17.635,   0.0  ,   3.800,   0.0  ,  21.785,   0.0  ,     061 
     2         18.498,   8.977,   0.0  , -13.812,   0.0  , -23.167/     062 
      DATA E1/  -0.052,  -0.225,  -0.210,  -0.070,   0.047,   0.041,     063
     2         -0.059,  -0.105,  -0.005,   0.166,   0.272,   0.189/     064 
      DATA E2/ -0.060,  -0.227,  -0.207,  -0.065,   0.049,   0.038,     065 
     2         -0.062,  -0.104,   0.000,   0.172,   0.273,   0.183/     066 
      DATA E3/ -0.068,  -0.229,  -0.204,  -0.060,   0.051,   0.036,     067 
     2         -0.065,  -0.103,   0.005,   0.177,   0.273,   0.176/     068 
      DATA E4/ -0.075,  -0.231,  -0.200,  -0.055,   0.053,   0.033,     069 
     2         -0.068,  -0.102,   0.011,   0.185,   0.273,   0.170/     070 
      DATA E5/ -0.083,  -0.233,  -0.196,  -0.050,   0.055,   0.030,     071 
     2         -0.071,  -0.100,   0.016,   0.187,   0.273,   0.163/     072 
      DATA E6/ -0.091,  -0.234,  -0.193,  -0.046,   0.056,   0.027,     073 
     2         -0.074,  -0.099,   0.022,   0.192,   0.273,   0.156/     074 
      DATA E7/ -0.098,  -0.236,  -0.189,  -0.041,   0.057,   0.024,     075 
     2         -0.078,  -0.097,   0.027,   0.197,   0.272,   0.149/     076 
      DATA E8/ -0.105,  -0.237,  -0.185,  -0.036,   0.059,   0.021,     077 
     2         -0.080,  -0.095,   0.033,   0.202,   0.271,   0.142/     078 
      DATA E9/ -0.112,  -0.237,  -0.181,  -0.031,   0.060,   0.018,     079 
     2         -0.083,  -0.093,   0.038,   0.207,   0.270,   0.135/     080 
      DATA E10/-0.119,  -0.238,  -0.177,  -0.027,   0.060,   0.015,     081 
     2         -0.085,  -0.091,   0.044,   0.211,   0.269,   0.127/     082 
      DATA E11/-0.126,  -0.238,  -0.173,  -0.022,   0.061,   0.012,     083 
     2         -0.088,  -0.089,   0.050,   0.216,   0.267,   0.120/     084 
      DATA E12/-0.133,  -0.238,  -0.168,  -0.018,   0.062,   0.008,     085 
     2         -0.090,  -0.086,   0.056,   0.220,   0.266,   0.112/     086 
      DATA E13/-0.139,  -0.238,  -0.164,  -0.014,   0.062,   0.005,     087 
     2         -0.092,  -0.083,   0.062,   0.224,   0.264,   0.105/     088 
      DATA E14/-0.146,  -0.238,  -0.159,  -0.009,   0.062,   0.001,     089 
     2         -0.094,  -0.080,   0.068,   0.229,   0.261,   0.097/     090 
      DATA E15/-0.152,  -0.237,  -0.155,  -0.005,   0.062,  -0.002,     091 
     2         -0.096,  -0.077,   0.074,   0.232,   0.259,   0.089/     092 
      DATA E16/-0.158,  -0.237,  -0.150,  -0.001,   0.062,  -0.006,     093 
     2         -0.098,  -0.074,   0.079,   0.236,   0.256,   0.081/     094 
      DATA E17/-0.164,  -0.236,  -0.145,   0.003,   0.062,  -0.009,     095 
     2         -0.099,  -0.071,   0.085,   0.240,   0.253,   0.073/     096 
      DATA E18/-0.169,  -0.235,  -0.141,   0.007,   0.062,  -0.013,     097 
     2         -0.101,  -0.067,   0.091,   0.243,   0.250,   0.065/     098 
      DATA E19/-0.175,  -0.233,  -0.136,   0.011,   0.061,  -0.016,     099 
     2         -0.102,  -0.064,   0.097,   0.247,   0.247,   0.057/     100 
      DATA E20/-0.180,  -0.232,  -0.131,   0.015,   0.060,  -0.020,     101 
     2         -0.103,  -0.060,   0.103,   0.250,   0.243,   0.048/     102 
      DATA E21/-0.185,  -0.230,  -0.126,   0.018,   0.060,  -0.024,     103 
     2         -0.104,  -0.056,   0.109,   0.253,   0.239,   0.040/     104 
      DATA E22/-0.190,  -0.228,  -0.121,   0.022,   0.059,  -0.027,     105 
     2         -0.105,  -0.052,   0.115,   0.256,   0.235,   0.032/     106 
      DATA E23/-0.194,  -0.226,  -0.116,   0.025,   0.057,  -0.031,     107 
     2         -0.106,  -0.048,   0.121,   0.258,   0.231,   0.024/     108 
      DATA E24/-0.198,  -0.224,  -0.111,   0.028,   0.056,  -0.034,     109 
     2         -0.106,  -0.043,   0.127,   0.261,   0.226,   0.015/     110 
      DATA E25/-0.202,  -0.221,  -0.106,   0.031,   0.055,  -0.038,     111 
     2         -0.107,  -0.039,   0.133,   0.263,   0.222,   0.007/     112 
      DATA E26/-0.206,  -0.219,  -0.101,   0.034,   0.053,  -0.041,     113 
     2         -0.107,  -0.034,   0.138,   0.265,   0.217,  -0.001/     114 
      DATA E27/-0.210,  -0.216,  -0.096,   0.037,   0.051,  -0.045,     115 
     2         -0.107,  -0.030,   0.144,   0.267,   0.212,  -0.010/     116 
      DATA E28/-0.213,  -0.213,  -0.090,   0.040,   0.050,  -0.048,     117 
     2         -0.107,  -0.025,   0.150,   0.268,   0.206,  -0.018/     118 
      DATA E29/-0.217,   0.0  ,  -0.085,   0.042,   0.048,  -0.052,     119 
     2         -0.107,  -0.020,   0.155,   0.270,   0.201,  -0.026/     120 
      DATA E30/-0.220,   0.0  ,  -0.080,   0.045,   0.046,  -0.055,     121 
     2         -0.106,  -0.015,   0.161,   0.271,   0.195,  -0.034/     122 
      DATA E31/-0.222,   0.0  ,  -0.075,   0.0  ,   0.043,   0.0  ,     123 
     2         -0.106,  -0.010,   0.0  ,   0.272,   0.0  ,  -0.042/     124 
      DATA IWND /0,11,12,22,32,33,34,44,54,55,56,66,76,77,78,88,18/ 
C   
C     FIRST HEADER (COL 1 ONLY) 
C     COL 1       = 0 FOR RUNS BY YEAR WHERE  EACH YEAR SEPARATE
C                 = 1 FOR RUNS WHERE MONTH SORTED TOGETHER FOR ENTIRE POR   
C     HEADER CARD NO 2 (80 CHARACTERS)  
C     COLS   1-8  = ALAT  LATITUDE (3 DEC)  
C            9-16 = ALON  LONGITUDE (3 DEC) 
C            17-22 = ZON   TIME ZONE (1 DEC)
C            23  = IRDN  TYPE OF STAR RUN   
C                   1 = REGULAR STAR WITH 5,6 OR  7 CLASSES 
C                   2 = STABILITY D BROKEN INTO DAY/NIGHT CLASSES   
C            24  = IWE   HEMISPHERE 
C                   1 = WESTERN 
C                   2 = EASTERN 
C            25  = IUR   NUMBER OF STABILITY CLASSES (5,6,7,8)  
C                        NOTE: THIS APPLIES TO DAY/NIGHT ONLY   
C                        IF 5 CLASSES ARE DESIRED PUNCH = 6 
C                        IF 6 CLASSES ARE DESIRED PUNCH = 7 
C                        IF 7 CLASSES ARE DESIRED PUNCH = 8 
C            26  = IFL   TYPE OF INPUT USED 
C                   0 = PUNCHED CARDS DECK 144  READER = 5  
C                   1 = MAGNETIC TAPE DECK FAMILY 14     TAPE = 4   
C                   2 = CARD IMAGE TAPE BLOCKED 10   TAPE = 8   
C            27  = IFOT  TYPE OF OUTPUT 
C                   1 = SEASONAL AND ANNUAL 
C                   2 = MONTHLY AND ANNUAL (SORT INPUT BY STATION MONTH)
C                   3 = ANNUAL  
C            28-32 = ISTNNO  STATION NUMBER 
C            33-34 = IBYR    BEGINNING YEAR 
C            35-36 = IBMO    BEGINNING MONTH
C            37-38 = IEYR    ENDING YEAR
C            39-40 = IEMO    ENDING MONTH   
C            41    = INHRX   NUMBER OF HOURS USED   
C                   0 = 24 HOURS PER DAY
C                   1 = 8 HOURS PER DAY 
C                   2 = SELECT HOUR IN  
C                        COLS 76-77 THRU HOUR IN COLS 79-80 
C                   3 = SELECT HOUR IN  
C                        COLS 76-77 AND HOUR IN COLS 79-80  
C            42-43 = INHRX2  BEGINNING HOUR USED ONLY WHEN COL 41 = 1   
C            44  = ISO  SHOULD A TAPE CONTAINING INDIVIDUAL STABILITY   
C                        OBSERVATIONS BE PREPARED ON TAPE 7 ?   
C                   1 = YES 
C                   2 = NO  
C            45-75 = ISTA STATION NAME AND PERIOD OF RECORD USED
C                       (PRINTED AT TOP OF EACH PAGE IN TABULATION) 
C            76-80 = ISTA  USED ONLY WHEN COL 41 = 2 OR 3   
C                   76-77 = BEGINNING HOUR USED IN THIS TABULATION  
C                     78  = '-' 
C                   79-80 = ENDING HOUR USED IN THIS TABULATION 
C   
  208 FORMAT(I5,4I2,3A1,22X,2I2,13X,A1,T39,A2,A2)   
C     DEFINE FILE 4 (ANSI,FB,495,1980,0)
      READ (5,404,END=700)ISORT 
 404  FORMAT (I1)   
      IF (ISORT.EQ.0)GO TO 408  
      IF (ISORT.EQ.1) GO TO 408 
      WRITE (6,409) 
 409  FORMAT ('0','NO 0 OR 1 HERE') 
      STOP  
 408  IF (ISORT.EQ.0) WRITE (6,410) 
 410  FORMAT (1H1,'ON THIS RUN NO MONTHLY SORTS PERFORMED') 
      IF (ISORT.EQ.1) WRITE (6,411) 
 411  FORMAT (1H1,'ON THIS RUN MONTH SORTS WERE PERFORMED') 
      ISWCH=0   
      IT15=0
 701  ITP=1 
C INITIALIZING ARRAY AND READING REFERENCE DATA 
      READ (5,207,END=702)ALAT,ALON,ZON,IRDN,IWE,IUR,IFL,IFOT,ISTNNO,   
     1IBYR,IBMO,IB1,IEYR,IEMO,IE1,INHRX,INHRX2,ISO,ISTA,LLSTA,  
     2FST,ABYR,ABMO,AEYR,AEMO,ANHRX2,IFNB,IFNE,AFNB,AFNE
207   FORMAT (2F8.3,F6.1,5I1,I5,2I2,T33,I4,2I2,T37,I4,I1,I2,I1,9A4,T50, 
     17A4,T28,A5,4A2,1X,A2,T76,I2,T79,I2,T76,A2,T79,A2) 
      ICUR = IUR
      IF (IRDN.EQ.2) ICUR = ICUR - 1
      IF (INHRX.GT.1) GO TO 705 
      IFNB = 0  
      IFNE = 0  
      GO TO 708 
 700  PRINT*,'HEADER CARD ERROR'
      STOP 11112
705   IF (IFNB.EQ.0.AND.IFNE.EQ.0) GO TO 700
 708  WRITE (6,1)   
1     FORMAT (1H1,'THIS TABULATION WAS PREPARED USING THE FOLLOWING HEAD
     1ER CARD INFORMATION') 
      WRITE (6,2) FST   
2     FORMAT ('0','STATION NUMBER = ',A5)   
      WRITE (6,3) LLSTA 
3     FORMAT ('0','STATION NAME = ',7A4)
      WRITE (6,4) ALAT  
4     FORMAT ('0','LATITUDE = ',F8.3)   
      WRITE (6,5) ALON  
5     FORMAT ('0','LONGITUDE = ',F8.3)  
      WRITE (6,6) ZON   
6     FORMAT ('0','TIME ZONE = ',F8.1)  
      IF (IRDN.EQ.1) WRITE (6,7)
7     FORMAT ('0','THIS IS A REGULAR STAR RUN') 
      IF (IRDN.EQ.2) WRITE (6,8)
8     FORMAT ('0','THIS RUN HAS STAB D BROKEN INTO DAY/NIGHT')  
      IF (IRDN.LT.1.OR.IRDN.GT.2) GO TO 700 
      IF (IWE.EQ.1) WRITE (6,230) WST,ERN   
      IF (IWE.EQ.2) WRITE (6,230) EST,ERN   
230   FORMAT ('0','HEMISPHERE = ',2A4)  
      IF (IWE.LT.1.OR.IWE.GT.2) GO TO 700   
      WRITE (6,231) ICUR
231   FORMAT ('0','NUMBER OF STABILITY CLASSES = ',I1)  
      IF (IUR.LT.5.OR.IUR.GT.8) GO TO 700   
      IF (IUR.LT.6.AND.IRDN.EQ.2) GO TO 700 
      IF (IFL.EQ.0) WRITE (6,232)   
232   FORMAT ('0','INPUT = PUNCHED CARDS DECK 144 READER = 5')  
      IF (IFL.EQ.1) WRITE (6,233)   
233   FORMAT ('0','INPUT = MAGNETIC TAPE DECK FAMILY 14 TAPE =4')   
      IF (IFL.EQ.2) WRITE (6,234)   
234   FORMAT ('0','INPUT = CARD IMAGE BLOCKED 10  TAPE = 8')
      IF (IFL.LT.0.OR.IFL.GT.2) GO TO 700   
      IF (IFOT.EQ.1) WRITE (6,235)  
235   FORMAT ('0','OUTPUT = SEASONAL AND ANNUAL')   
      IF (IFOT.EQ.2) WRITE (6,236)  
236   FORMAT ('0','OUTPUT = MONTHLY AND ANNUAL INPUT MUST BE SORTED IN  
     1STATION-MONTH SEQUENCE')  
      IF (IFOT.EQ.3) WRITE (6,237)  
237   FORMAT ('0','OUTPUT = ANNUAL')
      IF (IFOT.LT.1.OR.IFOT.GT.3) GO TO 700 
      WRITE (6,238) ABYR,ABMO,AEYR,AEMO 
238   FORMAT ('0','PERIOD OF RECORD = ',2A2,2X,2A2) 
      IF (INHRX.EQ.0)  WRITE (6,239)
239   FORMAT ('0','NUMBER OF HOURS USED = 24 OBSERVATIONS PER DAY WHEN  
     1DATA WERE AVAILABLE') 
      IF (INHRX.EQ.1)  WRITE (6,240) ANHRX2 
240   FORMAT ('0','NUMBER OF OBSERVATIONS USED = 8 OBSERVATIONS PER DAY 
     1BEGINNING WITH HOUR ',A2) 
      IF (INHRX.EQ.2) WRITE (6,241) AFNB,AFNE   
241   FORMAT ('0','SELECTED HOURS',A2,' THRU ',A2)  
      IF (INHRX.EQ.3) WRITE (6,242)AFNB,AFNE
242   FORMAT ('0','SELECTED HOURS',A2,' AND ',A2)   
      IF (INHRX.LT.0.OR.INHRX.GT.3) GO TO 700   
      IF (ISO.EQ.1)   WRITE (6,243) 
243   FORMAT ('0','A TAPE CONTAINING INDIVIDUAL STABILITY OBSERVATIONS  
     1WAS PREPARED ON DSREF 7') 
      IF (ISO.EQ.2)   WRITE (6,244) 
244   FORMAT ('0','A TAPE CONTAINING INDIVIDUAL STABILITY OBSERVATIONS  
     1WAS NOT REQUESTED')   
      IF (ISO.LT.1.OR.ISO.GT.2) GO TO 700   
      IF (IFL.EQ.0) GO TO 10
      IF (IFL.EQ.1) GO TO 202   
214   IF (IFL.EQ.1.AND.ISO.EQ.1) GO TO 213  
216   IF (IFL.EQ.2) GO TO 221   
   10 DO 11 IFRMO= 1,5                                                  XX  
      DO 11  ISC = 1,9  
      DO 11 IWD= 1,18                                                   XX  
      DO 11 IWSC= 1,7                                                   XX  
   11 IWMOX(IFRMO,ISC,IWD,IWSC)= 0                                      XX  
      DO 12  ISC = 1,9  
      DO 12 IWD= 1,18                                                   XX  
      DO 12 IWSC= 1,7                                                   XX  
   12 IWR(ISC,IWD,IWSC)=0                                               XX  
      T=0.0 
      IURXX= IUR +1 
      DO 8000 IXX= 1,5                                                  XX  
 8000 TT(IXX)= 0.0                                                      XX  
      IF (IWE.EQ.1) DIFL1 = (ZON-ALON) * 0.066667   
      IF (IWE.EQ.2)  DIFL1 = (ALON-ZON) * 0.066667  
      STH=SIN(ALAT/57.29578)
      CTH=COS(ALAT/57.29578)
      IMID= 0   
      ICBX= 0   
      ICBM= 0   
      IOTX= 0                                                           XX  
      WRITE (6,406)                                                     RODDY   
 406  FORMAT ( ' DID INITIALIZATION')                                   RODDY   
C DEFINING STABILITY CLASS  
 300  IF (IFL.EQ.1) GO TO 3011  
      IF (IFL.EQ.2) GO TO 3200  
C     READ(5,208,END=13) ISTNX,IY,IM,ID,IH,(CH(N),N=1,3),KWD,IWS,CH(4), XX  
C    1AWDX,AWDXX
      GO TO 18  
202   CONTINUE  
      IF (ISWCH.EQ.1) GO TO 270 
C *****THIS IS READ OF TD1440 ONTO FILE 4*****  
 203  IF (ISWCH.EQ.0) GO TO 2033
      ISWCH=0   
      GO TO 271 
 2033 READ (4,206,END=322,ERR=8900)ISTNX,IY,IM,ID,IB,ABC1,ABC2,ABC3,
     1ABC4,ABC5,ABC6
      WRITE (6,601)IY,IM,ID 
 601  FORMAT ( ' READ 4 ',3I2)  
      IF (ISTNX.NE.ISTNNO) GO TO 203
      IF (IB.LT.IB1) GO TO 203  
      IF (IB.LE.IE1) GO TO 271                                          RODDY   
      GO TO 323 
 271  WRITE (24,209) ISTNX,IY,IM,ID,ABC1,ABC2,ABC3,ABC4,ABC5,ABC6   
 209  FORMAT (4X,I5,3I2,6(20A4))
      WRITE (6,451)ISTNX,IY,IM,ID   
 451  FORMAT (' READ 24 ',I5,4I2)   
      GO TO 203 
 322  ENDFILE 24
      REWIND 24 
 703  ID1=24
      IF (IFOT.NE.2) GO TO 214  
      IF (ISORT.NE.1) GO TO 551 
      CALL FSORT ('KEY=(12/2,10/2,14/4),RSZ=495,CORE=20000!',   
     124,24,CORE)   
      WRITE (6,456) 
 456  FORMAT ( ' DID THE SORT AS EXPECTED') 
 551  ID1=24
      REWIND 24 
      GO TO 214 
213   CONTINUE  
      WRITE (6,275)ISWCH                                                RODDY   
 275  FORMAT (  'ISWCH = ',I1)                                          RODDY   
      IF (ISWCH.EQ.1) GO TO 216 
      OPEN(UNIT=7,TYPE='SDF',MRECL=25)  
C     DEFINE FILE 7 (ANSI,FB,100,1000,0)
      REWIND 7  
      GO TO 216 
221   CONTINUE  
      WRITE (6,276)ISWCH                                                RODDY   
 276  FORMAT (  'ISWCH = ',I1)                                          RODDY   
      IF (ISWCH.EQ.1) GO TO 369 
c     DEFINE FILE 8 (ANSI,FB,80,800,0)  
      OPEN(UNIT=8,TYPE='SDF',MRECL=20)  
      REWIND 8  
222   READ (8,223,END=224,ERR=8901)ISTNX,IY,IM,IB,ID,IH,(CH(I),I=1,3),  
     1KWD,IWS,CH(4) 
206   FORMAT (4X,I5,3I2,T10,I4,2X,6(20A4))  
223   FORMAT (I5,2I2,T6,I4,2I2,3A1,22X,2I2,13X,A1)  
      IF (ISTNX.NE.ISTNNO) GO TO 222
      IF (IB.LT.IB1) GO TO 222  
      IF (IB.LE.IE1) GO TO 370  
      GO TO 372 
 370  IF (IT15.EQ.0) GO TO 377  
      GO TO 372 
 377  WRITE (18,225) ISTNX,IY,IM,ID,IH,(CH(I),I=1,3),   
     1KWD,IWS,CH(4) 
225   FORMAT (I5,4I2,3A1,22X,2I2,13X,A1)
      GO TO 222 
224   REWIND 8  
 375  ENDFILE 18
      REWIND 18 
      ID1=18
      IF (IFOT.NE.2) GO TO 10   
      ID1=28
      CALL FSORT ('KEY=(8/6,6/2),RSZ=80,CORE=20000!',18,28,CORE)
      REWIND 28 
      GO TO 10  
 3200 READ(ID1,245,END=38)ISTNX,IY,IM,ID,IH,(CH(I),I=1,3),KWD,IWS,CH(4) 
     1,AWDX,AWDXX,HREC  
245   FORMAT (I5,4I2,3A1,22X,2I2,13X,A1,T39,2A2,T1,A80) 
 18   IF (IM.EQ.2.AND.ID.EQ.29) GO TO 300   
      IF(IM-13)7001,300,300                                             XX  
 7001 IF(ISTNX-ISTNNO)300,8020,300  
 8020 IF(IBYR-IY) 8022,8021,300 
 8021 IF(IBMO-IM) 8022,8022,300 
 8022 IF(IEYR-IY) 300,8023,8003 
 8023 IF(IEMO-IM) 300,8003,8003 
 8003 IFRMO= IM                                                         XX  
      IF (ICBX.EQ.0) ICBM= IM                                           XX  
      IF (AWDXX.EQ.ABK2) GO TO 300  
      IF (IY.LT.55) IWS = (IWS* 0.868931)   
      IF (INHRX.EQ.0) GO TO 405 
      IF (INHRX.EQ.2) GO TO 550 
      IF (INHRX.EQ.3) GO TO 530 
      IHXX = IH 
 401  IF (INHRX2 - IHXX) 402,405,300
 402  IHXX = IHXX - 3   
      GO TO 401 
550   IF (IFNB.GT.IFNE) GO TO 555   
      IF (IH.LT.IFNB.OR.IH.GT.IFNE) GO TO 300   
      GO TO 405 
 530  IF (IH.EQ.IFNB.OR.IH.EQ.IFNE) GO TO 405   
      GO TO 300 
 555  IF (IH.GT.IFNE.AND.IH.LT.IFNB) GO TO 300  
 405  ICBX = 1  
      IF (AWDX.EQ.ABK2) GO TO 300   
      IF (CH(1).EQ.ABK1) GO TO 300  
      IF (CH(2).EQ.ABK1) GO TO 300  
      IF (CH(3).EQ.ABK1) GO TO 300  
      IF (CH(4).EQ.ABK1) GO TO 300  
      IF (IFOT.EQ.2.AND.ICBM.NE.IM) GO TO 41                            XX  
      GO TO 3001                                                        XX  
 3011 IF (ITP.NE.1) GO TO 205   
  204 FORMAT (4X,I5,3I2,6(I2,1X,3A1,4X,I1,A1,I2,A1,27X,A1,37X),T16,         XX  
     16(20A4))  
 3111 READ (24,204,END=14,ERR=8902) ISTNX,IY,IM,ID, 
     &(HY1(I),HY2(I),HY3(I),HY4(I),HY5(I),HY6(I),HY7(I),
     &HY8(I),HY9(I),I=1,6), 
     1ABC1,ABC2,ABC3,ABC4,ABC5,ABC6 
      WRITE (6,451)ISTNX,IY,IM,ID,ID1   
 19   IF (IM.EQ.2.AND.ID.EQ.29) GO TO 3111  
      IF (ISTNNO-ISTNX) 8904,8004,3111  
 8004 IF(IBYR-IY) 8006,8005,3111
 8005 IF(IBMO-IM) 8006,8006,3111
 8006 IF (IEYR.LT.IY.AND.IFOT.EQ.2) GO TO 3111  
      IF (IEYR-IY) 8904,8007,8008   
 8007 IF(IEMO-IM) 3111,8008,8008
 8008 IFRMO = IM
      IF (ICBX.EQ.0) ICBM= IM                                           XX  
      ICBX= 1                                                           XX  
      IF (IFOT.EQ.2.AND.ICBM.NE.IM) GO TO 41                            XX  
 205   IH= HY1(ITP) 
      IF (INHRX.EQ.0) GO TO 425 
      IF (INHRX.EQ.2) GO TO 450 
      IF (INHRX.EQ.3) GO TO 430 
      IHXX = IH 
 421  IF (INHRX2 - IHXX) 422,425,26 
 422  IHXX = IHXX - 3   
      GO TO 421 
 430  IF (IH.EQ.IFNB.OR.IH.EQ.IFNE) GO TO 425   
      GO TO 26  
 450  IF (IFNB.GT.IFNE) GO TO 455   
      IF (IH.LT.IFNB.OR.IH.GT.IFNE) GO TO 26
      GO TO 425 
 455  IF (IH.GT.IFNE.AND.IH.LT.IFNB) GO TO 26   
 425  IF (HY4(ITP).EQ.INV.OR.HY4(ITP).EQ.IBK) GO TO 24  
      CH(1)= HY2(ITP)   
      CH(2)= HY3(ITP)   
      CH(3)= HY4(ITP)   
C     KWD= HY6(ITP) 
      IF (HY6(ITP).EQ.INV.OR.HY6(ITP).EQ.IBK) GO TO 24  
      DO 20 I = 1,9 
      IF (HY6(ITP).NE.  CM(I)) GO TO 20 
      KWD=I 
      GO TO 21  
 20   CONTINUE  
      KWD=0 
 21   KWD= KWD+HY5(ITP)*10  
C     IWS= HY8(ITP) 
      IF (HY8(ITP).EQ.INV.OR.HY8(ITP).EQ.IBK) GO TO 24  
      DO 22 I=1,9   
      IF (HY8(ITP).NE.IAPL(I)) GO TO 22 
      IWS=I 
      GO TO 23  
 22   CONTINUE  
      IWS=0 
 23   IWS= IWS+HY7(ITP)*10  
      IF (HY9(ITP).EQ.IBK) GO TO 24 
      CH(4)= HY9(ITP)   
C   
C  EXTRA CHECK ON 1440 WINDS, CEIL, AND TCA 
C   
      WRITE (6,272)                                                     RODDY   
 272  FORMAT ( ' GOT TO EXTRA CHECK, LN 535')                           RODDY   
      DO 28 NA = 1,17   
      IF (KWD.EQ.IWND(NA)) GO TO 29 
 28   CONTINUE  
      GO TO 24  
 29   IF (CH(1).EQ.CM(11))GO TO 44  
      GO TO 46  
 44   IF (CH(2).EQ.CM(11))GO TO 45  
      GO TO 24  
 45   IF (CH(3).EQ.CM(11))GO TO 48  
      GO TO 24  
 46   DO 48 NA = 1,4
      DO 47 NB = 1,10   
      IF (CH(NA).EQ.CM(NB)) GO TO 48
 47   CONTINUE  
      IF (NA.EQ.4.AND.CH(NA).EQ.CM(11)) GO TO 48
      GO TO 24  
 48   CONTINUE  
C   
C  END OF EXTRA CHECK   
C   
      WRITE (6,273)                                                     RODDY   
 273  FORMAT ( ' GOT TO END EXTRA CHCK')                                RODDY   
      ITP= ITP+1
      IF (ITP.LT.7) GO TO 3001  
      ITP=1 
      GO TO 3001
 24   IWD = 0   
      IWSC = 0  
      ISC = 0   
      IF (ISO.NE.1) GO TO 26
      WRITE (7,246) ISTNX,IY,IM,ID,IH,HREC,IWD,IWSC,ISC 
246   FORMAT (' ',I5,4I2,A80,3I2)   
 26   ITP = ITP+1   
      IF (ITP.LT.55) GO TO 205  
      ITP= 1
      GO TO 3111
 3001 IF(ID-31)302,302,300  
  302 IF(IH-23)303,303,300  
  303 IF (CH(1).EQ.CM(11))GO TO 304 
      GO TO 306 
  304 IF(CH(2).EQ.CM(11))GO TO 305  
      GO TO 300 
  305 IF(CH(3).EQ.CM(11))GO TO 315  
      GO TO 300 
  306 DO314 N=1,4   
      L=1   
  307 IF(CH(N).EQ.CM(L)) GO TO 309  
  308 L=L+1 
      IF (L.EQ.12) GO TO 300
      GOTO307   
  309 GOTO(310,311,312,313),N   
  310 N1=L  
      GOTO314   
  311 N2=L  
      GOTO314   
  312 N3=L  
      GOTO314   
  313 N4=L  
  314 CONTINUE  
      ICH=NC(N1)*100+NC(N2)*10+NC(N3)   
      GOTO319   
  315 ICH=999   
      L=1   
  316 IF(CH(4).EQ.CM(L))GOTO 318
  317 L=L+1 
      IF (L.EQ.12) GO TO 300
      GOTO316   
  318 N4=L  
  319 ICA=NC(N4)
      H=FLOAT(IH)   
      M=1   
      IMID2= 100*IM+ID  
      IF (IMID2-IMID) 30,40,30  
   30 CSH=-(STH*SIN(D(IM,ID)/57.29578))/(CTH*COS(D(IM,ID)/57.29578))
      IMID= IMID2   
      IF (CSH.LE.-1.0) GO TO 500
      IF (CSH.GE.1.0) GO TO 600 
      IF(CSH-0.99999)32,32,31   
 500  TNH = 180.0   
      GO TO 34  
 600  TNH = 0.0 
      GO TO 34  
   31 TNH=90.0  
      GOTO34
   32 TNH=(ATAN(((1.0-CSH*CSH)**0.5)/CSH))*57.29578 
      IF(TNH-0.0)33,34,34   
   33 TNH=180.0+TNH 
   34 SR=11.917-DIFL1-E(IM,ID)-TNH/15.0 
      IF (TNH.EQ.180.0)  SR = -1.0  
      SS=12.083-DIFL1-E(IM,ID)+TNH/15.0 
      DIFL2=12.0-DIFL1-E(IM,ID) 
   40 IF((H-SR)-1.0)83,81,81
   81 IF((SS-H)-1.0)83,82,82
   82 HAS=(ABS(DIFL2-H))*15.0   
      SNA=STH*SIN(D(IM,ID)/57.29578)+CTH*COS(D(IM,ID)/57.29578)*
     1COS(HAS/57.29578) 
      IF(SNA-0.0)83,83,84   
   83 A=9999.0000   
      M=2   
      GOTO72
   84 IF(SNA-0.99999)71,71,70   
   70 A=90.0
      GOTO72
   71 A=(ATAN(SNA/((1.0-SNA*SNA)**0.5)))*57.29578   
   72 IF(ICA-10)86,85,85
   85 IF(ICH-70)134,86,86   
   86 IF(M-1)87,87,122  
   87 IF(60.0-A)91,88,88
   88 IF(35.0-A)92,89,89
   89 IF(15.0-A)93,94,94
   91 ICN=4 
      GOTO100   
   92 ICN=3 
      GOTO100   
   93 ICN=2 
      GOTO100   
   94 ICN=1 
  100 IF(ICA-10)101,106,106 
  101 IF(ICA-5)102,102,103  
  102 IR=ICN
      GOTO107   
  103 IF(ICH-070)104,105,105
  104 IR=ICN-2  
      GOTO107   
  105 IF(ICH-160)106,102,102
  106 IR=ICN-1  
  107 IF(IR-1)108,110,110   
  108 IR=1  
  110 GOTO(121,118,114,111),IR  
  111 IF(IWS-5)131,131,112  
  112 IF(IWS-9)132,132,133  
  114 IF(IWS-1)131,131,115  
  115 IF(IWS-7)132,132,116  
  116 IF(IWS-11)133,133,134 
  118 IF(IWS-3)132,132,119  
  119 IF(IWS-9)133,133,134  
  121 IF(IWS-3)133,133,134  
  122 IF(ICUR-5)123,123,126 
  123 IF(ICA-4)124,124,125  
  124 IF(IWS-10)135,135,134 
  125 IF(IWS-6)135,135,134  
 126  IF (ICA-4) 227,227,129
 227  IF (ICUR-6) 127,127,228   
 228  IF (IWS-3) 137,137,127
  127 IF(IWS-6)136,136,128  
  128 IF(IWS-10)135,135,134 
  129 IF(IWS-3)136,136,130  
  130 IF(IWS-6)135,135,134  
  131 ISC=1 
      GOTO140   
  132 ISC=2 
      GOTO140   
  133 ISC=3 
      GOTO140   
 134  ISC = 4   
      IF (M.EQ.2.AND.IRDN.EQ.2)  ISC = 5
      GOTO140   
 135  ISC = 5   
      IF (IRDN.EQ.2) ISC = 6
      GOTO140   
 136  ISC = 6   
      IF (IRDN.EQ.2) ISC = 7
      GO TO 140 
 137  ISC = 7   
      IF (IRDN.EQ.2) ISC = 8
C DEFINING WIND DIRECTION CLASS 
  140 IF(IY-64)320,340,340  
  320 IF(KWD-0)321,367,321  
321   IF (KWD.EQ.18) GO TO 366  
      WRITE (6,274)                                                     RODDY   
 274  FORMAT ( ' GOT TO WIND DIR CLASS')                                RODDY   
      KW1=KWD/10
      KW2=KWD-KW1*10
      IWD=KW1+KW2-1 
      GO TO 368 
340   IF (IFL.EQ.1) GO TO 320   
      IF (KWD.LE.0) GO TO 367   
      IF (KWD.GE.37) GO TO 300  
      IWD=ITAB(KWD) 
      GO TO 368 
  366 IWD=16
      GOTO368   
  367 IWD=18                                                            XX  
C DEFINING WIND SPEED CLASS AND ACCUMULATING ARRAY VALUES   
 368  IF(IWS-3)151,151,141  
  141 IF(IWS-6)152,152,142  
  142 IF(IWS-10)153,153,143 
  143 IF(IWS-16)154,154,144 
  144 IF(IWS-21)155,155,156 
  151 IWSC=1
      GOTO161   
  152 IWSC=2
      GOTO161   
  153 IWSC=3
      GOTO161   
  154 IWSC=4
      GOTO161   
  155 IWSC=5
      GOTO161   
  156 IWSC=6
  161 IWR(ISC,IWD,IWSC)=IWR(ISC,IWD,IWSC)+1 
      IWR(ISC,17,IWSC)= IWR(ISC,17,IWSC) + IWS                           XX 
      IWR(ISC,IWD,7)= IWR(ISC,IWD,7) + IWS                               XX 
      IWR(ISC,17,7)= IWR(ISC,17,7) + IWS                                 XX 
      T=T+1.0   
      IFRMO=ISEA(IM)
      IWMOX(IFRMO,ISC,IWD,IWSC)=IWMOX(IFRMO,ISC,IWD,IWSC) +1            XX  
      IWMOX(IFRMO,ISC,IWD,7)   = IWMOX(IFRMO,ISC,IWD,7) +IWS            XX  
      IWMOX(IFRMO,ISC,17,IWSC) = IWMOX(IFRMO,ISC,17,IWSC) + IWS         XX  
      IWMOX(IFRMO,ISC,17,7)    = IWMOX(IFRMO,ISC,17,7) +IWS             XX  
      TT(IFRMO) = TT(IFRMO) +1.0                                        XX  
      IFRMO=5                                                           XX  
      IWMOX(IFRMO,ISC,IWD,IWSC)=IWMOX(IFRMO,ISC,IWD,IWSC) +1            XX  
      IWMOX(IFRMO,ISC,IWD,7)   = IWMOX(IFRMO,ISC,IWD,7) +IWS            XX  
      IWMOX(IFRMO,ISC,17,IWSC) = IWMOX(IFRMO,ISC,17,IWSC) + IWS         XX  
      IWMOX(IFRMO,ISC,17,7)    = IWMOX(IFRMO,ISC,17,7) +IWS             XX  
      TT(IFRMO) = TT(IFRMO) +1.0
      IF (ISO.NE.1) GO TO 300   
      WRITE (7,246) ISTNX,IY,IM,ID,IH,HREC,IWD,IWSC,ISC 
      GO TO 300 
C   
 38   REWIND 8  
      GO TO 13  
 39   IF (ISO.EQ.2) GO TO 41
      GO TO 41                                                          XX  
   13 ICBX= 2                                                           XX  
      GO TO 41                                                          XX  
   14 ICBX= 2                                                           XX  
      GO TO 39                                                          XX  
   41 IF(IFOT.EQ.2) IOT= 0                                              XX  
      IF (IFOT.EQ.2) GO TO 5050                                         XX  
      IF(IFOT.EQ.1) IOT= 1                                              XX  
      IF(IFOT.EQ.3) IOT= 5                                              XX  
 8888 DO 8889 ISC= 1,IUR
      DO 8889 IWD= 1,18 
      DO 8889 IWSC= 1,7 
 8889 IWR(ISC,IWD,IWSC)= IWMOX(IOT,ISC,IWD,IWSC)
 5050 DO 9 IWD= 1,18                                                    XX  
    9 WRJ(IWD)= 0.0                                                     XX  
      DO 8090 IWD= 1,18 
      DO 8090 IWSC= 1,7 
 8090 IWR(IURXX,IWD,IWSC)= 0
      DO 8010 ISC= 1,IUR
      DO 8010 IWD= 1,18                                                 XX  
      DO 8010 IWSC= 1,7                                                 XX  
 8010 IWR(IURXX,IWD,IWSC)= IWR(IURXX,IWD,IWSC)+ IWR(ISC,IWD,IWSC)       XX  
      IF (IOT. EQ. 0) IOTX= ICBM                                        XX  
      IF (IOT.NE.0) IOTX=IOT+12 
      DO 60 ISC=1,IURXX 
      WRITE (6,247) ADTE(IOTX),ISTA 
247   FORMAT (1H1,20X,A8,19X,'FREQUENCY DISTRIBUTION',14X,'STATION =',  
     19A4)  
      WRITE (6,248) 
248   FORMAT (////,52X,' SPEED(KTS)')   
      WRITE (6,249) 
249   FORMAT ('0',3X,'DIRECTION',8X,'1 - 3',9X,'4 - 6',8X,'7 - 10',9X,  
     1'11-16',9X,'17-21',4X,'GREATER THAN 21   AVG SP',3X,'TOTAL')  
      STI(ISC)=0.0  
      STJ=0 
      DO51 IWD=1,16 
      DO51 IWSC=1,6 
      STI(ISC)=STI(ISC)+IWR(ISC,IWD,IWSC)   
   51 CONTINUE  
      STI(ISC)=STI(ISC)+IWR(ISC,18,1)                                   XX  
      DO61 IWD=1,16 
      DO61 IWSC=1,2 
      STJ=STJ+IWR(ISC,IWD,IWSC) 
   61 CONTINUE  
      IF (IOT.NE.0) T= TT(IOT)                                          XX  
      DO53 IWD=1,16 
      WRJ(IWD)=IWR(ISC,IWD,1)   
      IWRD=0
      DO52 IWSC=1,6 
      IWRD=IWRD+IWR(ISC,IWD,IWSC)   
   52 CONTINUE  
      TAVG= 0.0                                                         XX  
      ISUM=IWR(ISC,IWD,7)                                               XX  
      SSUM= 0.0 
      SSUM= ISUM* 1.0   
      IF (IWRD.GT.0) TAVG= SSUM/IWRD
      WRITE (6,250)DRCTN(IWD),IWR(ISC,IWD,1),IWR(ISC,IWD,2),IWR(ISC,IWD,
     13),IWR(ISC,IWD,4),IWR(ISC,IWD,5),IWR(ISC,IWD,6),TAVG,IWRD 
250   FORMAT ('0',6X,A4,6(7X,I7),7X,F7.1,I7)
   53 CONTINUE  
      DO 55 IWSC= 1,6   
      IWRS(IWSC)=0  
      TWRS(IWSC)= 0.0                                                   XX  
      DO54 IWD=1,16 
      IWRS(IWSC)=IWRS(IWSC)+IWR(ISC,IWD,IWSC)   
   54 CONTINUE  
      TMPH(IWSC)= IWR(ISC,17,IWSC) * 1.0
      IF(IWRS(IWSC).GT.0) TWRS(IWSC)= TMPH(IWSC)/ IWRS(IWSC)
   55 CONTINUE  
      TWRS(7)= 0.0  
      TMPH(7)= IWR(ISC,IWD,7) * 1.0 
      IF(STI(ISC).GT.0) TWRS(7) = TMPH(7) / STI(ISC)
      WRITE(6,251)DRCTN(17),TWRS(1),TWRS(2),TWRS(3),TWRS(4),TWRS(5),TWRS
     1(6),TWRS(7)   
251   FORMAT ('0',6X,A4,7(7X,F7.1)) 
      WRITE (6,252) IWRS(1),IWRS(2),IWRS(3),IWRS(4),IWRS(5),IWRS(6) 
252   FORMAT ('0',2X,' TOTAL  ',6(7X,I7))   
      IST=STI(ISC)  
      IF (ISC.LT.IURXX) WRITE (6,253) STAB(ISC),IST 
253   FORMAT ('0',' NUMBER OF OCCURRENCES OF ',A1,'  STABILITY = ',I7)  
      IF (ISC.EQ.IURXX) WRITE (6,254) IST   
254   FORMAT ('0',2X,' TOTAL NUMBER OF OBSERVATIONS',2X,I7) 
      IF (ISC.LT.IURXX) WRITE (6,255)STAB(ISC),IWR(ISC,18,1)
255   FORMAT ('0',' NUMBER OF CALMS WITH  ',A1,' STABILITY =',I7)   
      IF (ISC.LT.IURXX.AND.IRDN.EQ.2.AND.ISC.EQ.4)  WRITE (6,256)   
256   FORMAT ('0',33X,'(NEUTRAL / DAY)')
      IF (ISC.LT.IURXX.AND.IRDN.EQ.2.AND.ISC.EQ.5)  WRITE (6,257)   
257   FORMAT ('0',33X,'(NEUTRAL / NIGHT)')  
      IF (ISC.EQ.IURXX) WRITE (6,258) IWR(ISC,18,1) 
258   FORMAT ('0',2X,' TOTAL NUMBER OF CALMS',2X,I7)
      WRITE (6,259) ADTE(IOTX),ISTA 
259   FORMAT (1H1,20X,A8,15X,' RELATIVE FREQUENCY DISTRIBUTION',9X, 
     1'STATION = ',9A4) 
      WRITE (6,248) 
      WRITE (6,260) 
260   FORMAT ('0',3X,'DIRECTION',6X,' 0 - 3',9X,'4 - 6',8X,'7 - 10',7X, 
     1'11 - 16',6X,'17 - 21',3X,'GREATER THAN 21',7X,'TOTAL')   
      WRS(1)=0.0
      DO58 IWD=1,16 
      WRD=WRJ(IWD)/T
      DO56 IWSC=2,6 
      WRD=WRD+FLOAT(IWR(ISC,IWD,IWSC))/T
   56 CONTINUE  
      IF(STJ-0.0)90,90,80   
   80 CLMC=(WRJ(IWD)+IWR(ISC,IWD,2))*IWR(ISC,18,1)/(STJ*T)              XX  
      GOTO99
   90 CLMC=FLOAT(IWR(ISC,18,1))/(16.0*T)
   99 WR(1)=WRJ(IWD)/T+CLMC 
      WRQ(ISC,IWD,1)=WR(1)  
      WRS(1)=WRS(1)+WR(1)   
      DO57 IWSC=2,6 
      WR(IWSC)=FLOAT(IWR(ISC,IWD,IWSC))/T   
      WRQ(ISC,IWD,IWSC)=WR(IWSC)
   57 CONTINUE  
      WRD=WRD+CLMC  
      WRITE (6,261)DRCTN(IWD),WR(1),WR(2),WR(3),WR(4),WR(5),WR(6),WRD   
261   FORMAT ('0',6X,A4,6(6X,F8.6),12X,F8.6)
   58 CONTINUE  
      DO59 IWSC=2,6 
      WRS(IWSC)=0   
      DO59 IWD=1,16 
      WRS(IWSC)=WRS(IWSC)+FLOAT(IWR(ISC,IWD,IWSC))/T
   59 CONTINUE  
      WRITE (6,262) WRS(1),WRS(2),WRS(3),WRS(4),WRS(5),WRS(6)   
262   FORMAT ('0',2X,' TOTAL  ',6(6X,F8.6)) 
      ST=STI(ISC)/T 
      IF (ISC.LT.IURXX) WRITE (6,263) STAB(ISC),ST  
263   FORMAT ('0',2X,' RELATIVE FREQUENCY OF OCCURRENCE OF  ',A1,   
     1'    STABILITY  = ',F8.6) 
      IF (ISC.EQ.IURXX) WRITE (6,264) ST
264   FORMAT ('0',3X,'TOTAL RELATIVE FREQUENCY OF OBSERVATIONS =  ' 
     1,F8.6)
      WRC= IWR(ISC,18,1) / T
      IF (ISC.LT.IURXX) WRITE (6,265) STAB(ISC),WRC 
265   FORMAT ('0','RELATIVE FREQUENCY OF CALMS DISTRIBUTED ABOVE WITH  '
     1,A1,2X,'STABILITY  =  ',F8.6) 
      IF (ISC.LT.IURXX.AND.IRDN.EQ.2.AND.ISC.EQ.4)  WRITE (6,256)   
      IF (ISC.LT.IURXX.AND.IRDN.EQ.2.AND.ISC.EQ.5)  WRITE (6,257)   
      IF (ISC.EQ.IURXX) WRITE (6,266) WRC   
266   FORMAT ('0',3X,'TOTAL RELATIVE FREQUENCY OF CALMS DISTRIBUTED ABOV
     1E =  ',F8.6)  
   60 CONTINUE  
C  THE FINAL OUTPUT IS PUT ONTO CARDS.  
C PAUSE TO PERMIT INSPECTION OF ARRAYS BEFORE PUNCHING CARD DECK
 3014 DO 301 ISC=1,IUR  
      DO 301 IWD=1,16   
 3012 WRITE(9,267)DRCTN(IWD),STAB(ISC),WRQ(ISC,IWD,1),WRQ(ISC,IWD,2),WRQ
     1(ISC,IWD,3),WRQ(ISC,IWD,4),WRQ(ISC,IWD,5),WRQ(ISC,IWD,6),ISTNNO,  
     2IWD,STAB(ISC),IOTX,IBYR,IBMO,IEYR,IEMO
 267  FORMAT (1X,A4,1X,A1,1X,6(F7.5),6X,I5,I2,A1,5I2,7X)
  301 CONTINUE  
      IOT= IOT+1                                                        XX  
      IF (IFOT.EQ.2.AND.ICBX.NE.2) GO TO 15                             XX  
      IF(IFOT.EQ.2.AND.ICBX.EQ.2.AND.IOT.EQ.6) GO TO 17 
      IF (IFOT.EQ.2.AND.ICBX.EQ.2) IOT=5                                XX  
      IF (IOT.LT.6) GO TO 8888  
      GO TO 17  
  15  DO 16  ISC = 1,9  
      DO 16 IWD= 1,18                                                   XX  
      DO 16 IWSC= 1,7                                                   XX  
   16 IWR (ISC,IWD,IWSC)= 0                                             XX  
      ICBX= 0                                                           XX  
      IOT= 0                                                            XX  
      T= 0.0
      IF (IFL.EQ.1) GO TO 8006                                          XX  
      GO TO 8003                                                        XX  
  17  DO 750  I = 1,3   
      WRITE (6,268) 
268   FORMAT (1X,'                ')
 750  CONTINUE  
      ISWCH=1   
      IT15=0
      IF (IFL.EQ.1) REWIND 24   
      WRITE (6,751) 
 751  FORMAT ( ' GOT TO THIS PLACE')
      GO TO 701 
 8900 WRITE (6,9004)
      STOP 82250
 702  WRITE (6,9008)
 9008 FORMAT (1H1, ' RUN IS NOW COMPLETED') 
      IF (ISO.EQ.1) GO TO 710   
 711  STOP  
 710  CLOSE (7) 
      GO TO 711 
 8901 WRITE(6,9005) 
 9005 FORMAT ( ' READ ERROR FROM RD 222')   
      STOP 82251
 8905 WRITE (6,9007)
 9007 FORMAT ( ' READ ERROR FROM READ 270') 
      STOP 82278
 8902 WRITE(6,9006) 
 9006 FORMAT ( ' READ ERROR FROM RD 3111')  
      STOP 82252
8904  WRITE (6,9000)
9000  FORMAT ('1STN # WRONG, CHECK HEADER, CORRECT AND RESUBMIT ')  
      STOP  
 9004 FORMAT ( ' READ ERROR FROM RD 203')   
 270  REWIND 15 
C *****THIS IS A READ OF CDIMAGE ONTO FILE 15 ***** 
C     READ (15,206,END=210,ERR=8905)ISTNX,IY,IM,ID,IB,ABC1,ABC2,ABC3,   
      READ (15,206,END=322,ERR=8905)ISTNX,IY,IM,ID,IB,ABC1,ABC2,ABC3,   
     1ABC4,ABC5,ABC6
      IT15=0
      ISWCH=0   
      GO TO 271 
 323  WRITE (15,209) ISTNX,IY,IM,ID,ABC1,ABC2,ABC3,ABC4,ABC5,ABC6   
      IT15=1
      GO TO 322 
 369  REWIND 16 
      READ (16,223,END=224,ERR=8901)ISTNX,IY,IM,IB,ID,IH,(CH(I),I=1,3), 
     1KWD,IWS,CH(4) 
      IT15=0
      GO TO 370 
 372  WRITE (16,225) ISTNX,IY,IM,ID,IH,(CH(I),I=1,3),   
     1KWD,IWS,CH(4) 
      IT15=1
      GO TO 375 
      END   
