SUBROUTINE NX_SLOC ( bull, lenb, ibptr, rawslc, lenslc, + iret ) C************************************************************************ C* NX_SLOC * C* * C* This subroutine locates, decodes, and stores the station location * C* information from within a NeXRaD RCM bulletin. * C* * C* NX_SLOC ( BULL, LENB, IBPTR, RAWSLC, LENSLC, * C* IRET ) * C* * C* Input parameters: * C* BULL CHAR* Bulletin * C* LENB INTEGER Length of BULL * C* * C* Input parameters (passed via common): * C* JSTN REAL Number of station in NXRDWND * C* station table * C* JSTNID CHAR*(JSTN) Array of station ids from table * C* YLAT REAL*(JSTN) Array of station lats from tbl * C* YLON REAL*(JSTN) Array of station lons from tbl * C* ELEV REAL*(JSTN) Array of station elevs from tbl * C* * C* Input and output parameters: * C* IBPTR INTEGER Pointer within BULL * C* * C* Output parameters: * C* CIVALS (ICRPID) CHAR* RCM identifer * C* RIVALS (IRSLAT) REAL Latitude in degrees * C* RIVALS (IRSLON) REAL Longitude in degrees * C* RIVALS (IRSELV) REAL Elevation in meters * C* RAWSLC CHAR* Raw station location information* C* as originally encoded in BULL * C* LENSLC INTEGER Length of RAWSLC * C* IRET INTEGER Return code * C* 0 = normal return * C* -1 = critical error in BULL * C* or reached end of BULL * C** * C* Log: * C* J. Ator/NCEP 04/98 * C* C. Caruso Magee/NCEP 05/00 Modify to use station table info. * C* J. Ator/NCEP 06/00 Get location info. from BULL if possible* C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'nxcmn.cmn' C CHARACTER*(*) bull, rawslc C----------------------------------------------------------------------- C C* Initialize output variables. C iret = -1 C C* Get the RCM identifier. C rawslc (1:6) = bull ( ibptr + 1 : ibptr + 6 ) lenslc = 6 IF ( rawslc (1:3) .ne. 'RCM' ) THEN logmsg = 'RCM identifer ' // rawslc (1:lenslc) CALL DC_WLOG ( 2, 'NX', -1, logmsg, ierwlg ) RETURN END IF C C* Store the RCM identifier. C civals ( icrpid ) (5:7) = rawslc (4:6) C C* Is the location information encoded in the bulletin? C IF ( ( bull ( ibptr + 7 : ibptr + 7 ) .eq. CHCR ) .and. + ( bull ( ibptr + 8 : ibptr + 8 ) .eq. CHCR ) .and. + ( bull ( ibptr + 9 : ibptr + 9 ) .eq. CHLF ) ) THEN ibptr = ibptr + 10 C C* Decode and store the latitude. C CALL MV_BTOI ( bull ( ibptr: ), 20, 4, 0, ilat, ierbti ) rivals ( irslat ) = FLOAT ( ilat ) * 0.001 C C* Decode and store the longitude. C CALL MV_BTOI ( bull ( ibptr: ), 24, 4, 0, ilon, ierbti ) rivals ( irslon ) = FLOAT ( ilon ) * 0.001 C C* Decode and store the elevation. C CALL MV_BTOI ( bull ( ibptr: ), 28, 2, 0, ielv, ierbti ) rivals ( irselv ) = PR_HGFM ( FLOAT ( ielv ) ) C ibptr = ibptr + 29 C WRITE ( UNIT = logmsg, FMT = '( 3A, F8.3, F9.3, F8.2 )' ) + 'bulletin lat long elev for ', rawslc (4:6), ' = ', + rivals ( irslat ), rivals ( irslon ), rivals ( irselv ) CALL DC_WLOG ( 3, 'NX', 1, logmsg, ierwlg ) ELSE C C* Compare rpid to station table array and look for a match. C* Set slat, slon, and selv if match is found. C CALL DC_BSRC ( rawslc (4:6), jstnid, jstn, ipos, jret ) IF ( ipos .eq. 0 ) THEN logmsg = 'could not find ' // + rawslc (4:6) // ' in stations table' CALL DC_WLOG ( 2, 'NX', -1, logmsg, ierwlg ) RETURN ELSE rivals ( irslat ) = ylat(ipos) rivals ( irslon ) = ylon(ipos) rivals ( irselv ) = elev(ipos) logmsg = 'Used station table to locate ' // rawslc (4:6) CALL DC_WLOG ( 2, 'NX', 1, logmsg, ierwlg ) END IF END IF C iret = 0 C* RETURN END