SUBROUTINE BT_GRPT( lenb, bulltn, irpt, istrp, mszrpt, report, + ngrps, istgrp, iret ) C************************************************************************ C* BT_GRPT * C* * C* This subroutine gets the next report in bulletin, gets its report * C* identifier, and checks that its length is within the given range * C* limits. * C* * C* BT_GRPT ( LENB, BULLTN, IRPT, ISTRP, MSZRPT, REPORT, IRET ) * C* * C* Input parameters: * C* IRPT INTEGER Number of current report in * C* bulletin * C* LENB INTEGER Length of bulletin in bytes * C* BULLTN CHAR* Current bulletin * C* ISTRP (5,MXRPT) INTEGER Array containing the report * C* types and the starting location * C* of the reports in the bulletin * C* * C* Output parameters: * C* MSZRPT INTEGER Length of report in bytes * C* REPORT CHAR* Current report * C* NGRPS INTEGER Total number of groups following* C* the first group in report * C* ISTGRP INTEGER Array containing the location * C* of the space before the start * C* of each group in the report * C* IRPTYP INTEGER Report type identifier * C* = 1, BATHY (JJYY) report * C* = 2, TESAC (KKXX) report * C* = 3, TRACKOB (NNXX) report * C* = 4, BATHY (JJVV) report with * C* a high precision lat/long * C* = 5, TESAC (KKYY) report with * C* a high precision lat/long * C* IRET INTEGER Return code * C* 0 = normal return * C* 1 = problems * C* 2 = no more reports in bulltin* C* * C** * C* Log: * C* R. Hollern/NCEP 11/98 * C* R. Hollern/NCEP 1/99 Increased istrp array size to handle up * C* to 100 reports per bulletin * C* R. Hollern/NCEP 3/99 Added code to get start location of each* C* group in the report * C* R. Hollern/NCEP 4/00 Expanded report type identifier logic * C* C. Caruso Magee/NCEP 01/03 Added code to check on array bound for * C* istrp array when checking for end of * C* current report and return to btdcod if * C* it's already at the upper array limit. * C* Also increased istrp array size to * C* handle up to 540 reports per bulletin * C* (see MXRPT in btcmn.cmn). * C* C. Caruso Magee/NCEP 04/03 Increased max report length to 3800 from* C* 1600. * C* R. Hollern/NCEP 03/04 Increased istgrp array size from 300 to * C* 1100. Set maximum size of report length * C* to MXBFRR16. * C* J. Ator/NCEP 11/12 Increase istgrp size from 1100 to 3000 * C************************************************************************ INCLUDE 'btcmn.cmn' INCLUDE 'BUFR.CMN' C* INTEGER istrp(5,MXRPT), istgrp(3000) C* CHARACTER*(*) bulltn, report C* LOGICAL more C----------------------------------------------------------------------- C iret = 0 C C* Get report type. C IF ( istrp(1,irpt) .eq. 1 ) THEN irptyp = 1 ELSE IF ( istrp(1,irpt) .eq. 2 ) THEN irptyp = 2 ELSE IF ( istrp(1,irpt) .eq. 3 ) THEN irptyp = 3 ELSE IF ( istrp(1,irpt) .eq. 4 ) THEN irptyp = 4 ELSE IF ( istrp(1,irpt) .eq. 5 ) THEN irptyp = 5 End IF C C* Get location of start of report in bulletin. C ist = istrp(2,irpt) C C* Get location of end of report using start location of C* next report (only if there are less than MXRPT reports in the C* current bulletin). C IF (irpt .lt. MXRPT) THEN mm = istrp(3,irpt+1) ELSE iret = 3 RETURN END IF C IF ( mm .eq. 0 ) THEN iend = lenb ELSE iend = mm - 1 END IF C C* Check for end of bulletin. C jsize = lenb - ist C IF ( jsize .lt. 25 ) THEN iret = 2 RETURN END IF C C* Check that length of report is neither too long nor too short. C IF ( mm .gt. 0 ) THEN lenrpt = mm - ist ELSE lenrpt = jsize END IF C IF ( lenrpt .lt. 25 .or. lenrpt .gt. MXBFRR16 ) THEN loglvl = 2 CALL DC_WLOG( loglvl, 'BT', -1, bulltn(ist-5:ist+20), ierwlg ) iret = 1 RETURN END IF C mszrpt = 0 C DO j = ist, iend C C* Store report in the array report. C IF ( bulltn(j:j) .ne. '=' ) THEN mszrpt = mszrpt + 1 report(mszrpt:mszrpt) = bulltn(j:j) END IF C END DO C C* Skip over any spaces at end of report. C ip = mszrpt more = .true. icnt = 0 C DO WHILE ( more ) C IF ( report ( ip:ip ) .eq. ' ' ) THEN ip = ip - 1 C C* Count the spaces. C icnt = icnt + 1 ELSE more = .false. mszrpt = ip END IF C IF ( icnt .gt. 20 ) THEN ierrno = -2 CALL BT_ERRS ( ierrno, report, iret ) iret = 1 RETURN END IF C END DO C C* Get location of the space which separates successive groups C n = 0 C DO i = 1, mszrpt IF ( report(i:i) .eq. ' ' .and. n .lt. 5020 ) THEN n = n + 1 istgrp(n) = i END IF END DO C ngrps = n C* RETURN END