REM ********************************************************** REM PROGRAM *************IEH-CUD.BAS************************* REM ********************************************************** REM Program to merge .tab file with cudls data REM KMP 2MAR93 REM KMP 24JAN94 Modified to handle new cudls format. 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 Merge table with cudls or endeco? 5 PRINT "Do you want to merge the table data with" PRINT "C = cudls data or E = endeco data" INPUT core$ REM Check for correct input. If wrong then recycle. IF core$ = "E" THEN GOTO 7 ELSEIF core$ = "e" THEN GOTO 7 ELSEIF core$ = "C" THEN GOTO 7 ELSEIF core$ = "c" THEN GOTO 7 ELSE PRINT "try again": PRINT : PRINT : GOTO 5 END IF REM Input files to be merged 7 PRINT "Input path and name of table file. " INPUT "example c:\tmp\9210\9210.tab >", n$: PRINT IF core$ = "C" OR core$ = "c" THEN xx$ = "cudls" IF core$ = "E" OR core$ = "e" THEN xx$ = "endeco" PRINT "Input path and name of the ", xx$, " file. " INPUT "example c:\tmp\9210\sum10 >", o$: PRINT REM Output files PRINT PRINT "Input a path and prefix for the two output files." PRINT "example c:\tmp\9210\cc9210 " INPUT "Output files will be named cc9210a.out and cc9210b.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 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 DO WHILE NOT EOF(2) ON ERROR GOTO 100 10 LINE INPUT #2, a$: REM Read table 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) PRINT : PRINT : PRINT "start" PRINT tyr$, tmo$, tdy$, tutc$ IF c1 = 1 GOTO 50: REM Dont read culds data on this loop. 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 PRINT b$ IF core$ = "C" OR core$ = "c" THEN 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 cyr$, cmo$, cdy$, chour$, cmin$ END IF REM Internal read date and time from endeco file IF core$ = "E" OR core$ = "e" THEN cyr$ = MID$(b$, 9, 2) cmo$ = MID$(b$, 1, 2) cdy$ = MID$(b$, 4, 2) chour$ = MID$(b$, 12, 2) cmin$ = MID$(b$, 15, 2) PRINT cyr$, cmo$, cdy$, chour$, cmin$ END IF REM Convert cudls date and time to utc. chr = VAL(chour$) + 8 PRINT chr 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 real and string with numbers REM like 08. IF cday < 10 THEN cdy$ = "0" + STR$(cday) END IF END IF chour$ = STR$(chr) cutc$ = chour$ + cmin$ PRINT cutc$ REM Compare table and cudls date 50 IF VAL(tyr$ + tmo$ + tdy$) > VAL(cyr$ + cmo$ + cdy$) THEN GOTO 20 END IF 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 =. REM IF VAL(tyr$ + tmo$ + tdy$) = VAL(cyr$ + cmo$ + cdy$) THEN REM Compare cudls and table utc IF VAL(tutc$) = VAL(cutc$) THEN PRINT #1, a$: PRINT #4, b$ c1 = 0 GOTO 10 END IF REM If the table and cudls time and not equal then search for the closest REM time less than the table time. IF c2 > 0 GOTO 70 IF VAL(tutc$) < VAL(cutc$) THEN PRINT #1, a$: PRINT #4, blank$ c1 = 1 GOTO 10 END IF 70 IF VAL(tutc$) > VAL(cutc$) 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 > tabel time. GOTO 20 END IF PRINT #1, a$: PRINT #4, btemp$ LOOP 100 CLOSE END