SUBROUTINE CX_OPER ( mxrpt, mxdatv, odescr, nmrpts, cxrpt, + ist, ic01flg, jdatwth, ic02lfg, jscale, + nn, dataval, iret ) C************************************************************************ C* CX_OPER * C* * C* This subroutine decodes the current operator descriptors: C01YYY, * C* C02YYY, C05YYY, and C07YYY. At this time the operator descriptor * C* C60YYY is not decoded. If it is encountered in the message, the * C* decoding of the CREX message will end. The operator descriptors * C* C01YYY and C02YYY redefine temporarily the CREX Table B attributes * C* for the element descriptor which follows them. The YYY part of the * C* C07YYY operator is saved in the dataval array, so that the user can * C* then get the new units for the data value which follows the YYY value* C* in the dataval array. The new units are defined in Common Table C-6 * C* by the code figure equal to YYY. * C* * C* * C* CX_OPER ( MXRPT, MXDATV, ODESCR, NMRPTS, CXRPT, IST, IC01FLG, * C* JDATWTH, IC02FLG, JSCALE, NN, DATAVAL, IRET ) * C* * C* * C* Input and output parameters: * C* MXRPT INTEGER Maximum number of reports * C* expected in message * C* MXDATV INTEGER Maximum number of data values * C* expected in a report * C* ODESCR CHAR* Current operator descriptor * C* NMRPTS INTEGER Array index referencing the * C* current report in dataval. Will * C* also be used to get the total * C* number of reports in CREX msg. * C* CXRPT CHAR* Current CREX report * C* * C* Input and Output parameters: * C* IST INTEGER Pointer to location in cxrpt of * C* where to get the next data item * C* NN INTEGER Pointer to where to store * C* current data item in dataval * C* report * C* * C* Output parameters: * C* IC01FLG INTEGER Operator data width replacement * C* flag * C* JDATWTH INTEGER Data width replacement value * C* IC02FLG INTEGER Operator scale factor * C* replacement flag * C* JSCALE INTEGER Scale factor replacement value * C* * C* DATAVAL (MXRPT,MXDATV) * C* REAL Array to hold the Section 2 * C* decoded data values * 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* REAL*8 dataval ( mxrpt, mxdatv ) REAL*8 rtemp C* LOGICAL bbb C* CHARACTER*(*) cxrpt CHARACTER odescr*6, fld2*2, fld3*3, ctemp*8, blanks*8 C* EQUIVALENCE ( ctemp, rtemp ) C* DATA blanks / ' ' / C----------------------------------------------------------------------- iret = 0 loglvl = 2 C C* Get the type of operator. C fld2 = odescr (2:3) CALL ST_INTG ( fld2, ixx, ier ) C IF ( ier .ne. 0 ) THEN iret = 1 logmsg = ' ' logmsg(1:20) = 'Operator descriptor ' logmsg(21:26) = odescr logmsg(27:48) = ' cannot be interpreted' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) logmsg = ' ' logmsg(1:12) = 'FATAL ERROR ' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) RETURN END IF C IF ( .not.( ixx .eq. 1 .or. ixx .eq. 2 .or. ixx .eq. 5 .or. + ixx .eq. 7 ) ) THEN iret = 1 logmsg = ' ' logmsg(1:20) = 'Operator descriptor ' logmsg(21:26) = odescr logmsg(27:46) = ' cannot be processed' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) logmsg = ' ' logmsg(1:34) = 'UNABLE TO PROCEED DECODING MESSAGE' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) RETURN END IF C fld3 = odescr (4:6) CALL ST_INTG ( fld3, iyyy, ier ) C IF ( ier .ne. 0 ) THEN iret = 1 logmsg = ' ' logmsg(1:20) = 'Operator descriptor ' logmsg(21:26) = odescr logmsg(27:48) = ' cannot be interpreted' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) logmsg = ' ' logmsg(1:27) = 'FATAL ERROR - CREX message ' logmsg(28:44) = 'cannot be decoded' CALL DC_WLOG( loglvl, 'CX', 2, logmsg, ierwlg ) RETURN END IF C IF ( ixx .eq. 1 ) THEN C C* Data width replacement value is gotten from the YYY C* value in the C01 operator. C IF ( iyyy .eq. 0 ) THEN ic01flg = 0 ELSE ic01flg = 1 jdatwth = iyyy END IF ELSE IF ( ixx .eq. 2 ) THEN C C* Scale factor replacement value is gotten from the C* YYY value in the C02 operator. C IF ( iyyy .eq. 0 ) THEN ic02flg = 0 ELSE ic02flg = 1 jscale = iyyy END IF ELSE IF ( ixx .eq. 5 ) THEN C nwords = iyyy / 8 C irem = MOD ( iyyy, 8 ) C IF ( irem .ne. 0 ) nwords = nwords + 1 C ist = ist + 1 C C* Skip leading blank(s) before start of next group. C bbb = .true. C DO WHILE ( bbb ) IF ( cxrpt(ist:ist) .eq. ' ' ) THEN ist = ist + 1 ELSE bbb = .false. END IF END DO C DO j = 1, nwords C nn = nn + 1 IF ( j .lt. nwords ) THEN ctemp ( 1:8 ) = cxrpt ( ist:ist+7 ) dataval ( nmrpts, nn ) = rtemp ist = ist + 8 ELSE ctemp = blanks ctemp ( 1:irem ) = cxrpt ( ist:ist+irem-1 ) dataval ( nmrpts, nn ) = rtemp ist = ist + irem END IF C END DO C ELSE IF ( ixx .eq. 7 ) THEN nn = nn + 1 ctemp = blanks ctemp(1:3) = fld3 dataval ( nmrpts, nn ) = rtemp END IF C* RETURN END