SUBROUTINE CG_WXVS ( cgrpt, mszrpt, ipt, iret ) C************************************************************************ C* CG_WXVS * C* * C* This subroutine decodes the sky cover (cloud), weather, and * C* visibility data in a report. It breaks the field down into its * C* cloud, weather, and vis components, then calls CG_GTCL, CG_GTWX, and * C* CG_GTVS to decode the respective components. * C* * C* CG_WXVS ( CGRPT, MSZRPT, IPT, IRET ) * C* * C* Input parameters: * C* MSZRPT INTEGER Length of report in bytes * C* CGRPT CHAR* Report array * C* * C* Input and Output parameters: * C* IPT INTEGER Pointer to start of field. * C* * C* Output parameters: * C* IRET INTEGER Return code * C* 0 = Normal return * C* -1 = No / found in rest of rpt * C* -2 = Misplaced slash * C** * C* Log: * C* C. Caruso Magee/NCEP 4/00 Original Author * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'cgcmn.cmn' character*(*) cgrpt character*100 stwxvsb, outst logical found integer mszrpt integer length integer iret, jret, kret, lret, mret, nret iret = 0 i = ipt found = .false. C C* look for '/' character. stop looping when the '/' we found is C* the field separator and not a '/' embedded in the wxvsb field. C DO WHILE ( .not. found ) IF ( i .le. mszrpt) THEN islash = index(cgrpt(i:i),'/') IF ( islash .eq. 0 ) THEN i = i + 1 ELSE C C* check to see if slash is too far to the right of the 1st slash C* in the header (located immediately before 'WIND'). If so, C* report has a bad format so return. C IF ( i .gt. iwindslsh + 3 ) THEN WRITE ( UNIT = logmsg, FMT = '( A )' ) * ' Probable report format error - skip this report' CALL DC_WLOG ( 2, 'CG', 1, logmsg, ierwlg ) iret = -2 RETURN ELSE C C* Check to see if char right after '/' is letter, number, or blank. C* if number, THEN we're still in wxvsb section (number is C* a part of the visibility), so look for next slash to be field C* separator. If letter or blank, THEN we've found C* the field separator between wxvsb and next parm. C CALL ST_ALNM ( cgrpt(i+1:i+1), ityp, jret ) IF ( ityp .eq. 2 .or. ityp .eq. 0 ) THEN iendwx = i - 1 found = .true. ELSE C C* Char after the slash is a number. Check position of slash C* relative to slash preceding 'WIND' in header. If this slash C* is at least one column left of '/WIND' in header, and C* it's not preceded by a blank, then it's the slash in a C* fractional visibility report. C IF ( i .le. (iwindslsh - 1) .and. * cgrpt(i-1:i-1) .ne. ' ' ) THEN i = i + 1 ELSE iendwx = i - 1 found = .true. END IF END IF END IF END IF ELSE iret = -1 RETURN END IF END DO C C* Wxvsb field lies between ipt and iendwx. C* Compress blanks out of wxvsb field. C stwxvsb = cgrpt(ipt:iendwx) CALL ST_RMBL ( stwxvsb, outst, length, kret ) if ( length .ge. 1 .and. outst(1:length) .ne. 'M' ) THEN C C* Decode cloud cover. C CALL CG_GTCL ( outst(1:length), lret ) C C* Decode weather. C CALL CG_GTWX ( outst(1:length), mret ) C C* Decode visibility. C CALL CG_GTVS ( outst(1:length), length, nret ) ELSE C C* Wxvsb is blank or missing. Skip forward 2 columns in this report C* and return to decode the next parm. C ipt = iendwx + 2 RETURN END IF ipt = iendwx + 2 RETURN END