SUBROUTINE SY_PRCP ( iubfma, iubfmn ) C************************************************************************ C* SY_PRCP * C* * C* This routine gets and stores the precipitation data. * C* * C* SY_PRCP ( IUBFMA, IUBFMN ) * C* * C* Input parameters: * C* IUBFMA INTEGER Logical unit number of messages * C* file for BUFR input stream * C* IUBFMN INTEGER Logical unit number of messages * C* file for BUFR output stream * C** * C* Log: * C* J. Ator/NCEP 09/12 * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'sycmn.cmn' C* LOGICAL gotp24 C* REAL*8 r8pcp1 (4), r8pcp2 (2,5) C* CHARACTER tagpr*10 C*----------------------------------------------------------------------- C* IF ( gots96 .or. gots91 ) THEN C C* Locate the name of the sequence containing the C* precipitation data. C CALL GETTAGPR ( iubfma, 'MOPM', 1, tagpr, ierptg ) IF ( ierptg .eq. 0 ) THEN CALL UFBSEQ ( iubfma, r8wk, MXMN, MXLV, nlv, tagpr ) IF ( nlv .eq. 1 ) THEN C C* Store the HSALG, MOPM and MLMP values. C r8pcp1 (1) = r8wk (1,1) r8pcp1 (2) = r8bfms r8pcp1 (3) = r8wk (2,1) r8pcp1 (4) = r8wk (3,1) CALL UFBSEQ ( iubfmn, r8pcp1, 4, 1, nlv, 'BSYPCP1' ) C C* Store the TPHR and TOPC values. C jj = 0 IF ( gots91 ) THEN IF ( IBFMS ( r8wk (4,1) ) .eq. 0 ) THEN jj = 1 C C* Convert TPMI to TPHR. C r8pcp2 ( 1, jj ) = + FLOAT( IDNINT( r8wk (4,1) / 60. ) ) r8pcp2 ( 2, jj ) = r8wk (5,1) END IF ELSE DO ii = 4, 12, 2 IF ( IBFMS ( r8wk (ii,1) ) .eq. 0 ) THEN jj = jj + 1 r8pcp2 ( 1, jj ) = r8wk (ii,1) r8pcp2 ( 2, jj ) = r8wk (ii+1,1) END IF END DO END IF IF ( jj .gt. 0 ) THEN CALL DRFINI ( iubfmn, jj, 1, '{BSYPCP2}' ) CALL UFBSEQ ( iubfmn, r8pcp2, 2, jj, nlv, + 'BSYPCP2' ) END IF END IF END IF ELSE C C* Look for TPHR and TOPC values in the PRECMEA2 sequence. C CALL UFBSEQ ( iubfma, r8wk, MXMN, MXLV, nlv, 'PRECMEA2' ) jj = 0 gotp24 = .false. DO ii = 2, 4, 2 IF ( IBFMS ( r8wk (ii,1) ) .eq. 0 ) THEN jj = jj + 1 r8pcp2 ( 1, jj ) = r8wk (ii,1) r8pcp2 ( 2, jj ) = r8wk (ii+1,1) C C* Is this a 24-hour precipitation value? C IF ( NINT ( r8pcp2 ( 1, jj ) ) .eq. -24 ) + gotp24 = .true. END IF END DO C C* Get the HSALG value from the PRECMEA2 sequence. C r8pcp1 (1) = r8wk (1,1) C C* Check whether a 24-hour precipitation value was reported in C* the PRECMEA2 sequence. C IF ( .not. gotp24 ) THEN C C* No, so look for it in the PRECIP24 sequence. C CALL UFBSEQ ( iubfma, r8wk, MXMN, MXLV, nlv, 'PRECIP24') IF ( IBFMS ( r8wk (2,1) ) .eq. 0 ) THEN C C* A 24-hour precipitation value was reported in the C* PRECIP24 sequence, so add it to the output array. C jj = jj + 1 r8pcp2 ( 1, jj ) = -24. r8pcp2 ( 2, jj ) = r8wk (2,1) END IF IF ( IBFMS ( r8pcp1 (1) ) .ne. 0 ) THEN C C* The HSALG value was missing from the PRECMEA2 C* sequence, so get it from the PRECIP24 sequence. C r8pcp1 (1) = r8wk (1,1) END IF END IF IF ( jj .gt. 0 ) THEN C C* Store the TPHR and TOPC values. C CALL DRFINI ( iubfmn, jj, 1, '{BSYPCP2}' ) CALL UFBSEQ ( iubfmn, r8pcp2, 2, jj, nlv, 'BSYPCP2' ) END IF IF ( IBFMS ( r8pcp1 (1) ) .eq. 0 ) THEN C C* Store the HSALG value. C r8pcp1 (2) = r8bfms r8pcp1 (3) = r8bfms r8pcp1 (4) = r8bfms CALL UFBSEQ ( iubfmn, r8pcp1, 4, 1, nlv, 'BSYPCP1' ) END IF END IF C* RETURN END