SUBROUTINE BT_DBAT ( iends2, report, ipt, ierr1 ) C************************************************************************ C* BT_DBAT * C* * C* This subroutine decodes the groups zzTTT in section 2 of the bathy * C* report. These groups contain the depths in meters (zz) and the * C* temperatures (TTT), in tenths of a degree Celsius, at the specified * C* depths. If the depth of the first level is 0.0 meters, the * C* temperature at this level will define the sea surface temperature. * C* * C* BT_DBAT ( IENDS2, REPORT, IPT, IERR1 ) * C* * C* Input parameters: * C* REPORT CHAR* Report array * C* IENDS2 INTEGER Points to the end of the last * C* zzTTT group in report * C* * C* Input and Output parameters: * C* IPT INTEGER On input, points to the start of* C* first zzTTT group in report, on * C* output, points to next group * C* following the last zzTTT group * C* * C* Output parameters: * C* RIVALS(IRNDTS) REAL Number of levels of data * C* RIVALS(IRDBSS) REAL Depth in meters * C* RIVALS(IRSTMP) REAL Temperature in degrees C * C* RIVALS(IRTOWD) REAL Total water depth in meters * C* IERR1 INTEGER Return code * C* 0 = No problems * C* 1 = Problems * C* * C** * C* Log: * C* R. Hollern/NCEP 11/98 * C* C. Caruso Magee/NCEP 03/02 Remove check on presence of Section 3 * C* data, since Section 3 surface current * C* data are now stored separately in the * C* Interface array (they have their own * C* counter and array elements). * C* C. Caruso Magee/NCEP 04/03 Correct logic error which would allow * C* ndts to be bigger than MXDLYR (see * C* inline comments below). * C* R. Hollern/NCEP 03/04 Modified lvl array index logic * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'btcmn.cmn' C* CHARACTER*(*) report C* CHARACTER fld2*2, fld3*3 C------------------------------------------------------------------------ ierr1 = 0 C xdpth = 0.0 lvl = 0 C DO WHILE ( ipt .le. iends2 ) C IF ( report(ipt:ipt+4) .eq. '00000' ) THEN C C* The last temperature group was the bottom layer C* temperature. C IF ( lvl .gt. 0 ) THEN rivals ( irtowd ) = rivals ( irdbss ( lvl ) ) rivals ( irndts ) = FLOAT ( lvl ) RETURN END IF C END IF C IF ( report(ipt:ipt+2) .eq. '999' ) THEN C C* Depth in hundredths of meters. C ipt = ipt + 3 fld2 = report ( ipt:ipt+1 ) ipt = ipt + 3 CALL ST_INTG ( fld2, ival, ier ) IF ( ier .eq. 0 ) THEN xdpth = 100. * FLOAT ( ival ) ELSE ierr1 = 1 RETURN END IF END IF C C* The index lvl is incremented for each level of data C* in the report. It can not exceed the maximum number of C* levels allowed (MXDLRY) to be stored in a 20000 byte C* BUFR message. If more than MXDLRY levels of data are C* in the report, then the last level of data decoded in C* the report will be saved in the MXDLYR location of C* the rivals array. C lvl = lvl + 1 IF ( lvl .gt. MXDLYR ) lvl = MXDLYR C C* Get selected and/or significant depth, in meters, C fld2 = report ( ipt:ipt+1 ) ipt = ipt + 2 C CALL ST_INTG ( fld2, ival, ier ) IF ( ier .eq. 0 ) THEN rval = xdpth + FLOAT ( ival ) rivals ( irdbss ( lvl ) ) = rval END IF C C* Get temperature, in tenths of a degree Celsius. C fld3 = report ( ipt:ipt+2 ) ipt = ipt + 4 C CALL ST_INTG ( fld3, ival, ier ) IF ( ier .eq. 0 ) THEN rval = FLOAT ( ival ) C C* Check for negative temperature. C IF ( rval .gt. 499. ) rval = 500. - rval rivals ( irstmp ( lvl ) ) = .1 * rval C END IF END DO C IF ( lvl .gt. 0 ) rivals ( irndts ) = FLOAT ( lvl ) C* RETURN END