SUBROUTINE GETGPD(MSGUN,ITIME,IKP,IAP,IAPD,IF107,IFQFR,ISSPT, + ISTAT,IWRK,IBLK,IUNPK,LREC) C This routine returns 1 days (1 logical records) values for C the UT date and hour to arrays IKP and IAP (3 hourly) C and daily values of IAPD, IF107, IFQFR, ISSPT; where, C IKP(8) = 8 3-hour samples of Kp for the day C IAP(8) = 8 3-hour samples of ap C IAPD = dialy mean AP C IF107 = F10.7 Solar Flux (daily) C IFQFR = F10.7 Solar Flux Qualifier (daily) C ISSPT = Sun spot number (daily) C Notes C - Although ITIME is in standard I.S. time format (four C integers holding year, monthday, hourminute, and centisec) C only the the year, month and day are used here. C - It is assumed that input time has reasonable values since C GETGPI normally does this checking. C - MSGUN is the fortran unit number to print diagnostic C messages. C - ISTAT = Status flag C = 99999 ON INPUT, implies only fatal errors C will cause diagnostic messages to be printed, C nonfatal errors will be signified only by the C returned value of ISTAT (thus allowing user C control of most diagnostic print messages). C ISTAT VALUES ON RETURN: C = 0 => ok C = 2 => Request time before first available C = 3 => Request time after last available C = 6 => Indicies dataset corrupted; should be C continuous, yet somehow read past ITIME C - The following arrays are used by RDBLK6, which must be C dimensioned appropriately by the initial calling routine: C IWRK = Work array (contains fortran unit to read C indicies, etc - see RDBLK6) C IBLK = Packed physical record buffer. C IUNPK = Unpacked block buffer. C LREC = Logical record. C Formal parameter argument declarations: DIMENSION ITIME(4), IKP(8), IAP(8), IWRK(*),IBLK(*), IUNPK(*), + LREC(*) C Local declarations: PARAMETER (MPAR=6 , NOPRT=99999 , MISS=-32767) DIMENSION IT(4) , LBEGT(4) DOUBLE PRECISION IDIF , JDIF LOGICAL ATBEGN SAVE ATBEGN,LBEGT,ISTRD DATA ATBEGN,LBEGT,ISTRD/.TRUE. , 1940,0101,0,0 , 0/ DO 10 I=1,8 IKP(I) = MISS 10 IAP(I) = MISS IAPD = MISS IF107 = MISS IFQFR = MISS ISSPT = MISS C See if already read past the requested date: IT(1) = ITIME(1) IT(2) = ITIME(2) IT(3) = 0 IT(4) = 0 CALL TIMDIF(LBEGT,IT,IDIF) IF (IDIF .EQ. 0D0) GO TO 1000 IF (IDIF .GT. 0D0) THEN C Must read more but first see if already at EOD IF(ISTRD .NE. 3)GO TO 100 IF(ISTAT .NE. NOPRT)WRITE(MSGUN,9100)(ITIME(I),I=1,2), + (LREC(J),J=5,6) ISTAT = 3 RETURN ENDIF CALL REWBLK(IWRK) IWRK(7) = 1 ATBEGN = .TRUE. C Read a new lrec, compute & test the new difference 100 CALL RDBLK6(IWRK,LREC,IBLK,IUNPK,ISTRD) IF(ISTRD .EQ. 0 .AND. LREC(2) .NE. 1002)GO TO 100 LBEGT(1)=LREC(5) LBEGT(2)=LREC(6) CALL TIMDIF(LREC(5),IT,JDIF) IF (JDIF .GT. 0D0) THEN C Must read more but first see if already at EOD ATBEGN = .FALSE. IF(ISTRD .NE. 3)GO TO 100 IF(ISTAT .NE. NOPRT)WRITE(MSGUN,9100)ITIME(1),ITIME(2), + (LREC(J),J=5,6) ISTAT = 3 RETURN ELSEIF (JDIF .LT. 0D0) THEN C After request time IF(ATBEGN)THEN IF(ISTAT .NE. NOPRT)WRITE(MSGUN,9200)ITIME(1),ITIME(2), + (LREC(J),J=5,6) ISTAT = 2 ELSE IF(ISTAT .NE. NOPRT)WRITE(MSGUN,9500)ITIME(1),ITIME(2) ISTAT = 6 ENDIF RETURN ENDIF C Assign new last begin time read and values, then return C (JOFF = lprol + 2*jpar = 16 + 8) 1000 JOFF=24 DO 1100 I=1,8 JOFF=JOFF+MPAR IKP(I)=LREC( 5 + JOFF) 1100 IAP(I)=LREC( 6 + JOFF) IAPD =LREC( 21 ) IF107 =LREC( 22 ) IFQFR =LREC( 23 ) ISSPT =LREC( 24 ) ISTAT = 0 RETURN C Error trap messages: 9100 FORMAT('0GETGPD: Requested date',2I5,' is after last available: +',2I5) 9200 FORMAT('0GETGPD: Requested date',2I5,' is before first available +: ',2I5) 9500 FORMAT('0GETGPD: Indicies dataset corrupted? Data should be', + ' continuous yet',/, + ' somehow read past requested date',2I5) END