SUBROUTINE CG_DCD1 ( mszrpt, cgrpt, ipt, iret ) C************************************************************************ C* CG_DCD1 * C* * C* This subroutine decodes the data in one report. It assumes that * C* the order of the fields will be the same for each report, but that * C* some fields may be missing from their respective positions from time * C* to time. * C* * C* CG_DCD1 ( MSZRPT, CGRPT, IPT, IRET ) * C* * C* Input parameters: * C* MSZRPT INTEGER Length of report in bytes * C* CGRPT CHAR* Report array * C* * C* Input parameters passed via common: * C* IWXVSB LOGICAL indicates presence of wx/vis * C* IWIND LOGICAL indicates presence of wind * C* IWAVE LOGICAL indicates presence of wave data * C* ISEA LOGICAL indicates presence of sst data * C* IAIR LOGICAL indicates presence of air temp. * C* IPRES LOGICAL indicates presence of slp data * C* IRMK LOGICAL indicates presence of remarks * C* * C* Input and Output parameters: * C* IPT INTEGER Pointer to start of report. * C* * C* Output parameters: * C* IRET INTEGER Return code * C* 0 = Normal return * C* -1 = station not found * C* 1 = err rtn from CG_WXVS * C* 2 = err rtn from CG_WIND * C* 3 = err rtn from CG_WAVE * C* 4 = err rtn from CG_SST * C* 5 = err rtn from CG_AIRT * C** * C* Log: * C* R. Hollern/NCEP 6/96 * C* R. Hollern/NCEP 8/96 Added logic to check the error return * C* variable from CG_LSCB * C* D. Kidwell/NCEP 4/97 Cleaned up code and documentation * C* D. Kidwell/NCEP 10/97 Changed interface * C* R. Hollern/NCEP 2/00 Changed name of CG_SC1B to CG_SEC1 * C* C. Caruso Magee/NCEP 4/00 Modifying for Coast Guard data * C* C. Caruso Magee/NCEP 8/00 Add setting of ircorn here if not set * C* previously in cgdcod or cgrmka. * C* C. Caruso Magee/NCEP 6/04 Fix err numbers in calls to DC_WLOG * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'BRIDGE.PRM' INCLUDE 'cgcmn.cmn' C* CHARACTER*(*) cgrpt character*(DCMXBF) cgrpto, cgrpto2 INCLUDE 'ERMISS.FNC' C------------------------------------------------------------------------ iret = 0 ipt = 0 C C* Set report date/time. C rivals(iryear) = FLOAT ( irptdt(1) ) rivals(irmnth) = FLOAT ( irptdt(2) ) rivals(irdays) = FLOAT ( irptdt(3) ) rivals(irhour) = FLOAT ( irptdt(4) ) rivals(irminu) = FLOAT ( irptdt(5) ) C C* Remove any unprintable (non-alphanumeric) chars from cgrpt. C CALL ST_UNPR ( cgrpt, mszrpt, cgrpto, mszrpto, iret ) C C* Remove any leading blanks from cgrpto. C IF ( cgrpto(1:1) .eq. ' ' ) THEN CALL ST_LDSP ( cgrpto, cgrpto2, ncout, iret ) mszrpto2 = ncout ELSE cgrpto2 = cgrpto mszrpto2 = mszrpto END IF C C* Decode station id group. C CALL CG_STID ( cgrpto2, mszrpto2, ipt, jret ) IF ( jret .lt. 0 ) THEN IF ( jret .eq. -1 ) THEN logmsg = 'Missing station id' CALL DC_WLOG ( 2, 'CG', 2, logmsg, ierwlg ) ELSEIF ( jret .eq. -2 ) THEN logmsg = 'Bad station id format' CALL DC_WLOG ( 2, 'CG', 2, logmsg, ierwlg ) END IF RETURN END IF C C* Compare stid with station table info and set lat/lon/elev. C IF ( civals(icstid) .ne. ' ' ) THEN CALL DC_BSRC ( civals(icstid), jstnid, jstn, ipos, jret ) IF ( ipos .eq. 0 ) THEN logmsg = 'Could not find ' * //civals(icstid)//' in station table' CALL DC_WLOG ( 2, 'CG', 1, logmsg, ierwlg ) iret = -1 RETURN ELSE rivals ( irslat ) = ylat(ipos) rivals ( irslon ) = ylon(ipos) rivals ( irselv ) = elev(ipos) END IF END IF C IF ( iwxvsb ) THEN C C* Decode the weather/visibility group. C CALL CG_WXVS ( cgrpto2, mszrpto2, ipt, jret ) IF ( jret .ne. 0 ) THEN iret = 1 RETURN END IF END IF C IF ( iwind ) THEN C C* Decode the wind group. C CALL CG_WIND ( cgrpto2, mszrpto2, ipt, jret ) IF ( jret .ne. 0 ) THEN iret = 2 RETURN END IF END IF C IF ( iwave ) THEN C C* Decode the wave group. C CALL CG_WAVE ( cgrpto2, mszrpto2, ipt, jret ) IF ( jret .ne. 0 ) THEN iret = 3 RETURN END IF END IF C IF ( isea ) THEN C C* Decode the sst group. C CALL CG_SST ( cgrpto2, mszrpto2, ipt, jret ) IF ( jret .ne. 0 ) THEN iret = 4 RETURN END IF END IF C IF ( iair ) THEN C C* Decode the air temp. group. C CALL CG_AIRT ( cgrpto2, mszrpto2, ipt, jret ) IF ( jret .ne. 0 ) THEN iret = 5 RETURN END IF END IF C IF ( ipres .or. irmk ) THEN C C* Decode the pressure, remarks, and station name groups. C CALL CG_PRSN ( cgrpto2, mszrpto2, ipt, jret ) END IF C C* Check to see if ircorn is missing. If so (means it wasn't set by C* either bulletin header or within report Remarks), set it to 0 C* (indicates report is not a correction). C IF ( ERMISS ( rivals ( ircorn ) ) ) rivals ( ircorn ) = 0. RETURN END