SUBROUTINE CX_DESC ( mxndesc, lenmsg, crexmsg, jpos, chkdge, + ndesc, datadesc, iret ) C************************************************************************ C* CX_DESC * C* * C* This subroutine gets the list of data descriptors in Section 1 - the * C* Data Description Section. The descriptor(s) are stored in the array * C* datadesc. The string 'ENDDSC', which will be used as a marker in * C* later routines, is inserted after the last descriptor in datadesc. * C* Also, the routine checks if the optional check digit indicator "E" is* C* present at the end of Section 1. A flag is set to indicate whether * C* the check digit indicator is present or not. * C* * C* CX_DESC ( MXNDESC, LENMSG, CREXMSG, JPOS, CHKDGE, NDESC, DATADESC, * C* IRET ) * C* * C* Input parameters: * C* MXNDESC INTEGER Maximum number of descriptors * C* expected in Section 1 of msg * C* LENMSG INTEGER CREX message length * C* CREXMSG CHAR* CREX message * C* * C* Input and output parameters: * C* JPOS INTEGER On input, points to start of * C* data descriptors in Sec 1; on * C* output, points to start of Sec 2* C* * C* Output parameters: * C* CHKDGE INTEGER Check digit indicator * C* NDESC INTEGER Number of data descriptors in * C* Section 1 of CREX message * C* DATADESC (MXNDESC) * C* CHAR* List of Section 1 descriptors * C* * C* IRET INTEGER Return code * C* 0 = normal return * C* 1 = fatal error * C* * C** * C* Log: * C* R. Hollern/NCEP 8/03 * C************************************************************************ INCLUDE 'cxcmn.cmn' C* INTEGER lenmsg, jpos, ndesc, mxndesc, iret INTEGER chkdge C* LOGICAL blanks C* CHARACTER*(*) crexmsg CHARACTER datadesc ( mxndesc )*6 C----------------------------------------------------------------------- iret = 0 chkdge = 0 C C* Locate the end of Section 1. C mpos = INDEX ( crexmsg(jpos:lenmsg), '++' ) C IF ( mpos .eq. 0 ) THEN C C* Reject message. C iret = 1 loglvl = 2 logmsg = ' ' logmsg(1:36) = 'CREX Section 1 terminator is missing' logmsg(37:51) = ' -- FATAL ERROR' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) RETURN END IF C C* Get list of descriptors. C ia = jpos ib = jpos + mpos - 1 ndesc = 0 C DO WHILE ( jpos .lt. ib ) C C* Skip leading blank(s) before start of group. C blanks = .true. C DO WHILE ( blanks ) C IF ( crexmsg(jpos:jpos) .eq. ' ' ) THEN jpos = jpos + 1 ELSE blanks = .false. END IF END DO C IF ( crexmsg(jpos:jpos) .eq. 'E' ) THEN C C* Check digit indicator "E" is present. C chkdge = 1 jpos = ib ELSE IF ( crexmsg(jpos:jpos) .eq. '+' ) THEN jpos = ib ELSE ndesc = ndesc + 1 datadesc(ndesc) = crexmsg(jpos:jpos+5) jpos = jpos + 6 END IF C END DO C jpos = ib + 2 ndesc = ndesc + 1 datadesc(ndesc) = 'ENDDSC' C* RETURN END