SUBROUTINE HY_BUFR ( iunbfo, irundt, cmsobn, iret ) C************************************************************************ C* HY_BUFR * C* * C* This subroutine retrieves data from the interface arrays, converts * C* it into BUFR output, and then writes the BUFR output to the BUFR * C* output stream. * C* * C* HY_BUFR ( IUNBFO, IRUNDT, CMSOBN, IRET ) * C* * C* Input parameters: * C* IUNBFO INTEGER BUFR output file unit number * C* IRUNDT (5) INTEGER Run date-time * C* (YYYY, MM, DD, HH, MM) * C* CMSOBN CHAR*18 HYDRO data file basename * C* * C* Output parameters: * C* IRET INTEGER Return code: * C* 0 = normal return * C** * C* Log: * C* C. Caruso Magee/NCEP 06/06 New * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'hycmn.cmn' C* INTEGER irundt (5) C* CHARACTER bfstyp*8, cmsobn*18 C* REAL*8 r8ary ( 5, 1 ), + UT_RIBM, PKFTBV, + bfdint, bflint, bftint, bfrolf C* INCLUDE 'ERMISS.FNC' C*----------------------------------------------------------------------- iret = 0 C C* Set the BUFR message subtype and redistribution restriction. C* Until further notice, set data to unrestricted. C IF ( civals (icprvid) .eq. 'UDFCD ') then bfstyp = 'NC255131' rsrd = RMISSD ELSE bfstyp = 'NC255160' rsrd = PKFTBV (9,1) END IF C C* Set the BUFR message date-time. C year = rivals ( iryear ) rmth = rivals ( irmnth ) days = rivals ( irdays ) hour = rivals ( irhour ) IF ( ( ERMISS ( year ) ) .or. ( ERMISS ( rmth ) ) .or. + ( ERMISS ( days ) ) .or. ( ERMISS ( hour ) ) ) THEN RETURN END IF ibfdt = ( INT ( year ) * 1000000 ) + ( INT ( rmth ) * 10000 ) + + ( INT ( days ) * 100 ) + INT ( hour ) C C* Open a BUFR message for output. C CALL OPENMB ( iunbfo, bfstyp, ibfdt ) C C* Report date-time. C CALL UT_RIBF ( iunbfo, 'YEAR', rivals ( iryear ), ierrbf ) CALL UT_RIBF ( iunbfo, 'MNTH', rivals ( irmnth ), ierrbf ) CALL UT_RIBF ( iunbfo, 'DAYS', rivals ( irdays ), ierrbf ) CALL UT_RIBF ( iunbfo, 'HOUR', rivals ( irhour ), ierrbf ) CALL UT_RIBF ( iunbfo, 'MINU', rivals ( irminu ), ierrbf ) C C* Receipt date-time. C CALL UT_RIBF ( iunbfo, 'RCYR', FLOAT ( irundt (1) ), ierrbf ) CALL UT_RIBF ( iunbfo, 'RCMO', FLOAT ( irundt (2) ), ierrbf ) CALL UT_RIBF ( iunbfo, 'RCDY', FLOAT ( irundt (3) ), ierrbf ) CALL UT_RIBF ( iunbfo, 'RCHR', FLOAT ( irundt (4) ), ierrbf ) CALL UT_RIBF ( iunbfo, 'RCMI', FLOAT ( irundt (5) ), ierrbf ) CALL UT_RIBF ( iunbfo, 'RCTS', 0., ierrbf ) C C* Station ID. C CALL UT_CIBF ( iunbfo, 'RPID', civals ( ichyid ), 8, iercbf ) C C* Provider ID. C CALL ST_LSTR ( civals ( icprvid ), lenp, ierltr ) CALL UT_CIBF ( iunbfo, 'PRVSTG', + civals ( icprvid ), lenp, iercbf ) C C* File basename. C CALL UT_CIBF ( iunbfo, 'FNSTG', cmsobn, 18, iercbf ) C C* Latitude. C CALL UT_RIBF ( iunbfo, 'CLATH', rivals ( irslat ), ierrbf ) C C* Longitude. C CALL UT_RIBF ( iunbfo, 'CLONH', rivals ( irslon ), ierrbf ) C C* Elevation. C CALL UT_RIBF ( iunbfo, 'SELV', rivals ( irselv ), ierrbf ) C C* River flow, reported in m**3/sec. C CALL UT_RIBF ( iunbfo, 'DCHG', rivals ( irrflo ), ierrbf ) C C* River stage, reported in meters. C CALL UT_RIBF ( iunbfo, 'RSHM', rivals ( irrstg ), ierrbf ) C C* Restrictions on redistribution. C CALL UT_RIBF ( iunbfo, 'RSRD', rsrd, ierrbf ) C C* Precip (and associated QC values), reported in meters, so C* convert to millimeters for storage into BUFR. C* 1 millimeter = 1 kg/m**2 (BUFR storage units). C* First do 5-min precip. C CALL UT_QIBF ( PR_HGKM ( rivals ( irpcp5m ) ), + civals ( icpcp5qd ), + rivals ( irpcp5qa ), + rivals ( irpcp5qr ), + r8ary ( 1, 1 ), r8ary ( 2, 1 ), + r8ary ( 3, 1 ), r8ary ( 4, 1 ), ierqbf ) IF ( ierqbf .eq. 0 ) THEN CALL DRFINI ( iunbfo, 1, 1, '' ) CALL UFBSEQ ( iunbfo, r8ary, 4, 1, ierusq, 'HYPCP5SQ' ) END IF C C* 1-hr precip. C CALL UT_QIBF ( PR_HGKM ( rivals ( irpcp1h ) ), + civals ( icpcp1qd ), + rivals ( irpcp1qa ), + rivals ( irpcp1qr ), + r8ary ( 1, 1 ), r8ary ( 2, 1 ), + r8ary ( 3, 1 ), r8ary ( 4, 1 ), ierqbf ) IF ( ierqbf .eq. 0 ) THEN CALL DRFINI ( iunbfo, 1, 1, '' ) CALL UFBSEQ ( iunbfo, r8ary, 4, 1, ierusq, 'HYPCP1SQ' ) END IF C C* 3-hr precip. C CALL UT_QIBF ( PR_HGKM ( rivals ( irpcp3h ) ), + civals ( icpcp3qd ), + rivals ( irpcp3qa ), + rivals ( irpcp3qr ), + r8ary ( 1, 1 ), r8ary ( 2, 1 ), + r8ary ( 3, 1 ), r8ary ( 4, 1 ), ierqbf ) IF ( ierqbf .eq. 0 ) THEN CALL DRFINI ( iunbfo, 1, 1, '' ) CALL UFBSEQ ( iunbfo, r8ary, 4, 1, ierusq, 'HYPCP3SQ' ) END IF C C* 6-hr precip. C CALL UT_QIBF ( PR_HGKM ( rivals ( irpcp6h ) ), + civals ( icpcp6qd ), + rivals ( irpcp6qa ), + rivals ( irpcp6qr ), + r8ary ( 1, 1 ), r8ary ( 2, 1 ), + r8ary ( 3, 1 ), r8ary ( 4, 1 ), ierqbf ) IF ( ierqbf .eq. 0 ) THEN CALL DRFINI ( iunbfo, 1, 1, '' ) CALL UFBSEQ ( iunbfo, r8ary, 4, 1, ierusq, 'HYPCP6SQ' ) END IF C C* 12-hr precip. C CALL UT_QIBF ( PR_HGKM ( rivals ( irpcp12h ) ), + civals ( icpcp12qd ), + rivals ( irpcp12qa ), + rivals ( irpcp12qr ), + r8ary ( 1, 1 ), r8ary ( 2, 1 ), + r8ary ( 3, 1 ), r8ary ( 4, 1 ), ierqbf ) IF ( ierqbf .eq. 0 ) THEN CALL DRFINI ( iunbfo, 1, 1, '' ) CALL UFBSEQ ( iunbfo, r8ary, 4, 1, ierusq, 'HYPC12SQ' ) END IF C C* 24-hr precip. C CALL UT_QIBF ( PR_HGKM ( rivals ( irpcp24h ) ), + civals ( icpcp24qd ), + rivals ( irpcp24qa ), + rivals ( irpcp24qr ), + r8ary ( 1, 1 ), r8ary ( 2, 1 ), + r8ary ( 3, 1 ), r8ary ( 4, 1 ), ierqbf ) IF ( ierqbf .eq. 0 ) THEN CALL DRFINI ( iunbfo, 1, 1, '' ) CALL UFBSEQ ( iunbfo, r8ary, 4, 1, ierusq, 'HYPC24SQ' ) END IF C C* Store the BUFR report. C CALL UT_WBFR ( iunbfo, 'hydro', 0, ierwbf ) C* RETURN END