REM program 9304mi-c.bas is a variation of pROGRAM IEH-CUD.BAS REM to accomodate differences in format on the cudls output. REM ********************************************************** REM Program to merge .tab file with cudls data REM FRB 15SEP95 Modified to handle extracted and averaged cudls data, REM now with the same format. The output are two files with REM surface data. extension a.out is from IEH REM externsion b.out is from CUDLS CLS 0 REM Input files to be merged PRINT "This program merges an IEH surface table file" PRINT "with an averaged or extracted raw data CUDLS file" PRINT "Input path and name of table file. " INPUT "example d:\data\cudls\9405\9405.TAB >", n$: PRINT PRINT "Input path and name of the CUDLS file. " INPUT "example d:\data\cudls\9405\A109405.CUD >", o$: PRINT REM Output files PRINT PRINT "Input a path and prefix for the two output files." PRINT "example d:\data\cudls\9405\AA9405 " INPUT "Output files will be named AA9405a.out and AA9405b.out >", k$ l$ = k$ + "b.out" m$ = k$ + "a.out" blank$ = " ": REM Blank line in the output files. c1 = 0: REM set counter to zero REM open files for input and output OPEN m$ FOR OUTPUT AS #1: REM ieh table file OPEN n$ FOR INPUT AS #2: REM ieh table file OPEN o$ FOR INPUT AS #3: REM cudls file OPEN l$ FOR OUTPUT AS #4: REM cudls file DO WHILE NOT EOF(2) ON ERROR GOTO 100 10 LINE INPUT #2, a$: REM Read table file. IF c2 = 2 THEN OPEN o$ FOR INPUT AS #3: REM cudls file c2 = 0: REM Set first pass counter to zero (true) REM Internal read date and time from table file tyr$ = MID$(a$, 15, 2) tmo$ = MID$(a$, 17, 2) tdy$ = MID$(a$, 19, 2) tutc$ = MID$(a$, 22, 4) th = VAL(MID$(tutc$, 1, 2)) + (VAL(MID$(tutc$, 3, 2))) / 60 PRINT "Start= ", tyr$, tmo$, tdy$, tutc$ 20 LINE INPUT #3, b$: REM Read CUDLS file. REM Internal read date and time from CUDLS file REM Reads the middle time from the averaged data blocks cyr$ = MID$(b$, 19, 2) cmo$ = MID$(b$, 13, 2) cdy$ = MID$(b$, 16, 2) chour$ = MID$(b$, 2, 2) cmin$ = MID$(b$, 5, 2) PRINT "CUDLS= ", cyr$, cmo$, cdy$, chour$, cmin$ REM Convert cudls date and time to utc. chr = VAL(chour$) + 8 IF chr >= 24 THEN chr = chr - 24 cday = VAL(cdy$) + 1: REM This makes midnight = the next day cdy$ = STR$(cday) REM Takes care of problem converting between REM real and string with numbers like 08. IF cday < 10 THEN cdy$ = "0" + STR$(cday) END IF END IF chour$ = STR$(chr) cutc$ = chour$ + cmin$ chr = chr + VAL(cmin$) / 60 PRINT "CUDLS UTC = ", cutc$ REM Compare table and cudls date 50 IF VAL(tyr$ + tmo$ + tdy$) > VAL(cyr$ + cmo$ + cdy$) GOTO 20 IF VAL(tyr$ + tmo$ + tdy$) < VAL(cyr$ + cmo$ + cdy$) THEN PRINT #1, a$: PRINT #4, blank$ c1 = 1: REM If table < cudls date then read next table and dont read cudls. GOTO 10 END IF REM Assume if table date is not < or > cudls date then they are =. IF VAL(tyr$ + tmo$ + tdy$) = VAL(cyr$ + cmo$ + cdy$) THEN REM Compare cudls and table utc IF ABS(th - chr) < .16 THEN PRINT #1, a$: PRINT #4, b$ CLOSE #3 c1 = 0 c2 = 2 GOTO 10 END IF REM If the table and cudls time are not equal then search for the closest REM time less than the table time. IF c2 > 0 GOTO 70 IF (th - chr) < -.16 THEN PRINT #1, a$: PRINT #4, blank$ CLOSE #3 c1 = 1 c2 = 2 GOTO 10 END IF 70 IF (th - chr) > .16 THEN ct1$ = cutc$: REM Store the last cudls time. btemp$ = b$: REM Store the last cudls data line. c2 = 1: REM Counter=0 means first pass. Cudls time may be > label time. GOTO 20 END IF PRINT #1, a$: PRINT #4, btemp$ END IF LOOP 100 CLOSE END